| summary.eff {effects} | R Documentation |
summary, print, plot, and [ methods for eff, effpoly,
efflist, and mlm.efflist objects.
## S3 method for class 'eff'
print(x, type=c("response", "link"), ...)
## S3 method for class 'effpoly'
print(x, type=c("probability", "logits"), ...)
## S3 method for class 'efflatent'
print(x, ...)
## S3 method for class 'efflist'
print(x, ...)
## S3 method for class 'mlm.efflist'
print(x, ...)
## S3 method for class 'summary.eff'
print(x, ...)
## S3 method for class 'eff'
summary(object, type=c("response", "link"), ...)
## S3 method for class 'effpoly'
summary(object, type=c("probability", "logits"), ...)
## S3 method for class 'efflatent'
summary(object, ...)
## S3 method for class 'efflist'
summary(object, ...)
## S3 method for class 'mlm.efflist'
summary(object, ...)
## S3 method for class 'eff'
plot(x, x.var,
z.var=which.min(levels), multiline=is.null(x$se), rug=TRUE,
xlab, ylab, main=paste(effect, "effect plot"),
colors=palette(), symbols=1:length(colors), lines=1:length(colors),
cex=1.5, lwd=2, ylim, xlim=NULL,
factor.names=TRUE, ci.style, band.transparency=0.15, band.colors=colors,
type=c("rescale", "response", "link"), ticks=list(at=NULL, n=5),
alternating=TRUE, rotx=0, roty=0, grid=FALSE, layout, rescale.axis,
transform.x=NULL, ticks.x=NULL,
key.args=NULL,
row=1, col=1, nrow=1, ncol=1, more=FALSE,
use.splines=TRUE, partial.residuals=c("adjusted", "raw"), show.fitted=FALSE,
residuals.color="blue", residuals.pch=1,
smooth.residuals=TRUE, residuals.smooth.color=residuals.color, span=2/3, ...)
## S3 method for class 'effpoly'
plot(x,
type=c("probability", "logit"),
x.var=which.max(levels),
rug=TRUE,
xlab,
ylab=paste(x$response, " (", type, ")", sep=""),
main=paste(effect, "effect plot"),
colors, symbols, lines, cex=1.5, lwd=2,
factor.names=TRUE, ci.style, band.colors, band.transparency=0.3,
style=c("lines", "stacked"),
confint=(style == "lines" && !is.null(x$confidence.level)),
transform.x=NULL, ticks.x=NULL, xlim=NULL,
ylim, rotx=0, alternating=TRUE, roty=0, grid=FALSE,
layout, key.args=NULL,
row=1, col=1, nrow=1, ncol=1, more=FALSE, use.splines=TRUE, ...)
## S3 method for class 'efflist'
plot(x, selection, rows, cols, ask=FALSE, graphics=TRUE, ...)
## S3 method for class 'mlm.efflist'
plot(x, ...)
setStrip(bg=3, fg="black", clip=c("off", "on"))
restoreStrip(saved)
## S3 method for class 'efflist'
x[...]
x |
an object of class |
object |
an object of class |
type |
for printing or summarizing linear and generalized linear models,
if For plotting linear or genealized linearized models, For polytomous logit models, this argument takes either |
rescale.axis |
this argument is deprecated — use the |
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 |
for linear, generalized linear or mixed models,
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 |
for linear, generalized linear or mixed models,
if |
confint |
plot point-wise confidence bands around fitted effects (for
multinomial and proportional-odds logit models); defaults to |
rug |
if |
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 constructed from the name of 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 |
For stacked multinomial-logit plots,
Warning: This argument
cannot be abbreviated to |
symbols, lines |
corresponding to the levels of the |
cex |
character expansion for plotted symbols; default is |
lwd |
line width for fitted lines. |
ylim |
2-element vector containing the lower and upper limits of the vertical axes;
if |
xlim |
a named list of 2-element vectors, with the names corresponding to numeric
predictors; if a numeric predictor is in the list, then when it appears on the horizontal
axis, the axis limits will be taken from the corresponding vector; if a predictor is
not in the list, or if the argument is |
factor.names |
a logical value, default |
ci.style |
confidence bounds can be indicated using error bars, using lines or confidence bands,
depending on the plot type.
For single line plots the default is |
band.colors |
A vector of colors for the color of the confidence band with |
band.transparency |
For |
style |
(for multinomial or proportional-odds logit models) |
ticks |
a two-item list controlling the placement of tick marks on the vertical axis,
with elements |
ticks.x |
a named list of two-item lists controlling the placement of tick marks
on the horizontal axis. Each list element is named for a numeric predictor in the model,
and each sublist has elements |
transform.x |
transformations to be applied to the horizontal axis, in the form of a named list,
each of whose elements is itself a list of two functions, with sublist element names |
alternating |
if |
rotx, roty |
rotation angles for the horizontal and vertical tick marks, respectively. Default is 0. |
grid |
if |
layout |
the |
key.args |
additional arguments to be passed to the |
row, col, nrow, ncol, more |
These arguments are used to graph an effect as part of an
array of plots; |
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. |
rows, cols |
Number of rows and columns in the “meta-array” of plots produced for an |
ask |
if |
graphics |
if |
use.splines |
If |
partial.residuals |
use |
smooth.residuals |
whether to show a |
span |
of the |
show.fitted |
if partial residuals are present in the effect object, also plot the partial fitted values (which will be shown as filled circles). |
residuals.color |
color for plotting partial residuals (default |
residuals.smooth.color |
color for plotting the smooth of the partial residuals; the default is the |
residuals.pch |
plotting symbol for partial residuals (default |
bg |
if a single numeric value (the default is |
fg |
foreground color or colors for the strips at the top of lattice panels (the default is
|
clip |
|
saved |
a set of lattice strip specifications returned by |
... |
arguments to be passed down. |
In a generalized linear model, by default, the print and summary methods for
eff 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.
When a factor is on the x-axis, the plot method for eff objects
connects the points representing the effect by line segments, creating a
response “profile.” If you wish to suppress these lines, add the argument
lty=0 to the call to plot (see the examples).
In a polytomous (multinomial or proportional-odds) logit model, by default effects are plotted on the probability scale; they may be alternatively plotted on the scale of the individual-level logits.
The setStrip and restoreStrip functions modify the strips that appear in subsequent
lattice plots, including those produced by functions in the effects package. The default call
setStrip() provides monochrome (rather than the lattice-default colored) strips with up to 3
gray-scale values corresponding to 3 conditioning variables; clipping at the left and right of strips
is also turned off by default by setStrip. restoreStrip may be used to reset
lattice strips to previously saved parameters returned by setStrip.
The summary method for "eff" objects returns a "summary.eff" 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. |
The setStrip function invisibly returns a list that can supply the argument of the
restoreStrip function to restore the previous lattice strip specification.
The [ method for "efflist" objects is used to subset an "efflist" object and returns an object of the same class.
John Fox jfox@mcmaster.ca and Jangman Hong.
effect, allEffects, xyplot,
densityplot, print.trellis, loess,
rainbow_hcl, sequential_hcl
# also see examples in ?effect
mod.cowles <- glm(volunteer ~ sex + neuroticism*extraversion,
data=Cowles, family=binomial)
eff.cowles <- allEffects(mod.cowles, xlevels=list(extraversion=seq(0, 24, 6)))
eff.cowles
as.data.frame(eff.cowles[[2]]) # neuroticism*extraversion interaction
plot(eff.cowles, 'sex', ylab="Prob(Volunteer)", grid=TRUE, rotx=90, lty=0)
.save.strip <- setStrip()
plot(eff.cowles, 'neuroticism:extraversion', ylab="Prob(Volunteer)",
ticks=list(at=c(.1,.25,.5,.75,.9)))
# change color of the confidence bands to 'black' with .15 transparency
plot(eff.cowles, 'neuroticism:extraversion', ylab="Prob(Volunteer)",
ticks=list(at=c(.1,.25,.5,.75,.9)), band.colors="red", band.transparency=.3)
plot(eff.cowles, 'neuroticism:extraversion', multiline=TRUE,
ylab="Prob(Volunteer)", key.args = list(x = 0.75, y = 0.75, corner = c(0, 0)))
# use probability scale in place of logit scale, all lines are black.
plot(eff.cowles, 'neuroticism:extraversion', multiline=TRUE,
ylab="Prob(Volunteer)", key.args = list(x = 0.75, y = 0.75, corner = c(0, 0)),
colors="black", lines=1:8,
ci.style="bands", type="response", band.colors=palette())
plot(effect('sex:neuroticism:extraversion', mod.cowles,
xlevels=list(extraversion=seq(0, 24, 6))), multiline=TRUE)
plot(effect('sex:neuroticism:extraversion', mod.cowles,
xlevels=list(extraversion=seq(0, 24, 6))), multiline=TRUE,
type="response", ci.style="bands")
if (require(nnet)){
mod.beps <- multinom(vote ~ age + gender + economic.cond.national +
economic.cond.household + Blair + Hague + Kennedy +
Europe*political.knowledge, data=BEPS)
plot(effect("Europe*political.knowledge", mod.beps,
xlevels=list(political.knowledge=0:3)))
plot(effect("Europe*political.knowledge", mod.beps,
xlevels=list(political.knowledge=0:3),
given.values=c(gendermale=0.5)),
style="stacked", colors=c("blue", "red", "orange"), rug=FALSE)
}
if (require(MASS)){
mod.wvs <- polr(poverty ~ gender + religion + degree + country*poly(age,3),
data=WVS)
plot(effect("country*poly(age, 3)", mod.wvs))
plot(effect("country*poly(age, 3)", mod.wvs), style="stacked",
colors=c("gray75", "gray50", "gray25"))
plot(effect("country*poly(age, 3)", latent=TRUE, mod.wvs))
}
mod.pres <- lm(prestige ~ log(income, 10) + poly(education, 3) + poly(women, 2),
data=Prestige)
eff.pres <- allEffects(mod.pres, default.levels=50)
plot(eff.pres)
plot(eff.pres[1:2])
plot(eff.pres[1],
transform.x=list(income=list(trans=log10, inverse=function(x) 10^x)),
ticks.x=list(income=list(at=c(1000, 2000, 5000, 10000, 20000))))
restoreStrip(.save.strip)
remove(.save.strip)