Learn R Programming

spatialprobit (version 0.9-1)

semprobit: Bayesian estimation of the SEM probit model

Description

Bayesian estimation of the probit model with spatial errors (SEM probit model).

Usage

semprobit(formula, W, data, subset, ...)

sem_probit_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,
  nu = 0, d0 = 0, lflag = 0), 
  start = list(rho = 0.75, beta = rep(0, ncol(X)), sige = 1),
  m=10, showProgress=FALSE)

Arguments

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 $\rho \sim Beta(a1,a2)$ and $\beta \sim N(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.
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 e
subset
an optional vector specifying a subset of observations to be used in the fitting process.
...
additional arguments to be passed

Value

  • Returns a structure of class semprobit:
  • betaposterior mean of bhat based on draws
  • rhoposterior mean of rho based on draws
  • bdrawbeta draws (ndraw-nomit x nvar)
  • pdrawrho draws (ndraw-nomit x 1)
  • sdrawsige draws (ndraw-nomit x 1)
  • totala matrix (ndraw,nvars-1) total x-impacts
  • directa matrix (ndraw,nvars-1) direct x-impacts
  • indirecta matrix (ndraw,nvars-1) indirect x-impacts
  • rdrawr 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
  • yy-vector from input (nobs x 1)
  • zip# of zero y-values
  • a1a1 parameter for beta prior on rho from input, or default value
  • a2a2 parameter for beta prior on rho from input, or default value
  • timetotal time taken
  • rmax1/max eigenvalue of W (or rmax if input)
  • rmin1/min eigenvalue of W (or rmin if input)
  • tflag'plevel' (default) for printing p-levels; 'tstat' for printing bogus t-statistics
  • lflaglflag from input
  • cflag1 for intercept term, 0 for no intercept term
  • lndeta matrix containing log-determinant information (for use in later function calls to save time)

Details

Bayesian estimates of the probit model with spatial errors (SEM probit model) $$z = X \beta + u, \ u = \rho W u + \epsilon, \epsilon \sim N(0, \sigma^2_{\epsilon} I_n)$$ which leads to the data-generating process $$z = X \beta + (I_n - \rho W)^{-1} \epsilon$$ where y is a binary 0,1 $(n \times 1)$ vector of observations for $z < 0$ and $z \ge 0$. $\beta$ is a $(k \times 1)$ vector of parameters associated with the $(n \times k)$ data matrix X. The prior distributions are $\beta \sim N(c,T)$, $\sigma^2_{\epsilon} \sim IG(a1, a2)$, and $\rho \sim Uni(rmin,rmax)$ or $\rho \sim Beta(a1,a2)$.

References

LeSage, J. and Pace, R. K. (2009), Introduction to Spatial Econometrics, CRC Press, chapter 10

See Also

sar_lndet for computing log-determinants

Examples

Run this code
library(Matrix)
# number of observations
n <- 200

# true parameters
beta <- c(0, 1, -1)
sige <- 2
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 <- sparseMatrix(i=rep(1:n, each=m), 
  j=replicate(n, sample(x=1:n, size=m, replace=FALSE)), x=1/m, dims=c(n, n))

# innovations
eps <- 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 model
semprobit.fit1 <- semprobit(y ~ X - 1, W, ndraw=500, burn.in=100, 
  thinning=1, prior=NULL)
summary(semprobit.fit1)

Run the code above in your browser using DataLab