frame_bayes: Mean probability of posterior distribution and...

Description Usage Arguments Value Author(s) Examples

View source: R/frame_bayes.R

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

1
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

Author(s)

Wenjing Wang wenjingwangr@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## 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')

## End(Not run)

quokar documentation built on May 2, 2019, 6:39 a.m.