Description Usage Arguments Details Value Examples
Calculates a posterior estimate of the CDF based on the output from gold
for an individual
or vector of values.
1 |
x |
A single value or vector of values at which to calculate the CDF. 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 |
burnin |
The desired burnin to discard from the results. If no values is entered, the default is half the number of iterations. |
The function gold_cdf
returns the posterior mean CDF. The CDF is calculated based on the following equation at each iteration:
F(x) =
\int_{0}^{x} exp(g(y)) / (\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. These weights are also used in the estimate of the integral in the numerator.
gold_cdf
returns a list of the CDF results from gold
.
|
A vector of the posterior mean CDF values at each value in |
|
A matrix with 2 columns and rows equaling the length of |
|
A matrix containing the CDF values for each |
|
A vector containing the values at which to estimate the CDF. |
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=.8, MH_N=20000)
#Calculate cdf at a variety of values
cdf_beta <- gold_cdf(x = c(.01, .25, .6, .9), gold_beta)
#Examine the CDF at 'x'
cdf_beta$cdf
#Examine the credibal intervals of the CDF at 'x'
cdf_beta$cri
## --------------------------------------------------------------------------------
## Normal Distribution
## --------------------------------------------------------------------------------
# First run 'gold' on data sampled from a Normal(0,1) distribution with 50 data points.
y <- rnorm(50, 0, 1)
gold_norm <- gold(y, s1 = 1, c1 = 0.8, s2 = 1, c2 = 0.5, MH_N=20000)
cdf_norm <- gold_cdf(x=c(-2, -1, 0, .8, 1.8), gold_norm)
#Examine the CDF at 'x'
cdf_norm$cdf
#Examine the credibal intervals of the CDF at 'x'
cdf_norm$cri
Histogram of distribution of the CDF density estimate at 0.8
hist(cdf_norm$mat[, 4])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.