sl_plot.lm {api2lm} | R Documentation |
Spread-level plot for lm
object
Description
sl_plot.lm
plots a spread-level plot of a fitted
lm
object. In general, it is intended to provide
similar functionality to plot.lm
when which = 3
, but can be used for different
types of residuals and can also plot first-order
predictor variables along the x-axis instead of only the
fitted values.
Details about the different types of
residuals are discussed in the
get_residuals
function.
Usage
## S3 method for class 'lm'
sl_plot(
model,
rtype = c("standardized", "studentized", "internally studentized",
"externally studentized"),
xaxis = "fitted",
id_n = 3,
predictors = ~.,
smooth = stats::loess,
add_smooth = TRUE,
...,
text_arglist = list(),
smooth_arglist = list(),
lines_arglist = list()
)
Arguments
model |
A fitted model object from the
|
rtype |
The residual type to plot. The default is
|
xaxis |
The variable to use on the x-axis of the
plot(s). The default is |
id_n |
The number of points to identify with labels.
The default is |
predictors |
A formula describing the first-order predictors to plot the residuals against. The default is all available first-order predictors. |
smooth |
A function with a
|
add_smooth |
A logical value indicating whether a
smooth should be added to each plot produced. The
default is |
... |
Additional arguments passed to the
|
text_arglist |
Additional arguments passed to the
|
smooth_arglist |
A named list specifying additional
arguments passed to the function provided in the
|
lines_arglist |
A named list specifying additional
arguments passed to the |
Author(s)
Joshua French
See Also
Examples
lmod <- lm(Petal.Length ~ Sepal.Length + Species,
data = iris)
# similarity with built-in plot.lm functionality
sl_plot(lmod)
plot(lmod, which = 3)
# spread-level plot for other residual types
sl_plot(lmod, rtype = "studentized", id_n = 0)
# spread-level plot for predictors
sl_plot(lmod, xaxis = "pred", id_n = 2)
# spread-level plot for individual predictors
sl_plot(lmod, xaxis = "pred",
predictors = ~ Sepal.Length,
id_n = 2)