Package 'whitestrap'

Title: White Test and Bootstrapped White Test for Heteroskedasticity
Description: Formal implementation of White test of heteroskedasticity and a bootstrapped version of it, developed under the methodology of Jeong, J., Lee, K. (1999) <https://yonsei.pure.elsevier.com/en/publications/bootstrapped-whites-test-for-heteroskedasticity-in-regression-mod>.
Authors: Jorge Lopez Perez [aut, cre, cph], Jinook Jeong [ctb]
Maintainer: Jorge Lopez Perez <[email protected]>
License: MIT + file LICENSE
Version: 0.0.1
Built: 2024-11-03 05:36:09 UTC
Source: https://github.com/jlopezper/whitestrap

Help Index


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 lm

Details

The approach followed is the one detailed at Wooldridge, 2012, p. 275. The fitted values from the original model are:

yi^=β0^+β1^xi1+...+βk^xik\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:

u2^=δ0+δ1y^+δ2y2^+error\widehat{u^2} = \delta_0 + \delta_1\widehat{y} + \delta_2\widehat{y^2} + error

The null hypothesis states that δ1=δ2=0\delta_1 = \delta_2 = 0 (homoskedasticity). The test statistic is defined as:

LM=nR2LM = nR^2

where R2R^2 is the R-squared value from the regression of u2u^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

# 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)

Bootstrapped version of the White's test (Jeong, J., Lee, K. (1999))

Description

This is a versioned White's test based on a bootstrap procedure that can improve the performance of White’s test, specially in small samples. It was proposed by Jeong, J., Lee, K. (1999) (see references for further details).

Usage

white_test_boot(model, bootstraps = 1000)

Arguments

model

An object of class lm

bootstraps

Number of bootstrap to be performed. If 'bootstraps' is less than 10, it will automatically be set to 10. At least 500 simulations are recommended. Default value is set to 1000.

Details

The bootstrapped error term is defined by:

ui^=σ2ti(i=1,...N)\widehat{u_i} = \sigma^2 * t_i^{*} (i = 1,...N)

where tit_i^{*} follows a distribution satisfying E(t)=0E(t) = 0 and var(t)=Ivar(t) = I.

In particular, the selected distribution of tt can be found at the bottom of page 196 at Handbook of Computational Econometrics (2009).

Value

A list with class white_test containing:

w_stat The value of the test statistic
p_value The p-value of the test
iters The number of bootstrap samples

References

Jeong, J., & Lee, K. (1999). Bootstrapped White’s test for heteroskedasticity in regression models. Economics Letters, 63(3), 261-267.

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,

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_boot(fit)