harrison_mccabe {skedastic} | R Documentation |
Harrison and McCabe's Test for Heteroskedasticity in a Linear Regression Model
Description
This function implements the method of Harrison and McCabe (1979) for testing for heteroskedasticity in a linear regression model.
Usage
harrison_mccabe(
mainlm,
deflator = NA,
m = 0.5,
alternative = c("less", "greater", "two.sided"),
twosidedmethod = c("doubled", "kulinskaya"),
qfmethod = "imhof",
statonly = FALSE
)
Arguments
mainlm |
Either an object of |
deflator |
Either a character specifying a column name from the
design matrix of |
m |
Either a |
alternative |
A character specifying the form of alternative
hypothesis. If it is suspected that the error variance is positively
associated with the deflator variable, |
twosidedmethod |
A character indicating the method to be used to compute
two-sided |
qfmethod |
A character, either |
statonly |
A logical. If |
Details
The test assumes that heteroskedasticity, if present, is
monotonically related to one of the explanatory variables (known as the
deflator). The OLS residuals are placed in increasing order of
the deflator variable and we let
be an
selector
matrix whose first
diagonal elements are 1 and all other elements
are 0. The alternative hypothesis posits that the error variance changes
around index
. Under the null hypothesis of homoskedasticity, the
ratio of quadratic forms
should be close to
. Since the test statistic
is a ratio of
quadratic forms in the errors, the Imhof algorithm is used to compute
-values (with normality of errors assumed).
Value
An object of class
"htest"
. If object is
not assigned, its attributes are displayed in the console as a
tibble
using tidy
.
References
Harrison MJ, McCabe BPM (1979). “A Test for Heteroscedasticity Based on Ordinary Least Squares Residuals.” Journal of the American Statistical Association, 74(366), 494–499.
See Also
lmtest::hmctest
, another
implementation of the Harrison-McCabe Test. Note that the -values
from that function are simulated rather than computed from the
distribution of a ratio of quadratic forms in normal random vectors.
Examples
mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
harrison_mccabe(mtcars_lm, deflator = "qsec")