bptest.sarlm: Breusch-Pagan test for spatial models

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/bptest.sarlm.R

Description

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.

Usage

1
bptest.sarlm(object, varformula=NULL, studentize = TRUE, data=list())

Arguments

object

An object of class "sarlm" from errorsarlm() or lagsarlm().

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 TRUE Koenker's studentized version of the test statistic will be used.

data

an optional data frame containing the variables in the varformula

Details

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.

Value

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 (wrongly reported if varformula given before 0.5-44.

method

a character string indicating what type of test was performed.

Author(s)

Torsten Hothorn [email protected] and Achim Zeileis [email protected], modified by Roger Bivand [email protected]

References

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.

See Also

errorsarlm, lagsarlm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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)

Example output

Loading required package: sp
Loading required package: Matrix

colmbs> require(maptools)
Loading required package: maptools
Checking rgeos availability: TRUE

colmbs> columbus <- readShapePoly(system.file("etc/shapes/columbus.shp",
colmbs+  package="spdep")[1])

colmbs> col.gal.nb <- read.gal(system.file("etc/weights/columbus.gal",
colmbs+  package="spdep")[1])
Warning message:
use rgdal::readOGR or sf::st_read 

	studentized Breusch-Pagan test

data:  
BP = 9.3694, df = 2, p-value = 0.009235


	Breusch-Pagan test

data:  
BP = 16.285, df = 2, p-value = 0.0002908

Loading required package: lmtest
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: sandwich

z test of coefficients:

                                            Estimate Std. Error z value
error.col$tarXI(x - lambda * WX)(Intercept) 61.05362    4.69780 12.9962
error.col$tarXI(x - lambda * WX)HOVAL       -0.30798    0.16434 -1.8740
error.col$tarXI(x - lambda * WX)INC         -0.99547    0.44404 -2.2418
                                            Pr(>|z|)    
error.col$tarXI(x - lambda * WX)(Intercept)  < 2e-16 ***
error.col$tarXI(x - lambda * WX)HOVAL        0.06093 .  
error.col$tarXI(x - lambda * WX)INC          0.02497 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

spdep documentation built on Sept. 2, 2017, 1:11 a.m.