*! version 1.1.3 8apr2021

*! version 1.0.1 19feb2021

*! version 1.0.2 15jul2021

*! version 1.0.3 22jul2021

help hetsaralso see: hetsar_postestimation

Title

hetsar -- Spatial autoregressive models with heterogeneous coefficients

Syntax

hetsar depvar [indepvars] [if] [in],
wmatrix(name) [options]

options

Model
wmatrix(name) specifies a spatial weights matrix used to create spatial lags of dependent and independent variables. Stata matrices, spmat or spmatrix objects are allowed.

detailed post to e(b) and e(V) the estimated unit-specific coefficients and corresponding VCV matrix.
Default is to post the mean group estimates (see Aquaro, Bailey and Pesaran, 2021 for more details)

ivarlag(durb_varlist) specifies that the spatial lag of the independent variables in durb_varlist is included in the model.

timelag([y wy x wx]) specifies a dynamic model.
If timelag(y) is specified the time lagged dependent variable is included in the model, then timelag(y wy x wx) implies a fully dynamic heterogeneous spatial Durbin model

noconstant suppress unit-specific intercepts in the model

Reporting
robust Sandwich estimator of the VCV matrix. Only when detailed is specified

save(filename[, replace]) save the parameters vector and related standard errors to a csv file

Maximization
maximize_options control the maximization process; seldom used

A panel and a time variable must be specified. Use xtset.

indepvars and durb_varlist may contain factor variables; see fvvarlist.

weights and tsvarlist are not allowed.

Description

hetsar fits spatial panel data models with heterogeneous coefficients, with and without weakly exogenous regressors, subject to heteroskedastic errors. The estimation is performed via quasi maximum-likelihood.

See Aquaro, Bailey and Pesaran (2021) for more details on the properties of the QML estimator and the section Remarks.

Maximization

maximize_options: difficult, technique(algorithm_spec),
iterate(#), [no]log, from(init_specs), tolerance(#),
ltolerance(#), nrtolerance(#); see [R] maximize. These
options are seldom used.

Remarks

hetsar performs a constrained minimization of the negative log-likelihood function of the model.

The parameters related to the spatial lag of the dependent variable (the rho_is) are constrained in [-0.995, 0.995] using the hyperbolic tangent parametrization,
i.e. the evaluator reads constr_rho_i=0.95*/, while the sigmasq parameters are constrained in [0, +infty], i.e. sigmasq=exp(lnsigmasq).

This is the only way to constrain parameters in Stata, i.e. hard-code a reparametrized evaluator. As a consequence, time series operators have been deliberately disallowed
and the timelag() option has been expliticitly designed to simplify the estimation of parameters in heterogeneous spatial autoregressive dynamic models.

When the options timelag(y), timelag(wy) or timelag(y wy) are specified, the parameters related to l.y and/or l.wy are indeed automatically constrained using
the hyperbolic tangent parametrization (notice that l.x and/or l.Wx are never constrained).
Users can avoid binding these two sets of parameters by specifying the undocumented nodconstraints option.

All the remaining parameters are left unconstrained and, once estimation has been performed, all (reparametrized) parameters are automatically translated to the original metric and reported.

The official Stata's commands convention is used for factor and time series variables (the latter when the timelag() option is specified).

A d1 evaluator is used for optimization (for more details see optimize).
By default hetsar runs the BFGS optimization alhorithm (use the technique() option to change among the available algorithms).
Our Monte Carlo simulations show that a mix between Newton and BFGS methods works very well in complex models. hetsar has been tested from Stata 11.2 onwards.

Examples

(The following examples runs from Stata 14 onwards)

Load and summarize the spatial weights matrix

spmat import w using Wrook_25.txt, replace noid normalize(row)

spmat summarize w

Load data and set-up the panel

import delimited hetsar_demo.csv, clear

xtset id time

Estimate a SAR static model

hetsar y x, wmatrix(w)

Estimate a Durbin static model

hetsar y x, wmatrix(w) ivarlag(x) technique(nr 3 bfgs 10)

Estimate a SAR dynamic model

hetsar y x, wmatrix(w) timelag(y wy) technique(nr 3 bfgs 10)

Estimate a Durbin dynamic model

hetsar y x, wmatrix(w) ivarlag(x) timelag(y wy x wx) technique(nr 3 bfgs 10)

Estimate a SAR static model and report estimated unit-specific coefficients

hetsar y x, wmatrix(w) detailed technique(nr 3 bfgs 10)

Estimate a Durbin dynamic model, report mean-group estimates but save the unit-specific coefficients in a csv file

hetsar y x, wmatrix(w) ivarlag(x) timelag(y wy x wx) technique(nr 3 bfgs 10) save(hetsar, replace)

Estimate a SAR static model using by passing starting values

(This example runs from Stata 15 onwards)

1) Get an spmatrix object from a spmat object passing through mata

spmat getmatrix w w_mata

spset id

preserve

keep if time == 1

spmatrix spfrommata w_sp = w_mata _ID, replace

restore

2) Estimate a homogenous random-effects SAR static model

spxtregress y x, re dvarlag(w_sp)

3) Get a vector theta0 of initial values exploiting mata

mat li e(b)

mata

end

4) Estimate a heterogenous SAR static model

hetsar y x, wmatrix(w) from(theta0)

Saved results

hetsar saves the following in e():

Scalars

e(N) number of observations

e(N_g) number of groups

e(k) number of parameters

e(mean_group) 1 if mean group estimator, 0 otherwise

e(k_mg) number of parameters (Mean group estimator)

e(dynamic) 1 if dynamic model, 0 otherwise

e(ll) negative log-likelihood

e(converged) 1 if the model converged, 0 otherwise

e(rank) rank of the variance-covariance matrix

e(iter) number of iterations

Macros

e(cmd) hetsar

e(vce) vcetype specified in vce()

e(properties) b V

Matrices

e(b) coefficient vector

e(V) variance-covariance matrix of the estimators

Functions

e(sample) marks estimation sample

References

Aquaro, M, Bailey, N and Pesaran, M.H., 2021
"Estimation and inference for spatial models with heterogeneous coefficients: An application to US house prices", Journal of Applied Econometrics, 36, pp. 18-44.

Authors

Federico Belotti

Department of Economics and Finance

University of Rome Tor Vergata

Rome, Italy

federico.belotti@uniroma2.it

Also see

Online: spxtregress, xsmle (if installed)