This function provides several plots of the result of fitting a two-predictor model.
# S3 method for lm
plot3d(x,
which = 1,
plane.col = "gray", plane.alpha = 0.5,
sharedMouse = TRUE,
use_surface3d,
do_grid = TRUE,
grid.col = "black",
grid.alpha = 1,
grid.steps = 5,
sub.steps = 4,
vars = get_all_vars(terms(x), x$model),
...)
An object inheriting from class "lm"
obtained by fitting
a two-predictor model.
Which plot to show? See Details below.
These parameters control the colour and transparency of a plane or surface.
If multiple plots are requested, should they share mouse controls, so that they move in sync?
Plot a grid.
Characteristics of the grid.
If use_surface3d
is TRUE
,
use an internal grid of grid.steps*sub.steps
to draw
the surface. sub.steps > 1
allows curvature within facets.
Similarly, if do_grid
is TRUE
, it allows
curvature within grid lines.
A dataframe containing the variables to plot in the first three columns, with the response assumed to be in column 1. See the Note below.
Other parameters to pass to the default plot3d
method, to control the appearance of aspects of the plot
other than the plane.
Called for the side effect of drawing one or more plots.
Invisibly returns a high-level vector of object ids. Names of object ids have the plot number (in drawing order) appended.
Three plots are possible, depending on the value(s) in which
:
(default) Show the points and the fitted plane.
Show the residuals and the plane at z = 0
.
Show the predicted values on the fitted plane.
# NOT RUN {
open3d()
ids <- plot3d(lm(mpg ~ wt + qsec, data = mtcars), which = 1:3)
names(ids)
open3d()
plot3d(lm(mpg ~ wt + I(wt^2) + qsec, data = mtcars))
open3d()
# Specify vars in the order: response, pred1, pred2.
plot3d(lm(mpg ~ poly(wt, 3) + qsec, data = mtcars),
vars = mtcars[,c("mpg", "wt", "qsec")])
# }
Run the code above in your browser using DataLab