GM estimation of panel data models with spatially correlated errors components of the form:
$$ y_N(t) = \lambda W y + X_N(t) \beta + u_N(t) $$
$$ u_N(t) = \rho W_N u_N(t) + \epsilon(t)$$
$$ \epsilon_N = (e_T \otimes I_N ) \mu_N + \nu_N $$
where \( \rho\), and the variance components \(\sigma^2_\mu\) and \(\sigma^2_\nu\) are estimated by GM, and the model coefficients by a feasible GLS estimator. The model can also include additional (other than the spatial lag) endogenous variables.
spgm(formula, data=list(), index=NULL, listw =NULL, listw2 = NULL,
model=c("within","random"), lag = FALSE, spatial.error=TRUE,
moments = c("initial", "weights", "fullweights"), endog = NULL,
instruments= NULL, lag.instruments = FALSE, verbose = FALSE,
method = c("w2sls", "b2sls", "g2sls", "ec2sls"), control = list(),
optim.method = "nlminb", pars = NULL)
a description of the model to be fit. The details of model specification are given
for lm
an object of class data.frame
or pdata.frame
. An optional data frame containing the variables
in the model. When the obect is a data.frame
, the first two columns may contain the indexes. See index
if not NULL (default), a character vector to identify the indexes among the columns of the data.frame
an object of class listw
, matrix
, or Matrix
an object of class listw
, matrix
, or Matrix
. Only
if both lag
and spatial.error
are both TRUE
One of "within"
or "random"
. The assumption
made on the individual effects
if TRUE
a spatial lag of the dependent variable is
added to the regression equation
a logic vector. If TRUE
the spatial autoregressive error term is added to the model and an estimate for \(\rho\) is produced
"initial"
(default) defines the set of GM estimator to be used. Alternatives are
"weights"
and "fullweights"
(See Details)
additional endogenous variables. Default NULL
. If not NULL
should be specified
as a formula with no dependent variable (endog = ~ x1 + x2). Note the ~ before the expression.
external instruments. Default NULL
. If not NULL
should be specified
as a formula with no dependent variable (instruments = ~ x1 + x2). Note the ~ before the expression.
should the external instruments be spatially lagged?
default FALSE
, If TRUE
reports function values during optimization
One of "w2sls"
, "b2sls"
, "g2sls"
, "ec2sls"
. (See Details)
a list of control parameters for the optimization
default set to "nlminb"
. or optionally a method passed to optim
to use an alternative optimizer.
initial values of the parameter rho
and sigmav
. The default for rho
is to
start from a regression of the spatially lagged residuals on the residuals (depending on the model).
For sigmav
the starting value is the variance of the residuals (again this depends on the model).
An object of class "splm"
.
GLS coefficients estimate of the model parameters
the variance covariance matrix of the estimated coefficients
the GLS residuals
difference between response variable and residuals
GLS residuals variance
'random effect GM'
a vector including the spatial parameter and the variance components (see Details)
the matrix of the data used
the call used to create the object
The function is a very general interface to estimate various nested specifications of the
general model including additional endogenous variables described above.
When both spatial.error
and lag
are FALSE
the model reduces to a
panel data model with an additional endogeneous variable. The function then uses ivsplm
to perform the Instrumental Variables and two-stage least squares for panel data model. method = "w2sls"
corresponds to the fixed effects estimator, method = "b2sls"
to the between effects model,
method = "g2sls"
to the GLS random effects model, and method = "ec2sls"
to the Baltagi's
EC2SLS.
When spatial.error
is TRUE
and lag
is FALSE
the model is one with spatially autocorrelated
error components. If effects
is "random"
, the Kapoor et al. (2007) GM estimator is performed and
the residuals in the first step come from an OLS regression.
When moments
is "initial"
, the initial estimator is calculated. This first set
of GM estimators is based only on a subset of the moments conditions and assigns
equal weigths to each of them.
When moments
is "fullweights"
, the second set of GM estimators is calculated. This estimator
is based on the full set of moments conditions. It also involves the expression for the variance
covariance matrix of the sample moments calculated under the assumption of
normally distributed innovations. The calculation of the trace terms in the expression
of the variance covariance matrix of the sample moments
uses codes from the Matrix
package.
When moments
is"weights"
, the third set of GM estimator is used. This is motivated by computational
issues. The procedure is analogous to the second one but uses a simplified expression for the
variance covariance matrix of the sample moments.
If effects
is "fixed"
, the initial
estimator is a within estimator and the moments conditions of Kapoor et al. (2007) are modified accordingly.
Finally, when both spatial.error
and lag
are TRUE
the complete model is estimated (with or without
additional endogenous variables). OLS residuals are no longer consistent because of the spatially lagged dependent variable.
If effects
is "random"
, two initial estimators are computed: a within two-stage least squares
and a between two stage least squares. The two sets of corresponding residuals are used in the spatial generalized moments estimator
(GM) where the moments conditions of Kapoor et al. (2007) are again modified accordingly.
If effects
is "fixed"
, the initial
estimator is a within two stage least squares estimator and the moments conditions of Kapoor et al. (2007) are modified accordingly.
Note that for the random effects models, \(\sigma^2_\mu\) is not reported. \(\sigma^2_1\) is reported instead. However, a value for \(\sigma^2_\mu\) can easily be obtained from: $$\sigma^2_1 = \sigma^2_\nu + T \sigma^2_\mu$$ The function also produces an estimate for \(\theta\) which is a function of the variance components.
Kapoor, M., Kelejian, H.H. and Prucha, I.R. (2007) Panel data model with spatially correlated error components, Journal of Econometrics, 140, pages 97--130.
Mutl, J., and Pfaffermayr, M. (2011) The Hausman test in a Cliff and Ord panel model, Econometrics Journal, 14, pages 48--76.
Kelejian, H.H. and Prucha, I.R. (1999) A Generalized Moments Estimator for the Autoregressive Parameter in a Spatial Model, International Economic Review, 40, pages 509--533.
Kelejian, H.H. and Prucha, I.R. (1999) 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, pages 99--121.
Millo, G., Piras, G. (2012) splm: Spatial Panel Data Models in R. Journal of Statistical Software, 47(1), 1--38. URL http://www.jstatsoft.org/v47/i01/.
# NOT RUN {
data(Produc, package = "plm")
data(usaww)
GM <- spgm(log(gsp)~log(pcap)+log(pc)+log(emp)+unemp, data=Produc,
listw = usaww, moments="fullweights", spatial.error = TRUE)
summary(GM)
# }
Run the code above in your browser using DataLab