General Spatial 3SLS for systems of spatial equations.
General Spatial 3SLS for systems of spatial equations.
The function estimates spatial SUR models using general spatial three stages least squares. This is a system instrumental variable procedure which also include GMM estimation when there is spatial correlations in the errors. The procedure allows for additional endogenous regressors in addition to spatial lags of the dependent variable. It could be applied to "slm", "sdm", "sem" and "sarar" spatial models. Furthermore, for non-spatial models including endogenous regressors ("iv"), it could be used to estimate using instrumental variables and Feasible Generalized Least Squares.
spsurgs3sls(formula =NULL, data =NULL, na.action, listw =NULL, zero.policy =NULL, type ="slm", Durbin =FALSE, endog =NULL, instruments =NULL, lag.instr =FALSE, initial.value =0.2, het =FALSE, trace =TRUE)
Arguments
formula: An object type Formula
similar to objects created with the package Formula
describing the equations to be estimated in the model. This model may contain several responses (explained variables) and a varying number of regressors in each equation.
data: An object of class data.frame or a matrix.
na.action: A function (default options("na.action")), can also be na.omit or na.exclude with consequences for residuals and fitted values. It may be necessary to set zero.policy to TRUE because this subsetting may create no-neighbour observations.
listw: A listw object created for example by nb2listw from spatialreg package; if nb2listw not given, set to the same spatial weights as the listw argument. It can also be a spatial weighting matrix of order (NxN) instead of a listw object. Default = NULL.
zero.policy: Similar to the corresponding parameter of lagsarlm function in spatialreg package. (NxN) instead of a listw object. Default = NULL.
type: Type of spatial model specification: "sim", "iv", "slm", "sem", "sdm" or "sarar" . Default = "slm".
Durbin: If a formula object and model is type "sdm" the subset of explanatory variables to lag for each equation.
endog: Additional endogenous variables. Default NULL. If not NULL should be specified as a Formula with no dependent variable. Examples: ~ x1 | x2 (x1 endogeous regressor for the first equation and x2 endogeneous regressor for the second equation) or ~ x1 | . (x1 endogenous regressor for the first equation and none endogenous regressors for the second equation)
instruments: external instruments. Default NULL. If not NULL should be specified as a formula with no dependent variable in the same way than previous endog argument.
lag.instr: should the external instruments be spatially lagged?
initial.value: he initial value for rho. It can be either numeric (default is 0.2) or set to 'SAR', in which case the optimization will start from the estimated coefficient of a regression of the 2SLS residuals over their spatial lag (i.e. a spatial AR model)
het: default FALSE: if TRUE uses the methods developed for heteroskedasticity for each equation. Wrapper using spreg function.
trace: A logical value to show intermediate results during the estimation process. Default = TRUE.
Returns
Object of spsur class with the output of the three-stages least-squares estimation of the specified spatial model. A list with:
call
Matched call.
type
Type of model specified.
Durbin
Value of Durbin argument.
coefficients
Estimated coefficients for the regressors.
deltas
Estimated spatial coefficients.
rest.se
Estimated standard errors for the estimates of β coefficients.
deltas.se
Estimated standard errors for the estimates of the spatial coefficients.
resvar
Estimated covariance matrix for the estimates of beta's and spatial coefficients.
R2
Coefficient of determination for each equation, obtained as the squared of the correlation coefficient between the corresponding explained variable and its estimates. spsur3sls also shows a global coefficient of determination obtained, in the same manner, for the set of G equations.
Sigma
Estimated covariance matrix for the residuals of the G equations.
residuals
Residuals of the model.
df.residuals
Degrees of freedom for the residuals.
fitted.values
Estimated values for the dependent variables.
G
Number of equations.
N
Number of cross-sections or spatial units.
Tm
Number of time periods.
p
Number of regressors by equation (including intercepts).
Y
If data is NULL , vector Y of the explained variables of the SUR model.
X
If data is NULL , matrix X of the regressors of the SUR model.
W
Spatial weighting matrix.
zero.policy
Logical value of zero.policy .
listw_style
Style of neighborhood matrix W .
Details
spsurg3sls generalize the spreg function to multiequational spatial SUR models. The methodology to estimate spatial SUR models by Generalized 3SLS follows the steps outlined in Kelejian and Piras (pp. 304-305). The summary of the algorithm is the next one:
Estimate each equation by 2SLS and obtain the estimated residuals u^j for each equation.
If the model includes a spatial lag for the errors. (that is, it is a SEM/SARAR model), apply GMM to obtain the spatial parameters λ^j for the residuals in each equation. In this case the spreg
function is used as a wrapper for the GMM estimation. If the model does not include a spatial lag for the errors (that is, it is a "sim", "iv", "slm" or "sdm" model), then λ^j=0
Compute
v^j=u^j−λ^jWu^j
and the covariances
σ^i,j=N−1v^iv^j
. Build Sigma^={σi,j^}
Compute
yj∗=yj−λ^jWyj
and
Xj∗=Xj−λ^jWXj
Compute
X^j∗=Hj(HjTHj)−1HjTXj∗
where Hj is the matrix including all the instruments and the exogenous regressors for each equation. That is, X^j∗
is the projection of Xj∗ using the instruments matrix Hj.
Compute, in a multiequational way, the Feasible Generalized Least Squares estimation using the new variables y^j∗, X^j∗ and Sigma^. This is the 3sls step.
Examples
#### Example 1: Spatial Phillips-Curve. Anselin (1988, p. 203)rm(list = ls())# Clean memorydata(spc)lwspc <- spdep::mat2listw(Wspc, style ="W")## No endogenous regressors Tformula <- WAGE83 | WAGE81 ~ UN83 + NMR83 + SMSA | UN80 + NMR80 + SMSA
## Endogenous regressors and InstrumentsTformula2 <- WAGE83 | WAGE81 ~ NMR83 | NMR80
## Endogenous regressors: UN83 , UN80## Instrumental variable: SMSA## A IV model with endogenous regressors only in first equationspciv <- spsurgs3sls(formula = Tformula2, data = spc, type ="iv", listw = lwspc, endog =~ UN83 | ., instruments =~ SMSA | .)summary(spciv)print(spciv)########################################################################### A SLM model with endogenous regressors spcslm <- spsurgs3sls(formula = Tformula2, data = spc, endog =~ UN83 | ., instruments =~ SMSA |., type ="slm", listw = lwspc)summary(spcslm)print(spcslm)impacts_spcslm <- impactspsur(spcslm, listw = lwspc, R =1000)summary(impacts_spcslm[[1]], zstats =TRUE, short =TRUE)summary(impacts_spcslm[[2]], zstats =TRUE, short =TRUE)########################################################################### A SDM model with endogenous regressors spcsdm <- spsurgs3sls(formula = Tformula2, data = spc, endog =~ UN83 | UN80, instruments =~ SMSA | SMSA, type ="sdm", listw = lwspc, Durbin =~ NMR83 | NMR80)summary(spcsdm)## Durbin only in one equationspcsdm2 <- spsurgs3sls(formula = Tformula2, data = spc, endog =~ UN83 | UN80, instruments =~ SMSA | SMSA, type ="sdm", listw = lwspc, Durbin =~ NMR83 | .)summary(spcsdm2)########################################################################### A SEM model with endogenous regressors spcsem <- spsurgs3sls(formula = Tformula2, data = spc, endog =~ UN83 | UN80, instruments =~ SMSA | SMSA, type ="sem", listw = lwspc)summary(spcsem)print(spcsem)########################################################################### A SARAR model with endogenous regressors spcsarar <- spsurgs3sls(formula = Tformula2, data = spc, endog =~ UN83 | UN80, instruments =~ SMSA | SMSA, type ="sarar", listw = lwspc)summary(spcsarar)print(spcsarar)impacts_spcsarar <- impactspsur(spcsarar, listw = lwspc, R =1000)summary(impacts_spcsarar[[1]], zstats =TRUE, short =TRUE)summary(impacts_spcsarar[[2]], zstats =TRUE, short =TRUE)
References
Kelejian, H. H. and Piras, G. (2017). Spatial Econometrics. Academic Press.
Kelejian, H.H. and Prucha, I.R. (2010). Specification and Estimation of Spatial Autoregressive Models with Autoregressive and Heteroskedastic Disturbances. Journal of Econometrics, 157, pp. 53-67.
Kelejian, H.H. and Prucha, I.R. (1999). A Generalized Moments Estimator for the Autoregressive Parameter in a Spatial Model. International Economic Review, 40, pp. 509-533.
Kelejian, H.H. and Prucha, I.R. (1998). A Generalized Spatial Two Stage Least Square Procedure for Estimating a Spatial Autoregressive Model with Autoregressive Disturbances. Journal of Real Estate Finance and Economics, 17, pp. 99–121.
Minguez, R., Lopez, F.A. and Mur, J. (2022). spsur: An R Package for Dealing with Spatial Seemingly Unrelated Regression Models. Journal of Statistical Software, 104(11), 1--43. <doi:10.18637/jss.v104.i11>
Piras, G. (2010). sphet: Spatial Models with Heteroskedastic Innovations in R. Journal of Statistical Software, 35(1), pp. 1-21. https://www.jstatsoft.org/v35/i01/. -