Description Usage Arguments Details Value Examples
Calculates a posterior estimate of the PDF based on the output from duos
for an individual
or vector of values.
1 |
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 |
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). |
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
duos_pdf
returns a list of the PDF results from duos
.
|
A vector of the posterior mean PDF at each value in |
|
A matrix with 2 columns and a row for each value in |
|
A matrix containing the PDF values for |
|
A vector containing the values at which to estimate the PDF. |
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])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.