β Import Posterior Draws
Drop CSV file here or click
Columns = parameters, rows = draws (e.g. as_draws_df() output)
Available columns (click to copy)
βΈ R code: Export draws (brms Β· G-Computation)
βΆ
# ββ 1 Β· Standard: parameter draws from brms βββββββββββββββββββββββββββββββββ
# Suitable for linear models (Gaussian family, identity link).
library(brms)
draws <- as_draws_df(fit) # all parameters as data.frame
draws_clean <- dplyr::select(draws,
starts_with("b_"), sigma) # relevant columns only β adjust!
write.csv(draws_clean, "draws.csv", row.names = FALSE)
# Stan: posterior::as_draws_df(fit$draws())
# rstanarm: as.data.frame(fit)
# ββ 2 Β· G-Computation draws from brms (ATE) βββββββββββββββββββββββββββββββββ
# Use this option if your model uses a GLM link (logit, log etc.).
# Raw Ξ² draws are on the link scale β substantively incorrect in that case.
# G-Computation draws are always on the response scale (e.g. percentage points).
# Note: this code estimates the ATE (entire population) only.
# For ATT or ATU: see Causal Calculator β sections 5 & 6.
library(marginaleffects)
comp <- avg_comparisons(fit_gc, variables = "A") # ATE: entire population
comp # Summary: median + 95% CI
# posteriordraws() extracts the draw distribution directly from comp:
ate_post <- posteriordraws(comp)$draw
# β Do NOT use raw parameter draws (e.g. Ξ²_A) if the model uses a GLM link
# (logit, log etc.) β these are on the link scale, not the response scale.
# G-Computation draws are the correct choice in that case.
write.csv(
data.frame(draw = ate_post),
"ate_draws.csv",
row.names = FALSE
)
# Then upload here β the column is named "draw".
β‘ Define Analysis Variables
β’ Settings
Credible Interval (CrI)
95% β Kruschke's standard, widely used in publications
Display interval (plot)
HDI = shortest interval. Especially informative for skewed posteriors.
Decision rule (ROPE logic)
Kruschke: HDI fully outside β effect; fully inside β null.
First load a CSV and define at least one variable
Background Knowledge
Why Posterior Draws?
Rather than summarising point estimates, the posterior contains full uncertainty. Each draw is a plausible parameter value β from the ensemble, HDI, ROPE, and any conceivable transformation can be computed without a normality assumption.
HDI vs. ETI
The HDI (Highest Density Interval) is the shortest interval containing X% of the mass β ideal for skewed posteriors. The ETI (Equal-Tailed Interval) is quantile-based and invariant under monotone transformations. For symmetric posteriors both are identical.
ROPE & SESOI
The Region of Practical Equivalence (ROPE) defines a region around zero that would be practically meaningless. It corresponds to the Smallest Effect Size of Interest (SESOI). Lakens (2018) recommends: for standardised effects, ROPE = [β0.1, 0.1] as a starting point.
Kruschke Decision
Kruschke's trichotomous logic: if the HDI lies entirely outside the ROPE β effect present. If it lies entirely inside β practically null. Otherwise β withhold judgement. This approach avoids binary p-value logic and quantifies uncertainty explicitly.
Transformations & Link Functions
In models with a log-link (Poisson, Gamma) or logit-link (Binomial), coefficients are not on the original scale.
exp(b) yields rate/odds ratios, plogis(b) probabilities. Decisions should always be made on the substantively meaningful scale.Derived Quantities (Cohen's d)
The advantage of real draws: any quantity can be computed. Cohen's d as
b_treatment / sigma propagates uncertainty across both parameters. The resulting HDI is a fully Bayesian credible band for the standardised effect β no delta-method standard errors needed.