Description Usage Arguments Value Author(s) References See Also Examples
A function used to visualize how two variables interact to affect the response in regression models.
1 2 3 |
fit |
The fitted model object you wish to visualize. Any object with 'predict' and 'model.frame' methods are supported, including lm, glm, gam, rlm, coxph, and many more. |
xvar |
Character string specifying the variable to be put on the x-axis of your plot. Both continuous variables and factors are supported. |
yvar |
Character string specifying the variable to be put on the y-axis of your plot. Both continuous variables and factors are supported. |
type |
The type of plot to be produced. The following options are supported:
For more details, see references. |
data |
The data frame used to fit the model. Typically, visreg() can figure out where the data is, so it is not necessary to provide this. In some cases, however, the data set cannot be located and must be supplied explicitly. |
trans |
(Optional) A function specifying a transformation for the vertical axis. |
scale |
By default, the model is plotted on the scale of the linear
predictor. If |
nn |
Resolution of the three dimensional plot. Higher values will results in a smoother looking plot. |
cond |
Named list specifying conditional values of other explanatory
variables. By default, conditional plots in visreg are constructed
by filling in other explanatory variables with the median (for
numeric variables) or most common category (for factors), but this
can be overridden by specifying their values using |
plot |
Send the calculations to |
... |
Graphical parameters (e.g., |
A visreg2d
object consisting of:
x |
Values of |
y |
Values of |
z |
Values of outcome to be plotted |
meta |
Meta-information needed to construct plots, such as the name of the x and y variables. |
Patrick Breheny and Woodrow Burchett
Breheny, P. and Burchett, W. (2017), Visualizing regression models using visreg. https://journal.r-project.org/archive/2017/RJ-2017-046/index.html
http://pbreheny.github.io/visreg/surface.html
visreg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | fit <- lm(Ozone ~ Solar.R + Wind + Temp + I(Wind^2) + I(Temp^2) +
I(Wind*Temp)+I(Wind*Temp^2) + I(Temp*Wind^2) + I(Temp^2*Wind^2),
data=airquality)
visreg2d(fit, x="Wind", y="Temp", plot.type="image")
visreg2d(fit, x="Wind", y="Temp", plot.type="persp")
## Requires the rgl package
## Not run:
visreg2d(fit, x="Wind", y="Temp", plot.type="rgl")
## End(Not run)
## Requires the ggplot2 package
## Not run:
visreg2d(fit, x="Wind", y="Temp", plot.type="gg")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.