Learn R Programming

spsur (version 1.0.2.5)

spsurml: Maximum likelihood estimation of spatial SUR model.

Description

This function estimates spatial SUR models using maximum-likelihood methods.The number of equations, time periods and cross-sectional units is not restricted.The user can choose between different spatial specifications as described below. The estimation procedure allows for the introduction of linear restrictions on the \(\beta\) parameters associated to the regressors.

Usage

spsurml(formula = NULL, data = NULL, na.action,
               listw = NULL, type = "sim", Durbin = NULL,
               method = "eigen", zero.policy = NULL, interval = NULL,
               trs = NULL, R = NULL, b = NULL, X = NULL, Y = NULL, 
               G = NULL, N = NULL, Tm = NULL,p = NULL, 
               control = list() )

Value

Object of spsur class with the output of the maximum-likelihood estimation of the specified spatial SUR model. A list with:

callMatched call.
typeType of model specified.
methodValue of method argument to compute the Jacobian
DurbinValue of Durbin argument.
coefficientsEstimated coefficients for the regressors.
deltasEstimated spatial coefficients.
rest.seEstimated standard errors for the estimates of beta.
deltas.seEstimated standard errors for the estimates of the spatial coefficients (deltas).
resvarEstimated covariance matrix for the estimates of beta's and spatial coefficients (deltas).
LLValue of the likelihood function at the maximum-likelihood estimates.
R2Coefficient of determination for each equation, obtained as the squared of the correlation coefficient between the corresponding explained variable and fitted values.
R2 pooledGlobal coefficient of determination obtained for the set of the G equations. It is computed in the same way than uniequational R2 but joining the dependent variable and fitted values in single vectors instead of one vector for each equation.
SigmaEstimated covariance matrix for the residuals of the G equations.
fdHessLogical value of fdHess argument when computing numerical covariances.
residualsResiduals of the model.
df.residualsDegrees of freedom for the residuals.
fitted.valuesEstimated values for the dependent variables.
BPValue of the Breusch-Pagan statistic to test the null hypothesis of diagonality among the errors of the G equations.
LMMMarginal Lagrange Multipliers, LM(\(\rho\)|\(\lambda\)) and LM(\(\lambda\)|\(\rho\)), to test for omitted spatial effects in the specification.
GNumber of equations.
NNumber of cross-sections or spatial units.
TmNumber of time periods.
pNumber of regressors by equation (including intercepts).
YIf data is NULL, vector Y of the explained variables of the SUR model.
XIf data is NULL, matrix X of the regressors of the SUR model.
WSpatial weighting matrix.
zero.policyLogical value of zero.policy .
intervalSearch interval for spatial parameter.
listw_styleStyle of neighborhood matrix W.
trsEither NULL or vector of powered spatial weights matrix traces output by trW.
insertLogical value to check if is.null(trs).

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.

type

Type of spatial model specification: "sim", "slx", "slm", "sem", "sdm", "sdem", "sarar" or "gnm". Default = "sim".

Durbin

If a formula object and model is type "sdm", "sdem" or "slx" the subset of explanatory variables to lag for each equation.

method

Similar to the corresponding parameter of lagsarlm function in spatialreg package. "eigen" (default) - the Jacobian is computed as the product of (1 - rho*eigenvalue) using eigenw, and "spam" or "Matrix_J" for strictly symmetric weights lists of styles "B" and "C", or made symmetric by similarity (Ord, 1975, Appendix C) if possible for styles "W" and "S", using code from the spam or Matrix packages to calculate the determinant; "Matrix" and "spam_update" provide updating Cholesky decomposition methods; "LU" provides an alternative sparse matrix decomposition approach. In addition, there are "Chebyshev" and Monte Carlo "MC" approximate log-determinant methods; the Smirnov/Anselin (2009) trace approximation is available as "moments". Three methods: "SE_classic", "SE_whichMin", and "SE_interp" are provided experimentally, the first to attempt to emulate the behaviour of Spatial Econometrics toolbox ML fitting functions. All use grids of log determinant values, and the latter two attempt to ameliorate some features of "SE_classic".

zero.policy

Similar to the corresponding parameter of lagsarlm function in spatialreg package. If TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA - causing spsurml() to terminate with an error. Default = NULL.

