[R-sig-Geo] Error object 'can.sim2' not found in spatianl panel data - splm with spdep

Rafael Wüest rafael.wueest at wsl.ch
Mon Oct 8 14:06:47 CEST 2012


Hi Patrick

I can not judge whether it makes any sense, but if you want listw and listw2 to be the same, try:

spml(formula = fm, data = rusp9508.subsvars, index ="index", listw =
wrus.knb5, listw2 = wrus.knb5, model = "within", lag = TRUE, spatial.error =
"b")

Otherwise, I guess, R is looking for listw in the wrong place. Look at http://obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/
for explanations.

HTH,
Rafael

On 08.10.2012, at 13:47, Patrick Meyfroidt wrote:

> OK, I may have some update, sorry for the disturbance.
> 
> By explicitly indicating that listw2 is the same as listw, like that:
> 
> spml(formula = fm, data = rusp9508.subsvars, index ="index", listw =
> wrus.knb5, listw2 = listw, model = "within", lag = TRUE, spatial.error =
> "b")
> 
> I now get the following error message:
> 
> Error in match(x, table, nomatch = 0L) : object 'listw' not found
> 
> So apparently the listw object cannot be read.
> 
> Is it because the weights were calculated once for each country, but the
> dataset is a panel one?
> 
> Does someone have a clue?
> 
> Thanks,
> 
> Patrick Meyfroidt
> 
> 
>> Dear list,
>> 
>> I have spatial panel data (regions over years), that I subsetted to make
>> sure that the panel is balanced.
>> 
>> Using spdep, I calculated weights using nearest neighbors on these
>> regions, with the following code:
>> 
>> --
>> RUSCRS <- CRS("+proj=lcc +lat_1=15 +lat_2=65 +lat_0=30 +lon_0=95 +x_0=0
>> +y_0=0 +units=m +datum=WGS84")
>> rus <- readShapeSpatial([filename], IDvar = "index", proj4string = RUSCRS)
>> coords <- coordinates(rus)
>> ruskn5 <- knearneigh(coords, k=5, longlat = NULL)
>> ruskn5.nb <- knn2nb(ruskn5, row.names=rus$index, sym = FALSE)
>> wrus.knb5 <- nb2listw(ruskn5.nb, glist=NULL, style="W", zero.policy=NULL)
>> --
>> 
>> Everything looks fine, i.e. I can print out the results at each step, and
>> each unit apparently has indeed 5 neighbors with 0.2 weight for each.
>> 
>> Then I use splm package to perform a spatial panel regression, using the
>> code:
>> 
>> --
>> fm <- rnabd ~ rlex + pbpl
>> spml(formula = fm, data = rusp9508.subsvars, index ="index", listw =
>> wrus.knb5, model = "within", lag = TRUE, spatial.error = "b")
>> --
>> 
>> But I end up with the following error message:
>> 
>> "Error in get("can.sim2", envir = env) : object 'can.sim2' not found"
>> 
>> 
>> Can someone explain what is this "can.sim2" object and possible reasons
>> for the error message?
>> 
>> Thank you very much for any input,
>> 
>> Patrick Meyfroidt
>> Université catholique de Louvain - Belgium
>> 
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



--
Rafael Wüest
Swiss Federal Research Institute WSL
Zürcherstrasse 111
8903 Birmensdorf
Switzerland

+41 44 7392126
rafael.wueest at wsl.ch
http://www.wsl.ch/info/mitarbeitende/wueest/index_EN



More information about the R-sig-Geo mailing list