Learn R Programming

bayesQR (version 2.0)

QRplot: Produce quantile plots with QRplot

Description

QRplot is a function that produces quantile plots based on the estimates obtained by the QRseq function. Note that the more quantiles p are estimated with QRseq, the more detailed the quantile plot, produced with QRplot, will be.

Usage

QRplot(QRseq.obj, var, burnin, credint, main, xlab, ylab, xlim)

Arguments

QRseq.obj
an output object of the QRseq function
var
the index of the variable that has to be plotted (default=1)
burnin
the number of burnin draws that should be discared (default=1, meaning all draws are included)
credint
the width of the credible interval (default=c(0.025, 0.975))
main
Main title of the plot (default="")
xlab
Label of the x-axis (default="quantile")
ylab
Label of the y-axis (default="beta")
xlim
Plot region of the x-axis (default=c(0,1))

Value

  • A quantile plot.

Details

QRplot is a function that produces quantile plots based on the estimates obtained by the QRseq function. A quantile plot shows how the value of the regression parameter changes over a range of quantiles together with the associated credible interval. Note that the more quantiles p are estimated with QRseq, the more detailed the quantile plot, produced with QRplot, will be. The minimum number of quantiles to plot is 2.

Examples

Run this code
# Simulate data from heteroskedastic regression
set.seed(66)
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(.05,.25,.5,.75,.95))
Mcmc = list(R=5000)

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

# Create default quantile plot of first variable
QRplot(out, var=1)

# Create quantile plot of second variable with 90% credible interval
QRplot(out, var=2, credint=c(.05, .95),main="This is an example")

Run the code above in your browser using DataLab