Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use spmat object as weighting matrix in spxtregress

    Hello everyone,

    I have longitudinal data containing almost 50,000 spatial units which I observe for 11 years. I am trying to run a model with spatial lags of the dependent variable using spxtregress in Stata 15. I would like to create a first-order neighbor contiguity matrix. Given the large number of units and limited computational resources, I can not use the built-in spmatrix create. However, I noticed that spmat runs considerably faster and I have been able to create a weighting matrix object using the following command:
    Code:
    spmat contiguity Q using Municipalities_EUR_shp.dta if year==18, id(_ID) normalize(row)
    Now, when I try to use the spmat object I get from this as weighting matrix with spxtregress, I get the error weighting matrix Q not found.

    The model I am trying to run is of the form
    Code:
    spxtregress y x1 x2 x3, fe dvarlag(Q)
    The data is xtset and the spmat object itself seems fine. I suspect that the issue comes from the fact that spxtregress only accepts weighting matrices that were created with spmatrix create.

    Is there any workaround that would allow me to use the spmat object as weighting matrix here? I have tried exporting to .txt and reimporting using spmatrix import, but Stata tells me it can't find the .txt file (although it is saved in the correct directory).

    Thanks a lot for any advice on this!

  • #2
    Dear Philipp,

    Be aware that spxtregress requires an object created by spmatrix and not by spmat. The output of those two routines are not interchangeable.
    Similarly, routines such as xsmle require an object created by spmat and not spmatrix.

    I agree that the names for those two routines are confusing, given the rule thta Stata commands can be abbreviated if there is no other command with an identical name.

    Comment

    Working...
    X