[R-sig-Geo] different Moran's I results using R and matlab
Roger Bivand
Roger.Bivand at nhh.no
Thu Mar 3 08:43:36 CET 2016
On Thu, 3 Mar 2016, Qiuhua Ma wrote:
> Hi,
>
> I run the exactly same regression using R and matlab and get the same
> regression results.
Well, you need to give the exact reference to the matlab code you have
used - are they the functions in Spatial Econometrics Toolbox under
spatial/stats? I do not see the robust variants there.
Most likely the data or the weights are different. Make your data set
available on a link, and I'll take a look.
Roger
>
> 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]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
More information about the R-sig-Geo
mailing list