Dear R-sig-geo,

I am fairly new to R and very new to spatial regression models. I am attempting 
to compare an OLS model to some sort of spatial regression such as SAR. 
However, I am unclear about how to properly designate the spatial neighbors and 
weights and hope that someone can provide guidance. 

My data set consists of variables taken from a series of irregularly shaped and 
spaced polygons, some are spatial nested (one completely inside another). I 
have approximate centroids for the polygons as well as some values for the max 
and min latitude and longitude of each. I am using the centroids in the example 
below. I have been using Bivand et al. (Applied Spatial Data Analysis with R) 
as a guide but my data is a bit different then the examples provided. 

I am attempting to make a weight file based on the distance based neighbors. I 
have pasted some example code below. My thought was that using distance based 
neighbors would associate the nested as well as some of the areas that are 
close by. This method seems to leave me with some areas without neighbors. This 
seems to cause a problem when I attempt to convert the 'nb' to the 'listw'. 

Can anyone provide me with guidance as to how to proceed or how to best 
associated the areas in my data set.
Thank you in advance for any help!


library(spdep)

my.lat <- c(36.4000, 36.3908, 35.0550, 36.0226, 36.4472, 36.1450, 35.2680, 
35.1335,
    35.3225, 35.0050, 35.0450, 35.0600, 35.0500, 35.6120, 35.4330, 36.4580,
    35.8850, 35.7647, 35.8842, 35.6135, 36.3915, 35.1290, 35.4769, 34.9881,
    35.4267, 35.5986, 35.8927, 35.4721, 35.4684, 35.6802, 35.6413, 36.2405,
    35.3650, 35.8183, 36.5495, 35.7250, 36.1955, 35.5960, 35.6300, 35.8930,
    35.2360, 35.1400, 35.1970, 36.5000, 35.1540, 35.5432, 35.8898, 35.5389,
    35.8641, 35.6340, 35.4560, 35.3630, 35.4270, 35.7080, 35.7930, 36.1020,
    35.0127, 35.1380, 35.1310, 35.5689, 35.5417, 35.5206, 35.5634, 35.5157,
    35.9020, 35.8975, 35.8843, 35.8872)

my.long <-  c(-81.4614, -81.5717, -83.4550, -81.8264, -81.0608, -81.8070, 
-82.4525,
    -79.8415, -82.5035, -83.1400, -83.0000, -82.9500, -82.9500, -83.7800, 
-82.2475,
    -81.4715, -81.8815, -82.2653, -78.5282, -79.1614, -81.0700, -79.1500, 
-76.8119,
    -79.5515, -80.0516, -81.6531, -78.5834, -76.9099, -78.9180, -80.9803, 
-80.5191,
    -77.8615, -80.0825, -78.8575, -76.3840, -78.7000, -78.8034, -79.1300, 
-83.5200,
    -79.0300, -77.8800, -79.2200, -77.8700, -76.1245, -79.1400, -79.3216, 
-79.0232,    
    -79.2881, -78.7555, -83.4000, -83.1300, -82.9200, -82.7600, -82.3700, 
-82.2900,
    -82.1100, -82.8264, -81.3900, -81.3700, -83.6629, -83.4933, -83.8661, 
-83.7328,
    -83.8830, -79.0390, -79.0305, -79.0469, -79.0166)


my.coords <- as.matrix(cbind(my.long,my.lat))
nb40km <- dnearneigh(my.coords,0,40, longlat = TRUE)
plot(my.coords)
plot(nb40km, my.coords, add = TRUE)

nb50km.w <- nb2listw(nb40km, glist=NULL, style="W", zero.policy=TRUE)
# this causes an error because of the regions with no neighbours found

I am using R 2.8.1, spdep 0.4-29 on Windows XP


Michael Denslow

I.W. Carpenter Jr. Herbarium [BOON]
Appalachian State University
Boone, North Carolina U.S.A.

-- AND --

Communications Manager
Southeastern Regional Network of Expertise and Collections
sernec.org





_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to