MCMCquantreg {MCMCpack} | R Documentation |
This function fits quantile regression models under Bayesian inference. The function samples from the posterior distribution using Gibbs sampling with data augmentation. A multivariate normal prior is assumed for beta and an inverse Gamma prior is assumed for sigma. The user supplies the prior parameters. A sample of the posterior distribution is returned as an mcmc object, which can then be analysed by functions in the coda package.
MCMCquantreg(formula, tau=0.5, data = NULL, burnin = 1000, mcmc = 10000, thin = 1, verbose = 0, seed = NA, beta.start = NA, b0 = 0, B0 = 0, c0 = 0.001, d0 = 0.001, ...)
formula |
Model formula. |
tau |
The quantile of interest. Must be between 0 and 1. The default value of 0.5 corresponds to median regression. |
data |
Data frame. |
burnin |
The number of burn-in iterations for the sampler. |
mcmc |
The number of MCMC iterations after burnin. |
thin |
The thinning interval used in the simulation. The number of MCMC iterations must be divisible by this value. |
verbose |
A switch which determines whether or not the progress of
the sampler is printed to the screen. If verbose is greater
than 0 the iteration number and the most recently sampled values of
beta and sigma are printed to
the screen every verbose th iteration. |
seed |
The seed for the random number generator. If NA, the Mersenne
Twister generator is used with default seed 12345; if an integer is
passed it is used to seed the Mersenne twister. The user can also
pass a list of length two to use the L'Ecuyer random number generator,
which is suitable for parallel computation. The first element of the
list is the L'Ecuyer seed, which is a vector of length six or NA (if NA
a default seed of rep(12345,6) is used). The second element of
list is a positive substream number. See the MCMCpack
specification for more details. |
beta.start |
The starting values for beta. This can either be a scalar or a column vector with dimension equal to the dimension of beta. The default value of NA will use the OLS estimate beta^hat with sigma^hat*Phi^(-1)(tau) added on to the first element of beta^hat as the starting value. ((sigma^hat)^2 denotes the usual unbiased estimator of sigma^2 under ordinary mean regression and Phi^(-1)(tau) denotes the inverse of the cumulative density function of the standard normal distribution.) Note that the default value assume that an intercept is included in the model. If a scalar is given, that value will serve as the starting value for all beta. |
b0 |
The prior mean of beta. This can either be a scalar or a column vector with dimension equal to the dimension of beta. If this takes a scalar value, then that value will serve as the prior mean for all beta. |
B0 |
The prior precision of beta. This can either be a scalar or a square matrix with dimensions equal to the number of betas. If this takes a scalar value, then that value times an identity matrix serves as the prior precision of beta. Default value of 0 is equivalent to an improper uniform prior for beta. |
c0 |
c0/2 is the shape parameter for the inverse Gamma prior on sigma. |
d0 |
d0/2 is the scale parameter for the inverse Gamma prior on sigma. |
... |
further arguments to be passed |
MCMCquantreg
simulates from the posterior distribution using
a partially collapsed Gibbs sampler with data augmentation (see http://people.brunel.ac.uk/~mastkky/).
This involves a multivariate Normal draw for beta, and an
inverse Gamma draw for sigma.
The augmented data are drawn conditionally from the inverse Gaussian distribution. The simulation
is carried out in compiled C++ code to maximise efficiency. Please consult
the coda documentation for a comprehensive list of functions that can be
used to analyse the posterior sample.
The model takes the following form:
y_i = x_i'beta + epsilon_i
The errors are assumed to have an Asymmetric Laplace distribution with tauth quantile equal to zero and shape parameter equal to sigma:
epsilon_i(tau) ~ AL(0, sigma, tau),
where beta and sigma depend on tau. We assume standard, semi-conjugate priors:
beta ~ N(b0,B0^(-1)),
and
sigma^(-1) ~ Gamma(c0/2, d0/2),
where beta and sigma^(-1) are assumed a priori independent of each other and the parameters associated with the other quantiles. Only starting values for beta are allowed for this sampler.
An mcmc object that contains the posterior sample. This object can be summarised by functions provided by the coda package.
Craig Reed
Daniel Pemstein, Kevin M. Quinn, and Andrew D. Martin. 2007. Scythe Statistical Library 1.2. http://scythe.wustl.edu.
Craig Reed and Keming Yu. 2009. "A Partially Collapsed Gibbs Sampler for Bayesian Quantile Regression." Technical Report.
Keming Yu and Jin Zhang. 2005. "A Three Parameter Asymmetric Laplace Distribution and it's extensions." Communications in Statistics - Theory and Methods, 34, 1867-1879.
Martyn Plummer, Nicky Best, Kate Cowles, and Karen Vines. 2002. Output Analysis and Diagnostics for MCMC (CODA). http://www-fis.iarc.fr/coda/.
MCMCregress
, plot.mcmc
,
summary.mcmc
, lm
, rq
## Not run: x<-rep(1:10,5) y<-rnorm(50,mean=x) posterior_50 <- MCMCquantreg(y~x) posterior_95 <- MCMCquantreg(y~x, tau=0.95, verbose=10000, mcmc=50000, thin=10, seed=2) plot(posterior_50) plot(posterior_95) raftery.diag(posterior_50) autocorr.plot(posterior_95) summary(posterior_50) summary(posterior_95) ## End(Not run)