white_test {whitestrap} | R Documentation |
This function performs a White's Test for heteroskedasticity (White, H. (1980))
Description
White's test is a statistical test that determines whether the variance of the residuals in a regression model is constant.
Usage
white_test(model)
Arguments
model |
An object of class |
Details
The approach followed is the one detailed at Wooldridge, 2012, p. 275. The fitted values from the original model are:
\widehat{y_i} = \widehat{\beta_0} + \widehat{\beta_1}x_{i1} + ... + \widehat{\beta_k}x_{ik}
Heteroscedasticity could be tested as a linear regression of the squared residuals against the fitted values:
\widehat{u^2} = \delta_0 + \delta_1\widehat{y} + \delta_2\widehat{y^2} + error
The null hypothesis states that \delta_1 = \delta_2 = 0
(homoskedasticity). The test statistic
is defined as:
LM = nR^2
where R^2
is the R-squared value from the regression of u^2
.
Value
AA list with class white_test
containing:
w_stat | The value of the test statistic |
p_value | The p-value of the test |
References
White, H. (1980). A Heteroskedasticity-Consistent Covariance Matrix Estimator and a Direct Test for Heteroskedasticity. Econometrica, 48(4), 817-838.
Wooldridge, Jeffrey M., 1960-. (2012). Introductory econometrics : a modern approach. Mason, Ohio : South-Western Cengage Learning,
See Also
Examples
# Define a dataframe with heteroscedasticity
n <- 100
y <- 1:n
sd <- runif(n, min = 0, max = 4)
error <- rnorm(n, 0, sd*y)
X <- y + error
df <- data.frame(y, X)
# OLS model
fit <- lm(y ~ X, data = df)
# White's test
white_test(fit)