Formula: p ~ Dir(alpha); y ~ Multinomial(n, p)
Details
The posterior is Dir(alpha + y), so the posterior mean of p_j is (y_j + alpha_j) / (n + sum alpha) and the marginal likelihood is the Polya distribution n! Gamma(A)/Gamma(n+A) prod Gamma(y_j+a_j)/(y_j! Gamma(a_j)). With two categories this is exactly the beta-binomial.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Diripr(V)
#> $estimate
#> [1] 0.04545455
#>
#> $post_mean
#> [1] 0.04545455 0.06818182 0.09090909 0.11363636 0.13636364 0.15909091 0.18181818
#> [8] 0.20454545
#>
#> $post_var
#> [1] 0.0009641873 0.0014118457 0.0018365473 0.0022382920 0.0026170799
#> [6] 0.0029729109 0.0033057851 0.0036157025
#>
#> $post_alpha
#> [1] 2 3 4 5 6 7 8 9
#>
#> $log_marginal
#> [1] -17.28823
#>
#> $n
#> [1] 36
#>
#> $K
#> [1] 8
#>
#> $method
#> [1] "Dirichlet-multinomial conjugate model"
#>
#> attr(,"class")
#> [1] "morie_rich_result" "list"
