Description Usage Arguments Details Value Examples
Calculates a variety of statistics from the gold
density estimate.
1 |
stat |
A value indicating choice of statistic (see details). |
gold_output |
The list returned by |
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. |
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
.
"mean" or "m"
: The E[x] is calculated as in the deatils section for each iteration, and the average of this result is returned as the mean.
"var" or "v"
: The Var[x] is calculated as in the deatils section for each iteration, and the average of this result is returned as the variance.
"quant" or "q"
: Returns the quantiles specified in 'p' using the inverse CDF described in the details section.
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.
gold_stat
the statistic of choice and the credible intervals associated with it.
If 'mean' or 'm' is specified for stat
:
|
The E[X] from the details is calulated at each iteration and the mean of these is returned. |
|
The credible intervals for E[X] calculated using the 0.025th and 0.975th quantiles. |
If 'var' or 'v' is specified for stat
:
|
The Var[X] from the details is calulated at each iteration and the mean of these is returned. |
|
The credible intervals for Var[X] calculated using the 0.025th and 0.975th quantiles. |
If 'quant' or 'q' is specified for stat
:
|
The quantils specified in 'p' is calulated using the inverse CDF in the details at each iteration and the mean of these is returned. |
|
The credible intervals for the quantiles calculated using the 0.025th and 0.975th quantiles. |
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.