[R-sig-Geo] A question about the splm package
Danlin Yu
yud @ending from m@il@montcl@ir@edu
Sun Sep 2 09:23:28 CEST 2018
Dear list:
I hope this email finds you all well.
I've been recently using the spml package to estimate my data sets for
spatial panel analysis. During the process of applying the package, I made
a few mistakes and realized that when I was supplying the weight matrix
(through the listw object) to the spml/spgm routines, there is no check or
guarantee that the order of the spatial objects as represented in the listw
object is exactly the same as the order of the spatial objects in the data
set as supplied by the argument data = (please let me know if I was wrong
here).
I made such a mistake the first time when I was using the spml/spgm
routines, and found that when I used the pdata.frame routine to convert my
panel data to plm agreeable format (I suspect even if I didn't do that, it
will get converted within the routines), the order of the spatial object
gets re-ordered based on their alphabetic order of the "name" item supplied
to the "index" argument, but the listw was still in the order as it was
created based on the original order of the map object (the
SpatialPolygonDataFrame).
I tried to make some work around, but I can not be 100% sure if what I did
was right, so I am writing to ask for your advice.
Here is what I did:
#for a listw object, say w.listw, I changed it to a weight matrix using
listw2mat:
w.wmat <-listw2mat(w.listw)
#I then assign the names of the spatial objects that correspond to each row
and column to the weight matrix:
colnames(w.wmat)<-colnames(spatialObject using data$Name)
rownames(w.wmat)<-colnames(spatialObject using data$Name)
#I then re-order the weight matrix to make sure the order of the spatial
objects in the new weight matrix is ordered alphabetically:
w.wmat <- w.wmat[order(rownames(w.wmat)),]
w.wmat<- w.wmat[,order(colnames(w.wmat))]
#And then I either supply this weight matrix to the spml/spgm routines or
change it back to a listw object and supply it to the routines:
w.listw<-mat2listw(w.wmat)
After I've done that the outputs from the routines are different from if I
didn't do it. But I am not entire sure if I did this correctly or maybe I
am missing something.
Thank you in advance.
Best,
Danlin Yu, Ph.D.
Professor of GIS and Urban Geography
Department of Earth & Environmental Studies
Montclair State University
Montclair, NJ, 07043
Tel: 973-655-4313
Fax: 973-655-4072
Office: CELS 314
Email: yud using mail.montclair.edu
webpage: csam.montclair.edu/~yu
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list