Learn R Programming

bayesQR (version 1.2)

QRb: Bayesian quantile regression with binary dependent variable

Description

QRb implements a Bayesian method for estimating binary quantile regression parameters. This method uses the asymmetric Laplace distribution for this goal (see references). To improve the speed of the routine, the Markov Chain Monte Carlo (MCMC) part of the algorithm is programmed in FORTRAN and is called from within the R function QRb.

Usage

QRb(Data, Prior, Mcmc)

Arguments

Data
list(y, X, p)
Prior
list(betabar, A)
Mcmc
list(R, keep, step)

Value

  • A list containing:
  • betadrawR x nvar(X) array of beta draws
  • loglikeR vector of evaluations of the loglikelihood
  • rejrateRejection rate of the MH proposals for beta

Details

ll{ Model: y* = Xbeta + e e ~ ALD(location=0, scale=1, quantile=p) y = 1, if (y* > 0); y = 0, otherwise Priors: beta ~ N(betabar, A^(-1)) } List arguments contain:
  • X: n x nvar(X) matrix of predictors (first column should be a vector of ones if intercept is desired)
  • y: n x 1 vector of zero-one observations (dependent variable)
  • p: quantile of interest (should be between 0 and 1)
  • betabar: nvar(X) x 1 vector of prior means (default: 0)
  • A: nvar(X) x nvar(X) prior precision matrix (inverse variancecovariance matrix) (default: .01*diag(ncol(X)))
  • R: number of MCMC draws
  • keep: thinning parameter, i.e. keep every keepth draw (default: 1)
  • step: MH step for beta, tune to getrejratebetween 0.3 and 0.5

References

The algorithm is an implementation of: Benoit, D.F and Van den Poel, D. (2011). Binary quantile regression: A Bayesian approach based on the asymmetric Laplace distribution, Journal of Applied Econometrics, (in press).

Examples

Run this code
## Simulate data from binary regression model
set.seed(66)
n = 200
X = as.matrix(runif(n=n, min=0, max=10))
ystar = 1.5*X + rnorm(n=n, mean=0, sd=2*X)
y <- as.numeric(ystar>0)

## Set input arguments for QRb, with quantile of interest p=0.75
Data = list(y=y, X=X, p=.75)
Prior = list(betabar=c(rep(0,ncol(X))),A=.01*diag(ncol(X)))
Mcmc = list(R=100000, keep=10, step=.2)

out <- QRb(Data=Data, Prior=Prior, Mcmc=Mcmc)

# Check rejection rate of MH algorithm
out$rejrate

# Traceplot of betadraws
matplot(out$betadraw,typ="l")

# Posterior distribution of betadraws
hist(out$betadraw,breaks=100)

# Posterior Bayes estimates and credible intervals
quantile(out$betadraw[,1],c(.025,.5,.975))

Run the code above in your browser using DataLab