Spatial Regressions with Panel Data in R
Asked Answered
T

0

6

I have a panel dataset with several hundred regions, ~10 years and spatial data for the regions. I created a weight matrix with the spdeppackage (via the standard way, and then, nb2listw). I have, thus, a matrix with weights for each region (in relation to the other regions) - but each region is represented just once.

I would like to run some of the spatial regressions from the spdeppackage (lagsarlm, errorsarlm), but I get an error:

Error in subset.listw(listw, subset, zero.policy = zero.policy) : Not yet able to subset general weights lists

and

Error in lagsarlm(y ~ x1 + x2: Input data and weights have different dimensions

I assume this is because the weight matrix has only one row per region (and then, only one year can be calculated). Do you have any suggestions how to attack the issue? My ideas revolve around the following:

  • Extend the spatial weight matrix OR
  • Tell spdep that the regions will repeat in the same order (but how?)

Looking forward to your suggestions.

Tuckerbag answered 3/7, 2018 at 20:37 Comment(1)
Hi Jonathan, welcome to SO. Please, make sure to provide a reproducible example if you would like to have some chances to get a reply to your questions. As of now, it is basically impossible to understand what is wrong with your code. If the problem is just the dimension of the weight matrix, then you can just reproduce it again using all the observations (I mean, if you have a panel, just replicate the same coords for the number of years, as it is in you data.frame structure and then re calculate the nb list and so on), but I'm not sure this is the problemGreataunt

© 2022 - 2024 — McMap. All rights reserved.