One of the key assumptions of linear regression is that the residuals are distributed with equal variance at each level of the predictor variable. This assumption is known as **homoscedasticity**.

When this assumption is violated, we say that heteroscedasticity is present in the residuals. When this occurs, the results of the regression become unreliable.

One way to visually detect whether heteroscedasticity is present is to create a plot of the residuals against the fitted values of the regression model.

If the residuals become more spread out at higher values in the plot, this is a tell-tale sign that heteroscedasticity is present.

A formal statistical test we can use to determine if heteroscedasticity is present is the **Breusch-Pagan test**.

This tutorial provides a brief explanation of the Breusch-Pagan test along with an example.

**What is the Breusch-Pagan Test?**

The **Breusch-Pagan test** is used to determine whether or not heteroscedasticity is present in a regression model.

The test uses the following null and alternative hypotheses:

**Null Hypothesis (H**Homoscedasticity is present (the residuals are distributed with equal variance)_{0}):**Alternative Hypothesis (H**Heteroscedasticity is present (the residuals are not distributed with equal variance)_{A}):

If the p-value of the test is less than some significance level (i.e. α = .05) then we reject the null hypothesis and conclude that heteroscedasticity is present in the regression model.

We use the following steps to perform a Breusch-Pagan test:

**1. **Fit the regression model.

**2. **Calculate the squared residuals of the model.

**3.** Fit a new regression model, using the squared residuals as the response values.

**4. **Calculate the Chi-Square test statistic X^{2} as n*R^{2}_{new} where:

**n:**The total number of observations**R**The R-squared of the new regression model that used the squared residuals as the response values^{2}_{new}:

If the p-value that corresponds to this Chi-Square test statistic with *p* (the number of predictors) degrees of freedom is less than some significance level (i.e. α = .05) then reject the null hypothesis and conclude that heteroscedasticity is present.

Otherwise, fail to reject the null hypothesis. In this case, it’s assumed that homoscedasticity is present.

Note that most statistical software can easily perform the Breusch-Pagan test so you will likely never have to perform these steps by hand, but it’s useful to know what’s going on behind the scenes.

**An Example of the Breusch-Pagan Test**

Suppose we have the following dataset that contains information for 10 different basketball players:

Using statistical software, we fit the following multiple linear regression model:

rating = 62.47 + 1.12*(points) + 0.88*(assists) – 0.43*(rebounds)

We then use this model to make predictions for the rating of each player and calculated the squared residuals (i.e. the squared difference between the predicted rating and the actual rating):

Next, we fit a new regression model using the squared residuals as the response values and the original predictor variables as the predictor variables once again. We find the following:

**n:**10**R**0.600395^{2}_{new}:

Thus, our Chi-Square test statistic for the Breusch-Pagan test is n*R^{2}_{new} = 10*.600395 = **6.00395**. The degrees of freedom is *p* = 3 predictor variables.

According to the Chi-Square to P-Value Calculator, the p-value that corresponds to X^{2} = 6.00395 with 3 degrees of freedom is **0.111418**.

Since this p-value is not less than .05, we fail to reject the null hypothesis. Thus, we assume that homoscedasticity is present.

**The Breusch-Pagan Test in Practice**

The following tutorials provide step-by-step examples of how to perform the Breusch-Pagan test in different statistical programs:

How to Perform a Breusch-Pagan Test in Excel

How to Perform a Breusch-Pagan Test in R

How to Perform a Breusch-Pagan Test in Python

How to Perform a Breusch-Pagan Test in Stata

You have no idea how many “lives” you’ve just saved with this wonderful tutorial and resources to go along with it.

Thank you so much!

There’s a typo in the null hypothesis… it should read:

Null Hypothesis (H0): Homoscedasticity is not present (the residuals are distributed with equal variance)

Hi !

Thank you very much for your work !

Is it normal that the squared residuals don’t correspond to predicted rating minus rating ?

I don’t find the same results as you…

I thank you for your answer,

Hi Zack. I was stuck and you have rescued me. Thanks!

Joshua

I think you got the hypothesis part wrong. Based on my sources, if the chi-square calculated is less than the critical value, homoskedasticity is present. You got it the other way around. A typo perhaps.

Hi Yuds…You’re absolutely correct, and I appreciate the clarification. My apologies for any confusion caused by the error. Let me correct that:

In the context of testing for homoscedasticity using the Breusch-Pagan test, the null hypothesis is that the errors are homoscedastic (constant variance), while the alternative hypothesis is that the errors are heteroscedastic (varying variance).

To conduct the Breusch-Pagan test for homoscedasticity in R, you would typically use the `bptest()` function from the `lmtest` package. The function returns a test statistic and a p-value. If the p-value is less than your chosen significance level (e.g., 0.05), you reject the null hypothesis of homoscedasticity, indicating the presence of heteroscedasticity.

Here’s an example:

“`R

# Load the lmtest package

library(lmtest)

# Fit a linear regression model

model <- lm(y ~ x1 + x2, data = your_data) # Perform Breusch-Pagan test for homoscedasticity test_result <- bptest(model) # Print test result print(test_result) ``` If the p-value from `bptest()` is less than your chosen significance level (e.g., 0.05), you would conclude that there is evidence of heteroscedasticity in the errors. Conversely, if the p-value is greater than your significance level, you would fail to reject the null hypothesis and conclude that homoscedasticity is present. Again, I appreciate your attention to detail and apologize for any confusion caused by the earlier error.

True. I think the hypothesis has been stated incorrectly and the inference that would be would be incorrect.