Description Usage Arguments Details Value Note Author(s) Examples
This function provides several plots of the result of fitting a two-predictor model.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
x |
An object inheriting from class |
which |
Which plot to show? See Details below. |
plane.col, plane.alpha |
These parameters control the colour and transparency of a plane or surface. |
sharedMouse |
If multiple plots are requested, should they share mouse controls, so that they move in sync? |
use_surface3d |
Use the |
do_grid |
Plot a grid. |
grid.col, grid.alpha, grid.steps |
Characteristics of the grid. |
sub.steps |
If |
vars |
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. |
clip_to_density |
If positive, the surface, plane or grid will be clipped to a region with sufficient data. |
... |
Other parameters to pass to the default |
Three plots are possible, depending on the value(s) in which
:
(default) Show the points and the fitted plane or surface.
Show the residuals and the plane at z = 0
.
Show the predicted values on the fitted plane or surface.
If clip_to_density
is positive, then the
surface, plane or grid will be clipped to
the region where a non-parametric density estimate
(using MASS::kde2d
), normalized to have a
maximum value of 1, is greater than the given value.
This will suppress parts of the plot that aren't
supported by the observed data.
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.
The default value for the vars
argument will handle
simple linear models with a response and two predictors, and
some models with functions of those two predictors. For
models that fail (e.g. models using poly
), you
can include the observed values as in the third example below.
If clip_to_density > 0
,
The clipping is approximate, so it may not agree perfectly between surfaces, planes and grids.
This option requires the suggested packages MASS and akima, and will be ignored with a warning if either is not installed.
Duncan Murdoch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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")])
open3d()
# Clip parts of the plot with few (wt, qsec) points
plot3d(lm(mpg ~ poly(wt, 3) + qsec, data = mtcars),
vars = mtcars[,c("mpg", "wt", "qsec")],
clip_to_density = 0.1)
|
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'.
null
1
[1] "data.1" "axes.1" "xlab.1" "ylab.1" "zlab.1" "plane.1" "grid.1"
[8] "data.2" "axes.2" "xlab.2" "ylab.2" "zlab.2" "plane.2" "grid.2"
[15] "data.3" "axes.3" "xlab.3" "ylab.3" "zlab.3" "plane.3" "grid.3"
null
2
null
3
null
4
Loading required namespace: MASS
Loading required namespace: akima
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.