Dear List,

I have a complete (distance/border based binary) spatial weights matrix
from Stata (e.g. as a txt-file). I want to apply spatial filtering in
spdep, however the routine needs an "nb" object. Is there any way to
extract the information from my matrix automatically (something like
mat2nb ???) or do I have to edit the "nb" object by hand? (e.g. in terms
of creating a GAL file by any text editor and then use "read.gal" option
- this strategy would mean a lot of work since I have a 240 x 240
matrix). I'd be happy about any help.

Best wishes,

Timo

P.S.: I have tried it with a spatial weights matrix in spdep
(mat2listw), but it does not work - see my code below:

****************************************************

#### Code for Griffith Eigenvector Filtering ###



library(spdep)



migration_spatial <-
read.table("C:/migration_laptop/spdep_migration.txt", header=TRUE,
sep="\t", na.strings="NA", dec=".", strip.white=TRUE)



summary(migration_spatial)



mat = matrix(0, 240, 240)



mat[row(mat) >= col(mat)] <-
scan("C:/migration_laptop/spdep_Wmat_Chun_border.txt")



# not sure if the following is needed :



mat <- mat + t(mat)



list(mat)



migmat.listw <- mat2listw(mat)



migmat.listw



migfilt <- SpatialFiltering(lnmr_i ~ lnmr_i_lag1 + ldwager_ij_lag1 +
ldur_ij_lag1 + ldyrl_ij_fd_lag1 + ldq_ij_lag1 + ldpland_ij_lag1 +
ldhc6_ij_lag1, data=migration_spatial, nb=migmat.listw, style="W",
ExactEV=TRUE, zero.policy=TRUE)



****************************************************








	[[alternative HTML version deleted]]

