white_test: This function performs a White's Test for heteroskedasticity...

Description Usage Arguments Details Value References See Also Examples

View source: R/white_test.R

Description

White's test is a statistical test that determines whether the variance of the residuals in a regression model is constant.

Usage

1
white_test(model)

Arguments

model

An object of class lm

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{β_0} + \widehat{β_1}x_{i1} + ... + \widehat{β_k}x_{ik}

Heteroscedasticity could be tested as a linear regression of the squared residuals against the fitted values:

\widehat{u^2} = δ_0 + δ_1\widehat{y} + δ_2\widehat{y^2} + error

The null hypothesis states that δ_1 = δ_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

lm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 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)

whitestrap documentation built on July 1, 2020, 10:02 p.m.