Type: | Package |
Title: | White Test and Bootstrapped White Test for Heteroskedasticity |
Version: | 0.0.1 |
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. |
License: | MIT + file LICENSE |
BugReports: | https://github.com/jlopezper/whitestrap/issues |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.0.0 |
Imports: | stats, graphics |
Depends: | R (≥ 2.10) |
Suggests: | testthat, covr |
NeedsCompilation: | no |
Packaged: | 2020-06-01 23:15:42 UTC; jlopezper |
Author: | Jorge Lopez Perez [aut, cre, cph], Jinook Jeong [ctb] |
Maintainer: | Jorge Lopez Perez <jorge@loperez.com> |
Repository: | CRAN |
Date/Publication: | 2020-06-04 14:10:02 UTC |
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)
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 |
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:
\widehat{u_i} = \sigma^2 * t_i^{*} (i = 1,...N)
where t_i^{*}
follows a distribution satisfying E(t) = 0
and var(t) = I
.
In particular, the selected distribution of t
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)