Skip to content

Add Gaussian partner-dependence predictive checks - #18

Open
Pascal-Kueng wants to merge 40 commits into
mainfrom
residual-diagnostics
Open

Add Gaussian partner-dependence predictive checks#18
Pascal-Kueng wants to merge 40 commits into
mainfrom
residual-diagnostics

Conversation

@Pascal-Kueng

@Pascal-Kueng Pascal-Kueng commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add simulate_dyad_responses() to generate plug-in response datasets from cross-sectional Gaussian glmmTMB models.
  • Add check_partner_dependence() to compare observed and simulated partner variation and association.
    • Support model-centred and raw responses, meaningful member roles, and label-invariant summaries for interchangeable members.
    • Add help pages, examples, plots, tests, developer validation, and a known-population outer simulation study.

Scope and interpretation

This PR supports unweighted cross-sectional Gaussian identity-link glmmTMB models without zero inflation. The fitted parameters and fitted-row design remain fixed, while random effects and Gaussian errors are newly generated for each simulated dataset.

This is a descriptive plug-in predictive reference. The model is not refitted, parameter uncertainty is not included, and observations are not held out. Observed positions and middle 95% ranges are descriptive guides, not p-values or calibrated confidence intervals.

The check is likely most useful when the model makes a simplifying assumption that could be wrong (for example, no remaining partner relationship or equal variation across roles). When the model freely estimates the same feature from these data, close agreement is expected (learned patterns are reproduced).

For exchangeable dyads, the deterministic summary follows Woody and Sadler's (2005) between-/within-dyad decomposition. The observed-versus-simulated comparison adapts the principle from Gelman, Meng, and Stern (1996). It is not a posterior predictive distribution.

Review focus

Conceptual questions about the diagnostic target and interpretation are collected in Discussion #21.

  • Column-first tidy evaluation (.data / .env) and {{ }} wrapper forwarding
  • Fitted-row alignment, pairing, and omitted-row handling
  • Whether the interpretation is clear and appropriately cautious
  • Readability of the API, output, and documentation

Review cleanup

  • Resolve bare identifiers in the fitted model frame before the calling environment; retain quoted names and explicit external vectors.
  • Share paired-statistic, label, and reference-summary helpers, and apply one calculation to observed and simulated responses. The refactor at ab87b04 removed 39 R-source lines while preserving the Gaussian formulas and result schema.
  • Cover name collisions, explicit pronouns, embraced wrappers, and single-simulation dimensions.
  • Add plain-language source comments explaining reusable objects, their shapes, and how later functions use them.
  • Lead the guide and help pages with quick starts, examples, and interpretation. Put object shapes, tidy-evaluation programming, and implementation details later; use the same practical-first structure in both worked examples.
  • Preserve the existing prototype branches as references. Build fresh non-Gaussian cross-sectional work first, then Gaussian ILD on the accepted combined foundation. Keep family restrictions and undefined-statistic policies explicit.

Validation

Documentation cleanup at fadb3b6:

  • Synchronized the three Rd help pages with their revised source documentation; checked whitespace, section order, and local documentation links.
  • Source comparisons confirmed that executable R code, existing help-example code, and all 44 R chunks in the two worked examples are unchanged. The runnable help example gained only a note about using fewer simulations for speed.
  • New R CMD checks, coverage, and the documentation build are running on this commit. R is unavailable locally, so R-based validation is delegated to CI.

Cleanup validation at ab87b04:

Earlier validation of the unchanged numerical design (not rerun for this cleanup):

  • The independent Woody–Sadler/Dingy validation report renders with all assertions passing.
  • In the outer simulation study, all 7,000 fitted-model runs completed without warnings, convergence problems, or check errors.
  • The known-truth control behaved as expected: 4–7% of summaries fell outside the middle 95%, and position SDs were 0.275–0.290 versus 0.289 expected.
  • Flexible correct fits clustered tightly near the middle, showing why close agreement is not independent evidence of good fit. The deliberately wrong assumptions were flagged in the expected direction in 84.4–96.8% of datasets with 50 dyads and 100% with 200 dyads.

@Pascal-Kueng
Pascal-Kueng marked this pull request as ready for review August 26, 2026 00:36

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be shortened. The basic idea is:

  • apply criteria to simulation
  • apply criteria to prediction
  • plot

Resolve identifiers in the fitted data mask, with explicit .data/.env access
and embraced wrapper arguments. Extract shared pair statistics, labels, and
reference summaries while preserving the current Gaussian check contract.

Cover name collisions and wrapper/single-simulation behavior; update the
development plan to rebuild generalized and ILD work from the accepted base.
Add plain-language comments describing response datasets, fitted-row and
partner indices, statistic vectors, reference tables, and plotting inputs.
Explain tidy evaluation and the simulation choices that preserve dependence.

Executable code and roxygen documentation are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant