plot.margins | R Documentation |
An implementation of Stata's ‘marginsplot’ as an S3 generic function
## S3 method for class 'margins'
plot(
x,
pos = seq_along(marginal_effects(x, with_at = FALSE)),
which = colnames(marginal_effects(x, with_at = FALSE)),
labels = gsub("^dydx_", "", which),
horizontal = FALSE,
xlab = "",
ylab = "Average Marginal Effect",
level = 0.95,
pch = 21,
points.col = "black",
points.bg = "black",
las = 1,
cex = 1,
lwd = 2,
zeroline = TRUE,
zero.col = "gray",
...
)
x |
An object of class “margins”, as returned by |
pos |
A numeric vector specifying the x-positions of the estimates (or y-positions, if |
which |
A character vector specifying which marginal effect estimate to plot. Default is all. |
labels |
A character vector specifying the axis labels to use for the marginal effect estimates. Default is the variable names from |
horizontal |
A logical indicating whether to plot the estimates along the x-axis with vertical confidence intervals (the default), or along the y-axis with horizontal confidence intervals. |
xlab |
A character string specifying the x-axis (or y-axis, if |
ylab |
A character string specifying the y-axis (or x-axis, if |
level |
A numeric value between 0 and 1 indicating the confidence level to use when drawing error bars. |
pch |
The point symbol to use for plotting marginal effect point estimates. See |
points.col |
The point color to use for plotting marginal effect point estimates. See |
points.bg |
The point color to use for plotting marginal effect point estimates. See |
las |
An integer value specifying the orientation of the axis labels. See |
cex |
A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default. See |
lwd |
A numerical value giving the width of error bars in points. |
zeroline |
A logical indicating whether to draw a line indicating zero. Default is |
zero.col |
A character string indicating a color to use for the zero line if |
... |
Additional arguments passed to |
This function is invoked for its side effect: a basic dot plot with error bars displaying marginal effects as generated by margins
, in the style of Stata's ‘marginsplot’ command.
The original “margins” object x
, invisibly.
margins
, persp.lm
## Not run:
require("datasets")
x <- lm(mpg ~ cyl * hp + wt, data = mtcars)
mar <- margins(x)
plot(mar)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.