Skip to contents

Rao's score and adjusted Rao's score tests of linear hypotheses applied to a fitted linear model to examine whether either the spatially lagged dependent variable lag or the spatially lagged independent variable(s) WX should be included in the model, or both (SDM). Adjusted tests are provided for lag and WX adapting to the presence of the other, and a joint test for both. The joint test is equal to the unadjusted of one plus the adjusted of the other. In addition, draft tests are added from Koley (2024, section 6) for spatial Durbin error models to examine whether either the spatially lagged error err or the spatially lagged independent variable(s) WX should be included in the model, or both (SDEM); because of orthogonality, no adjusted tests are required.

Usage

SD.RStests(model, listw, zero.policy = attr(listw, "zero.policy"), test = "SDM",
 Durbin = TRUE)

Arguments

model

an object of class lm returned by lm

listw

a listw object created for example by nb2listw, expected to be row-standardised (W-style)

zero.policy

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

test

test=“SDM” computes the SDM tests, a character vector of tests requested chosen from SDM_RSlag, SDM_adjRSlag, SDM_RSWX, SDM_adjRSWX, SDM_Joint, test=“SDEM” computes the SDEM tests, a character vector of tests requested chosen from SDEM_RSerr, SDEM_RSWX, SDEM_Joint; test=“all” computes all the tests

Durbin

default TRUE for Durbin models including WX; if TRUE, full spatial Durbin model; if a formula object, the subset of explanatory variables to lag

Value

A list of class LMtestlist of htest objects, each with:

statistic

the value of the Lagrange Multiplier test.

parameter

number of degrees of freedom

p.value

the p-value of the test.

method

a character string giving the method used.

data.name

a character string giving the name(s) of the data.

References

Malabika Koley and Anil K. Bera (2024) To use, or not to use the spatial Durbin model? – that is the question, Spatial Economic Analysis, 19:1, 30-56, doi:10.1080/17421772.2023.2256810 ; Malabika Koley (2024) Specification Testing under General Nesting Spatial Model (Appendix C), https://sites.google.com/view/malabikakoley/research.

Author

Roger Bivand Roger.Bivand@nhh.no, Malabika Koley and Anil K. Bera

Note

The results in the example below agree with those in Table 3, p. 22 in Koley and Bera (2024).

See also

Examples

columbus <- sf::st_read(system.file("shapes/columbus.gpkg", package="spData")[1])
#> Reading layer `columbus' from data source 
#>   `/home/rsb/lib/r_libs/spData/shapes/columbus.gpkg' using driver `GPKG'
#> Simple feature collection with 49 features and 20 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 5.874907 ymin: 10.78863 xmax: 11.28742 ymax: 14.74245
#> Projected CRS: Undefined Cartesian SRS with unknown unit
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
col.listw <- nb2listw(col.gal.nb, style="W")
lm_obj <- lm(CRIME ~ INC + HOVAL, data=columbus)
summary(lm.RStests(lm_obj, col.listw, test="all"))
#> 	Rao's score (a.k.a Lagrange multiplier) diagnostics for spatial
#> 	dependence
#> data:  
#> model: lm(formula = CRIME ~ INC + HOVAL, data = columbus)
#> test weights: col.listw
#>  
#>          statistic parameter  p.value   
#> RSerr     4.611126         1 0.031765 * 
#> RSlag     7.855675         1 0.005066 **
#> adjRSerr  0.033514         1 0.854744   
#> adjRSlag  3.278064         1 0.070212 . 
#> SARMA     7.889190         2 0.019359 * 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
res <- SD.RStests(lm_obj, col.listw, test="SDM")
summary(res)
#> 	Rao's score test spatial Durbin diagnostics
#> data:  
#> model: lm(formula = CRIME ~ INC + HOVAL, data = columbus)
#> weights: col.listw
#>  
#>              statistic parameter  p.value   
#> SDM_RSlag       7.8557         1 0.005066 **
#> SDM_adjRSlag    4.6111         1 0.031765 * 
#> SDM_RSWX        6.1376         2 0.046477 * 
#> SDM_adjRSWX     2.8931         2 0.235386   
#> SDM_Joint      10.7487         3 0.013165 * 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
all.equal(unname(res$SDM_Joint$statistic),
 unname(res$SDM_RSlag$statistic + res$SDM_adjRSWX$statistic))
#> [1] TRUE
all.equal(unname(res$SDM_Joint$statistic),
 unname(res$SDM_adjRSlag$statistic + res$SDM_RSWX$statistic))
