Skip to contents

Summarises the posterior of the covariate effects \(\beta_{jp}\) from a ZI_MLN() fit that was run with covariates. Errors if the model was fit without covariates (X = NULL).

Usage

posterior_beta(fit, prob = c(0.025, 0.975))

Arguments

fit

A list returned by ZI_MLN() with a beta component in each draw.

prob

Length-2 vector of lower/upper probabilities for the credible interval. Default c(0.025, 0.975).

Value

A list with three J x P matrices: mean, lower and upper (posterior mean and credible bounds of each \(\beta_{jp}\)), plus a tidy long data.frame table with columns otu, covariate, mean, lower, upper.

Examples

# \donttest{
sim <- simulate_zimln(n = 30, J = 20, K = 2, p = 2, seed = 1)
fit <- ZI_MLN(sim$Y, X = sim$X, m = sim$m, M = sim$M, niter = 400, burnin = 200)
b <- posterior_beta(fit)
head(b$table)
#>   otu covariate       mean      lower      upper
#> 1   1         1  1.2606389  0.1269379  2.6832901
#> 2   2         1  0.3878016 -0.6582672  1.3611266
#> 3   3         1 -1.2163554 -1.9590218 -0.5702727
#> 4   4         1 -0.1479200 -1.1102355  0.8661351
#> 5   5         1  0.5815872 -0.3464085  1.4099690
#> 6   6         1 -1.1432988 -2.0537082 -0.2125540
# }