predictorEffects {effects} | R Documentation |
Alternatives to the Effect
and allEffects
functions that use a different paradigm for conditioning in an effects display. The user specifies one predictor, either continuous or a factor, for the horizontal axis of a plot, and the function determines the appropriate plot to display (which is drawn by plot
).
predictorEffect(predictor, mod, xlevels, ...) ## S3 method for class 'svyglm' predictorEffect(predictor, mod, xlevels, ...) ## Default S3 method: predictorEffect(predictor, mod, xlevels, ...) predictorEffects(mod, predictors, ...) ## Default S3 method: predictorEffects(mod, predictors = ~ ., ...)
mod |
A model object. Supported models include all those described on the help page for |
predictor |
quoted name of the focal predictor. |
xlevels |
this argument is used to set the values for any predictor in the
effect that is not a factor. For a predictor
effect, the default is to use 50 quantiles of the focal predictor on the x-axis
between the 0.01 and 0.98 quantiles. See |
predictors |
If the default |
... |
Additional arguments passed to |
Effects plots view a fitted regression function E(Y|X) in (sequences of) two-dimensional plots using conditioning and slicing. The functions describe here use a different method of determining the conditioning and slicing than Effects
uses. The predictor effects a focal predictor say x1
will be the the usual effect for the generalized interaction of x1
with all the other predictors in a model. When a predictor effects object is plotted, the focal predictor is by default plotted on the horizontal axis.
For example, in the model mod
with formula y ~ x1 + x2 + x3
, then p1 <- predictorEffects(mod, ~ x1)
is essentially equilavent to p2 <- Effect("x1", mod)
. When plotted, these objects may be different because plot(p1)
will always put x1
on the horizontal axis while plot(p2)
uses a rule to determine the horizontal axis based on the characteristics of all the predictors, preferring continuous predictors over factors.
If mod
has the formula y ~ x1 + x2 + x3 + x1:x2
, then p1 <- predictorEffects(mod, ~ x1)
is essentially equilavent to p2 <- Effect(c("x1", "x2"), mod)
. As in the last example, the plotted versions of these objects may differ because of rules used to determine the horizontal axis.
If mod
has the formula y ~ x1 + x2 + x3 + x1:x2 + x1:x3
, then p1 <- predictorEffects(mod, ~ x1)
is essentially equilavent to p2 <- Effect(c("x1", "x2", "x3"), mod)
. The plotted versions of these objects may differ because of rules used to determine the horizontal axis.
predictorEffect
returns an object of class c(predictoreff, eff)
. The components of the object are described under the detalis at Effect
. predictorEffects
returns an object of class predictorefflist
, which is a list whose elements are of class c(predictoreff, eff)
S. Weisberg, sandy@umn.edu
See Effect
.
mod <- lm(prestige ~ type*(education + income) + women, Prestige) plot(predictorEffect("income", mod)) plot(predictorEffects(mod, ~ education + income + women)) # svyglm() example (adapting an example from the survey package) if (require(survey)){ data(api) dstrat<-svydesign(id=~1, strata=~stype, weights=~pw, data=apistrat, fpc=~fpc) mod <- svyglm(sch.wide ~ ell + meals + mobility, design=dstrat, family=quasibinomial()) plot(predictorEffects(mod), axes=list(y=list(lim=log(c(0.4, 0.99)/c(0.6, 0.01)), ticks=list(at=c(0.4, 0.75, 0.9, 0.95, 0.99))))) }