MCMCquantreg | 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
. 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,
data = NULL,
tau = 0.5,
burnin = 1000,
mcmc = 10000,
thin = 1,
verbose = 0,
seed = sample(1:1e+06, 1),
beta.start = NA,
b0 = 0,
B0 = 0,
...
)
formula |
Model formula. |
data |
Data frame. |
tau |
The quantile of interest. Must be between 0 and 1. The default value of 0.5 corresponds to median regression. |
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 |
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 default value for this argument
is a random integer between 1 and 1,000,000. This default value ensures that
if the function is used again with a different value of |
beta.start |
The starting values for |
b0 |
The prior mean of
|
B0 |
The prior precision of |
... |
further arguments to be passed |
MCMCquantreg
simulates from the posterior distribution using Gibbs
sampling with data augmentation (see
http://people.brunel.ac.uk/~mastkky/). \beta
are drawn
from a multivariate normal distribution. 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.
We assume the model
Q_{\tau}(y_i|x_i) = x_i'\beta
where Q_{\tau}(y_i|x_i)
denotes the
conditional \tau
th quantile of y_i
given
x_i
, and \beta=\beta(\tau)
are the
regression parameters possibly dependent on \tau
. The likelihood
is formed based on assuming independent Asymmetric Laplace distributions on
the y_i
with skewness parameter \tau
and location
parameters x_i'\beta
. This assumption ensures that the
likelihood function is maximised by the \tau
th conditional
quantile of the response variable. We assume standard, semi-conjugate
priors on \beta
:
\beta \sim \mathcal{N}(b_0,B_0^{-1})
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.s3-website-us-east-1.amazonaws.com/.
Craig Reed and Keming Yu. 2009. “An Efficient 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. 2006. “Output Analysis and Diagnostics for MCMC (CODA)”, R News. 6(1): 7-11. https://CRAN.R-project.org/doc/Rnews/Rnews_2006-1.pdf.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.