Support brms models in simulate_dyad_responses() and the predictive checks
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
- Domain
- documentation, testing
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
R/predictive_checks_simulation.R: dispatch on the model class, asextract_exchangeable_residual_blocks()does inR/model_exchangeable_covariance.R. Add a brms branch that returns the same fields anddyadMLMattribute:simulated_responses:brms::posterior_predict()withnsimposterior draws. Give each grouping level a new name and useallow_new_levels = TRUE, sample_new_levels = "gaussian", so every dataset draws new random effects, likesimCode = 2in glmmTMB. Stop ifnsimexceeds the available draws.predicted_response:brms::posterior_epred(re_formula = NA), averaged over draws.observed_responseandmodel_framefrom 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.
- Help text: add brms to "Supported models" in
?simulate_dyad_responses, and state the difference in the reference distribution. Rundevtools::document().
Tests
- New
tests/testthat/test-simulate-dyad-responses-brms.R, withskip_if_not_installed("brms"):- Fast unit tests with an
empty = TRUEfit (as intest-backtransform-residual-covariance.R) and mockedposterior_predict()andposterior_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.
- Fast unit tests with an
- 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 incalibration-summary.md. Posterior predictive references are expected to be more conservative.family-comparison/andcovariance-pooling/: rerun a reduced brms version for the partner check, and summarise it in the reports invignettes/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
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Pascal-Kueng/dyadMLM
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Pascal-Kueng/dyadMLM#92 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Pascal-Kueng/dyadMLM#83 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Pascal-Kueng/dyadMLM#71 · 2 comments ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 86/100
Pascal-Kueng/dyadMLM#70 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Pascal-Kueng/dyadMLM#69 ·
Maintainers usually reply within 1 day
All issues in Pascal-Kueng/dyadMLM
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
stan-dev/priorsense#150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
xuzhougeng/wisp-science#1571 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
bennettoxford/opencodecounts#170 ·