duos_pdf: Estimate of PDF from 'duos'

Description Usage Arguments Details Value Examples

Description

Calculates a posterior estimate of the PDF based on the output from duos for an individual or vector of values.

Usage

1
duos_pdf(x, duos_output, burnin = NA, scale = FALSE)

Arguments

x

A single value or vector of values at which to calculate the PDF. These values should be entered on the scale of the data (i.e. values can fall outside of 0 and 1 if data does).

duos_output

The list returned by duos containing the density estimate results.

burnin

The desired burnin to discard from the results. If no value is entered, the default is half the number of iterations.

scale

This value TRUE/FALSE indicates whether to return scaled or unscaled results IF the original data does not fall between 0 and 1. The default is FALSE (i.e. returns results on the original data scale).

Details

The function duos_pdf returns the posterior mean PDF. The PDF is calculated based on the following equation at each iteration:

f(x) =

(π_1) / (γ_1) , 0 ≤ x < γ_1

(π_2) / (γ_2-γ_1) , γ_1 ≤ x < γ_2

(π_3) / (γ_3-γ_2) , γ_2 ≤ x < γ_3

... , ... ≤ x < ...

(π_k) / (γ_k-γ_{k-1}) , γ_{k-1} ≤ x < γ_k

(π_{k+1}) / (1-γ_k) , γ_k ≤ x < 1

where γ_1 < γ_2 < ... < γ_k is in (0,1) and π_1 + π_2 + ... + π_{k+1} = 1

Value

duos_pdf returns a list of the PDF results from duos.

pdf

A vector of the posterior mean PDF at each value in x.

cri

A matrix with 2 columns and a row for each value in x. It contains the 95% credible interval for the PDF at each point in x.

mat

A matrix containing the PDF values for x at EACH iteration after the burnin is discarded. There is a column for each value in x.

x

A vector containing the values at which to estimate the PDF.

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
29
30
31
32
33
34
35
36
## --------------------------------------------------------------------------------
## Uniform Distribution
## --------------------------------------------------------------------------------

# First run \code{duos} on data sampled from a Unif(0,1) distribution with 70 data points.
y <- runif(70)
duos_unif <- duos(y = y, k = 4, MH_N = 20000)

# Estimate the PDF at a vector of values
pdf_unif <- duos_pdf(x = c(.1, .5, .65, .98), duos_unif)

# Examine the PDF at \code{x}
pdf_unif$pdf

# Examine the credible intervals of the PDF at \code{x}
pdf_unif$cri

## --------------------------------------------------------------------------------
## Gamma Distribution
## --------------------------------------------------------------------------------

# First run \code{duos} on data sampled from a Gamma(2,2) distribution with 90 data points.
y <- rgamma(90, 2, 2)
duos_gamma <- duos(y = y, MH_N = 20000)

# Estimate the PDF at a vector of values
pdf_gamma <- duos_pdf(x = c(0.4, 1, 2, 3), duos_gamma)

# Examine the PDF at \code{x}
pdf_gamma$pdf

# Examine the credible intervals of the PDF at \code{x}
pdf_gamma$cri

#Plot a histogram of distribution of the posterior draws for the PDF estimate at 1
hist(pdf_gamma$mat[,2])

reykp/BEDr documentation built on May 28, 2019, 8:40 a.m.