A set of functions to calculate
model diagnostics on models, including constructors,
a generic function, a test of whether an object is of the
modelDiagnostics
class, and methods.
modelDiagnostics(object, ...)as.modelDiagnostics(x)
is.modelDiagnostics(x)
# S3 method for lm
modelDiagnostics(
object,
ev.perc = 0.001,
robust = FALSE,
distr = "normal",
standardized = TRUE,
...
)
A logical (is.modelDiagnostics
) or
a modelDiagnostics object (list) for
as.modelDiagnostics
and modelDiagnostics
.
A fitted model object, with methods for
model.frame
, resid
and fitted
.
Additional arguments, passed to methods or residualDiagnostics
.
An object to test or a list to coerce to a
modelDiagnostics
object.
A real number between 0 and 1 indicating the proportion of the theoretical distribution beyond which values are considered extreme values (possible outliers). Defaults to .001.
Whether to use robust mean and standard deviation estimates for normal distribution
A character string given the assumed distribution.
Passed on to testDistribution
.
Defaults to “normal”.
A logical whether to use standardized residuals.
Defaults to TRUE
generally where possible but may depend on
method.
testm <- stats::lm(mpg ~ hp * factor(cyl), data = mtcars)
md <- modelDiagnostics(testm)
plot(md$residualDiagnostics$testDistribution)
md$extremeValues
plot(md)
md <- modelDiagnostics(testm, ev.perc = .1)
md$extremeValues
plot(md, ncol = 2)
testdat <- data.frame(
y = c(1, 2, 2, 3, 3, NA, 9000000, 2, 2, 1),
x = c(1, 2, 3, 4, 5, 6, 5, 4, 3, 2))
modelDiagnostics(
lm(y ~ x, data = testdat, na.action = "na.omit"),
ev.perc = .1)$extremeValues
modelDiagnostics(
lm(y ~ x, data = testdat, na.action = "na.exclude"),
ev.perc = .1)$extremeValues
## clean up
rm(testm, md, testdat)
Run the code above in your browser using DataLab