Skip to content

Generalize variance decomposition pipeline#50

Open
bridgetilin wants to merge 2 commits into
aims-foundations:mainfrom
bridgetilin:generalize-variance-decomp
Open

Generalize variance decomposition pipeline#50
bridgetilin wants to merge 2 commits into
aims-foundations:mainfrom
bridgetilin:generalize-variance-decomp

Conversation

@bridgetilin

Copy link
Copy Markdown

Multi-facet G-theory support

Extends the G-theory module from a fixed two-facet (subject × item) design to support fully crossed, balanced N-facet designs.

Changes

_generalizability.py (new) — Private helpers for multi-facet designs: design validation, interaction parsing, cell means construction, ANOVA method-of-moments variance component estimation via Möbius inversion, G-coefficient computation, and a shared bootstrap loop for both two-facet and multi-facet paths.

generalizability.py (modified) — Public API additions:

  • variance_components(): multi-facet path via facet_cols, object_facet, and interactions params.
    Returns components keyed by facet name or interaction tuple, plus raw_components with unclamped estimates. Raises TypeError if both two-facet and multi-facet params are mixed.
  • g_coefficient(): added facet_sizes kwarg for multi-facet mode. n_reps now defaults to observed value in multi-facet mode.
  • d_study(): added design_grid and n_reps_grid_multi for multi-facet projections.
  • bootstrap_variance_components(): supports both modes via shared _bootstrap_resample().

test_generalizability_multifacet.py (new) — 33 tests: variance component estimation, design validation, G-coefficients, D-study, bootstrap, ICC rejection for multi-facet dicts, and an end-to-end pipeline test.

Design notes

  • Two-facet API is unchanged — existing subject_col/item_col/trial_col code works as before (42
    existing tests pass).
  • Negative higher-order estimates are propagated unclamped during the top-down EMS solve to avoid
    biasing lower-order estimates. Final output is clamped to ≥ 0, and both clamped and raw values are
    returned.
  • When n_reps=1, residual is confounded with the full k-way interaction; only those two are marked
    identifiable: False.
  • Facet names are not hardcoded — any string column names work.

@bridgetilin

Copy link
Copy Markdown
Author

@nicchiou

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