lm.LMtests(model, listw, zero.policy=NULL, test="LMerr", spChk=NULL, naSubset=TRUE)
"print"(x, ...)
"summary"(object, p.adjust.method="none", ...)
"print"(x, digits=max(3, getOption("digits") - 2), ...)lm returned by lm, or optionally a vector of externally calculated residuals (run though na.omit if any NAs present) for use when only "LMerr" is chosen; weights and offsets should not be used in the lm objectlistw object created for example by nb2listw,
expected to be row-standardised (W-style)get.spChkOption()model$na.action component was ignored, and the listw object had to be subsetted by hand)p.adjust) for multiple tests, default "none"LMtestlist of htest objects, each with:$$ \mathbf{y} = \mathbf{X \beta} + \rho \mathbf{W_{(1)} y} + \mathbf{u}, $$ $$ \mathbf{u} = \lambda \mathbf{W_{(2)} u} + \mathbf{e} $$
where $e$ is a well-behaved, uncorrelated error term. Tests for a missing spatially lagged dependent variable test that $rho = 0$, tests for spatial autocorrelation of the error $u$ test whether $lambda = 0$. $W$ is a spatial weights matrix; for the tests used here they are identical.
lmdata(oldcol)
oldcrime.lm <- lm(CRIME ~ HOVAL + INC, data = COL.OLD)
summary(oldcrime.lm)
res <- lm.LMtests(oldcrime.lm, nb2listw(COL.nb), test=c("LMerr", "LMlag",
"RLMerr", "RLMlag", "SARMA"))
summary(res)
lm.LMtests(oldcrime.lm, nb2listw(COL.nb))
lm.LMtests(residuals(oldcrime.lm), nb2listw(COL.nb))
Run the code above in your browser using DataLab