Skip to contents

p | y ~ Beta(alpha + y, beta + n - y); the marginal likelihood is C(n,y) B(alpha+y, beta+n-y)/B(alpha, beta); the posterior predictive over m trials has mean m p and variance m p (1-p)(m+s)/(s+1) with s the posterior shape total.

Usage

Betabinom(y, n, alpha = 1, beta = 1, m = NULL)

Arguments

y

Observed successes.

n

Trials, y <= n.

alpha, beta

Prior shapes, strictly positive.

m

Future trials for the posterior predictive; NULL uses n.

Value

List with postalpha, postbeta, postmean, postvar, postmode, priormean, logmarglik, predmean, predvar, m.

References

Gelman et al. (2013), Bayesian Data Analysis, 3rd edn, Sects. 2.4-2.5 and Appendix A; standard published form.

Examples

Betabinom(y = 5L, n = 5L)
#> $postalpha
#> [1] 6
#> 
#> $postbeta
#> [1] 1
#> 
#> $postmean
#> [1] 0.8571429
#> 
#> $postvar
#> [1] 0.01530612
#> 
#> $postmode
#> [1] NA
#> 
#> $priormean
#> [1] 0.5
#> 
#> $logmarglik
#> [1] -1.791759
#> 
#> $predmean
#> [1] 4.285714
#> 
#> $predvar
#> [1] 0.9183673
#> 
#> $m
#> [1] 5
#> 
#> $method
#> [1] "Beta-Binomial conjugate updating (Gelman et al. BDA3 Sect. 2.4)"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"