lm()
). The helper function listw2U()
constructs a weights list object corresponding to the sparse matrix $1/2 (W + W')$
lm.morantest(model, listw, zero.policy=NULL, alternative = "greater", spChk=NULL, resfun=weighted.residuals, naSubset=TRUE)
listw2U(listw)
lm
returned by lm
; weights
may be specified in the lm
fit, but offsets should not be usedlistw
object created for example by nb2listw
get.spChkOption()
lm
object, may be residuals
, weighted.residuals
, rstandard
, or rstudent
model$na.action
component was ignored, and the listw object had to be subsetted by hand)htest
containing the following components:lm.LMtests
, lm
data(oldcol)
oldcrime1.lm <- lm(CRIME ~ 1, data = COL.OLD)
oldcrime.lm <- lm(CRIME ~ HOVAL + INC, data = COL.OLD)
lm.morantest(oldcrime.lm, nb2listw(COL.nb, style="W"))
lm.LMtests(oldcrime.lm, nb2listw(COL.nb, style="W"))
lm.morantest(oldcrime.lm, nb2listw(COL.nb, style="S"))
lm.morantest(oldcrime1.lm, nb2listw(COL.nb, style="W"))
moran.test(COL.OLD$CRIME, nb2listw(COL.nb, style="W"),
randomisation=FALSE)
oldcrime.wlm <- lm(CRIME ~ HOVAL + INC, data = COL.OLD,
weights = I(1/AREA_PL))
lm.morantest(oldcrime.wlm, nb2listw(COL.nb, style="W"),
resfun=weighted.residuals)
lm.morantest(oldcrime.wlm, nb2listw(COL.nb, style="W"),
resfun=rstudent)
Run the code above in your browser using DataLab