index_plot_lm {api2lm} | R Documentation |
Index plot of statistics from of an lm
object
Description
index_plot_lm
creates an index plot of statistcs
from an lm
object.
Usage
index_plot_lm(
model,
stat,
id_n = 3,
add_reference = FALSE,
...,
text_arglist = list(),
abline_arglist = list(),
extendrange_f = 0.08
)
Arguments
model |
A fitted model object from the
|
stat |
A function that can be applied to an |
id_n |
The number of points to identify with labels.
The default is |
add_reference |
A logical value indicating whether a
reference line should be added. The default is
|
... |
Additional arguments passed to the
|
text_arglist |
Additional arguments passed to the
|
abline_arglist |
A named list specifying additional
arguments passed to the |
extendrange_f |
Positive number(s) specifying the
fraction by which the range of the residuals should be
extended using the |
Author(s)
Joshua French
See Also
plot
,
text
,
lm
,
rstudent
,
hatvalues
,
cooks.distance
Examples
lmod <- lm(Petal.Length ~ Sepal.Length + Species,
data = iris)
# outlier plot
# number of observations
n <- stats::nobs(lmod)
# loo residual degrees of freedom
rdf <- stats::df.residual(lmod) - 1
h <- c(-1, 1) * stats::qt(0.05/(2 * n), df = rdf)
index_plot_lm(lmod, stat = stats::rstudent,
abline_arglist = list(h = h))
# leverage plot
index_plot_lm(lmod, stat = stats::hatvalues, id_n = 1)
# Cook's distance
index_plot_lm(lmod, stat = stats::cooks.distance,
id_n = 3)