interval

Search interval for autoregressive parameter. Default = NULL.

trs

Similar to the corresponding parameter of lagsarlm function in spatialreg package. Default NULL, if given, a vector of powered spatial weights matrix traces output by trW.

R

A row vector of order (1xpr) with the set of r linear constraints on the beta parameters. The first restriction appears in the first p terms, the second restriction in the next p terms and so on. Default = NULL.

b

A column vector of order (rx1) with the values of the linear restrictions on the beta parameters. Default = NULL.

X

A data matrix of order (NTmGxp) with the observations of the regressors. The number of covariates in the SUR model is p = \(sum(p_{g})\) where \(p_{g}\) is the number of regressors (including the intercept) in the g-th equation, g = 1,...,G). The specification of "X" is only necessary if not available a Formula and a data frame. Default = NULL.

Y

A column vector of order (NTmGx1), with the observations of the explained variables. The ordering of the data must be (first) equation, (second) time dimension and (third) cross-sectional/spatial units. The specification of Y is only necessary if not available a Formula and a data frame. Default = NULL.

G

Number of equations.

N

Number of cross-section or spatial units

Tm

Number of time periods.

p

Number of regressors by equation, including the intercept. p can be a row vector of order (1xG), if the number of regressors is not the same for all the equations, or a scalar, if the G equations have the same number of regressors. The specification of p is only necessary if not available a Formula and a data frame.

control

list of additional arguments.

Control arguments

tolNumerical value for the tolerance for the estimation algorithm until convergence. Default = 1e-3.
maxitMaximum number of iterations until convergence; it must be an integer value. Default = 200.
traceA logical value to show intermediate results during the estimation process. Default = TRUE.
fdHessCompute variance-covariance matrix using the numerical hessian. Suited for large samples. Default = FALSE
Imultdefault 2; used for preparing the Cholesky decompositions for updating in the Jacobian function
superif NULL (default), set to FALSE to use a simplicial decomposition for the sparse Cholesky decomposition and method "Matrix_J", set to as.logical(NA) for method "Matrix", if TRUE, use a supernodal decomposition
cheb_qdefault 5; highest power of the approximating polynomial for the Chebyshev approximation
MC_pdefault 16; number of random variates
MC_mdefault 30; number of products of random variates matrix and spatial weights matrix
spamPivotdefault "MMD", alternative "RCM"
in_coefdefault 0.1, coefficient value for initial Cholesky decomposition in "spam_update"
typedefault "MC", used with method "moments"; alternatives "mult" and "moments", for use if trs is missing
correctdefault TRUE, used with method "moments" to compute the Smirnov/Anselin correction term
truncdefault TRUE, used with method "moments" to truncate the Smirnov/Anselin correction term
SE_methoddefault "LU", may be "MC"
nrhodefault 200, as in SE toolbox; the size of the first stage lndet grid; it may be reduced to for example 40
interpndefault 2000, as in SE toolbox; the size of the second stage lndet grid
SElndetdefault NULL, may be used to pass a pre-computed SE toolbox style matrix of coefficients and their lndet values to the "SE_classic" and "SE_whichMin" methods
LU_orderdefault FALSE; used in "LU_prepermutate", note warnings given for lu method
pre_eigdefault NULL; may be used to pass a pre-computed vector of eigenvalues

Author

Fernando Lopezfernando.lopez@upct.es
Roman Minguezroman.minguez@uclm.es
Jesus Murjmur@unizar.es

Details

