qreg.spike {BoomSpikeSlab}  R Documentation 
MCMC algorithm for quasiBayesian quantile models with a 'spikeandslab' prior that places some amount of posterior probability at zero for a subset of the regression coefficients.
qreg.spike(formula, quantile, niter, ping = niter / 10, nthreads = 0, data, subset, prior = NULL, na.action = options("na.action"), contrasts = NULL, drop.unused.levels = TRUE, initial.value = NULL, seed = NULL, ...)
formula 
Formula for the maximal model (with all variables included). 
quantile 
A scalar value between 0 and 1 indicating the quantile of the conditional distribution being modeled. 
niter 
The number of MCMC iterations to run. Be sure to include enough so you can throw away a burnin set. 
ping 
If positive, then print a status update to the console
every 
nthreads 
The number of CPUthreads to use for data augmentation. There is some small overhead to stopping and starting threads. For small data sets, thread overhead will make it faster to run single threaded. For larger data sets multithreading can speed things up substantially. This is all machine dependent, so please experiment. 
data 
An optional data frame, list or environment (or object
coercible by 
subset 
An optional vector specifying a subset of observations to be used in the fitting process. 
prior 
An optional list such as that returned from

na.action 
A function which indicates what should happen when
the data contain 
contrasts 
An optional list. See the 
drop.unused.levels 
A logical value indicating whether factor levels that are unobserved should be dropped from the model. 
initial.value 
Initial value for the MCMC algorithm. Can either
be a numeric vector, a 
seed 
Seed to use for the C++ random number generator. It
should be 
... 
Extra arguments to be passed to 
Just like ordinary regression models the mean of a distribution as a linear function of X, quantile regression models a specific quantile (e.g. the 90th percentile) as a function of X.
Median regression is a special case of quantile regression. Median regression is sometimes cast in terms of minimizing y  X * beta, because the median is the optimal action under L1 loss. Similarly, selecting quantile tau is optimal under the asymmetric loss function
rho_tau(u) = tau * u * I(u > 0) + (1  tau) * u * I(u < 0)
Thus quantile regression (for a specific quantile tau) minimizes
Q(beta) = sum(rho_tau(y  X %*% beta))
Bayesian quantile regression treats
2Q(beta)
as a likelihood function to which a prior distribution p(beta) is applied. For posterior sampling, a data augmentation scheme is used where each observation is associated with a latent variable lambda, which has a marginal distribution of
Exp(2 * tau * (1  tau)).
The conditional distribution given the residual r = y  x * beta is
(1 / lambda)  r ~ InverseGaussian(1 / r, 1.0)
The conditional distribution of beta given complete data (lambda and y) is a weighted least squares regression, where observation i has precision lambda[i] and where observation i is offset by 2 * (tau  1) * lambda[i].
Returns an object of class qreg.spike
, which inherits from
lm.spike
. The returned object is a list with the following
elements
beta 
A 
prior 
The prior used to fit the model. If a 
Steven L. Scott
Parzen and Polson (2011, unpublished)
lm.spike
SpikeSlabPrior
,
plot.qreg.spike
,
predict.qreg.spike
.
n < 50 x < rnorm(n) y < rnorm(n, 4 * x) model < qreg.spike(y ~ x, quantile = .8, niter = 1000, expected.model.size = 100) ## Should get a slope near 4 and an intercept near qnorm(.8). PlotManyTs(model$beta[(1:100),], same.scale = TRUE, truth = c(qnorm(.8), 4))