In practical terms, ncvTest
uses the left-hand-side of the equation and bptest
uses the right-hand-side, by default.
It means that in a case of Y ~ X
, both tests will provide the same results (regarding the studentize = F
option of bptest
). But in a multivariate analysis such as Y ~ X1 + X2
, the results will be different. (As @Helix123 pointed out)
From the help file of ncvTest : var.formula
: "a one-sided formula for the error variance; if omitted, the error variance depends on the fitted values." Which means that, by default, the fitted values will be used, but it also allows to use a linear combination of the independent variables (X1 + X2).
From the help file of bptest : varformula
: "By default the same explanatory variables are taken as in the main regression model."
Continuing the same example of @Francis (data stat500
, from faraway
package):
> mdl_t = lm(final ~ midterm + hw, data = stat500)
BP test, using fitted values:
> ncvTest(mdl_t) # Default
Non-constant Variance Score Test
Variance formula: ~ fitted.values
Chisquare = 0.6509135 Df = 1 p = 0.4197863
> bptest(mdl_t, varformula = ~ fitted.values(mdl_t), studentize = F)
Breusch-Pagan test
data: mdl_t
BP = 0.65091, df = 1, p-value = 0.4198
BP test, using a linear combination of predictors:
> ncvTest(mdl_t, var.formula = ~ midterm + hw)
Non-constant Variance Score Test
Variance formula: ~ midterm + hw
Chisquare = 0.7689743 Df = 2 p = 0.6807997
> bptest(mdl_t, studentize = F) # Default
Breusch-Pagan test
data: mdl_t
BP = 0.76897, df = 2, p-value = 0.6808
The "linear combination option" allows to investigate heteroskedasticity associated to linear dependence of a specific independent variable. For example, just the hw
variable:
> ncvTest(mdl_t, var.formula = ~ hw)
Non-constant Variance Score Test
Variance formula: ~ hw
Chisquare = 0.04445789 Df = 1 p = 0.833004
> bptest(mdl_t, varformula = ~ stat500$hw, studentize = F)
Breusch-Pagan test
data: mdl_t
BP = 0.044458, df = 1, p-value = 0.833
Lastly, as @Francis summarized, "In short, the studentized BP test is more robust than the original one", I usually go with bptest
, with studentize = TRUE
(default) and varformula = ~ fitted.values(my.lm)
as options, for an initial approach for homoskedasticity.