The list of (spatial) models that can be estimated with the spsurml function are:

  • "sim": SUR model with no spatial effects $$ y_{tg} = X_{tg} \beta_{g} + \epsilon_{tg} $$

  • "slx": SUR model with spatial lags of the regressors $$ y_{tg} = X_{tg} \beta_{g} + WX_{tg} \theta_{g} + \epsilon_{tg} $$

  • "slm": SUR model with spatial lags of the explained variables $$y_{tg} = \rho_{g} Wy_{tg} + X_{tg} \beta_{g} + \epsilon_{tg} $$

  • "sem": SUR model with spatial errors $$ y_{tg} = X_{tg} \beta_{g} + u_{tg} $$ $$ u_{tg} = \lambda_{g} Wu_{tg} + \epsilon_{tg} $$

  • "sdm": SUR model of the Spatial Durbin type $$ y_{tg} = \rho_{g} Wy_{tg} + X_{tt} \beta_{g} + WX_{tg} \theta_{g} + \epsilon_{tg} $$

  • "sdem": SUR model with spatial lags of the regressors and spatial errors $$ y_{tg} = X_{tg} \beta_{g} + WX_{tg} \theta_{g} + u_{tg} $$ $$ u_{tg} = \lambda_{g} W u_{tg} + \epsilon_{tg} $$

  • "sarar": SUR model with spatial lags of the explained variables and spatial errors $$ y_{tg} = \rho_{g} Wy_{tg} + X_{tg} \beta_{g} + u_{tg} $$ $$ u_{tg} = \lambda_{g} W u_{tg} + \epsilon_{tg} $$

  • "gnm": SUR model with spatial lags of the explained variables, regressors and spatial errors $$ y_{tg} = \rho_{g} Wy_{tg} + X_{tg} \beta_{g} + WX_{tg} \theta_{g} + u_{tg} $$ $$ u_{tg} = \lambda_{g} W u_{tg} + \epsilon_{tg} $$

References

  • Anselin, L. (1988). Spatial econometrics: methods and models. Dordrecht: Kluwer

  • Bivand, R.S. and Piras G. (2015). Comparing Implementations of Estimation Methods for Spatial Econometrics. Journal of Statistical Software, 63(18), 1-36. <doi: 10.18637/jss.v063.i18>

  • Bivand, R. S., Hauke, J., and Kossowski, T. (2013). Computing the Jacobian in Gaussian spatial autoregressive models: An illustrated comparison of available methods. Geographical Analysis, 45(2), 150-179. <doi:10.1111/gean.12008>

  • Breusch T., Pagan A. (1980). The Lagrange multiplier test and its applications to model specification in econometrics. Rev Econ Stud 47: 239-254

  • Cliff, A.D. and Ord, J.K. (1981). Spatial processes: Models and applications, Pion.

  • LeSage J and Pace, R.K. (2009). Introduction to Spatial Econometrics. CRC Press, Boca Raton.

  • Lopez, F.A., Mur, J., and Angulo, A. (2014). Spatial model selection strategies in a SUR framework. The case of regional productivity in EU. Annals of Regional Science, 53(1), 197-220. <doi:10.1007/s00168-014-0624-2>

  • 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>

  • Mur, J., Lopez, F., and Herrera, M. (2010). Testing for spatial effects in seemingly unrelated regressions. Spatial Economic Analysis, 5(4), 399-440. <doi:10.1080/17421772.2010.516443>

  • Ord, J.K. (1975). Estimation methods for models of spatial interaction, Journal of the American Statistical Association, 70, 120-126.

See Also

spsur3sls, lagsarlm, lmtestspsur, wald_betas, lr_betas

Examples

Run this code

#################################################
######## CROSS SECTION DATA (G>1; Tm=1) ########
#################################################

#### Example 1: Spatial Phillips-Curve. Anselin (1988, p. 203)
rm(list = ls()) # Clean memory
data(spc)
Tformula <- WAGE83 | WAGE81 ~ UN83 + NMR83 + SMSA | UN80 + NMR80 + SMSA
spcsur.sim <- spsurml(formula = Tformula, data = spc, type = "sim")
summary(spcsur.sim)
# All the coefficients in a single table.
print(spcsur.sim)
# Plot of the coefficients of each equation in different graphs
plot(spcsur.sim) 

## A SUR-SLX model 
## (listw argument can be either a matrix or a listw object )
spcsur.slx <- spsurml(formula = Tformula, data = spc, type = "slx", 
  listw = Wspc, Durbin = TRUE)
summary(spcsur.slx)
# All the coefficients in a single table.
print(spcsur.slx)
# Plot of the coefficients in a single graph
if (require(gridExtra)) {
  pl <- plot(spcsur.slx, viewplot = FALSE)
  grid.arrange(pl$lplbetas[[1]], pl$lplbetas[[2]], 
                        nrow = 2)
} 

