[R] Using the effects package

John Fox jfox at mcmaster.ca
Mon Jul 9 15:27:38 CEST 2012


Dear Abraham,

I must admit that I don't really follow what you want to do. Disregarding the fact that the example you provide doesn't converge to a proper solution, the plot that you've requested will range over all values of bid at the median home, which is 0. You may have intended home to be a categorical variable, but you've specified it as numeric rather than a factor, and so effect() treats it as numeric.

If you want to display the fit at all combinations of values of the two predictors, give the first argument to effect as "bid:home", even though this isn't a term in the model, the two terms bid and home are marginal to it.

I hope that this helps, though I doubt it, since, as I said, I don't think that I understand what you want to do.

John

------------------------------------------------
John Fox
Sen. William McMaster Prof. of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

On Sun, 8 Jul 2012 21:03:47 -0600
 Abraham Mathew <abmathewks at gmail.com> wrote:
> I've been looking into the effects package and it seems to be a great tool
> for plotting the probabilities of the
> response variable by the predictors. However, I'm wonder if I can use the
> effects package to plot the probabilities
> on the y axis and one predictor on the x axis, with the curve having the
> info for another predictor.
> 
> So let's say our response variable is win, a binary variable. There are two
> predictors, home (categorical) and
> bid (continuous). For both home and bid, I want to generate plots showing
> the predicted probabilities for all
> the "levels" of that variable.
> 
> For bid, that means the probability for winning at all bid levels. For
> home, the curve for the probability for winning
> at each level.
> 
> df <- data.frame(won=c(1,0,1,0,1,0,0,0,0,1),
>                  bid=c(150,200,135,140,130,150,200,135,140,130),
>                  home=c(1,0,0,0,1,1,0,0,0,1))
> df
> 
> m1 = glm(won ~ bid + home, data=df, family=binomial(link="logit"))
> summary(m1)
> eff <- effect("bid", m1, xlevels=list(bid=df$bid), typical="median")
> print(plot(eff, rescale.axis=F))
> 
> The thing I'm concerned about is the curve for home. For any logit
> equation, say with a coefficient of 2.5, that is the
> log odds change in Y regardless of the values of the other predictors. So
> I'm not sure I'm doing the write thing in that
> context.
> 
> Can anyone help.
> 
> Thanks
> *
> *
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list