Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Support brms models in simulate_dyad_responses() and the predictive checks

Open
#79 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active

Research direction

Start in R/predictive_checks_simulation.R, mirroring the class dispatch used by extract_exchangeable_residual_blocks() in R/model_exchangeable_covariance.R; the goal is a brms branch returning identical fields plus the dyadMLM attribute. Read how glmmTMB handles families and free_conditional_interest_intercept to reuse it, then study tests/testthat/test-backtransform-residual-covariance.R for the empty = TRUE + mocked-function test pattern. Done means tests/testthat/test-simulate-dyad-responses-brms.R passes, glmmTMB tests are untouched, devtools::document() output includes brms in ?simulate_dyad_responses, and README/NEWS are updated. Note the issue is blocked on #77.

Written by the indexing model from the issue text.

Description

simulate_dyad_responses() accepts only glmmTMB models, so check_partner_dependence(), check_residuals() and check_outcomes() are unavailable for brmsfit models. The README lists them as "Not implemented" for brms, while other dyadMLM tools already support brms. Do this after #77 is merged (and include bernoulli() if #78 is done).

The checks only use the object returned by simulate_dyad_responses(). Supporting brms therefore means creating the same object from a brmsfit; the checks themselves should need no changes.

Scope: single-response, unweighted brmsfit models with the families already supported for glmmTMB. Reject multivariate models, addition terms such as weights(), trials(), cens() and trunc(), and unsupported autocorrelation terms with clear messages.

Code
  1. R/predictive_checks_simulation.R: dispatch on the model class, as extract_exchangeable_residual_blocks() does in R/model_exchangeable_covariance.R. Add a brms branch that returns the same fields and dyadMLM attribute:
    • simulated_responses: brms::posterior_predict() with nsim posterior draws. Give each grouping level a new name and use allow_new_levels = TRUE, sample_new_levels = "gaussian", so every dataset draws new random effects, like simCode = 2 in glmmTMB. Stop if nsim exceeds the available draws.
    • predicted_response: brms::posterior_epred(re_formula = NA), averaged over draws.
    • observed_response and model_frame from the fitted data, keeping fitted-row order.
    • free_conditional_intercept: same rule as for glmmTMB, using the brms fixed-effect design (intercept, or role terms that span it).
    • Map brms family names (for example negbinomial → NB2, cumulative → ordinal, student → t) to the existing family handling.
    • Record that references are posterior predictive (they include parameter uncertainty, unlike glmmTMB's plug-in simulations), and use this in printed headers and help text.
  2. Help text: add brms to "Supported models" in ?simulate_dyad_responses, and state the difference in the reference distribution. Run devtools::document().
Tests
  • New tests/testthat/test-simulate-dyad-responses-brms.R, with skip_if_not_installed("brms"):
    • Fast unit tests with an empty = TRUE fit (as in test-backtransform-residual-covariance.R) and mocked posterior_predict() and posterior_epred(): object structure, row order, new random effects, family mapping, and rejection messages.
    • One small real fit behind skip_on_cran() that runs all three checks end to end.
  • Confirm the glmmTMB tests are unchanged.
Simulation studies

Run as described in dev/diagnostic_checks/simulation-studies/README.md. Fitting is slow, so start with fewer datasets.

  • dev/diagnostic_checks/distribution-diagnostics/calibration-check.R: add brms fits for the Gaussian and one count scenario (correct model and omitted role mean). Compare false alarms and detection with glmmTMB, and record them in calibration-summary.md. Posterior predictive references are expected to be more conservative.
  • family-comparison/ and covariance-pooling/: rerun a reduced brms version for the partner check, and summarise it in the reports in vignettes/articles/.
Docs
  • README: update the brms column for the three checks.
  • APIM vignette: optionally a short brms example next to the glmmTMB checks.
  • NEWS.md: one bullet.
Dominant language
R
Stars
1
Forks
2
Avg merge
9h 28m
Merged PRs (30d)
21

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Pascal-Kueng/dyadMLM

All issues in Pascal-Kueng/dyadMLM

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.