white: White's Test for Heteroskedasticity in a Linear Regression...

View source: R/white.R

whiteR Documentation

White's Test for Heteroskedasticity in a Linear Regression Model

Description

This function implements the popular method of \insertCiteWhite80;textualskedastic for testing for heteroskedasticity in a linear regression model.

Usage

white(mainlm, interactions = FALSE, statonly = FALSE)

Arguments

mainlm

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".

interactions

A logical. Should two-way interactions between explanatory variables be included in the auxiliary regression? Defaults to FALSE, since when interaction terms are present the test is not a pure test of heteroskedasticity but also of model specification.

statonly

A logical. If TRUE, only the test statistic value is returned, instead of an object of class "htest". Defaults to FALSE.

Details

White's Test entails fitting an auxiliary regression model in which the response variable is the vector of squared residuals from the original model and the design matrix includes the original explanatory variables, their squares, and (optionally) their two-way interactions. The test statistic is the number of observations multiplied by the coefficient of determination from the auxiliary regression model:

T = n r_{\mathrm{aux}}^2

White's Test is thus a special case of the method of \insertCiteBreusch79;textualskedastic. Under the null hypothesis of homoskedasticity, the distribution of the test statistic is asymptotically chi-squared with parameter 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

\insertAllCited

See Also

This function should not be confused with tseries::white.test, which does not implement the method of \insertCiteWhite80;textualskedastic for testing for heteroskedasticity in a linear model.

Examples

mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
white(mtcars_lm)
white(mtcars_lm, interactions = TRUE)


skedastic documentation built on Nov. 10, 2022, 5:43 p.m.