Bayesian estimation of the SAR Tobit model
Bayesian estimation of the spatial autoregressive Tobit model (SAR Tobit model).
sartobit(formula, W, data, ...) sar_tobit_mcmc(y, X, W, ndraw = 1000, burn.in = 100, thinning = 1, prior=list(a1=1, a2=1, c=rep(0, ncol(X)), T=diag(ncol(X))*1e12, lflag = 0), start = list(rho = 0.75, beta = rep(0, ncol(X)), sige = 1), m=10, computeMarginalEffects=FALSE, showProgress=FALSE)
y
: dependent variables. vector of zeros and ones
X
: design matrix
W
: spatial weight matrix
ndraw
: number of MCMC iterations
burn.in
: number of MCMC burn-in to be discarded
thinning
: MCMC thinning factor, defaults to 1.
prior
: A list of prior settings for
and . Defaults to diffuse prior for beta.
start
: list of start values
m
: Number of burn-in samples in innermost Gibbs sampler. Defaults to 10.
computeMarginalEffects
: Flag if marginal effects are calculated. Defaults to FALSE. We recommend to enable it only when sample size is small.
showProgress
: Flag if progress bar should be shown. Defaults to FALSE.
formula
: an object of class "formula
" (or one that can be coerced to that class): a symbolic description of the model to be fitted.
data
: an optional data frame, list or environment (or object coercible by as.data.frame
to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which sarprobit is called.
...
: additional arguments to be passed
Bayesian estimates of the spatial autoregressive Tobit model (SAR Tobit model)
where is only observed for and censored to 0 otherwise. is a
vector of parameters associated with the data matrix X.
The prior distributions are
and
or .
Returns a structure of class sartobit
:
beta: posterior mean of bhat based on draws
rho: posterior mean of rho based on draws
bdraw: beta draws (ndraw-nomit x nvar)
pdraw: rho draws (ndraw-nomit x 1)
sdraw: sige draws (ndraw-nomit x 1)
total: a matrix (ndraw,nvars-1) total x-impacts
direct: a matrix (ndraw,nvars-1) direct x-impacts
indirect: a matrix (ndraw,nvars-1) indirect x-impacts
rdraw: r draws (ndraw-nomit x 1) (if m,k input)
nobs: # of observations
nvar: # of variables in x-matrix
ndraw: # of draws
nomit: # of initial draws omitted
nsteps: # of samples used by Gibbs sampler for TMVN
y: y-vector from input (nobs x 1)
zip: # of zero y-values
a1: a1 parameter for beta prior on rho from input, or default value
a2: a2 parameter for beta prior on rho from input, or default value
time: total time taken
rmax: 1/max eigenvalue of W (or rmax if input)
rmin: 1/min eigenvalue of W (or rmin if input)
tflag: 'plevel' (default) for printing p-levels; 'tstat' for printing bogus t-statistics
lflag: lflag from input
cflag: 1 for intercept term, 0 for no intercept term
lndet: a matrix containing log-determinant information (for use in later function calls to save time)
LeSage, J. and Pace, R. K. (2009), Introduction to Spatial Econometrics, CRC Press, chapter 10, section 10.3, 299--304
adapted to and optimized for R by Stefan Wilhelm wilhelm@financial.com based on Matlab code from James P. LeSage
sarprobit
, sarorderedprobit
or semprobit
for SAR probit/SAR Ordered Probit/ SEM probit model fitting
# 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) # full information yfull <- y # set negative values to zero to reflect sample truncation ind <- which(y <=0) y[ind] <- 0 # Fit SAR (with complete information) fit_sar <- sartobit(yfull ~ X-1, W,ndraw=1000,burn.in=200, showProgress=FALSE) summary(fit_sar) # Fit SAR Tobit (with approx. 50% censored observations) fit_sartobit <- sartobit(y ~ x,W,ndraw=1000,burn.in=200, showProgress=TRUE) par(mfrow=c(2,2)) for (i in 1:4) { ylim1 <- range(fit_sar$B[,i], fit_sartobit$B[,i]) plot(fit_sar$B[,i], type="l", ylim=ylim1, main=fit_sartobit$names[i], col="red") lines(fit_sartobit$B[,i], col="green") legend("topleft", legend=c("SAR", "SAR Tobit"), col=c("red", "green"), lty=1, bty="n") } # Fit SAR Tobit (with approx. 50% censored observations) fit_sartobit <- sartobit(y ~ x,W,ndraw=1000,burn.in=0, showProgress=TRUE, computeMarginalEffects=TRUE) # Print SAR Tobit marginal effects impacts(fit_sartobit) #--------Marginal Effects-------- # #(a) Direct effects # lower_005 posterior_mean upper_095 #x 1.013 1.092 1.176 # #(b) Indirect effects # lower_005 posterior_mean upper_095 #x 2.583 2.800 3.011 # #(c) Total effects # lower_005 posterior_mean upper_095 #x 3.597 3.892 4.183 #mfx <- marginal.effects(fit_sartobit)