bptest.sarlm {spdep} | R Documentation |
Performs the Breusch-Pagan test for heteroskedasticity on the least squares fit of the spatial models taking the spatial coefficients rho or lambda into account. This function is a copy of the bptest
function in package "lmtest", modified to use objects returned by spatial simultaneous autoregressive models.
bptest.sarlm(object, varformula=NULL, studentize = TRUE, data=list())
object |
An object of class |
varformula |
a formula describing only the potential explanatory variables for the variance (no dependent variable needed). By default the same explanatory variables are taken as in the main regression model |
studentize |
logical. If set to |
data |
an optional data frame containing the variables in the varformula |
Asymptotically this corresponds to the test given by Anselin (1988), but is not exactly the same. The studentized version is more conservative and perhaps to be prefered. The residuals, and for spatial error models the RHS variables, are adjusted for the spatial coefficient, as suggested bt Luc Anselin (personal communication).
It is also technically possible to make heteroskedasticity corrections to standard error estimates by using the “lm.target” component of sarlm
objects - using functions in the lmtest and sandwich packages.
A list with class "htest"
containing the following components:
statistic |
the value of the test statistic. |
p.value |
the p-value of the test. |
parameter |
degrees of freedom. |
method |
a character string indicating what type of test was performed. |
Torsten Hothorn Torsten.Hothorn@rzmail.uni-erlangen.de and Achim Zeileis zeileis@ci.tuwien.ac.at, modified by Roger Bivand Roger.Bivand@nhh.no
T.S. Breusch & A.R. Pagan (1979), A Simple Test for Heteroscedasticity and Random Coefficient Variation. Econometrica 47, 1287–1294
W. Krämer & H. Sonnberger (1986), The Linear Regression Model under Test. Heidelberg: Physica.
L. Anselin (1988) Spatial econometrics: methods and models. Dordrecht: Kluwer, pp. 121–122.
example(columbus) error.col <- errorsarlm(CRIME ~ HOVAL + INC, data=columbus, nb2listw(col.gal.nb)) bptest.sarlm(error.col) bptest.sarlm(error.col, studentize=FALSE) ## Not run: lm.target <- lm(error.col$tary ~ error.col$tarX - 1) if (require(lmtest) && require(sandwich)) { coeftest(lm.target, vcov=vcovHC(lm.target, type="HC0"), df=Inf) } ## End(Not run)