quokar (version 0.1.0)

frame_bayes: Mean probability of posterior distribution and Kullback-Leibler divergence for observations in Bayesian quantile regression model

Description

This function give the dataframe to plot the mean probability of posterior and Kullback-leibler divergence of quantile regression model with asymmetric laplace distribution based on bayes estimation procedure.

Usage

frame_bayes(y, x, tau, M, burn, method = c("bayes.prob", "bayes.kl"))

Arguments

y

vector, dependent variable in quantile regression

x

matrix, design matrix for quantile regression. For quantile regression model with intercept, the firt column of x is 1.

tau

sigular or vector, quantiles

M

the iteration frequancy for MCMC used in Baysian estimation

burn

burned MCMC draw

method

the diagnostic method for outlier detection

Value

Mean probability or Kullback-Leibler divergence for observations in Bayesian quantile regression model

Examples

Run this code
# NOT RUN {
library(ggplot2)
ais_female <- subset(ais, Sex == 1)
y <- ais_female$BMI
x <- matrix(ais_female$LBM, 1)
tau <- c(0.1, 0.5, 0.9)
case <- rep(1:length(y), length(tau))
prob <- frame_bayes(y, x, tau, M =  5000, burn = 1000,
                 method = 'bayes.prob')
prob_m <- cbind(case, prob)
ggplot(prob_m, aes(x = case, y = value )) +
  geom_point() +
  geom_text(aes(label = case)) +
  facet_wrap(~variable, scale = 'free') +
  xlab("case number") +
  ylab("Mean probability of posterior distribution")
It takes time to run the following code.
kl <- frame_bayes(y, x, tau, M = 50, burn = 10,
                method = 'bayes.kl')
kl_m <- cbind(case, kl)
ggplot(kl_m, aes(x = case, y = value)) +
  geom_point() +
  geom_text(aes(label = case)) +
  facet_wrap(~variable, scale = 'free')+
  xlab('case number') +
  ylab('Kullback-Leibler')
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab