Learn R Programming

rsm (version 1.13)

contour.lm: Contour plot(s) of a fitted linear model

Description

contour method that will work with any lm object involving two or more numerical predictors.

Usage

## S3 method for class 'lm':
contour(x, form, at, bounds, zlim, image = TRUE, img.col = terrain.colors(50), ...)

Arguments

x
A lm object.
form
A formula, or a list of formulas.
at
Optional named list of fixed values to use for variables other than the axis variables. If not provided, the mean is used for numeric variables, or the first level if it is a factor.
bounds
Optional named list of bounds or grid values to use for the variables having the same names. See details.
zlim
Optional zlim setting passed to image. If not provided, the range of values across all plotted surfaces is used.
image
Set to TRUE if you want an image plot underneath the contours.
img.col
Color map to use when image=TRUE.
...
Additional arguments passed to contour.

Details

form may be a single formula or a list of formulas. A simple formula like x2 ~ x1 will produce a contour plot of the fitted regression surface for combinations of x2 (vertical axis) and x1 (horizontal axis). A list of several such simple formulas will produce a contour plot for each formula. A two-sided formula produces contour plots for each left-hand variable versus each right-hand variable (except when they are the same); for example, x1+x3 ~ x2+x3 is equivalent to list(x1~x2, x3~x2, x1~x3). A one-sided formula produces contour plots for each pair of variables. For example, ~ x1+x2+x3 is equivalent to list(x2~x1, x3~x1, x3~x2). For any variables not in the bounds argument, a grid of 26 equally-spaced values in the observed range of that variable is used. If you specify a vector of length 2, it is interpreted as the desired range for that variable and a grid of 26 equally-spaced points is generated. If it is a vector of length 3, the first two elements are used as the range, and the third as the number of grid points. If it is a vector of length 4 or more, those values are used directly as the grid values.

See Also

contour

Examples

Run this code
library (rsm)
heli.rsm = rsm (ave ~ block + SO(x1, x2, x3, x4), data = heli)

par (mfrow = c (2,3))
contour (heli.rsm, ~x1+x2+x3+x4, at=summary(heli.rsm)$canonical$xs)

Run the code above in your browser using DataLab