On Fri, 3 Sep 2010, German Sanchez Hernandez wrote:
Dear list,
I would like to complete my neighbour list in order to increase the number of neighbours of regions with less neighbours (links) than a certain number. The idea is to complete these links using knearneigh function.
My try:
nb <- poly2nb(map)
# Compute distribution of linkage:
distr <- as.data.frame(table(card(nb)))
# Try to identify the "isolated" regions (equal or less than, for example, 3 neighbours
minim <- 3 # It's a computed number
isolated <- subset(nb, subset=card(nb) <= minim)
# Get the "isolated" region IDs
regions <- attr(unclass(isolated), 'region.id')
# Modify nb using knearneigh ??
For the edited version of nblag_cumul on R-forge on the spdep project, you'd do something like:
example(columbus)
table(card(col.gal.nb))
k4 <- knn2nb(knearneigh(coordinates(columbus), 4))
mod_nb <- nblag_cumul(list(col.gal.nb, k4))
table(card(mod_nb))
but I'm not at all sure that this is a good idea. Most often observations with few neighbours are on the edge of the data set, so there is a very good reason for their apparent "isolation".
Hope this helps,
Roger
# Alternative 2:
nbmat <- nb2mat(nb)
# Modify nbmat ??, mat2listw, listw2nb
# Alternative 3:
listw <- nb2listw(nb)
# Modify listw ??, listw2nb
The question is:
How to modify nb (or nbmat or listw) to increase the number of links of the "isolated" regions?
Any idea?
Thank you!
Germ?n S?nchez