Studentized Breusch–Pagan test (deprecated)¶
Source: R/additional_tests.R · Help: ?performStudentizedBPTest
performStudentizedBPTest() is deprecated since 0.14.0: use
performKoenkerTest(), which computes the same statistic. It still works
and warns, and returns what it returned before except on a fit returned by
fitWLS(). The model frame of that fit holds the weights of the model
fitWLS() refitted (none, for an unweighted model), not the estimated
weights, and before 0.15.0 performStudentizedBPTest() read them from
there, so it computed the statistic of the unweighted fit. Since 0.15.0 it
reads the weights of the fit, as performKoenkerTest() does, and the two
agree. On a model with an offset they still differ:
performStudentizedBPTest() drops the offset, which is to be fixed in
0.16.0, and performKoenkerTest() is the correct one.
Usage¶
Arguments¶
model- A fitted stats::lm object providing the residuals and design matrix for the auxiliary regression.
data- A base::data.frame containing the variables used to fit
model. It must include all observations referenced by the model object. WhenNULL, the default, the model frame ofmodelis used. It holds the terms of the model rather than its variables (log(x)rather thanx), so a model that transforms a variable needsdata, as does a model with anoffset()term, and so may a fit whoseweightsoroffsetargument is a column of the data, which the model frame holds as(weights)or(offset).
Value¶
An object of class htest reporting the chi-squared statistic
and p-value for the null hypothesis of constant error variance.
Details¶
Computes Koenker's (1981) studentized form of the Breusch–Pagan Lagrange
multiplier statistic, \(n R^2\) from the regression of the squared
residuals on the regressors. The classical Breusch–Pagan statistic assumes
normal errors and this one does not: in the simulations of
inst/validation/ it holds its level under \(t_5\) errors, where the
classical statistic rejects far too often.
Following Koenker (1981) and the implementation in
lmtest::bptest(), the procedure fits an auxiliary
regression of \(e_i^2 - \hat{\sigma}^2\) on the regressors from the
original model (including the intercept), where \(e_i\) denotes the
residuals and \(\hat{\sigma}^2 = \sum e_i^2 / n\) the mean of their
squares. With \(\hat{g}_i\) the fitted values of that regression, the
statistic \(T = n \sum \hat{g}_i^2 / \sum (e_i^2 - \hat{\sigma}^2)^2\) is
its \(n R^2\). Under homoskedasticity it is asymptotically chi-squared with
degrees of freedom equal to the number of regressors beyond the intercept,
whether or not the errors are normal. On a weighted fit \(e_i\) is the Pearson
residual \(\sqrt{w_i}\) times the raw residual and the auxiliary
regression is unweighted; see the section on weighted fits in
performKoenkerTest(). This departs from lmtest::bptest(), which keeps the
raw residuals and weights the auxiliary regression. The implementation
shares the validation
helpers used across the package to ensure that: (i) the model and data satisfy
minimum sample-size thresholds via rvalidateModelInputs() and
rvalidateDataInputs(), (ii) missing values are handled by
rhandleMissingValues(), and (iii) the
requirements registered for this test in
rvalidateTestRequirements() are met.
References¶
Koenker, R. (1981). A note on studentizing a test for heteroscedasticity. Journal of Econometrics, 17(1), 107–112. doi:10.1016/0304-4076(81)90062-2
Davidson, R., & MacKinnon, J. G. (2004). Econometric Theory and Methods. Oxford University Press. Section 7.5 derives the test as \(n R^2\) from the regression of the squared residuals on the variance regressors.
See also¶
performBPTest() for the classical LM statistic, which assumes normal
errors, and performKoenkerTest(), which computes the same studentized
\(n R^2\) statistic on the squared residuals. The robust workflow in
performBPTestRobust() augments the studentized statistic with bootstrap
diagnostics.