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:
Heteroscedasticity could be tested as a linear regression of the squared residuals against the fitted values:
The null hypothesis states that (homoskedasticity). The test statistic
is defined as:
where is the R-squared value from the regression of
.
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)