| Title: | Spatial Models for Limited Dependent Variables |
|---|---|
| Description: | The current version of this package estimates spatial autoregressive models for binary dependent variables using GMM estimators <doi:10.18637/jss.v107.i08> and RIS estimator <doi:10.1007/978-3-662-05617-2_8>. It supports one-step (Pinkse and Slade, 1998) <doi:10.1016/S0304-4076(97)00097-3> and two-step GMM estimator along with the linearized GMM estimator proposed by Klier and McMillen (2008) <doi:10.1198/073500107000000188>. It also allows for either Probit or Logit model and compute the average marginal effects. The RIS estimator allows to estimate the SAR and SEM model. All these models are presented in Sarrias and Piras (2023) <doi:10.1016/j.jocm.2023.100432>. |
| Authors: | Mauricio Sarrias [aut, cre] (ORCID: <https://orcid.org/0000-0001-5932-4817>), Gianfranco Piras [aut] (ORCID: <https://orcid.org/0000-0003-0225-6061>), Daniel McMillen [ctb] |
| Maintainer: | Mauricio Sarrias <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.2.2 |
| Built: | 2026-05-15 08:23:14 UTC |
| Source: | https://github.com/gpiras/spldv |
A generic function to collect coefficients and summary statistics from a bingmm object. It is used in mtable
## S3 method for class 'bingmm' getSummary(obj, alpha = 0.05, ...)## S3 method for class 'bingmm' getSummary(obj, alpha = 0.05, ...)
obj |
a |
alpha |
level of the confidence intervals, |
... |
further arguments, |
For more details see package memisc.
A list with an array with coefficient estimates and a vector containing the model summary statistics.
A generic function to collect coefficients and summary statistics from a binlgmm object. It is used in mtable
## S3 method for class 'binlgmm' getSummary(obj, alpha = 0.05, ...)## S3 method for class 'binlgmm' getSummary(obj, alpha = 0.05, ...)
obj |
a |
alpha |
level of the confidence intervals, |
... |
further arguments, |
For more details see package memisc.
A list with an array with coefficient estimates and a vector containing the model summary statistics.
A generic function to collect coefficients and summary statistics from a binris object. It is used in mtable
## S3 method for class 'binris' getSummary(obj, alpha = 0.05, ...)## S3 method for class 'binris' getSummary(obj, alpha = 0.05, ...)
obj |
a |
alpha |
level of the confidence intervals, |
... |
further arguments, |
For more details see package memisc.
A list with an array with coefficient estimates and a vector containing the model summary statistics.
Computes marginal effects (direct, indirect, total, from-region, and cumulative) from a spatial binary response model. Supports inference via the Delta method or Monte Carlo simulation.
## S3 method for class 'bingmm' impacts( obj, data = NULL, variable = NULL, from.unit = 1, dydx = c("exact", "numeric"), change = NULL, vce = c("robust", "efficient", "ml"), type = c("delta", "mc"), result = c("summary", "from.region", "cumulative"), vcov = NULL, het = TRUE, empirical = FALSE, approximation = FALSE, R = 50, pw = 5, draws = NULL, Q = 3, tol = 1e-06, verbose = FALSE, ... ) ## S3 method for class 'binlgmm' impacts( obj, data = NULL, variable = NULL, from.unit = 1, dydx = c("exact", "numeric"), change = NULL, vce = c("robust", "efficient", "ml"), type = c("delta", "mc"), result = c("summary", "from.region", "cumulative"), vcov = NULL, het = TRUE, empirical = FALSE, approximation = FALSE, R = 50, pw = 5, draws = NULL, Q = 3, tol = 1e-06, verbose = FALSE, ... ) ## S3 method for class 'binris' impacts( obj, data = NULL, variable = NULL, from.unit = 1, dydx = c("exact", "numeric"), change = NULL, vce = c("robust", "efficient", "ml"), type = c("delta", "mc"), result = c("summary", "from.region", "cumulative"), vcov = NULL, het = TRUE, empirical = FALSE, approximation = FALSE, R = 50, pw = 5, draws = NULL, Q = 3, tol = 1e-06, verbose = FALSE, ... ) ## S3 method for class 'impacts.bingmm' print(x, ...) ## S3 method for class 'impacts.bingmm' summary(object, ...) ## S3 method for class 'summary.impacts.bingmm' print(x, digits = max(3, getOption("digits") - 3), ...)## S3 method for class 'bingmm' impacts( obj, data = NULL, variable = NULL, from.unit = 1, dydx = c("exact", "numeric"), change = NULL, vce = c("robust", "efficient", "ml"), type = c("delta", "mc"), result = c("summary", "from.region", "cumulative"), vcov = NULL, het = TRUE, empirical = FALSE, approximation = FALSE, R = 50, pw = 5, draws = NULL, Q = 3, tol = 1e-06, verbose = FALSE, ... ) ## S3 method for class 'binlgmm' impacts( obj, data = NULL, variable = NULL, from.unit = 1, dydx = c("exact", "numeric"), change = NULL, vce = c("robust", "efficient", "ml"), type = c("delta", "mc"), result = c("summary", "from.region", "cumulative"), vcov = NULL, het = TRUE, empirical = FALSE, approximation = FALSE, R = 50, pw = 5, draws = NULL, Q = 3, tol = 1e-06, verbose = FALSE, ... ) ## S3 method for class 'binris' impacts( obj, data = NULL, variable = NULL, from.unit = 1, dydx = c("exact", "numeric"), change = NULL, vce = c("robust", "efficient", "ml"), type = c("delta", "mc"), result = c("summary", "from.region", "cumulative"), vcov = NULL, het = TRUE, empirical = FALSE, approximation = FALSE, R = 50, pw = 5, draws = NULL, Q = 3, tol = 1e-06, verbose = FALSE, ... ) ## S3 method for class 'impacts.bingmm' print(x, ...) ## S3 method for class 'impacts.bingmm' summary(object, ...) ## S3 method for class 'summary.impacts.bingmm' print(x, digits = max(3, getOption("digits") - 3), ...)
obj |
An object of class |
data |
Optional dataset used for computing partial effects. |
variable |
Variable name (string) for which marginal effects are computed. |
from.unit |
Integer specifying the spatial unit (row) for computing impacts. |
dydx |
Character: type of derivative approximation to use ( |
change |
For numeric variables, a vector indicating the lower and upper value to compute the partial change. |
vce |
A string indicating what kind of variance-covariance matrix of the estimate should be computed when using |
type |
String indicating which method is used to compute the standard errors of the marginal effects. If |
result |
String indicating the output format: |
vcov |
Optional user-supplied variance-covariance matrix. |
het |
Logical. If |
empirical |
Logical. Argument passed to |
approximation |
Logical. If |
R |
Numerical. Indicates the number of draws used in the Monte Carlo approximation if |
pw |
numeric. The power used for the approximation |
draws |
Optional matrix of parameter draws for Monte Carlo simulation. |
Q |
Number of columns for cumulative effects (if applicable). |
tol |
Numerical. Argument passed to |
verbose |
Logical. Display progress. |
... |
further arguments. Ignored. |
x |
An object of class |
object |
An object of class |
digits |
the number of digits. |
Let the model be:
where if and 0 otherwise; if link = "probit" or if link = "logit".
The RIS estimator assumes that .
The marginal effects respect to variable can be computed as
where is the pdf, which depends on the assumption of the error terms; is the operator that creates a diagonal matrix; ; and is a diagonal matrix whose elements represent the square root of the diagonal elements of the variance-covariance matrix of .
We implement these three summary measures: (1) The average total effects, , (2) The average direct effects, , and (3) the average indirect effects, .
The standard errors of the average total, direct and indirect effects can be estimated using either Monte Carlo (MC) approximation, which takes into account the sampling distribution of , or Delta Method.
An object of class impacts.bingmm.
Mauricio Sarrias and Gianfranco Piras.
# Data set data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # Two-step (Probit) GMM estimator ts <- sbinaryGMM(CRIMED ~ INC * HOVAL + factor(CP) | HOVAL, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "twostep") # Summary marginal effects using Delta Method summary(impacts(ts, type = "delta")) # Summary marginal effects using MC with 100 draws summary(impacts(ts, type = "mc", R = 100)) # Marginal effects using efficient VC matrix summary(impacts(ts, type = "delta", vce = "efficient")) # Marginal effects using efficient VC matrix and ignoring the heteroskedasticity summary(impacts(ts, type = "delta", vce = "efficient", het = FALSE)) # Obtain total impact when INC changes in region 20 imp <- impacts(ts, type = "delta", result = "from.region", from.unit = 20, variable = "INC") head(imp$out, 6) # Cumulative impact when INC changes in region 20 up to power = 3 cum <- impacts(ts, type = "delta", result = "cumulative", from.unit = 20, variable = "INC", Q = 3) head(cum$out$`Q:3`, 6) # Marginal effects using RIS estimator ris_sar <- sbinaryRis(CRIMED ~ INC + HOVAL, data = COL.OLD, R = 50, listw = spdep::nb2listw(COL.nb, style = "W")) summary(impacts(ris_sar, method = "delta")) summary(impacts(ris_sar, method = "mc", R = 100))# Data set data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # Two-step (Probit) GMM estimator ts <- sbinaryGMM(CRIMED ~ INC * HOVAL + factor(CP) | HOVAL, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "twostep") # Summary marginal effects using Delta Method summary(impacts(ts, type = "delta")) # Summary marginal effects using MC with 100 draws summary(impacts(ts, type = "mc", R = 100)) # Marginal effects using efficient VC matrix summary(impacts(ts, type = "delta", vce = "efficient")) # Marginal effects using efficient VC matrix and ignoring the heteroskedasticity summary(impacts(ts, type = "delta", vce = "efficient", het = FALSE)) # Obtain total impact when INC changes in region 20 imp <- impacts(ts, type = "delta", result = "from.region", from.unit = 20, variable = "INC") head(imp$out, 6) # Cumulative impact when INC changes in region 20 up to power = 3 cum <- impacts(ts, type = "delta", result = "cumulative", from.unit = 20, variable = "INC", Q = 3) head(cum$out$`Q:3`, 6) # Marginal effects using RIS estimator ris_sar <- sbinaryRis(CRIMED ~ INC + HOVAL, data = COL.OLD, R = 50, listw = spdep::nb2listw(COL.nb, style = "W")) summary(impacts(ris_sar, method = "delta")) summary(impacts(ris_sar, method = "mc", R = 100))
Make instruments for spatial models
make.instruments(listw, x, q)make.instruments(listw, x, q)
listw |
object. An object of class |
x |
variable(s) to be lagged |
q |
number of lags |
Mauricio Sarrias and Gianfranco Piras.
Computes predicted probabilities for spatial binary response models estimated via GMM. Supports both probit and logit links, accounts for spatial heteroskedasticity, and optionally returns standard errors using the Delta method with robust or efficient variance estimators.
## S3 method for class 'bingmm' predict( object, newdata, Sinv = NULL, het = TRUE, approximation = FALSE, pw = 5, ses = FALSE, vce = c("robust", "efficient", "ml"), theta = NULL, ... )## S3 method for class 'bingmm' predict( object, newdata, Sinv = NULL, het = TRUE, approximation = FALSE, pw = 5, ses = FALSE, vce = c("robust", "efficient", "ml"), theta = NULL, ... )
object |
An object of class |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the original data used to fit the model is used. |
Sinv |
Optional user-supplied spatial multiplier matrix |
het |
Logical. If |
approximation |
Logical. If |
pw |
Integer. Power-order to use when |
ses |
Logical. If |
vce |
Type of variance-covariance estimator: |
theta |
Optional parameter vector (including |
... |
Additional arguments (currently unused). |
The function computes predicted probabilities where is a spatially filtered linear index.
In the presence of heteroskedasticity (het = TRUE), the normalization involves the row-wise standard deviation
of the spatial multiplier. When ses = TRUE, standard errors are computed using the analytical Jacobian of the
prediction function with respect to the parameters and the estimated variance-covariance matrix.
A numeric vector of predicted probabilities if ses = FALSE. If ses = TRUE, returns a matrix with:
p_hatPredicted probabilities.
Std. errorStandard errors of the predictions.
z valueZ-statistics.
Pr(> z)Two-sided p-values.
Mauricio Sarrias and Gianfranco Piras.
# Data set data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # Two-step (Probit) GMM estimator ts <- sbinaryGMM(CRIMED ~ INC*HOVAL + factor(CP), link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "twostep", verbose = FALSE) # Compute just the predicted probability p_hat <- predict(ts) # Compute predicted probability and standard errors res <- predict(ts, ses = TRUE, het = TRUE, vce = "efficient") head(res)# Data set data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # Two-step (Probit) GMM estimator ts <- sbinaryGMM(CRIMED ~ INC*HOVAL + factor(CP), link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "twostep", verbose = FALSE) # Compute just the predicted probability p_hat <- predict(ts) # Compute predicted probability and standard errors res <- predict(ts, ses = TRUE, het = TRUE, vce = "efficient") head(res)
Computes predicted probabilities for spatial binary response models estimated via LGMM. Supports both probit and logit links, accounts for spatial heteroskedasticity, and optionally returns standard errors using the Delta method.
## S3 method for class 'binlgmm' predict( object, newdata, Sinv = NULL, het = TRUE, approximation = FALSE, pw = 5, ses = FALSE, theta = NULL, ... )## S3 method for class 'binlgmm' predict( object, newdata, Sinv = NULL, het = TRUE, approximation = FALSE, pw = 5, ses = FALSE, theta = NULL, ... )
object |
An object of class |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the original data used to fit the model is used. |
Sinv |
Optional user-supplied spatial multiplier matrix |
het |
Logical. If |
approximation |
Logical. If |
pw |
Integer. Power-order to use when |
ses |
Logical. If |
theta |
Optional parameter vector (including |
... |
Additional arguments (currently unused). |
The function computes predicted probabilities where is a spatially filtered linear index.
In the presence of heteroskedasticity (het = TRUE), the normalization involves the row-wise standard deviation
of the spatial multiplier. When ses = TRUE, standard errors are computed using the analytical Jacobian of the
prediction function with respect to the parameters and the estimated variance-covariance matrix.
A numeric vector of predicted probabilities if ses = FALSE. If ses = TRUE, returns a matrix with:
p_hatPredicted probabilities.
Std. errorStandard errors of the predictions.
z valueZ-statistics.
Pr(> z)Two-sided p-values.
Mauricio Sarrias and Gianfranco Piras.
# Data set data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # Estimate the model lgmm <- sbinaryLGMM(CRIMED ~ INC + HOVAL | INC, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), nins = 3, data = COL.OLD) # Predicted probabilities with SES out <- predict(lgmm, ses = TRUE) head(out, 5)# Data set data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # Estimate the model lgmm <- sbinaryLGMM(CRIMED ~ INC + HOVAL | INC, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), nins = 3, data = COL.OLD) # Predicted probabilities with SES out <- predict(lgmm, ses = TRUE) head(out, 5)
Computes predicted probabilities for spatial binary response models estimated via RIS. Supports probit models and accounts for spatial heteroskedasticity, and optionally returns standard errors using the Delta method.
## S3 method for class 'binris' predict( object, newdata, Sinv = NULL, het = TRUE, approximation = FALSE, pw = 5, ses = FALSE, theta = NULL, ... )## S3 method for class 'binris' predict( object, newdata, Sinv = NULL, het = TRUE, approximation = FALSE, pw = 5, ses = FALSE, theta = NULL, ... )
object |
An object of class |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the original data used to fit the model is used. |
Sinv |
Optional user-supplied spatial multiplier matrix |
het |
Logical. If |
approximation |
Logical. If |
pw |
Integer. Power-order to use when |
ses |
Logical. If |
theta |
Optional parameter vector (including |
... |
Additional arguments (currently unused). |
The function computes predicted probabilities where is a spatially filtered linear index.
In the presence of heteroskedasticity (het = TRUE), the normalization involves the row-wise standard deviation
of the spatial multiplier. When ses = TRUE, standard errors are computed using the analytical Jacobian of the
prediction function with respect to the parameters and the estimated variance-covariance matrix.
A numeric vector of predicted probabilities if ses = FALSE. If ses = TRUE, returns a matrix with:
p_hatPredicted probabilities.
Std. errorStandard errors of the predictions.
z valueZ-statistics.
Pr(> z)Two-sided p-values.
Mauricio Sarrias and Gianfranco Piras.
data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # Estimate the model ris_sar <- sbinaryRis(CRIMED ~ INC + HOVAL, data = COL.OLD, R = 50, listw = spdep::nb2listw(COL.nb, style = "W")) # Predicted probabilities with SES out <- predict(ris_sar, ses = TRUE) head(out, 5)data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # Estimate the model ris_sar <- sbinaryRis(CRIMED ~ INC + HOVAL, data = COL.OLD, R = 50, listw = spdep::nb2listw(COL.nb, style = "W")) # Predicted probabilities with SES out <- predict(ris_sar, ses = TRUE) head(out, 5)
Estimates a Spatial Autoregressive (SAR) model for binary outcomes using the Generalized Method of Moments (GMM). The model supports both Probit and Logit links, with one-step or two-step GMM estimation. The structural equation is:
where if and 0 otherwise.
The error term follows a standard normal distribution (link = "probit") or logistic distribution (link = "logit").
sbinaryGMM( formula, data, listw = NULL, nins = 2, link = c("probit", "logit"), winitial = c("optimal", "identity"), s.matrix = c("robust", "iid"), type = c("onestep", "twostep"), gradient = TRUE, start = NULL, cons.opt = FALSE, approximation = FALSE, verbose = TRUE, print.init = FALSE, pw = 5, tol.solve = .Machine$double.eps, fastmom = FALSE, ... ) ## S3 method for class 'bingmm' coef(object, ...) ## S3 method for class 'bingmm' vcov( object, vce = c("robust", "efficient", "ml"), method = "bhhh", R = 1000, tol.solve = .Machine$double.eps, ... ) ## S3 method for class 'bingmm' print(x, digits = max(3, getOption("digits") - 3), ...) ## S3 method for class 'bingmm' summary( object, vce = c("robust", "efficient", "ml"), method = "bhhh", R = 1000, tol.solve = .Machine$double.eps, ... ) ## S3 method for class 'summary.bingmm' print(x, digits = max(5, getOption("digits") - 3), ...)sbinaryGMM( formula, data, listw = NULL, nins = 2, link = c("probit", "logit"), winitial = c("optimal", "identity"), s.matrix = c("robust", "iid"), type = c("onestep", "twostep"), gradient = TRUE, start = NULL, cons.opt = FALSE, approximation = FALSE, verbose = TRUE, print.init = FALSE, pw = 5, tol.solve = .Machine$double.eps, fastmom = FALSE, ... ) ## S3 method for class 'bingmm' coef(object, ...) ## S3 method for class 'bingmm' vcov( object, vce = c("robust", "efficient", "ml"), method = "bhhh", R = 1000, tol.solve = .Machine$double.eps, ... ) ## S3 method for class 'bingmm' print(x, digits = max(3, getOption("digits") - 3), ...) ## S3 method for class 'bingmm' summary( object, vce = c("robust", "efficient", "ml"), method = "bhhh", R = 1000, tol.solve = .Machine$double.eps, ... ) ## S3 method for class 'summary.bingmm' print(x, digits = max(5, getOption("digits") - 3), ...)
formula |
A symbolic description of the model of the form |
data |
A |
listw |
A spatial weights matrix of class |
nins |
Integer. Order of spatial instruments to generate; default is |
link |
Character string; distributional assumption on the error term. Either |
winitial |
Character string. A string indicating the initial moment-weighting matrix |
s.matrix |
Character string. Only valid of |
type |
Character string. A string indicating whether the one-step ( |
gradient |
Logical. Only for testing procedures. Should the analytic gradient be used in the GMM optimization procedure? |
start |
Vector of optional starting values. If not |
cons.opt |
Logical. Should a constrained optimization procedure for |
approximation |
Logical. If |
verbose |
Logical. If |
print.init |
Logical. If |
pw |
Integer. The power used for the approximation |
tol.solve |
Tolerance for |
fastmom |
Logical. Use faster approximate gradient for |
... |
additional arguments passed to |
vce |
Character string. A string indicating what kind of standard errors should be computed when using |
method |
Character string. Only valid if |
R |
Integer. Only valid if |
x, object
|
an object of class |
digits |
Integer. The number of digits for |
The data generating process is:
where if and 0 otherwise; if link = "probit" or if link = "logit". The general GMM
estimator minimizes:
where and
where is the generalized residuals. Let , then the instrument matrix contains the linearly independent
columns of . The one-step GMM estimator minimizes setting either
if winitial = "identity" or if winitial = "optimal". The two-step GMM estimator
uses an additional step to achieve higher efficiency by computing the variance-covariance matrix of the moments to weight the sample moments.
This matrix is computed using the residuals or generalized residuals from the first-step, which are consistent. This matrix is computed as
if s.matrix = "robust" or
, where are the first-step generalized residuals.
An object of class “bingmm”, a list with elements:
coefficients |
the estimated coefficients, |
call |
the matched call, |
callF |
the full matched call, |
X |
the X matrix, which contains also WX if the second part of the |
H |
the H matrix of instruments used, |
y |
the dependent variable, |
listw |
the spatial weight matrix, |
link |
the string indicating the distribution of the error term, |
Psi |
the moment-weighting matrix used in the last round, |
type |
type of model that was fitted, |
s.matrix |
the type of S matrix used in the second round, |
winitial |
the moment-weighting matrix used for the first step procedure, |
opt |
object of class |
approximation |
a logical value indicating whether approximation was used to compute the inverse matrix, |
pw |
the powers for the approximation, |
formula |
the formula, |
data |
the data, |
contrastsX |
the contrasts used in the first part of the formula, |
contrastsD |
the contrasts used in the second part of the formula, |
Xlevels |
a record of the levels of the factors used in fitting, |
fastmom |
whether the model was fitted using the faster gradient for |
Mauricio Sarrias and Gianfranco Piras.
Pinkse, J., & Slade, M. E. (1998). Contracting in space: An application of spatial statistics to discrete-choice models. Journal of Econometrics, 85(1), 125-154.
Fleming, M. M. (2004). Techniques for estimating spatially dependent discrete choice models. In Advances in spatial econometrics (pp. 145-168). Springer, Berlin, Heidelberg.
Klier, T., & McMillen, D. P. (2008). Clustering of auto supplier plants in the United States: generalized method of moments spatial logit for large samples. Journal of Business & Economic Statistics, 26(4), 460-471.
LeSage, J. P., Kelley Pace, R., Lam, N., Campanella, R., & Liu, X. (2011). New Orleans business recovery in the aftermath of Hurricane Katrina. Journal of the Royal Statistical Society: Series A (Statistics in Society), 174(4), 1007-1027.
Piras, G., & Sarrias, M. (2023). One or Two-Step? Evaluating GMM Efficiency for Spatial Binary Probit Models. Journal of choice modelling, 48, 100432.
Piras, G,. & Sarrias, M. (2023). GMM Estimators for Binary Spatial Models in R. Journal of Statistical Software, 107(8), 1-33.
# Data set data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # Two-step (Probit) GMM estimator ts <- sbinaryGMM(CRIMED ~ INC + HOVAL, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "twostep", verbose = TRUE) # Robust standard errors summary(ts) # Efficient standard errors summary(ts, vce = "efficient") # One-step (Probit) GMM estimator os <- sbinaryGMM(CRIMED ~ INC + HOVAL, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "onestep", verbose = TRUE) summary(os) # One-step (Logit) GMM estimator with identity matrix as initial weight matrix os_l <- sbinaryGMM(CRIMED ~ INC + HOVAL, link = "logit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "onestep", winitial = "identity", verbose = TRUE) summary(os_l) # Two-step (Probit) GMM estimator with WX ts_wx <- sbinaryGMM(CRIMED ~ INC + HOVAL| INC + HOVAL, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "twostep", verbose = FALSE) summary(ts_wx) # Constrained two-step (Probit) GMM estimator ts_c <- sbinaryGMM(CRIMED ~ INC + HOVAL, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "twostep", verbose = TRUE, cons.opt = TRUE) summary(ts_c)# Data set data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # Two-step (Probit) GMM estimator ts <- sbinaryGMM(CRIMED ~ INC + HOVAL, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "twostep", verbose = TRUE) # Robust standard errors summary(ts) # Efficient standard errors summary(ts, vce = "efficient") # One-step (Probit) GMM estimator os <- sbinaryGMM(CRIMED ~ INC + HOVAL, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "onestep", verbose = TRUE) summary(os) # One-step (Logit) GMM estimator with identity matrix as initial weight matrix os_l <- sbinaryGMM(CRIMED ~ INC + HOVAL, link = "logit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "onestep", winitial = "identity", verbose = TRUE) summary(os_l) # Two-step (Probit) GMM estimator with WX ts_wx <- sbinaryGMM(CRIMED ~ INC + HOVAL| INC + HOVAL, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "twostep", verbose = FALSE) summary(ts_wx) # Constrained two-step (Probit) GMM estimator ts_c <- sbinaryGMM(CRIMED ~ INC + HOVAL, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), data = COL.OLD, type = "twostep", verbose = TRUE, cons.opt = TRUE) summary(ts_c)
Estimation of SAR model for binary dependent variables (either Probit or Logit), using Linearized GMM estimator suggested by Klier and McMillen (2008). The model is:
where if and 0 otherwise; if link = "probit" or link = "logit".
sbinaryLGMM( formula, data, listw = NULL, nins = 2, link = c("logit", "probit"), ... ) ## S3 method for class 'binlgmm' coef(object, ...) ## S3 method for class 'binlgmm' vcov(object, ...) ## S3 method for class 'binlgmm' print(x, digits = max(3, getOption("digits") - 3), ...) ## S3 method for class 'binlgmm' summary(object, ...) ## S3 method for class 'summary.binlgmm' print(x, digits = max(3, getOption("digits") - 2), ...)sbinaryLGMM( formula, data, listw = NULL, nins = 2, link = c("logit", "probit"), ... ) ## S3 method for class 'binlgmm' coef(object, ...) ## S3 method for class 'binlgmm' vcov(object, ...) ## S3 method for class 'binlgmm' print(x, digits = max(3, getOption("digits") - 3), ...) ## S3 method for class 'binlgmm' summary(object, ...) ## S3 method for class 'summary.binlgmm' print(x, digits = max(3, getOption("digits") - 2), ...)
formula |
A symbolic description of the model of the form |
data |
A |
listw |
A spatial weights matrix of class |
nins |
Integer. Order of spatial instruments to generate; default is |
link |
Character string; distributional assumption on the error term. Either |
... |
additional arguments. |
x, object
|
an object of class |
digits |
Integer. The number of digits for |
The steps for the linearized spatial Probit/Logit model are the following:
1. Estimate the model by standard Probit/Logit model, in which spatial autocorrelation and heteroskedasticity are ignored. The estimated values are . Calculate the generalized residuals assuming that and the gradient terms and .
2. The second step is a two-stage least squares estimator of the linearized model. Thus regress and on and obtain the predicted values . Then regress on . The coefficients are the estimated values of and .
The variance-covariance matrix can be computed using the traditional White-corrected coefficient covariance matrix from the last two-stage least squares estimator of the linearlized model.
An object of class “bingmm”, a list with elements:
coefficients |
the estimated coefficients, |
call |
the matched call, |
X |
the X matrix, which contains also WX if the second part of the |
H |
the H matrix of instruments used, |
y |
the dependent variable, |
listw |
the spatial weight matrix, |
link |
the string indicating the distribution of the error term, |
fit |
an object of |
formula |
the formula, |
data |
the data, |
contrastsX |
the contrasts used in the first part of the formula, |
contrastsD |
the contrasts used in the second part of the formula, |
Xlevels |
a record of the levels of the factors used in fitting. |
Mauricio Sarrias and Gianfranco Piras.
Klier, T., & McMillen, D. P. (2008). Clustering of auto supplier plants in the United States: generalized method of moments spatial logit for large samples. Journal of Business & Economic Statistics, 26(4), 460-471.
Piras, G., & Sarrias, M. (2023). One or Two-Step? Evaluating GMM Efficiency for Spatial Binary Probit Models. Journal of choice modelling, 48, 100432.
Piras, G,. & Sarrias, M. (2023). GMM Estimators for Binary Spatial Models in R. Journal of Statistical Software, 107(8), 1-33.
# Data set data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # LGMM for probit using q = 3 for instruments lgmm <- sbinaryLGMM(CRIMED ~ INC + HOVAL | INC, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), nins = 3, data = COL.OLD) summary(lgmm)# Data set data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # LGMM for probit using q = 3 for instruments lgmm <- sbinaryLGMM(CRIMED ~ INC + HOVAL | INC, link = "probit", listw = spdep::nb2listw(COL.nb, style = "W"), nins = 3, data = COL.OLD) summary(lgmm)
Estimation of spatial probit model using RIS-normal (a.k.a GHK) simulator. The models can be the SAR or SEM probit model model. The SAR probit model has the following structure:
where if and 0 otherwise, , , with ,
and . The SEM probit model has the following structure:
where if and 0 otherwise, , ,
such that , and ,
sbinaryRis( formula, data, subset, na.action, listw = NULL, R = 20, model = c("SAR", "SEM"), varcov = c("invsigma", "sigma"), approximation = TRUE, pw = 5, start = NULL, Qneg = FALSE, print.init = FALSE, ... ) ## S3 method for class 'binris' terms(x, ...) ## S3 method for class 'binris' estfun(x, ...) ## S3 method for class 'binris' bread(x, ...) ## S3 method for class 'binris' df.residual(object, ...) ## S3 method for class 'binris' vcov(object, ...) ## S3 method for class 'binris' coef(object, ...) ## S3 method for class 'binris' logLik(object, ...) ## S3 method for class 'binris' print(x, ...) ## S3 method for class 'binris' summary(object, eigentol = 1e-12, ...) ## S3 method for class 'summary.binris' print(x, digits = max(3, getOption("digits") - 2), ...)sbinaryRis( formula, data, subset, na.action, listw = NULL, R = 20, model = c("SAR", "SEM"), varcov = c("invsigma", "sigma"), approximation = TRUE, pw = 5, start = NULL, Qneg = FALSE, print.init = FALSE, ... ) ## S3 method for class 'binris' terms(x, ...) ## S3 method for class 'binris' estfun(x, ...) ## S3 method for class 'binris' bread(x, ...) ## S3 method for class 'binris' df.residual(object, ...) ## S3 method for class 'binris' vcov(object, ...) ## S3 method for class 'binris' coef(object, ...) ## S3 method for class 'binris' logLik(object, ...) ## S3 method for class 'binris' print(x, ...) ## S3 method for class 'binris' summary(object, eigentol = 1e-12, ...) ## S3 method for class 'summary.binris' print(x, digits = max(3, getOption("digits") - 2), ...)
formula |
A symbolic description of the model of the form |
data |
A |
subset |
An optional vector specifying a subset of observations to be used in the fitting process. |
na.action |
A function which indicates what should happen when the data contains |
listw |
Object. An object of class |
R |
Integer. The number of draws used in RIS (GHK) simulator. |
model |
String. A string indicating which model to estimate. It can be |
varcov |
String. A string indicating over which variance-covariance matrix to apply the Chokesly factorization. |
approximation |
Logical. If |
pw |
Integer. The power used for the approximation |
start |
If not |
Qneg |
Logical. Whether to construct the negative of the diagonal elements of |
print.init |
Logical. If |
... |
additional arguments passed to |
x, object
|
An object of class |
eigentol |
The standard errors are only calculated if the ratio of the smallest and largest eigenvalue of the Hessian matrix is less than |
digits |
The number of digits for |
The models are estimated by simulating the probabilities using the RIS-normal (GHK) simulator. The aim is to evaluate
the multivariate density function , where is a diagonal matrix with entries , and the vector
depends on whether the model is SAR or SEM. If model = "SAR", then where ;
if model = "SEM", then .
Let be the variance-covariance model of the transformed model. If model = "SAR"
, where .
If model = "SEM", then , where .
Since is positive definite, there exists a Cholesky decomposition such that
, where is the upper triangular Cholesky matrix and is the precision matrix.
Let . Then the random vector can be replaced by , where is
a vector of standard normal variables. Then, the upper limit of the integration becomes , which
can be written as .
The RIS simulator is implemented by drawing a large number of random vector and computing recursively
for . The parameters are estimated using the simulated maximum likelihood (SML) function:
where:
and is the univariate CDF of the standard normal density.
By default, sbinaryRis compute the SML using the Cholesky transformation on , varcov = "invsigma".
The transformation can also be applied to using varcov = "sigma", which is slower than the previous option.
This estimator can take several minutes for large datasets. Thus, by default the inverse matrices and
are approximated using the Leontief expansion.
An object of class "binris", a list with elements:
varcov |
the matrix over which the Chokesly factorization is applied, |
model |
type of model that was fitted, |
Qneg |
matrix Q used, |
approximation |
a logical value indicating whether approximation was used to compute the inverse matrix, |
pw |
the powers for the approximation, |
call |
the matched call, |
X |
the X matrix, which contains also WX if the second part of the |
y |
the dependent variable, |
listw |
the spatial weight matrix, |
formula |
the formula, |
R |
number of draws, |
mf |
model frame, |
data |
the data, |
contrastsX |
the contrasts used in the first part of the formula, |
contrastsD |
the contrasts used in the second part of the formula, |
Xlevels |
a record of the levels of the factors used in fitting. |
Mauricio Sarrias and Gianfranco Piras.
Beron, K. J., & Vijverberg, W. P. (2004). Probit in a spatial context: a Monte Carlo analysis. In Advances in spatial econometrics: methodology, tools and applications (pp. 169-195). Berlin, Heidelberg: Springer Berlin Heidelberg.
Fleming, M. M. (2004). Techniques for estimating spatially dependent discrete choice models. In Advances in spatial econometrics (pp. 145-168). Springer, Berlin, Heidelberg.
Pace, R. K., & LeSage, J. P. (2016). Fast simulated maximum likelihood estimation of the spatial probit model capable of handling large samples. In Spatial Econometrics: Qualitative and Limited Dependent Variables (pp. 3-34). Emerald Group Publishing Limited.
Piras, G., & Sarrias, M. (2023). One or Two-Step? Evaluating GMM Efficiency for Spatial Binary Probit Models. Journal of choice modelling, 48, 100432.
data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # Estimate SAR probit model using RIS simulator using Sigma_v^{-1} ris_sar <- sbinaryRis(CRIMED ~ INC + HOVAL, data = COL.OLD, R = 50, listw = spdep::nb2listw(COL.nb, style = "W"), print.level = 2) summary(ris_sar) # Estimate SAR probit model using RIS simulator using Sigma_v ris_sar_2 <- sbinaryRis(CRIMED ~ INC + HOVAL, data = COL.OLD, R = 50, listw = spdep::nb2listw(COL.nb, style = "W"), varcov = "sigma", print.level = 2) summary(ris_sar_2) # Estimate SDM probit model using RIS simulator ris_sdm <- sbinaryRis(CRIMED ~ INC + HOVAL | INC + HOVAL, data = COL.OLD, R = 50, listw = spdep::nb2listw(COL.nb, style = "W"), print.level = 2) summary(ris_sdm) # Estimate SEM probit model using RIS simulator ris_sem <- sbinaryRis(CRIMED ~ INC + HOVAL | INC, data = COL.OLD, R = 50, listw = spdep::nb2listw(COL.nb, style = "W"), model = "SEM") summary(ris_sem)data(oldcol, package = "spdep") # Create dependent (dummy) variable COL.OLD$CRIMED <- as.numeric(COL.OLD$CRIME > 35) # Estimate SAR probit model using RIS simulator using Sigma_v^{-1} ris_sar <- sbinaryRis(CRIMED ~ INC + HOVAL, data = COL.OLD, R = 50, listw = spdep::nb2listw(COL.nb, style = "W"), print.level = 2) summary(ris_sar) # Estimate SAR probit model using RIS simulator using Sigma_v ris_sar_2 <- sbinaryRis(CRIMED ~ INC + HOVAL, data = COL.OLD, R = 50, listw = spdep::nb2listw(COL.nb, style = "W"), varcov = "sigma", print.level = 2) summary(ris_sar_2) # Estimate SDM probit model using RIS simulator ris_sdm <- sbinaryRis(CRIMED ~ INC + HOVAL | INC + HOVAL, data = COL.OLD, R = 50, listw = spdep::nb2listw(COL.nb, style = "W"), print.level = 2) summary(ris_sdm) # Estimate SEM probit model using RIS simulator ris_sem <- sbinaryRis(CRIMED ~ INC + HOVAL | INC, data = COL.OLD, R = 50, listw = spdep::nb2listw(COL.nb, style = "W"), model = "SEM") summary(ris_sem)