Description Usage Arguments Details Value Examples
Calculates a posterior estimate of the CDF 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 CDF. 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_cdf
returns the posterior mean CDF. The CDF is calculated based on the following equation at each iteration:
F(x) =
(π_1) / (γ_1) * x , 0 ≤ x < γ_1
π_1 + (π_2) / (γ_2-γ_1) * (x-γ_1) , γ_1 ≤ x < γ_2
π_1 + π_2 + (π_3) / (γ_3-γ_2) * (x-γ_2) , γ_2 ≤ x < γ_3
... , ... ≤ x < ...
∑_{i=1}^{k-1} π_i + (π_k) / (γ_k-γ_{k-1}) * (x-γ_{k-1}) , γ_{k-1} ≤ x < γ_k
∑_{i=1}^{k}π_i + (π_{k+1}) / (1-γ_k) * (x-γ_k) , γ_k ≤ x < 1
where γ_1 < γ_2 < ... < γ_k is in (0,1) and π_1 + π_2 + ... + π_{k+1} = 1
duos_cdf
returns a list of the CDF results from duos
.
|
A vector of the posterior mean CDF at each value in |
|
A matrix with 2 columns and a row for each value in |
|
A matrix containing the CDF values for |
|
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 34 35 36 37 | ## --------------------------------------------------------------------------------
## Beta Distribution
## --------------------------------------------------------------------------------
# First run 'duos' on data sampled from a Beta(2,5) distribution with 100 data points.
y <- rbeta(100, 2, 5)
duos_beta <- duos(y = y, k = 5, MH_N = 20000)
# Estimate the CDF at a vector of values
cdf_beta <- duos_cdf(x = c(.01, .25, .6, .9), duos_beta)
# Examine the CDF at each value in 'x'
cdf_beta$cdf
# Examine the credible intervals of the CDF at 'x'
cdf_beta$cri
## --------------------------------------------------------------------------------
## Normal Distribution
## --------------------------------------------------------------------------------
# First run 'duos' on data sampled from a Normal(0,1) distribution with 50 data points.
y <- rnorm(50, 0, 1)
duos_norm <- duos(y = y, k = 4, MH_N = 20000, scale_l = sd(y), scale_u = sd(y))
# Estimate the CDF at a vector of values
cdf_norm <- duos_cdf(x = c(-2, -1, 0, .8, 1.8), duos_norm)
# Examine the CDF at 'x'
cdf_norm$cdf
# Examine the credible intervals of the CDF at 'x'
cdf_norm$cri
# Plot a histogram of distribution of the posterior draws for the CDF estimate at 0.8
hist(cdf_norm$mat[, 4])
# Find probability of being greater than 2
1 - duos_cdf(2, duos_norm)$cdf
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.