# Testing homoscedasticity with Breusch-Pagan test

In these days I'm working with Breusch-Pagan to test homoscedasticity.

I've tested the prices of two stocks with this method. This is the result:

> mod <- lm(prices[,1] ~ prices[,2])
> bp <- bptest(mod)
> bp

studentized Breusch-Pagan test

data:  prices[, 1] ~ prices[, 2]
BP = 0.032, df = 1, p-value = 0.858


Reading the result the series should be homoscedastic, but if I plot the residuals and the squares residuals it seems totally not! Take a look below:

the Residuals Vs FItted below:

How is it possible this series pass the test with a very high p-value?

• BP test requires that variables on the right hand side should be exogenous. Since you have two prices, they may influence each other. Another feature of the prices is that they are usually unit-root processes, that is usually a no-no in simple regression tests. I should check these two things before investigating further. – mpiktas Sep 13 '11 at 12:12
• @Mpiktas, The series you see above has not unit root.I checked it using PP test and KPSS test. How can i change the formula in this case?do i have to use another test instead of BP? – Dail Sep 13 '11 at 13:16

The problem isn't heteroskedasticity, that's why it's passing the test. The problem is that your model doesn't work well for (at least some of) your observations.

I've never seen anyone analyze stock prices without looking at their differences. Try a Dickey-Fuller test for a unit root---I bet that you can't reject that there is one, as @mpiktas alludes to in his comment.

If there isn't a unit root, perhaps there is a time trend or seasonality. You might try including a linear time trend or seasonal components.

Alternatively, you might try working with the log of the prices, which sometimes helps the fit.

• I have replied to mpiktas, before Breusch-Pagan I check the series with: Phillips-Perron and KPSS unit root tests. Unfortunately, the series pass these tests. I also check the cointegration with Johansen and the series pass again(cointegrated). What could I do? – Dail Sep 13 '11 at 14:06
• Your data do not reject the null in the KPSS and do reject the null in the Phillips-Perron test? As I said, BP is telling you that heteroskedasticity isn't a problem here, so you don't need to correct for it. The pattern of your residuals suggests that there may be some kind of time trend lurking around if there isn't a unit root; I added that part to my answer. Don't worry about heteroskedasiticy (you pass BP), worry about your model. Suggestions to remove spikes in residuals: Try incorporating time trends or seasonality; try using logs of prices instead. – Charlie Sep 13 '11 at 15:07
• If you really worry about heteroskedasticity for some reason, even though BP says that you don't need to and your plots suggest that your model needs to be tweaked instead, you can use robust standard errors. – Charlie Sep 13 '11 at 15:08
• the PP reject the null and KPSS can't reject the null. So the series should not have unit root and should be stationary...and also johansen procedure tell me that the series are cointegrated. My problem is not to correct it, I only what to delete the pair (stockA - stockB) that don't have constant variance. BP test is saying that the data is homoscedastic but is not. So what is the method that i can use to understand if this "variance" is constant for real ? – Dail Sep 13 '11 at 15:20
• as you surely understand I need to do the linear regression to know the coefficient, EVERY stock of A how many stocks of B I need to have? If i remove spikes, or doing any other change I cant get fixed coefficients. – Dail Sep 13 '11 at 15:22