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

Patrick Meyfroidt patrick.meyfroidt at uclouvain.be
Tue Oct 9 13:57:09 CEST 2012


Yes,
in that case the error I get is:

Error in match(x, table, nomatch = 0L) : object 'wrus.knb5' not found

Thus, no matter I specify this for listw or listw2, in both cases R cannot
find the object.

Which I suppose answer my first question: it is not the "listw" function
which is not found, but the object I use as argument of that function,
right?

But now I'm still unclear about what to do.

Thanks anyway

> Hi Patrick
>
> Have you tried what I suggested?
>
> spml(formula = fm, data = rusp9508.subsvars, index ="index", listw =
> wrus.knb5,
> listw2 = wrus.knb5, model = "within", lag = TRUE, spatial.error="b")
>
> Rafael
>
> On 09.10.2012, at 11:25, Patrick Meyfroidt wrote:
>
>> Hi Rafael,
>>
>> thank you very much for the answer.
>>
>> I read the page you referred to, and it was indeed very interesting, but
>> I
>> haven't yet figured out how to use that in my problem.
>>
>> When I do:
>>  ls( envir = .GlobalEnv )
>> I see that the object I use for listw, which is "wrus.knb5", is indeed
>> located in .GlobalEnv
>>
>> I tried - not sure it was necessary or useful - to force spml to be
>> enclosed in .GlobalEnv by doing:
>>  environment( spml ) = .GlobalEnv
>> But still the object listw is not found.
>>
>> I also tried to specify where to look for wrus.knb5, by using:
>>  spml( ... listw = .GlobalEnv:::wrus.knb5 ...)
>> but, as can be expected, it does not work because .GlobalEnv is not a
>> package.
>>
>> So, two questions:
>> - What is R looking in the wrong place? Is it the function listw, or the
>> object wrus.knb5 that I use as input for listw ?
>> - Based on that, how can I help R to look at the right place?
>>
>> Thanks,
>>
>> Patrick
>>
>>
>>> 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
>>>
>>>
>>>
>>>
>>
>>
>
>
>
> --
> 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