gold_pdf: Estimate of PDF from GOLD

Description Usage Arguments Details Value Examples

Description

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

Usage

1
gold_pdf(x, gold_output, burnin = NA)

Arguments

x

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

gold_output

The list returned by gold containing the density estimate results.

burnin

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

Details

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

f(x) =

exp(g(x)) / (\int_{0}^{1} exp(g(u)) du)

where g(x) is an unknown log density.

Given that g(x) is unknown, the normalizing constant is estimated using a weighted average and the set of unknown paramters that recieve a prior is g(x) at a finite set of points.

Value

gold_pdf returns a list of the PDF results from gold.

pdf

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

cri

A matrix with 2 columns and rows equaling the length of x containing the 95% credible interval for the PDF at each of the points in x.

mat

A matrix containing the PDF values for each x at EACH itertation after the burnin is discarded. The number of columns is the length of 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
## --------------------------------------------------------------------------------
## Beta Distribution
## --------------------------------------------------------------------------------

# First run 'duos' on data sampled from a Beta(2,5) distribution wiht 100 data points.
y <- rbeta(100, 2, 5)
gold_beta <- gold(y, s1 = 1, c1 = 1, s2 = 0.8, c2 = 0.8, MH_N = 20000)
#Calculate pdf at a variety of values
pdf_beta <- gold_pdf(x = c(.01, .25, .6, .9), gold_beta)

#Examine the PDF at 'x'
pdf_beta$pdf

#Examine the credibal intervals of the PDF at 'x'
pdf_beta$cri

## --------------------------------------------------------------------------------
## Normal Distribution
## --------------------------------------------------------------------------------

# First run 'gold' on data sampled from a Normal(0,1) distribution with 200 data points.
y <- rnorm(200, 0, 1)
gold_norm <- gold(y, s1 = 1, c1 = 0.8, s2 = 1, c2 = 0.5, MH_N = 20000)
pdf_norm <- gold_pdf(x = c(-2, -1, 0, 0.8, 1.8), gold_norm)

#Examine the PDF at 'x'
pdf_norm$pdf

#Examine the credibal intervals of the CDF at 'x'
pdf_norm$cri

Histogram of distribution of the PDF density estimate at 0.8
hist(pdf_norm$mat[, 4])

reykp/biRd documentation built on May 17, 2019, 8:16 p.m.