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

Support binary outcomes in simulate_dyad_responses() and the predictive checks

Open
#78 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
66/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
r
Domain
testing

Research direction

Start in R/predictive_checks_simulation.R (simulate_dyad_responses()): add "binomial" to supported, keep only the successes column of glmmTMB draws, convert logical/two-level-factor responses to 0/1, and error on non-0/1 responses; then add "binomial" to count_families in R/predictive_checks_outcomes.R. Verify with tests/testthat/test-predictive-checks-generalized.R, test-simulate-dyad-responses.R and test-predictive-checks-outcomes.R. Note the issue is blocked on #77, and simulation studies under dev/diagnostic_checks/simulation-studies/ must be rerun per its README before updating reports and NEWS.md.

Written by the indexing model from the issue text.

Description

simulate_dyad_responses() rejects binomial() models ("Unsupported family"), so no check_*() function works for binary outcomes. A quick test on the branch of #77 showed that check_partner_dependence(), check_residuals() and check_outcomes() all run on a 0/1 model after a small change to the simulation. Do this after #77 is merged.

Scope: ungrouped 0/1 outcomes only (numeric 0/1, logical, or a two-level factor). Keep rejecting grouped binomial models (cbind(successes, failures)) and weighted proportions.

Code
  1. R/predictive_checks_simulation.R, simulate_dyad_responses():
    • Add "binomial" to supported.
    • glmmTMB returns successes and failures for each draw. Keep successes:
      if (family$family == "binomial") simulated[] <- lapply(simulated, function(x) x[, 1])
    • Convert a logical or two-level factor response to 0/1 (first factor level = 0, as in glmmTMB).
    • Stop with a clear message if the response is not 0/1.
    • Add binomial() (0/1 outcomes) under "Supported models" in the help, then run devtools::document().
  2. R/predictive_checks_outcomes.R: add "binomial" to count_families, so the outcome page shows bars for 0 and 1 instead of an ECDF. Decide whether to hide the "Number of zeros" row for binary outcomes, since it repeats the bar for 0.
  3. check_residuals() and check_partner_dependence() should need no changes. Confirm that residual centring applies (free_conditional_intercept is TRUE for models with an intercept).
Tests
  • tests/testthat/test-predictive-checks-generalized.R: add binomial() with a 0/1 outcome to the family loop, so all three checks run. Keep the grouped-binomial test (update its expected message if it changes). Add tests for logical and factor outcomes, and for rejecting outcomes that are not 0/1.
  • tests/testthat/test-simulate-dyad-responses.R: simulations are an nsim × n matrix of 0/1; observed values are 0/1.
  • tests/testthat/test-predictive-checks-outcomes.R: bars for 0 and 1.
Simulation studies

Run from the repository root as described in dev/diagnostic_checks/simulation-studies/README.md.

  • dev/diagnostic_checks/simulation-studies/shared/family-margins.R: add a Bernoulli margin (logit link).
  • family-comparison/ and generalized-covariance-pooling/: add binomial to their family lists, rerun, and update report-data/ and the reports in vignettes/articles/.
  • dev/diagnostic_checks/distribution-diagnostics/calibration-check.R: add a binary scenario (correct model, and one with an omitted role mean). Record false alarms and detection rates in calibration-summary.md.
Docs
  • NEWS.md: one bullet.
  • Optional: an example in the empty "Dichotomous outcomes" section of dev/vignettes/generalized-apim.Rmd.
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.