Learn R Programming

bayesQR (version 2.0)

QRb.AL: Bayesian quantile regression with binary dependent variable using adaptive LASSO

Description

QRb.AL implements a Bayesian method for estimating binary quantile regression parameters with adaptive LASSO penalty (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.AL.

Usage

QRb.AL(Data, Prior, Mcmc)

Arguments

Data
list(y, X, p)
Prior
list(lambdasq_shape, lambdasq_scale)
Mcmc
list(R, keep)

Value

  • A list containing:
  • methoda string containing 'QRb.AL'
  • pthe quantile that was estimated
  • betadrawR/keep x nvar(X) matrix of beta draws

Details

ll{ Model: y* = Xbeta + e e ~ ALD(location=0, scale=1, quantile=p) y = 1, if (y* > 0); y = 0, otherwise Priors: beta ~ ALD(location=0, scale=1/lambda, p=0.5) lambda^2 ~ Gamma(shape=lambdasq_shape, scale=lambdasq_scale) } 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)
  • lambdasq_shape: shape parameter for the gamma prior on lambdasq (default: 0.01)
  • lambdasq_scale: scale parameter for the gamma prior on lambdasq (default: 0.01)
  • R: number of MCMC draws
  • keep: thinning parameter, i.e. keep every keepth draw (default: 1)

References

The algorithm is a slightly modified implementation of: Al-Hamzawi, R., Benoit, D.F. and Yu, K. (2012). Binary quantile regression with adaptive lasso: A Bayesian approach, working paper.

Examples

Run this code
## set seed value
set.seed(66)

## set dimension of problem
n <- 200
k <- 4

## set parameter values
beta <- c(-1,-.5,0,2.5)

## simulate Laplace distributed data
X <- cbind(1,matrix(runif(n=n*(k-1)),nrow=n))
y <- X%*%beta
Vo1 <- rgamma(n=n,shape=1,scale=2)
ystar <- y + sqrt(Vo1)*rnorm(n=n)
y <- ifelse(ystar>0,1,0)
table(y)

## prepare the inputs
Data <- list(y=y,X=X,p=.5)
Prior <- list(lambda_shape=.01,lambda_scale=.01)
Mcmc <- list(R=5000,keep=1)

## estimate the parameters
out <- QRb.AL(Data=Data,Prior=Prior,Mcmc=Mcmc)

## calculate posterior median and credible intervals
apply(out$betadraw,FUN=quantile,MARGIN=2,prob=c(.025,.5,.975))

Run the code above in your browser using DataLab