Dear all, I have a dataset with several lat-long coordinates (48) and corresponding residuals values (not a grid). Using the spdep package, I try to create a correlogram of these residuals according to several lags (i.e. distance classes) but I cant seem to get the neighborhood and weights right
Below, I show the main parts of the code and the results: rnp <- read.table ("D:/Diederik/RESID_WITH_DISTANCE.csv",sep=",",header=T) resids <- rnp$RESID ##create neighbourhood list and make symmetric## xy <- cbind(rnp$X, rnp$Y) rnp_nb <-knn2nb(knearneigh(xy, longlat=TRUE)) rnp_nb <-make.sym.nb(rnp_nb) rnp_nb Neighbour list object: Number of regions: 48 Number of nonzero links: 66 Percentage nonzero weights: 2.864583 Average number of links: 1.375 ##create weights## rnp_w <- nb2listw(rnp_nb,glist=NULL,style="W",zero.policy=FALSE) rnp_w Characteristics of weights list object: Neighbour list object: Number of regions: 48 Number of nonzero links: 66 Percentage nonzero weights: 2.864583 Average number of links: 1.375 Weights style: W Weights constants summary: n nn S0 S1 S2 W 48 2304 48 73.72222 209.3333 ## Moran's I test for spatial autocorrelation## moran.test(resids, rnp_w, randomisation=TRUE, ) Moran's I test under randomisation data: resids weights: rnp_w Moran I statistic standard deviate = -0.3353, p-value = 0.6313 alternative hypothesis: greater sample estimates: Moran I statistic Expectation Variance -0.08060979 -0.02127660 0.03130522 ##make a correlogram## sp.correlogram(rnp_nb, resids, order=16, method="I", zero.policy=TRUE) Error in nb2listw(nblags[[i]], style = style, zero.policy = zero.policy) : No valid observations In addition: Warning message: In moran.test(var, listw, randomisation = randomisation, zero.policy = zero.policy) : Out-of-range p-value: reconsider test arguments Moran.test seems to work fine, but the sp.correlogram doesnt Do I in any way- have to attach the weigths (rnp_w) to the neighourhood list (rnp_nb)? Many thanks!! Diederik PS: R-version 2.9.2, Package spdep version 0.4-56, Windows Vista Home Premium Service Pack 2 on Acer Extensa 5630 Dr. Diederik Strubbe Evolutionary Ecology Group Department of Biology University of Antwerp Groenenborgerlaan 171 2020 Antwerpen, Belgium tel: +32 3 265 3464 [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo