How to Perform White’s Test in R

Spread the love

In the realm of regression diagnostics, identifying heteroscedasticity is paramount to ensuring the accuracy and reliability of model inferences. White’s Test, also known as White’s heteroscedasticity test, is a popular statistical tool designed to detect this phenomenon. In this comprehensive guide, we’ll delve into the specifics of White’s Test, understand its significance, and demonstrate how to execute it in R.

Unraveling Heteroscedasticity

At the heart of linear regression is the assumption of homoscedasticity, which means that the variance of the residuals remains constant across all levels of the independent variables. When this assumption is violated, we face heteroscedasticity, which can distort the standard errors, undermining the efficiency of the coefficient estimates and the accuracy of hypothesis tests.

White’s Test: The Essentials

White’s Test is a versatile tool that detects heteroscedasticity by considering non-linear combinations of the independent variables. It doesn’t require you to specify a particular structure for the heteroscedasticity, making it a general test.

The test follows these stages:

  1. Estimate the desired regression model and retrieve the residuals.
  2. Square the residuals to acquire a proxy for variance.
  3. Regress these squared residuals on the original predictors, their squares, and their cross-products.
  4. Evaluate the significance of this auxiliary regression.

Executing White’s Test in R

Step 1: Install and Load Necessary Packages

Ensure the lmtest package is installed. If you don’t have it:


Load the library:


Step 2: Establish Your Regression Model

Assume you have a dataset named data with dependent variable y and independent variables x1 and x2.

model <- lm(y ~ x1 + x2, data = data)

Step 3: Conduct White’s Test

With the bptest() function, albeit traditionally used for the Breusch-Pagan test, can also be adapted for White’s Test:

white_result <- bptest(model, ~ x1 + x2 + I(x1^2) + I(x2^2) + I(x1*x2), data = data)

Here, I() is a way to incorporate non-linear transformations in formulas in R. We regress on the predictors, their squares, and their cross-products.

Step 4: Interpret the Outcome

The bptest() function outputs a test statistic and a p-value:

  • p-value < 0.05: Indicates heteroscedasticity.
  • p-value > 0.05: No significant heteroscedasticity detected.

Contemplating Heteroscedasticity Remedies

If White’s Test indicates heteroscedasticity, consider these solutions:

  1. Data Transformation: Techniques like logging or taking the square root of the dependent variable can help.
  2. Robust Standard Errors: Use heteroscedasticity-consistent (HC) standard errors that adjust for varying variances.
  3. Generalized Least Squares (GLS): An extension of OLS, GLS can model varying variances explicitly.

Points to Ponder

  1. Model Adequacy: Sometimes, heteroscedasticity is a symptom of model misspecification. An omitted crucial variable or a wrong functional form can be the root cause.
  2. Test Limitations: White’s Test, despite its general nature, has limitations. It may not detect heteroscedasticity stemming from omitted variables, and it might suffer from low power in small samples.
  3. Other Tests: It’s beneficial to consider tests like the Breusch-Pagan or Goldfeld-Quandt, especially if you suspect a specific form of heteroscedasticity.


White’s Test provides an expansive framework for detecting heteroscedasticity, ensuring the robustness of regression analyses. By incorporating this test into your statistical toolbox and executing it in R, you’re better equipped to interpret regression results accurately and make more informed decisions in your research or analytics work.

Posted in RTagged

Leave a Reply