model_bernoulli_beta: Run bayesian beta - bernoulli model for estimating proportion...

Description Usage Arguments Value Author(s) Examples

View source: R/model_bernoulli_beta.R

Description

Runs a bayesian estimation of proportion using bernoulli distribution as likelihood and beta distribution as conjugate prior. Posterior distribution is beta distribution. Prior used is Beta(alpha + 1, beta + 1)

Usage

1
model_bernoulli_beta(alpha, beta, success, n_sample, n_post = 1e+05)

Arguments

alpha

Parameter for prior distribution representing the number of success - 1

beta

Parameter for prior distribution representing the number of fails - 1

success

Number of success cases in your data

n_sample

Total number of cases in your data

n_post

Size of sample from posterior distribution

Value

Vector of samples from posterior distribution

Posterior distribution is Beta(alpha + 1 + success, beta + 1 + total - success)

Author(s)

Elio Bartoš

Examples

1
2
3
4
5
6
7
8
post = model_bernoulli_beta(0, 0, 20, 100) # No prior information, pror is uniform
post2 = model_bernoulli_beta(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))

eliobartos/bayeselio documentation built on Feb. 5, 2021, 2:16 p.m.