## 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