marginal.effects {spatialprobit} | R Documentation |
Marginal effects for spatial probit and Tobit models (SAR probit, SAR Tobit)
Description
Estimate marginal effects (average direct, indirect and total impacts) for the SAR probit and SAR Tobit model.
Usage
## S3 method for class 'sarprobit'
marginal.effects(object, o = 100, ...)
## S3 method for class 'sartobit'
marginal.effects(object, o = 100, ...)
## S3 method for class 'sarprobit'
impacts(obj, file=NULL,
digits = max(3, getOption("digits")-3), ...)
## S3 method for class 'sartobit'
impacts(obj, file=NULL,
digits = max(3, getOption("digits")-3), ...)
Arguments
object |
Estimated model of class |
obj |
Estimated model of class |
o |
maximum value for the power |
digits |
number of digits for printing |
file |
Output to file or console |
... |
additional parameters |
Details
impacts()
will extract and print the marginal effects from a fitted model,
while marginal.effects(x)
will estimate the marginal effects anew for a fitted
model.
In spatial models, a change in some explanatory variable for observation
will not only affect the observations
directly (direct impact),
but also affect neighboring observations
(indirect impact).
These impacts potentially also include feedback loops from observation
to observation
and back to
.
(see LeSage (2009), section 2.7 for interpreting parameter estimates in spatial models).
For the -th non-constant explanatory variable,
let
be the
matrix
that captures the impacts from observation
to
.
The direct impact of a change in on its own observation
can be written as
and the indirect impact from observation to observation
as
.
LeSage(2009) proposed summary measures for direct, indirect and total effects,
e.g. averaged direct impacts across all observations.
See LeSage(2009), section 5.6.2., p.149/150 for marginal effects estimation in general spatial models
and section 10.1.6, p.293 for marginal effects in SAR probit models.
We implement these three summary measures:
average direct impacts:
average total impacts:
average indirect impacts:
The average direct impact is the average of the diagonal elements, the average total impacts is the mean of the row (column) sums.
For the average direct impacts ,
there are efficient approaches available, see LeSage (2009), chapter 4, pp.114/115.
The computation of the average total effects and hence
also the average indirect effects
are more subtle,
as
is a dense
matrix.
In the LeSage Spatial Econometrics Toolbox for MATLAB (March 2010),
the implementation in
sarp_g
computes the matrix inverse of
which all the negative consequences for large n.
We implemented
via a QR decomposition of
(already available from a previous step) and solving a linear equation,
which is less costly and will work better for large
.
SAR probit model
Specifically, for the SAR probit model the matrix of marginal effects is
SAR Tobit model
Specifically, for the SAR Tobit model the matrix of marginal effects is
Value
This function returns a list with 6 elements: 'direct' for direct effects, 'indirect' for indirect effects, 'total' for total effects, and 'summary_direct', 'summary_indirect', 'summary_total' for the summary of direct, indirect and total effects.
Warning
1. Although the direct impacts can be efficiently estimated, the computation
of the indirect effects require the inversion of a matrix
and will break down for large
.
2. is determined with simulation,
so different calls to this method will produce different estimates.
Author(s)
Stefan Wilhelm <wilhelm@financial.com>
References
LeSage, J. and Pace, R. K. (2009), Introduction to Spatial Econometrics, CRC Press
See Also
Examples
require(spatialprobit)
# number of observations
n <- 100
# true parameters
beta <- c(0, 1, -1)
rho <- 0.75
# design matrix with two standard normal variates as "covariates"
X <- cbind(intercept=1, x=rnorm(n), y=rnorm(n))
# sparse identity matrix
I_n <- sparseMatrix(i=1:n, j=1:n, x=1)
# number of nearest neighbors in spatial weight matrix W
m <- 6
# spatial weight matrix with m=6 nearest neighbors
# W must not have non-zeros in the main diagonal!
W <- kNearestNeighbors(x = rnorm(n), y = rnorm(n), k = m)
# innovations
eps <- rnorm(n=n, mean=0, sd=1)
# generate data from model
S <- I_n - rho * W
z <- solve(qr(S), X %*% beta + eps)
y <- as.vector(z >= 0) # 0 or 1, FALSE or TRUE
# estimate SAR probit model
set.seed(12345)
sarprobit.fit1 <- sar_probit_mcmc(y, X, W, ndraw=500, burn.in=100,
thinning=1, prior=NULL, computeMarginalEffects=TRUE)
summary(sarprobit.fit1)
# print impacts
impacts(sarprobit.fit1)
################################################################################
#
# Example from LeSage/Pace (2009), section 10.3.1, p. 302-304
#
################################################################################
# Value of "a" is not stated in book!
# Assuming a=-1 which gives approx. 50% censoring
library(spatialprobit)
a <- -1 # control degree of censored observation
n <- 1000
rho <- 0.7
beta <- c(0, 2)
sige <- 0.5
I_n <- sparseMatrix(i=1:n, j=1:n, x=1)
x <- runif(n, a, 1)
X <- cbind(1, x)
eps <- rnorm(n, sd=sqrt(sige))
param <- c(beta, sige, rho)
# random locational coordinates and 6 nearest neighbors
lat <- rnorm(n)
long <- rnorm(n)
W <- kNearestNeighbors(lat, long, k=6)
y <- as.double(solve(I_n - rho * W) %*% (X %*% beta + eps))
table(y > 0)
# set negative values to zero to reflect sample truncation
ind <- which(y <=0)
y[ind] <- 0
# Fit SAR Tobit (with approx. 50% censored observations)
fit_sartobit <- sartobit(y ~ x, W, ndraw=1000, burn.in=200,
computeMarginalEffects=TRUE, showProgress=TRUE)
# print impacts
impacts(fit_sartobit)