knitr::opts_chunk$set( collapse = TRUE, comment = "#>", warning = FALSE, message = FALSE )
library(glmbayes) library(bayestestR)
bayestestR implements a wide range indices for posterior description and decision-oriented summaries (probability of direction, ropes, equivalence tests, etc.). Here we treat the coefficients component of a glmb fit as stored i.i.d. draws and summarize them using bayestestR.
This complements Chapter 12 (optional bayesplot graphics, commented out in the vignette) with tabular summaries you can cite in applied reports.
data(menarche, package = "MASS") Age2 <- menarche$Age - 13 Menarche_Model_Data <- data.frame( Menarche = menarche$Menarche, Total = menarche$Total, Age2 = Age2 ) ps <- Prior_Setup( cbind(Menarche, Total - Menarche) ~ Age2, family = binomial(link = "logit"), data = Menarche_Model_Data ) fit_logit <- glmb( cbind(Menarche, Total - Menarche) ~ Age2, family = binomial(link = "logit"), pfamily = dNormal(mu = ps$mu, Sigma = ps$Sigma), data = Menarche_Model_Data, n = 800, use_parallel = FALSE ) coef_draws <- as.data.frame(fit_logit$coefficients)
bayestestR::describe_posterior(coef_draws) bayestestR::hdi(coef_draws, ci = 0.89) bayestestR::rope(coef_draws, range = c(-0.02, 0.02)) bayestestR::p_direction(coef_draws)
Tune rope(..., range = ...) to match substantive “practical equivalence” hypotheses on the logit scale (see also the binomial likelihood discussion in Chapter 09). For richer reporting pipelines (parameters, performance, …), see the easystats ecosystem linking out from ?bayestestR.
bayesplot workflows and legacy_code/pp_check.glmb.R. summary.glmb() defaults.Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.