| plot.regvec3d | R Documentation |
The plot method for regvec3d objects uses the low-level graphics tools in this package to draw 3D and 3D
vector diagrams reflecting the partial and marginal
relations of y to x1 and x2 in a bivariate multiple linear regression model,
lm(y ~ x1 + x2).
The summary method prints the vectors and their vector lengths, followed by the summary
for the model.
## S3 method for class 'regvec3d'
plot(
x,
y,
dimension = 3,
col = c("black", "red", "blue", "brown", "lightgray"),
col.plane = "gray",
cex.lab = 1.2,
show.base = 2,
show.marginal = FALSE,
show.hplane = TRUE,
show.angles = TRUE,
error.sphere = c("none", "e", "y.hat"),
scale.error.sphere = x$scale,
level.error.sphere = 0.95,
grid = FALSE,
add = FALSE,
...
)
## S3 method for class 'regvec3d'
summary(object, ...)
## S3 method for class 'regvec3d'
print(x, ...)
x |
A “regvec3d” object |
y |
Ignored; only included for compatibility with the S3 generic |
dimension |
Number of dimensions to plot: |
col |
A vector of 5 colors. |
col.plane |
Color of the base plane in a 3D plot or axes in a 2D plot |
cex.lab |
character expansion applied to vector labels. May be a number or numeric vector corresponding to the the
rows of |
show.base |
If |
show.marginal |
If |
show.hplane |
If |
show.angles |
If |
error.sphere |
Plot a sphere (or in 2D, a circle) of radius proportional to the length of
the residual vector, centered either at the origin ( |
scale.error.sphere |
Whether to scale the error sphere if |
level.error.sphere |
The confidence level for the error sphere, applied if |
grid |
If |
add |
If |
... |
Parameters passed down to functions [unused now] |
object |
A |
A 3D diagram shows the vector y and the plane formed by the predictors,
x1 and x2, where all variables are represented in deviation form, so that
the intercept need not be included.
A 2D diagram, using the first two columns of the result, can be used to show the projection
of the space in the x1, x2 plane.
The drawing functions vectors and vectors3d used by the plot.regvec3d method only work
reasonably well if the variables are shown on commensurate scales, i.e., with
either scale=TRUE or normalize=TRUE.
None
Fox, J. (2016). Applied Regression Analysis and Generalized Linear Models, 3rd ed., Sage, Chapter 10.
regvec3d, vectors3d, vectors
Other vector diagrams:
Proj(),
arc(),
arrows3d(),
circle3d(),
corner(),
pointOnLine(),
regvec3d(),
vectors(),
vectors3d()
if (require(carData)) {
data("Duncan", package="carData")
dunc.reg <- regvec3d(prestige ~ income + education, data=Duncan)
plot(dunc.reg)
plot(dunc.reg, dimension=2)
plot(dunc.reg, error.sphere="e")
summary(dunc.reg)
# Example showing Simpson's paradox
data("States", package="carData")
states.vec <- regvec3d(SATM ~ pay + percent, data=States, scale=TRUE)
plot(states.vec, show.marginal=TRUE)
plot(states.vec, show.marginal=TRUE, dimension=2)
summary(states.vec)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.