#> [1] TRUE
res <- SD.RStests(lm_obj, col.listw, test="SDEM")
summary(res)
#> 	Rao's score test spatial Durbin diagnostics
#> data:  
#> model: lm(formula = CRIME ~ INC + HOVAL, data = columbus)
#> weights: col.listw
#>  
#>            statistic parameter p.value  
#> SDEM_RSerr    4.6111         1 0.03177 *
#> SDEM_RSWX     6.1376         2 0.04648 *
#> SDEM_Joint   10.7487         3 0.01317 *
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
all.equal(unname(res$SDEM_Joint$statistic),
 unname(res$SDEM_RSerr$statistic + res$SDEM_RSWX$statistic))
#> [1] TRUE
summary(SD.RStests(lm_obj, nb2listw(col.gal.nb, style="C"), test="all"))
#> Warning: Spatial weights matrix not row standardized
#> 	Rao's score test spatial Durbin diagnostics
#> data:  
#> model: lm(formula = CRIME ~ INC + HOVAL, data = columbus)
#> weights: nb2listw(col.gal.nb, style = "C")
#>  
#>              statistic parameter  p.value   
#> SDM_RSlag      10.6095         1 0.001125 **
#> SDM_adjRSlag    4.8428         1 0.027762 * 
#> SDM_RSWX        9.2305         3 0.026378 * 
#> SDM_adjRSWX     3.4637         3 0.325498   
#> SDM_Joint      14.0733         4 0.007065 **
#> SDEM_RSerr      4.8428         1 0.027762 * 
#> SDEM_RSWX       9.2305         3 0.026378 * 
#> SDEM_Joint     14.0733         4 0.007065 **
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(SD.RStests(lm_obj, col.listw, test="all", Durbin= ~ INC))
#> 	Rao's score test spatial Durbin diagnostics
#> data:  
#> model: lm(formula = CRIME ~ INC + HOVAL, data = columbus)
#> weights: col.listw
#> Durbin: ~ INC
#>  
#>              statistic parameter  p.value   
#> SDM_RSlag      7.85568         1 0.005066 **
#> SDM_adjRSlag   3.16076         1 0.075428 . 
#> SDM_RSWX       4.92399         1 0.026486 * 
#> SDM_adjRSWX    0.22908         1 0.632210   
#> SDM_Joint      8.08475         2 0.017556 * 
#> SDEM_RSerr     4.61113         1 0.031765 * 
#> SDEM_RSWX      4.92399         1 0.026486 * 
#> SDEM_Joint     9.53512         2 0.008501 **
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
lm_obj0 <- lm(I(scale(CRIME)) ~ 0 + I(scale(INC)) + I(scale(HOVAL)),
 data=columbus)
summary(SD.RStests(lm_obj0, col.listw, test="all"))
#> 	Rao's score test spatial Durbin diagnostics
#> data:  
#> model: lm(formula = I(scale(CRIME)) ~ 0 + I(scale(INC)) +
#> I(scale(HOVAL)), data = columbus)
#> weights: col.listw
#>  
#>              statistic parameter  p.value   
#> SDM_RSlag       7.8250         1 0.005153 **
#> SDM_adjRSlag    4.6111         1 0.031765 * 
#> SDM_RSWX        6.0609         2 0.048295 * 
#> SDM_adjRSWX     2.8470         2 0.240873   
#> SDM_Joint      10.6720         3 0.013638 * 
#> SDEM_RSerr      4.6111         1 0.031765 * 
#> SDEM_RSWX       6.0609         2 0.048295 * 
#> SDEM_Joint     10.6720         3 0.013638 * 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
columbusNA <- columbus
columbusNA$HOVAL[15] <- NA
lm_objNA <- lm(CRIME ~ INC + HOVAL, data=columbusNA)
summary(SD.RStests(lm_objNA, col.listw, test="all"))
#> 	Rao's score test spatial Durbin diagnostics
#> data:  
#> model: lm(formula = CRIME ~ INC + HOVAL, data = columbusNA)
#> weights: col.listw
#>  
#>              statistic parameter  p.value   
#> SDM_RSlag       7.6010         1 0.005834 **
#> SDM_adjRSlag    4.4716         1 0.034463 * 
#> SDM_RSWX        6.0812         2 0.047807 * 
#> SDM_adjRSWX     2.9518         2 0.228576   
#> SDM_Joint      10.5527         3 0.014407 * 
#> SDEM_RSerr      4.4716         1 0.034463 * 
#> SDEM_RSWX       6.0812         2 0.047807 * 
#> SDEM_Joint     10.5527         3 0.014407 * 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1