summary.effect {effects} | R Documentation |
summary
, print
, and plot
methods for effect
and effect.list
objects.
## S3 method for class 'effect': print(x, type=c("response", "link"), ...) ## S3 method for class 'effect.list': print(x, ...) ## S3 method for class 'summary.effect': print(x, ...) ## S3 method for class 'effect': summary(object, type=c("response", "link"), ...) ## S3 method for class 'effect.list': summary(object, ...) ## S3 method for class 'effect': plot(x, x.var=which.max(levels), z.var=which.min(levels), multiline=is.null(x$se), rug=TRUE, xlab, ylab=x$response, main=paste(effect, "effect plot"), colors=palette(), symbols=1:10, lines=1:10, cex=1.5, ylim, factor.names=TRUE, type=c("response", "link"), ticks=list(at=NULL, n=5), alternating=TRUE, rescale.axis=TRUE, row=1, col=1, nrow=1, ncol=1, more=FALSE, ...) ## S3 method for class 'effect.list': plot(x, selection, ask=TRUE, ...)
x |
an object of type "effect" , "summary.effect" , or "effect.list" ,
as appropriate. |
object |
an object of type "effect" or "effect.list" ,
as appropriate. |
type |
if "response" (the default), effects are printed
or the vertical axis is labelled on the scale of the response
variable; if "link" , effects are printed
or the vertical axis labelled on the scale of the linear predictor. |
x.var |
the index (number) or quoted name of the covariate or factor to place on the horizontal axis of each panel of the effect plot. The default is the predictor with the largest number of levels or values. |
z.var |
the index (number) or quoted name of the covariate or factor for which
individual lines are to be drawn in each panel of the effect plot. The default is the
predictor with the smallest number of levels or values. This argument is only
used if multiline = TRUE . |
multiline |
if TRUE , each panel of the display represents combinations
of values of two predictors, with one predictor (corresponding to x.var )
on the horzontal axis, and the other (corresponding to z.var ) used to define
lines in the graph; defaults to TRUE if there are no standard errors in
the object being plotted, and FALSE otherwise. |
rug |
if TRUE , the default, a rug plot is shown giving the marginal
distribution of the predictor on the horizontal axis, if this predictor is
a covariate. |
xlab |
the label for the horizontal axis of the effect plot; if missing, the function will use the name of the predictor on the horizontal axis. |
ylab |
the label for the vertical axis of the effect plot; the default is the response variable for the model from which the effect was computed. |
main |
the title for the plot, printed at the top; the default title is constructed from the name of the effect. |
colors |
colors[1] is used to plot effects, colors[2] to plot
confidence bands. In a mulitline plot, the successive colors correspond
to the levels of the z.var covariate or factor. |
symbols, lines |
corresponding to the levels of the z.var covariate
or factor on a multiline plot. These arguments are used only if multiline = TRUE ;
in this case a legend is drawn at the top of the display. |
cex |
character expansion for plotted symbols; default is 1 . |
ylim |
2-element vector containing the lower and upper limits of the vertical axes;
if NULL , the default, then the vertical axes are scaled from the data. |
factor.names |
a logical value, default TRUE , that controls the inclusion of
factor names in conditioning-variable labels. |
ticks |
a two-item list controlling the placement of tick marks on the vertical axis,
with elements at and n . If at=NULL (the default), the program
attempts to find `nice' locations for the ticks, and the value of n (default,
5 ) gives the
approximate number of tick marks desired; if at is non-NULL , then the
value of n is ignored. |
alternating |
if TRUE (the default), the tick labels alternate by panels in
multi-panel displays from left to right and top to bottom; if FALSE , tick labels
appear at the bottom and on the left. |
rescale.axis |
if TRUE (the default), the tick marks on the vertical axis
are labelled on the response scale (e.g., the probability scale for effects computed on
the logit scale for a binomial GLM). |
row, col, nrow, ncol, more |
These arguments are used to graph an effect as part of an
array of plots; row , col , nrow , and ncol are used to compose
the split argument and more the more argument to print.trellis .
Normally these arguments are not set by the user, but by print.effect.list . |
selection |
the optional index (number) or quoted name of the effect in an effect list to be plotted; if not supplied, a menu of high-order terms is presented or all effects are plotted. |
ask |
if selection is not supplied and ask is TRUE (the default),
a menu of high-order terms is presented; if ask is FALSE , effects for all
high-order terms are plotted in an array. |
... |
arguments to be passed down. |
In a generalized linear model, by default, the print
and summary
methods for
effect
objects print the computed effects on the scale of the
response variable using the inverse of the
link function. In a logit model, for example, this means that the effects are expressed on the probability
scale.
By default, effects in a GLM are plotted on the scale of the linear predictor, but the vertical axis is labelled on the response scale. This preserves the linear structure of the model while permitting interpretation on what is usually a more familiar scale. This approach may also be used with linear models, for example to display effects on the scale of the response even if the data are analyzed on a transformed scale, such as log or square-root.
The summary
method for "effect"
objects returns a "summary.effect"
object with the following components
(those pertaining to confidence limits need not be present):
header |
a character string to label the effect. |
effect |
an array containing the estimated effect. |
lower.header |
a character string to label the lower confidence limits. |
lower |
an array containing the lower confidence limits. |
upper.header |
a character string to label the upper confidence limits. |
upper |
an array containing the upper confidence limits. |
John Fox jfox@mcmaster.ca.
data(Cowles) mod.cowles <- glm(volunteer ~ sex + neuroticism*extraversion, data=Cowles, family=binomial) eff.cowles <- all.effects(mod.cowles, xlevels=list(neuroticism=0:24, extraversion=seq(0, 24, 6))) eff.cowles ## Not run: model: volunteer ~ sex + neuroticism * extraversion sex effect sex female male 0.4409441 0.3811941 neuroticism*extraversion effect extraversion neuroticism 0 6 12 18 24 0 0.07801066 0.1871263 0.3851143 0.6301824 0.8225756 1 0.08636001 0.1963396 0.3870453 0.6200668 0.8083638 2 0.09551039 0.2058918 0.3889798 0.6098458 0.7932997 3 0.10551835 0.2157839 0.3909179 0.5995275 0.7773775 . . . 23 0.51953129 0.4747277 0.4303273 0.3870199 0.3454282 24 0.54709527 0.4895731 0.4323256 0.3768303 0.3243880 ## End(Not run) plot(eff.cowles, 'sex', ylab="Prob(Volunteer)") ## Not run: Loading required package: lattice ## End(Not run) plot(eff.cowles, 'neuroticism:extraversion', ylab="Prob(Volunteer)", ticks=list(at=c(.1,.25,.5,.75,.9))) plot(eff.cowles, 'neuroticism:extraversion', multiline=TRUE, ylab="Prob(Volunteer)") plot(effect('sex:neuroticism:extraversion', mod.cowles, xlevels=list(neuroticism=0:24, extraversion=seq(0, 24, 6))), multiline=TRUE) ## Not run: Warning message: sex:neuroticism:extraversion does not appear in the model in: effect("sex:neuroticism:extraversion", mod.cowles, xlevels = list(neuroticism = 0:24, ## End(Not run) data(Prestige) mod.pres <- lm(prestige ~ log(income, 10) + poly(education, 3) + poly(women, 2), data=Prestige) eff.pres <- all.effects(mod.pres, default.levels=50) plot(eff.pres, ask=FALSE)