Dear there I am trying to construct spatial weight matrix using inverse distance, which means that high weight is given to near observations and ,vies versa, where w_ij=w_ji and w_ii=0, Since, I am a new R user, I've tried many functions in sp,spdep packages and I find some functions to find weight matrix by using nearest neighbours and by distance-based neighbours, but I want to use all observations as neighbours and based on the inverse distance, I can construct the weights. Before I write the code I'll give some information about my data, I have the coordinates of 51 states (US states) , thus latitude and longitude of each states and based on the distance between each state I will give a weight for states where the weight is the the inverse of the distance. obviously , the weight matrix are symmetric. Then I've tried the following code data(location)# data.frame with 2 col and 51 row loc.sp = SpatialPoints(cbind(location$latitude,location$longitude)) sy8<-knn2nb(knearneigh(loc.sp,k=50)) # for each state all other states are considered as neighbour dsts<-nbdists(sy8, loc.sp) idw<-lapply(dsts, function(x) 1/(x)) sy<-nb2listw(sy8, glist=idw, style="B") col.mat <- listw2mat(sy) after running this code, I got symmetric matrix (51* 51), where w_ii=0 and w_ij=w_ji but I am not sure if this is true!!! any commands and helps are appreciated Regards, Alsulami
[[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo