Repository navigation
Add Cronbach alpha and Feldt (1965) exact-F confidence interval - #227
Conversation
There was a problem hiding this comment.
Pull request overview
Adds coefficient alpha reliability support (Cronbach’s alpha) and Feldt (1965) exact-F confidence intervals to the mlsirm_core::reliability Rust crate, exposes them through the PyO3 core module, and provides Python-facing wrappers + tests to pin the numeric contract against independent NumPy/SciPy fixtures.
Changes:
- Implement
cronbach_alpha(raw-covariance form) andfeldt_alpha_ci(Feldt exact-F CI) incrates/mlsirm-core. - Add PyO3 bindings and Python wrapper API (
cronbach_alpha,feldt_alpha_ci,AlphaCiResult) and export them fromfast_mlsirm. - Add Rust + Python fixtures/rejection tests and document the feature in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/reliability_tests.rs | Adds Rust-side fixture tests, regression for extreme CI endpoint behavior, and rejection coverage. |
| tests/test_paper_features.py | Adds Python-level fixture test and boundary rejection tests for the new reliability APIs. |
| python/fast_mlsirm/reliability.py | Introduces Python wrappers + AlphaCiResult dataclass and appends reference text to docstrings. |
| python/fast_mlsirm/init.py | Re-exports the new reliability functions/types at the package top-level. |
| crates/mlsirm-core/src/reliability.rs | Implements Cronbach alpha, Feldt CI, and internal F CDF/quantile utilities (incomplete beta + bisection). |
| crates/mlsirm-core/src/fitstats.rs | Makes ln_gamma pub(crate) for reuse in the new incomplete-beta implementation. |
| crates/fast-mlsirm-py/src/lib.rs | Adds PyO3 functions cronbach_alpha / feldt_alpha_ci and wires them into the module init. |
| CHANGELOG.md | Documents the newly added reliability metrics and key behavioral divergences from psych. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot Fix the code for all comments in this review thread. When a review comment includes a suggested change, apply the suggestion exactly. Do not make changes beyond what is described in the linked review thread. |
Implemented the requested review-thread fix in commit |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
crates/mlsirm-core/src/reliability.rs:632
df2is computed as((n - 1) * (p - 1)) as f64; the(n-1)*(p-1)multiplication can overflowusizein release builds before the cast. Please usechecked_mul(as elsewhere in the crate) so extreme inputs fail fast with a clear error instead of wrapping to an incorrect df2.
let df1 = (n - 1) as f64;
let df2 = ((n - 1) * (p - 1)) as f64;
let delta = 1.0 - level;
d324467 to
1d8bf72
Compare
40a260a to
afb84cf
Compare
1d8bf72 to
05e23ce
Compare
afb84cf to
8d59b0f
Compare
05e23ce to
0fc4ced
Compare
8d59b0f to
64418ec
Compare
3c00995 to
7463911
Compare
64418ec to
67b034e
Compare
Rebased onto main after #225 squash merge; preserve audit-safe fitstats checks and only expose ln_gamma as pub(crate) for reliability CI routines. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
67b034e to
863f33e
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Rebased onto main after #227 squash merge. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Iteration 10 of the paper-implementation loop. Stacked on #226 (base
seonghobae-tenberge-mu).What
mlsirm_core::reliability::cronbach_alpha— raw-covariance Cronbach's alpha:p/(p-1) * (1 - tr(C)/sum(C))(Cronbach, 1951).mlsirm_core::reliability::feldt_alpha_ci— Feldt (1965) exact-F CI: pivot(1-alpha)/(1-alpha_hat) ~ F(n-1, (n-1)(p-1));lower = 1-(1-a)*qF(1-d/2),upper = 1-(1-a)*qF(d/2); plus impliedr_bar. In-crate F quantile (Lentz continued-fraction incomplete beta + bisection; endpoints guarded to 0/+inf).cronbach_alpha/feldt_alpha_ci/AlphaCiResult.Sources actually verified
alpha.ci(R/alpha.R)Evidence
f_quantilereturned a finite bisection cap at prob>=1 where qf/scipy give inf → endpoint guards + regression test; (2) wrapper docstrings were"..." + CONSTexpressions (__doc__None) → literal docstring +__doc__ +=.guttman_lambdaslambda3 at 1e-10 (crate-vs-crate).f_cdfz-orientation flip → 3 FAIL;df2=n-1→ A/B FAIL (p=2 passes by identity, documented); tr/sum inversion → 3 FAIL. Disclosed equivalent mutant: dropping theinc_betasymmetry branch survives (convergence acceleration only at these dfs; scipy literals anchor everything coarser).Divergences from psych (documented in module docs)
Raw-data input only (no reverse-keying/check.keys); zero-variance items rejected; confidence
levelinstead ofp.val; hard errors instead of NA; bounds not clamped (negative alpha allowed, matching psych).