Description Usage Arguments Details Value Author(s) Examples
View source: R/model_exponential_gamma.R
Runs a bayesian estimation of non-zero positive variable using exponential distribution as likelihood and gamma distribution as conjugate prior. Posterior distribution is gamma distribution. Prior used is Gamma(shape, rate)
1 | model_exponential_gamma(shape, rate, n_sample, sum_sample, n_post = 1e+05)
|
shape |
Parameter for prior distribution representing the number of samples from before - 1 |
rate |
Parameter for prior distribution representing the sum of samples from before |
n_sample |
Total number of cases in your data |
sum_sample |
Sum of variable for each successful case. |
n_post |
Size of sample from posterior distribution |
Mean of prior distribution is shape/rate. Remember Exp(lambda) has mean of 1/lambda.
Vector of samples from posterior distribution representing mean of exponential distribution (1/lambda).
Posterior distribution is Gamma(shape + n_sample, rate + sum_sample)
Elio Bartoš
1 2 3 4 5 6 7 8 | post = model_exponential_gamma(0, 0, 20, 100) # No prior information, pror is uniform
post2 = model_exponential_gamma(5, 95, 3, 50) # Prior succes rate is around 5% with estimation strenght as it was estimated on a sample of 100
mean(post)
quantile(post, probs = c(0.05, 0.95)) # 90% highest density posterior interval
mean(post2)
quantile(post2, probs = c(0.05, 0.95))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.