Skip to content
Prev 15126 / 29559 Next

Switching from Matlab to R

On Mon, 21 May 2012, Michael Sumner wrote:

            
If you mean (particularly sparse) spatial weights in the spatial 
regression sense, then in Matlab do for example:

[i,j,w] = find(weights);
wts = [i,j,w];
save -ascii wts.txt wts

and in R

library(spdep)
lw0 <- read.dat2listw("wts.txt")
lw <- nb2listw(lw0$neighbours, glist=lw0$weights, style="W")

If more general structures, follow Mike's suggestions.

Roger