This function implements the method of Anscombe61;textualskedastic for testing for heteroskedasticity in a linear regression model, with or without the studentising modification of Bickel78;textualskedastic.
anscombe(mainlm, studentise = TRUE, statonly = FALSE)An object of class
"htest". If object is
not assigned, its attributes are displayed in the console as a
Either an object of class "lm"
(e.g., generated by lm), or
a list of two objects: a response vector and a design matrix. The objects
are assumed to be in that order, unless they are given the names
"X" and "y" to distinguish them. The design matrix passed
in a list must begin with a column of ones if an intercept is to be
included in the linear model. The design matrix passed in a list should
not contain factors, as all columns are treated 'as is'. For tests that
use ordinary least squares residuals, one can also pass a vector of
residuals in the list, which should either be the third object or be
named "e".
A logical. Should studentising modification of
Bickel78;textualskedastic be implemented? Defaults to
TRUE; if FALSE, the original form of the test proposed by
Anscombe61;textualskedastic is used.
A logical. If TRUE, only the test statistic value
is returned, instead of an object of class
"htest". Defaults to FALSE.
Anscombe's Test is among the earliest suggestions for heteroskedasticity
diagnostics in the linear regression model. The test is not based on
formally derived theory but on a test statistic that Anscombe intuited
to be approximately standard normal under the null hypothesis of
homoskedasticity. Bickel78;textualskedastic discusses
the test and suggests a studentising modification (included in this
function) as well as a robustifying modification
(included in bickel). The test is two-tailed.
bickel, which is a robust extension of this test.
mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
anscombe(mtcars_lm)
Run the code above in your browser using DataLab