qreg.spike {BoomSpikeSlab}  R Documentation 
Quantile Regression
Description
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.
Usage
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,
...)
Arguments
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 
Details
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_i \rho_\tau( y_i  \beta^Tx_i)
Bayesian quantile regression treats
\exp(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_i
, which has a marginal
distribution of
Exp(2 \tau(1\tau)).
The conditional distribution given the residual r = y  x
\beta
is
\frac{1}{\lambda}  r \sim InvGaus( 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
.
Value
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 
Author(s)
Steven L. Scott
References
Parzen and Polson (2011, unpublished)
See Also
lm.spike
SpikeSlabPrior
,
plot.qreg.spike
,
predict.qreg.spike
.
Examples
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))