Compares observed counts per bin with posterior predictive (brms) or
simulated (sdmTMB) counts, summed within levels of grp. Predicted
totals are rescaled to the observed total within each group and draw, so
the check is on the composition rather than on the total.
Requires a fit from fit_model(..., add_preds = TRUE).
Value
A ggplot with predicted medians and intervals (black) and observed
counts (blue), faceted by grp.
Examples
dat <- data_prep(ex_comp, c("Year", "Season", "Vessel", "trip"), "length", "count")
fit <- fit_model("Year", "Season + Vessel", data = dat, backend = "TMB",
iter = 300, warmup = 100, thin = 2, add_preds = TRUE)
#> Model formula: tot_by_bin ~ 0 + bin + factor(Year):bin + (1 | bin:Season) + (1 | bin:Vessel)
post_pred_group(fit, grp = "Year", xlab = "Length (cm)")
