[R-sig-Geo] inconsistent results from moran.test()
Roger Bivand
Roger@B|v@nd @end|ng |rom nhh@no
Fri Mar 8 21:25:36 CET 2019
On Fri, 8 Mar 2019, Jay Wang wrote:
> Hello,
>
> Having my own spatial weight matrix, I converted it to a listw format and
> calculated the Moran index. The codes are listed below:
>
> Wod_lw<-mat2listw(Wod)
> moran.test(mydata$Ties_processed,Wod_lw, randomisation=TRUE)
Here, Wod_lw has an unknown style, "M" for matrix.
>
> However, after I generated a gal file, imported it, converted it back to a
> listw file, and re-calculated the Moran index with the following codes, the
> results became totally different (0.1624 vs. 0.1942):
> write.nb.gal(Wod_lw$neighbours,"Wod.gal")
This only writes the neighbours (read the help page), not the weights.
> Wod.gal.nb <- read.gal(file="Wod.gal")
> Wod_lw2<-nb2listw(Wod.gal.nb)
The default style in nb2listw() is "W", row standardised.
What does:
all.equal(Wod_lw$weights, Wod_lw2$weights, check.attributes=FALSE)
say? And:
all.equal(Wod_lw$neighbours, Wod_lw2$neighbours, check.attributes=FALSE)
> moran.test(mydata$Ties_processed,Wod_lw, randomisation=TRUE)
> moran.test(mydata$Ties_processed,Wod_lw2, randomisation=TRUE)
>
> I don't know where the problem is. I would appreciate if anyone can help me
> with this. Thank you
Do read the help pages, you'll find they explain these things.
Roger
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using 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; e-mail: Roger.Bivand using nhh.no
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
More information about the R-sig-Geo
mailing list