Skip to content

Robust regression wrapper

Source: R/fitRobust.R ยท Help: ?fitRobust

Provides a simple interface to MASS::rlm for robust estimation.

Usage

fitRobust(model, data = NULL, ...)

Arguments

model
A fitted model of class lm or a formula.
data
Optional data frame if model is a formula.
...
Additional arguments passed to MASS::rlm.

Value

An object of class rlm.

Details

The result is an M-estimate, not a least-squares fit: its residuals are not least-squares residuals, and the null distributions of the tests of the package assume least squares. Since 0.17.0 every test refuses it, and so do fitWLS(), runHeteroTests() and runDiagnostics(), with an error of class heteroTests_model_context_error; until then 37 tests took it for an lm and tested its residuals as least-squares ones. To test the variance of the errors, test the stats::lm() fit of the same formula. The result is for estimation, and for comparisons such as those of autoCompareRemediations(), which reads its AIC and residuals only.

Since 0.17.0 the call the result records names what was given: the formula, and the data as the caller named them, or, for an lm, the data, subset and na.action of its call, so that print() and summary() show MASS::rlm(formula = mpg ~ wt + qsec, data = mtcars), where they showed rlm(formula = form, data = data), update() refits it, and the refusal of the tests names the stats::lm() call to test instead, lm(mpg ~ wt + qsec, data = mtcars).

Examples

data(mtcars)
m <- fitRobust(mpg ~ wt + qsec, mtcars)
summary(m)
# The tests refuse it; test the lm() fit of the same formula instead.
performKoenkerTest(lm(mpg ~ wt + qsec, mtcars))