## VIP: The output of the whole set of the examples can be examined 
## by executing demo(demo_spsurml, package="spsur")
  
# \donttest{
### A SUR-SLM model
spcsur.slm <- spsurml(formula = Tformula, data = spc, type = "slm", 
                     listw = Wspc)
summary(spcsur.slm)
if (require(gridExtra)) {
  pl <- plot(spcsur.slm, viewplot = FALSE) 
  grid.arrange(pl$lplbetas[[1]], pl$lplbetas[[2]], 
               pl$pldeltas, nrow = 3)
}


### A SUR-SDM model
spcsur.sdm <- spsurml(formula = Tformula, data = spc, type = "sdm", 
                     listw = Wspc)
summary(spcsur.sdm)
print(spcsur.sdm)
if (require(gridExtra)) {
  pl <- plot(spcsur.sdm, viewplot = FALSE) 
  grid.arrange(pl$lplbetas[[1]], pl$lplbetas[[2]], 
               pl$pldeltas, nrow = 3)
}

## A SUR-SDM model with different spatial lags in each equation
TformulaD <- ~ UN83 + NMR83 + SMSA | UN80
spcsur.sdm2 <- spsurml(formula = Tformula, data = spc, type = "sdm", 
                      listw = Wspc, Durbin = TformulaD)
summary(spcsur.sdm2)
if (require(gridExtra)) {
  pl <- plot(spcsur.sdm2, viewplot = FALSE) 
  grid.arrange(pl$lplbetas[[1]], pl$lplbetas[[2]], 
               pl$pldeltas, nrow = 3)
}
# }

##################################################
#########  CLASSIC PANEL DATA G=1; Tm>1   ########
##################################################
#
##### Example 2: Homicides + Socio-Economics (1960-90)
## Homicides and selected socio-economic characteristics for continental
## U.S. counties.
## Data for four decennial census years: 1960, 1970, 1980 and 1990.
## \url{https://geodacenter.github.io/data-and-lab/ncovr/}

# \donttest{
### It usually requires 1-2 minutes maximum...
rm(list = ls()) # Clean memory
### Read NCOVR.sf object
data(NCOVR, package = "spsur")
nbncovr <- spdep::poly2nb(NCOVR.sf, queen = TRUE)
### Some regions with no links...
lwncovr <- spdep::nb2listw(nbncovr, style = "W", zero.policy = TRUE)
Tformula <- HR80  | HR90 ~ PS80 + UE80 | PS90 + UE90
### A SUR-SIM model
NCOVRSUR.sim <- spsurml(formula = Tformula, data = NCOVR.sf, type = "sim")
summary(NCOVRSUR.sim)
if (require(gridExtra)) {
  pl <- plot(NCOVRSUR.sim, viewplot = FALSE) 
  grid.arrange(pl$lplbetas[[1]], pl$lplbetas[[2]], nrow = 3)
}
### A SUR-SLX model
NCOVRSUR.slx <- spsurml(formula = Tformula, data = NCOVR.sf, type = "slx", 
                       listw = lwncovr, zero.policy = TRUE)
print(NCOVRSUR.slx)
if (require(gridExtra)) {
  pl <- plot(NCOVRSUR.slx, viewplot = FALSE) 
  grid.arrange(pl$lplbetas[[1]], pl$lplbetas[[2]], nrow = 2)
}

### A SUR-SLM model
### method = "Matrix" (Cholesky) instead of "eigen"
### (fdHess = TRUE to compute numerical covariances )
NCOVRSUR.slm <- spsurml(formula = Tformula, data = NCOVR.sf, 
                       type = "slm", listw = lwncovr, method = "Matrix", 
                       zero.policy = TRUE, control = list(fdHess = TRUE))
summary(NCOVRSUR.slm)

if (require(gridExtra)) {
  pl <- plot(NCOVRSUR.slm, viewplot = FALSE) 
  grid.arrange(pl$lplbetas[[1]], pl$lplbetas[[2]], 
               pl$pldeltas, nrow = 3)
}
# LR test for nested models
anova(NCOVRSUR.sim, NCOVRSUR.slm)
# }

Run the code above in your browser using DataLab