Spatial Lag Models with Regression Weights: A Practical Approach in R and beyond

Spatial Lag Models with Regression Weights: A Deep Dive into the World of Spatial Econometrics

Introduction

Spatial econometrics is a fascinating field that deals with the analysis of economic phenomena at spatially aggregated levels, such as counties or regions. One of the key concepts in spatial econometrics is the spatial lag model, which accounts for the spatial autocorrelation between neighboring units. In this article, we will delve into the world of spatial lag models and explore how to integrate regression weights into these models.

What are Spatial Lag Models?

Spatial lag models are a type of spatial autoregressive (SAR) model that assumes that the dependent variable at one unit is a function of its own value and the values of neighboring units. Mathematically, a spatial lag model can be represented as:

y = ρWy + Xβ + ε

where y is the dependent variable, ρ is the spatial autoregression parameter, W is the weighted matrix of distance across spatial units, X is the independent variable vector, β is the vector of regression coefficients, and ε is the error term.

What are Regression Weights?

Regression weights are a way to weight the independent variables in a regression model based on their importance or relative magnitude. In the context of spatial lag models, regression weights can be used to adjust the importance of each neighboring unit’s value when predicting the dependent variable at a given unit.

Why Can’t Lagsarlm Handle Regression Weights?

The lagsarlm function in R does not natively support regression weights because it is designed specifically for spatial error models. The errorsarlm function, on the other hand, accepts a “weights” argument that allows for weighted estimates of the error term.

In contrast, the lagsarlm function assumes that the dependent variable at each unit is only a function of its own value and the values of neighboring units. When regression weights are used, the model becomes more complex, and the assumption of equal weighting across all units no longer holds.

Can We Estimate a Weighted Spatial Lag Model in R?

Fortunately, there are alternative approaches to estimate weighted spatial lag models in R. One approach is to use the nlmer function from the lme4 package, which allows for generalized linear mixed models with spatially autocorrelated errors.

Here’s an example of how you can modify the previous code to estimate a weighted spatial lag model using nlmer:

# Load necessary libraries
library(lme4)
library(spdep)

# Create a list of weights that are proportional to population size
listw <- nb2listw(col.gal.nb, style = "bivar")

# Define the regression weights as a function of population size
myweights <- function(x) {
  return(rnorm(nrow(x), mean = 1000 / sum(x), sd = 100))
}

# Estimate the weighted spatial lag model using nlmer
model <- nlmer(CRIME ~ INC + HOVAL + (1|nb), data = col.gal, 
               weight = listw, weights = myweights)

summary(model)

In this example, we define a function myweights that returns a vector of regression weights proportional to population size. We then pass these weights to the nlmer function using the weight and weights arguments.

Alternative Approaches

Another approach is to use a combination of spatial autoregression and ordinary least squares (OLS) regression. This can be achieved by estimating the OLS model separately for each unit and then combining the estimates using a weighted average.

Here’s an example of how you can implement this approach:

# Estimate the OLS model for each unit
ols_models <- lapply(1:nrow(col.gal), function(i) {
  ols_model <- lm(CRIME ~ INC + HOVAL, data = col.gal[i])
  return(ols_model)
})

# Combine the estimates using weighted averages
weighted_ols <- sapply(ols_models, function(model) {
  summary(model)
})

# Estimate the spatial autoregression model
sar_model <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw)

# Combine the OLS and SAR estimates using a weighted average
final_model <- lm(CRIME ~ INC + HOVAL + (1|nb), data = col.gal, 
                  weights = cbind(1, sar_model$coefficients))

summary(final_model)

In this example, we estimate the OLS model separately for each unit and then combine the estimates using a weighted average. We also estimate the spatial autoregression model using lagsarlm and combine it with the OLS estimates.

Conclusion

Estimating weighted spatial lag models can be challenging due to the lack of support in popular R packages like spdep. However, there are alternative approaches that can be used to achieve this goal. By combining spatial autoregression and ordinary least squares regression or using generalized linear mixed models with spatially autocorrelated errors, you can estimate weighted spatial lag models that account for the importance of each neighboring unit’s value when predicting the dependent variable.

Remember to carefully evaluate the performance of your model by checking for spatial autocorrelation, outliers, and other potential issues that may affect the accuracy of your estimates.


Last modified on 2023-08-05