When I conduct a manual BP test in R, like so
model <- lm(Y~X, data = dataset)
summary(model)
# BP Test
adj_model <- lm(resid(model)^2 ~ dataset$X)
summary(adj_model)
I get an F statistic of 18.74:
> summary(adj_model)
Call:
lm(formula = resid(model)^2 ~ dataset$X)
Residuals:
Min 1Q Median 3Q Max
-186.517 -47.607 -6.497 36.640 269.204
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -53.869 36.477 -1.477 0.150889
dataset$X 8.895 2.055 4.329 0.000173 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 97.41 on 28 degrees of freedom
Multiple R-squared: 0.401, Adjusted R-squared: 0.3796
F-statistic: 18.74 on 1 and 28 DF, p-value: 0.0001728
There are 30 observations in the sample, and the model has a multiple R^2 of 0.401 with just the one regressor. So if I use a calculator to get the F statistic, the result is the same as above:
F=\frac{0.401\div(2-1)}{(1-0.401)\div(30-2)}=18.74
But when I use the bptest()
function from the lmtest
library, I get something completely different:
> bptest(model)
studentized Breusch-Pagan test
data: model
BP = 12.029, df = 1, p-value = 0.0005237
I thought that this might have something to do with the 'studentisation', but even when I turn this off, I still get a result that isn't close to 18.74:
> bptest(model, studentize = FALSE)
Breusch-Pagan test
data: model
BP = 12.599, df = 1, p-value = 0.0003859
How can these discrepancies be explained?