Discussion 7: Heteroskedasticity with White’s Test

Author

Will Brewster

Published

April 25, 2026

I. Issue Summary

  1. Heteroskedasticity refers to variance of the distribution of the error terms for a different values of a variable. We see that if the distributions become more spread out, the errors are heteroskedastic. The issue that this causes is that inferences made are no longer completely accurate due to the distribution of the t-statistic, and this also impacts the validity of confidence intervals.
  2. The null hypothesis is that the variances are equal (homoskedasticity). The alternative hypothesis is that there is not homoskedasticity (and therefore heteroskedasticity). I agree with the logic of the two different approaches in the sense that if the White’s test is more general than the BP test, it would not assume a particular relationship like the BP does and be more flexible.

II. Coding

The data I selected is also from the “births” data set. Below is a description of the variable from the data set, which is comprised of 150 observations from birth records from North Carolina in 2004:

Variable Definition
weight Birth weight of baby
visits Number of hospital visits
gained Weight gained by mother
weeks Weeks at which mother gave birth

The linear regression that I will use is :

\(weight = \beta_{0}+visits\times\beta_{1}+gained\times\beta_{2}+weeks\times\beta_{3}\)

births1 <- drop_na(births)
birthmodel <-lm(births1$weight ~ births1$visits + births1$gained + births1$weeks)
summary(birthmodel)

Call:
lm(formula = births1$weight ~ births1$visits + births1$gained + 
    births1$weeks)

Residuals:
     Min       1Q   Median       3Q      Max 
-2.29653 -0.60125  0.00053  0.66863  2.65133 

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)    -6.020699   1.329592  -4.528 1.48e-05 ***
births1$visits  0.034837   0.030012   1.161   0.2482    
births1$gained  0.011897   0.006184   1.924   0.0569 .  
births1$weeks   0.319191   0.037207   8.579 5.80e-14 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.01 on 113 degrees of freedom
Multiple R-squared:  0.4924,    Adjusted R-squared:  0.4789 
F-statistic: 36.54 on 3 and 113 DF,  p-value: < 2.2e-16
stargazer(birthmodel, type = "text")

===============================================
                        Dependent variable:    
                    ---------------------------
                              weight           
-----------------------------------------------
visits                         0.035           
                              (0.030)          
                                               
gained                        0.012*           
                              (0.006)          
                                               
weeks                        0.319***          
                              (0.037)          
                                               
Constant                     -6.021***         
                              (1.330)          
                                               
-----------------------------------------------
Observations                    117            
R2                             0.492           
Adjusted R2                    0.479           
Residual Std. Error      1.010 (df = 113)      
F Statistic           36.538*** (df = 3; 113)  
===============================================
Note:               *p<0.1; **p<0.05; ***p<0.01
par(mfrow = c(2, 2))

# Create a residual plot
plot(birthmodel)

At first glance it seems like the data is quite even (the Q-Q residuals for example are all along a straight line).

Computing the White’s test with interactions = True (should two-way interactions between explanatory variables be included):

white(birthmodel, interactions = TRUE)
# A tibble: 1 × 5
  statistic p.value parameter method       alternative
      <dbl>   <dbl>     <dbl> <chr>        <chr>      
1      14.7   0.100         9 White's Test greater    

We see that the test statistic of 14.7 and the corresponding p-value (0.1) is above 0.05. Therefore, we fail to reject the null hypothesis of homogeneity and conclude that there is no heteroskedasticity.

Running the auxiliary regression, the p-value ends up being almost the same (0.1 versus 0.097):

births1$residuals <- resid(object = birthmodel)

summary(births1$residuals)
      Min.    1st Qu.     Median       Mean    3rd Qu.       Max. 
-2.2965349 -0.6012509  0.0005323  0.0000000  0.6686250  2.6513278 
births1$residuals_squared <-(births1$residuals)^2

summary(births1$residuals_squared)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
0.00000 0.08742 0.44706 0.98525 1.18052 7.02954 
white_auxillary_reg <- lm(
  formula = residuals_squared ~ visits + gained + weeks +
    I(visits^2) + I(gained^2) + I(weeks^2) +
    visits:gained + visits:weeks + weeks:gained,
  data = births1
)

white_auxillary_reg_summary <- summary(white_auxillary_reg)
white_auxillary_reg_summary

Call:
lm(formula = residuals_squared ~ visits + gained + weeks + I(visits^2) + 
    I(gained^2) + I(weeks^2) + visits:gained + visits:weeks + 
    weeks:gained, data = births1)

Residuals:
    Min      1Q  Median      3Q     Max 
-2.3236 -0.7934 -0.4068  0.4546  6.2030 

Coefficients:
                Estimate Std. Error t value Pr(>|t|)   
(Intercept)   20.9898145 12.8031114   1.639  0.10406   
visits         0.2312707  0.7493751   0.309  0.75821   
gained         0.2508783  0.1553229   1.615  0.10921   
weeks         -1.3352465  0.8398400  -1.590  0.11481   
I(visits^2)    0.0009932  0.0095980   0.103  0.91778   
I(gained^2)    0.0001150  0.0003253   0.354  0.72429   
I(weeks^2)     0.0190508  0.0134878   1.412  0.16072   
visits:gained -0.0078190  0.0029095  -2.687  0.00835 **
visits:weeks  -0.0004469  0.0196079  -0.023  0.98186   
gained:weeks  -0.0039124  0.0040400  -0.968  0.33502   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.313 on 107 degrees of freedom
Multiple R-squared:  0.1254,    Adjusted R-squared:  0.05182 
F-statistic: 1.704 on 9 and 107 DF,  p-value: 0.09674

Since the R-squared value (0.052) is low, intuitively this shows that there is no heteroskedasticity in the model. Now testing this value using the chi-square test, we find the same p-value and test statistic from the original White’s test function:

chisq_p_value <- pchisq(
  q = white_auxillary_reg_summary$r.squared * nobs(white_auxillary_reg),
  df = 9,
  lower.tail = FALSE
)

chisq_p_value
[1] 0.1004133
#replicating the test statistic:
white_auxillary_reg_summary$r.squared * nobs(white_auxillary_reg)
[1] 14.66984
#critical value = 3.325
qchisq(p = .05, df = 9)
[1] 3.325113
# test statistic = 14.66
qchisq(p  = chisq_p_value, 
       df = 9, 
       lower.tail = FALSE
       )
[1] 14.66984

So, given that test statistic is beyond (to the right) of the critical value of 3.325, it is not in the critical region and we again fail to reject the null hypothesis.