Good evening,

I'm new to spatial analysis R and therefore to this group but am thankful
for any level of feedback on my question that follows.  I've encountered an
error in calculating Moran's I using the spdep package in R and am unable
to isolate the problem on my own:

*Error in moran.test(AODED$adcount/AODED$POP100, nb2listw(BC_nb, style =
"B")) : objects of different length*

How might I begin solving this problem?

My code, adapted from prior posts on this subject:

*# load data for 70 area units*

*AODED<-read.csv("AODEDlags_R.csv",header=TRUE)
*


*BC <- readShapePoly("StudyareaZC11.shp") *

*# create a weight matrix*

*BC_nb <- poly2nb(as(BC, "SpatialPolygons"))
X <- nb2mat(BC_nb,zero.policy=TRUE)
n<-length(BC_nb)
*

*Nbr.matrix<-matrix(0,n,n) for(i in 1:n) *

*  Nbr.matrix[i,BC_nb[[i]]]<-1**> BC_nb*

I have 70 area units, yet the weight matrix counts 71:

*Neighbour list object:*
*Number of regions: 71 *
*Number of nonzero links: 320 *
*Percentage nonzero weights: 6.347947 *
*Average number of links: 4.507042 *

Any insights on this problem and/or references to prior posts are welcome.
 Thank you.

Respectfully,
Lareina

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to