bamset {skedastic} | R Documentation |
Ramsey's BAMSET Test for Heteroskedasticity in a Linear Regression Model
Description
This function implements the Bartlett's Specification Error Test
(BAMSET) method of Ramsey (1969) for testing
for heteroskedasticity in a linear regression model.
Usage
bamset(
mainlm,
k = 3,
deflator = NA,
correct = TRUE,
omitatmargins = TRUE,
omit = NA,
categorical = FALSE,
statonly = FALSE
)
Arguments
mainlm |
Either an object of |
k |
An integer. The number of subsets (>= 2) into which the BLUS residuals are to be partitioned. Defaults to 3, the value suggested in Ramsey (1969). |
deflator |
Either a character specifying a column name from the
design matrix of |
correct |
A logical. Should the test statistic be divided by a scaling
constant to improve the chi-squared approximation? Defaults to
|
omitatmargins |
A logical. Should the indices of observations at the
margins of the |
omit |
A numeric vector of length |
categorical |
A logical. Is the deflator a categorical variable? If
so, the number of levels will be used as |
statonly |
A logical. If |
Details
BAMSET is an analogue of Bartlett's Test for heterogeneity
of variances across independent samples from
populations. In this
case the populations are
subsets of the residuals from a linear
regression model. In order to meet the independence assumption,
BLUS residuals are computed, meaning that only
observations are used (where
is the number of rows and
the number of columns in the design matrix). Under the null hypothesis
of homoskedasticity, the test statistic is asymptotically chi-squared
distributed with
degrees of freedom. The test is right-tailed.
Value
An object of class
"htest"
. If object is
not assigned, its attributes are displayed in the console as a
tibble
using tidy
.
References
Ramsey JB (1969). “Tests for Specification Errors in Classical Linear Least-Squares Regression Analysis.” Journal of the Royal Statistical Society. Series B (Statistical Methodology), 31(2), 350–371.
Examples
mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
bamset(mtcars_lm, deflator = "qsec", k = 3)
# BLUS residuals cannot be computed with given `omit` argument and so
# omitted indices are randomised:
bamset(mtcars_lm, deflator = "qsec", k = 4, omitatmargins = FALSE, omit = "last")