bamset | R Documentation |
This function implements the Bartlett's M Specification Error Test (BAMSET) method of \insertCiteRamsey69;textualskedastic for testing for heteroskedasticity in a linear regression model.
bamset( mainlm, k = 3, deflator = NA, correct = TRUE, omitatmargins = TRUE, omit = NA, categorical = FALSE, statonly = FALSE )
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 \insertCiteRamsey69;textualskedastic. |
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 p (the number of columns in the
linear model design matrix) giving the indices of p observations to
omit in the BLUS residual vector; or a character partially matching
|
categorical |
A logical. Is the deflator a categorical variable? If
so, the number of levels will be used as k with each level forming
a subset. Defaults to |
statonly |
A logical. If |
BAMSET is an analogue of Bartlett's M Test for heterogeneity of variances across independent samples from k populations. In this case the populations are k subsets of the residuals from a linear regression model. In order to meet the independence assumption, BLUS residuals are computed, meaning that only n-p observations are used (where n is the number of rows and p the number of columns in the design matrix). Under the null hypothesis of homoskedasticity, the test statistic is asymptotically chi-squared distributed with k-1 degrees of freedom. The test is right-tailed.
An object of class
"htest"
. If object is
not assigned, its attributes are displayed in the console as a
tibble
using tidy
.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.