prior: A list of prior settings for orrhoBeta(a1,a2)
and betaN(c,T). Defaults to diffuse prior for beta.
start: list of start values
m: Number of burn-in samples in innermost Gibbs sampler. Defaults to 10.
showProgress: Flag if progress bar should be shown. Defaults to FALSE.
univariateConditionals: Switch whether to draw from univariate or multivariate truncated normals. See notes. Defaults to TRUE.
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 semprobit is called.
subset: an optional vector specifying a subset of observations to be used in the fitting process.
...: additional arguments to be passed
Details
Bayesian estimates of the probit model with spatial errors (SEM probit model)
where y is a binary 0,1 (nx1) vector of observations for z<0 and z>=0. beta is a (kx1)
vector of parameters associated with the (nxk) data matrix X.
The prior distributions are betaN(c,T), σϵ2∼IG(a1,a2), and rhoUni(rmin,rmax)
or orrhoBeta(a1,a2).
Returns
Returns a structure of class semprobit:
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)
References
LeSage, J. and Pace, R. K. (2009), Introduction to Spatial Econometrics, CRC Press, chapter 10
Author(s)
adapted to and optimized for R by Stefan Wilhelm wilhelm@financial.com based on code from James P. LeSage
See Also
sar_lndet for computing log-determinants
Examples
library(Matrix)# number of observationsn <-200# true parametersbeta <- c(0,1,-1)sige <-2rho <-0.75# design matrix with two standard normal variates as "covariates"X <- cbind(intercept=1, x=rnorm(n), y=rnorm(n))# sparse identity matrixI_n <- sparseMatrix(i=1:n, j=1:n, x=1)# number of nearest neighbors in spatial weight matrix Wm <-6# spatial weight matrix with m=6 nearest neighbors# W must not have non-zeros in the main diagonal!i <- rep(1:n, each=m)j <- rep(NA, n * m)for(k in1:n){ j[(((k-1)*m)+1):(k*m)]<- sample(x=(1:n)[-k], size=m, replace=FALSE)}W <- sparseMatrix(i, j, x=1/m, dims=c(n, n))# innovationseps <- sqrt(sige)*rnorm(n=n, mean=0, sd=1)# generate data from model S <- I_n - rho * W
z <- X %*% beta + solve(qr(S), eps)y <- as.double(z >=0)# 0 or 1, FALSE or TRUE# estimate SEM probit modelsemprobit.fit1 <- semprobit(y ~ X -1, W, ndraw=500, burn.in=100, thinning=1, prior=NULL)summary(semprobit.fit1)