Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Re: spmat matrix size issues with panel data

From   Gordon Hughes <>
Subject   st: Re: spmat matrix size issues with panel data
Date   Mon, 25 Jul 2011 10:50:58 +0100

spmat & spreg are not designed to deal with panel data. Even if your dataset was smaller, the spatial weights constructed by using country-by-year in spmat wouldn't make any sense when used with spreg.

There are possible workarounds but whether they are feasible depends upon the number of spatial units that you have and the exact model that you want to estimate. In essence, the idea is to go back to the original spatial autocorrelation model and construct the spatially-weighted values of your dependent and independent variables. Then you can use an instrumental variables estimator such as -ivreg- or the user-write procedure -ivreg2- with the spatially weighted independent variables as instruments for the spatially weighted dependent variable. It is not too difficult to program this using Mata, but this assumes a degree of familiarity with matrix languages. In addition, you may run into matrix size limitations if the number of spatial units is too large - working with the set of all US counties is likely to be dificult.

I have been developing a set of Stata routines specifically designed to estimate various specifications of spatial panel models. They are extended versions of procedures originally published as Matlab routines which I have translated to Mata. I intend to carry out some additional testing and error-checking over the next month, so that they should be ready for more general use in the fall.

Gordon Hughes


Date: Sun, 24 Jul 2011 11:01:38 -0500
From: Tatyana Deryugina <>
Subject: st: spmat matrix size issues with panel data

I'm trying to estimate spatial standard errors for a panel data set
(county-by-year) using spmat/spreg. When I try to create the spatial
weights matrix using one observation per county (since the distances
between them don't change over time) and then run the regression,
spreg complains that the id variable (county-by-year) does not match
the id variable in the matrix (county). However, if I try to create
spatial weights using the county-year observations, I run into matrix
size constraints - the max is 11,000 and I have over 30,000

Does anyone know of a workaround to this? Ideally, I would define the
weights based on county-level observations, then expand them onto
county-year observations.


- ---------------------------------------------------------------
Tatyana Deryugina

Lecturer, Department of Finance
University of Illinois, Urbana-Champaign
(925) 349 - 8999 (cell)

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index