library(bellreg)
data(cells)
# ML approach:
mle <- zibellreg(cells ~ smoker+gender|smoker+gender, data = cells, approach = "mle")
summary(mle)
#> Call:
#> zibellreg(formula = cells ~ smoker + gender | smoker + gender,
#> data = cells, approach = "mle")
#>
#> Zero-inflated regression coefficients:
#> Estimate StdErr z.value p.value
#> (Intercept) -1.95360 0.84599 -2.3093 0.020930 *
#> smoker 2.17802 0.82416 2.6427 0.008224 **
#> gender -0.49531 0.42048 -1.1780 0.238808
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#>
#> Count regression coefficients:
#> Estimate StdErr z.value p.value
#> (Intercept) 0.716390 0.179869 3.9828 6.809e-05 ***
#> smoker -0.611354 0.183404 -3.3334 0.000858 ***
#> gender 0.036439 0.177460 0.2053 0.837310
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> ---
#> logLik = -610.3234 AIC = 1232.647
# Bayesian approach:
bayes <- zibellreg(cells ~ 1|smoker+gender, data = cells, approach = "bayes", refresh = FALSE)
summary(bayes)
#> Call:
#> zibellreg(formula = cells ~ 1 | smoker + gender, data = cells,
#> approach = "bayes", refresh = FALSE)
#>
#> Zero-inflated regression coefficients:
#> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff
#> (Intercept) -1.159 0.008 0.338 -1.897 -1.348 -1.121 -0.931 -0.62 1727.777
#> Rhat
#> (Intercept) 1
#>
#> Count regression coefficients:
#> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff
#> (Intercept) 0.721 0.003 0.146 0.438 0.621 0.721 0.817 1.005 3041.289
#> smoker -1.077 0.003 0.146 -1.355 -1.177 -1.081 -0.978 -0.784 2478.982
#> gender 0.169 0.003 0.140 -0.103 0.075 0.168 0.265 0.440 2819.792
#> Rhat
#> (Intercept) 0.999
#> smoker 1.000
#> gender 0.999
#> ---
#> Inference for Stan model: zibellreg.
#> 4 chains, each with iter=2000; warmup=1000; thin=1;
#> post-warmup draws per chain=1000, total post-warmup draws=4000.
log_lik <- loo::extract_log_lik(bayes$fit)
loo::loo(log_lik)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
#> Computed from 4000 by 511 log-likelihood matrix.
#>
#> Estimate SE
#> elpd_loo -1071.0 53.8
#> p_loo 223.3 21.4
#> looic 2142.0 107.7
#> ------
#> MCSE of elpd_loo is NA.
#> MCSE and ESS estimates assume independent draws (r_eff=1).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
#> (-Inf, 0.7] (good) 418 81.8% 2796
#> (0.7, 1] (bad) 30 5.9% <NA>
#> (1, Inf) (very bad) 63 12.3% <NA>
#> See help('pareto-k-diagnostic') for details.
loo::waic(log_lik)
#> Warning:
#> 93 (18.2%) p_waic estimates greater than 0.4. We recommend trying loo instead.
#>
#> Computed from 4000 by 511 log-likelihood matrix.
#>
#> Estimate SE
#> elpd_waic -1011.2 48.6
#> p_waic 163.5 15.1
#> waic 2022.4 97.2
#>
#> 93 (18.2%) p_waic estimates greater than 0.4. We recommend trying loo instead.