plot.visreg2d: Visualization of regression functions for two variables

View source: R/plotVisreg2d.R

plot.visreg2dR Documentation

Visualization of regression functions for two variables

Description

Plot method for visualizing how two variables interact to affect the response in regression models.

Usage

## S3 method for class 'visreg2d'
plot(x, plot.type=c("image","persp","rgl", "gg"),
xlab, ylab, zlab, color, print.cond=FALSE, whitespace=0.2, ...)

Arguments

x

A visreg2d object.

plot.type

The style of plot to be produced. The following three options are supported:

  • 'image', a filled contour plot.

  • 'gg', a filled contour plot using ggplot2.

  • 'persp', a 3 dimensional perspective plot.

  • 'rgl', a version of the perspective plot that can be rotated. Note: requires the rgl package to use.

xlab

Axis label for x variable

ylab

Axis label for y variable

zlab

Axis label for outcome

color

For plot.type='persp' or plot.type='rgl', the color of the surface. For plot.type='image' or plot.type='gg', a vector of colors used to establish a color palette.

print.cond

If print.cond==TRUE, the explanatory variable values conditioned on in a conditional plot are printed to the console (default: FALSE). If print.cond==TRUE and type=="contrast", the conditions will still be printed, but they have no bearing on the plot unless interactions are present.

whitespace

When xvar or yvar is a factor, whitespace determines the amount of space in between the factors. Default is 0.2, meaning that 20 percent of the axis is whitespace.

...

Graphical parameters can be passed to the function to customize the plots.

Author(s)

Patrick Breheny and Woodrow Burchett

References

See Also

https://pbreheny.github.io/visreg/surface.html visreg

Examples

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="image",
         color=c("purple", "green", "red"))
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)


pbreheny/visreg documentation built on March 20, 2024, 1:07 a.m.