# Load the Prostate cancer dataset
data(Prostate)
# Initialize the inputs for QRc.AL
Data <- list(y=as.vector(Prostate[,9]),X=as.matrix(Prostate[,1:8]),p=.95)
Prior <- list(sigma_shape=.01, sigma_scale=.01, etasq_shape=.01, etasq_scale=.01)
Mcmc <- list(R=5000, keep=1)
# Estimate the model parameters
out <- QRc.AL(Data=Data, Prior=Prior, Mcmc=Mcmc)
# Plot the trace plots of the regression parameters
for (i in 1:ncol(Data$X)){
plot(out$betadraw[,i],typ="l")
if (i == 1) par(ask=TRUE)
if (i == ncol(Data$X)) par(ask=FALSE)
}
# Bayes estimates and credible intervals for the regression parameters
burnin <- 2000
parest <- matrix(NA,ncol=3,nrow=ncol(Data$X))
for (i in 1:ncol(Data$X)){
parest[i,] <- round(quantile(out$betadraw[burnin:Mcmc$R,i],c(.025,.5,.975)),5)
}
rownames(parest) <- names(Prostate)[1:8]
colnames(parest) <- c(2.5,50,97.5)
parestRun the code above in your browser using DataLab