gold_stat: Statistics from GOLD.

Description Usage Arguments Details Value Examples

Description

Calculates a variety of statistics from the gold density estimate.

Usage

1
gold_stat(stat, gold_output, p = NA, burnin = NA)

Arguments

stat

A value indicating choice of statistic (see details).

gold_output

The list returned by gold containing the density estimate results.

p

A list of quantiles if quantiles are requested (see details).

burnin

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

Details

The form of the density is below:

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.

E[X] = \int_{0}^{1} x * exp(g(x)) / (\int_{0}^{1} exp(g(u)) du)

Var[X] = \int_{0}^{1} (x-x^2) * exp(g(x)) / (\int_{0}^{1} exp(g(u)) du)

The inverse CDF is specified below:

Options for stat

Several of the standard statistics are available through the function gold_stat.

Options for p

Default is NA is quantiles are not the desired statistics. If 'quant' is specified for stat, p is a single value or vector of values between 0 and 1.

Value

gold_stat the statistic of choice and the credible intervals associated with it.

If 'mean' or 'm' is specified for stat:

mean

The E[X] from the details is calulated at each iteration and the mean of these is returned.

cri

The credible intervals for E[X] calculated using the 0.025th and 0.975th quantiles.

If 'var' or 'v' is specified for stat:

variance

The Var[X] from the details is calulated at each iteration and the mean of these is returned.

cri

The credible intervals for Var[X] calculated using the 0.025th and 0.975th quantiles.

If 'quant' or 'q' is specified for stat:

quantiles

The quantils specified in 'p' is calulated using the inverse CDF in the details at each iteration and the mean of these is returned.

cri

The credible intervals for the quantiles calculated using the 0.025th and 0.975th quantiles.

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
## --------------------------------------------------------------------------------
## Beta Distribution
## --------------------------------------------------------------------------------

# First run 'gold' on data sampled from a Beta(2, 6) distribution with 100 data points.
y <- rbeta(100, 2, 6)
gold_beta <- gold(y, s1 = 1, c1 = 1, s2 = 1, c2 = 0.8, MH_N = 20000)

#Get an estimate of the mean and its credible intervals
gold_stat(gold_beta, stat="mean")

#Get an estimate of the variance and its credible intervals
gold_stat(gold_beta, stat="var")

## --------------------------------------------------------------------------------
## 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 = 1, s2 = 0.5, c2 = 0.8, MH_N = 20000)

#Get an estimate of the quantils and their credible intervals
gold_stat(gold_norm, stat="q", p=c(0.1, 0.5, 0.9))

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