Created
October 25, 2015 16:58
-
-
Save Framartin/d6a8d7847f360a2960dc to your computer and use it in GitHub Desktop.
Renormalization issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(spdep) | |
data(oldcol) | |
lw <- nb2listw(COL.nb) | |
attr(lw, "region.id") | |
region.id.wanted.order <- attr(lw, "region.id")[c(1:41, 44:49, 42, 43)] # cannot be obtain with subset.listw | |
# we convert it to a Matrix and re-normalized it with mat2listw() | |
W <- as(lw, "CsparseMatrix") | |
W <- W[region.id.wanted.order, region.id.wanted.order] | |
style <- lw$style | |
lw1 <- mat2listw(W, row.names = region.id.wanted.order, style = style) # re-normalize to keep the style | |
lw2 <- subset.listw(lw1, attr(lw1, "region.id") != "1043") # not working |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment