[R-sig-Geo] different Moran's I results using R and matlab

Qiuhua Ma qiuhuanihao at gmail.com
Thu Mar 3 00:50:42 CET 2016


Hi,

I run the exactly same regression using R and matlab and get the same
regression results.

However I got different results for Moran't I test and LM test results.

*R command:*
nb4 <- knn2nb(knearneigh(sale.sp, k = 4))
knn4listw <- nb2listw(nb4, style="W")

lm.morantest(near7_comrisk_semilog.out, knn4listw)
lm.LMtests(near7_comrisk_semilog.out, knn4listw, test=c("LMerr", "LMlag",
"RLMerr", "RLMlag"))

*R results:*
Moran I statistic standard deviate = 1.4135, p-value = 0.07875
Observed Moran's I        Expectation           Variance
      8.780168e-03      -2.762542e-04       4.104967e-05

LMerr = 1.8752, df = 1, p-value = 0.1709
LMlag = 0.14335, df = 1, p-value = 0.705
RLMerr = 2.1193, df = 1, p-value = 0.1455
RLMlag = 0.38741, df = 1, p-value = 0.5337

*Matlab command:*
W_sale_4 = make_nnw(xc,yc,4);

moran4= moran(y,x, W_sale_4)
error_4 = lmerror(y,x,W_sale_4)
lag_4 = lmlag(y,x,W_sale_4)
error_4r = lmerror_robust(y,x,W_sale_4)
lag_4r = lmlag_robust(y,x,W_sale_4)

*Matlab results:*
Moran I-test for spatial correlation in residuals
Moran I                    0.13979528
Moran I-statistic         22.05018073
Marginal Probability       0.00000000
mean                      -0.00126742
standard deviation         0.00639735

error_4 =
    meth: 'lmerror'
      lm: 475.1839
    prob: 0
    chi1: 17.6110


lag_4 =
    meth: 'lmlag'
      lm: 465.4518
    prob: 0
    chi1: 17.6110

error_4r =
    meth: 'lmerror_robust'
      lm: 76.5845
    prob: 0
    chi1: 6.6400

lag_4r =

    meth: 'lmlag_robust'
      lm: 66.1547
    prob: 4.4409e-16
    chi1: 6.6400

Did I do anything wrong? Any thought on this problem?

thanks,

qiuhua

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list