Learn R Programming

bayesQR (version 2.0)

QRseq: Estimate series of Bayesian quantile regressions with QRc or QRb

Description

QRseq is a wrapper function that automates the estimation of a series of quantile regressions. This function will be used most often to produce the input for the QRplot or QRb.pred functions. It should be noted that, as always, the convergence of each mcmc chain has to be checked by the user. A visual convergence check can be done, for example, with the QRsummary function.

Usage

QRseq(Method, Data, Prior, Mcmc)

Arguments

Method
should be QRc, QRc.AL, QRb or QRb.AL
Data
list(y, X, p)
Prior
See documentation of specific method used (i.e. QRc, QRc.AL, QRb or QRb.AL)
Mcmc
list(R, keep)

Value

  • A list of lists, where each lower level list contains:
  • methodthe method that was used, i.e. QRc, QRc.AL, QRb or QRb.AL
  • pa scalar containing the estimated quantile
  • betadrawR/keep x nvar(X) matrix of beta draws
  • And in case of QRc and QRc.AL also:
  • sigmadrawR/keep vector of sigma draws

Details

For more details about the models, see the specific documentation about QRc, QRc.AL, QRb or QRb.AL.

Examples

Run this code
# Simulate data from heteroskedastic regression
n <- 200
X <- runif(n=n,min=0,max=10)
X <- cbind(1,X)
y <- 1 + 2*X[,2] + rnorm(n=n, mean=0, sd=.6*X[,2])

# Initialize the inputs for QRc
Data = list(y=y, X=X, p=c(.25,.5,.75))
Mcmc = list(R=5000)

# Analyze 5 quantiles using default prior
out = QRseq(Method="QRc", Data=Data, Mcmc=Mcmc)

# Look at the structure of the output
str(out)

Run the code above in your browser using DataLab