contour method that will work with any lm object involving two or
more numerical predictors.## S3 method for class 'lm':
contour(x, form, at, bounds, zlim, image = TRUE, img.col = terrain.colors(50), ...)lm object.zlim setting passed to image.
If not provided, the range of values across all plotted surfaces is used.TRUE if you want an image plot underneath the contours.image=TRUE.contour.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.contourlibrary (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