Add Satterthwaite and Kenward-Roger fixed-effect tests

This commit is contained in:
2026-08-13 07:02:10 +08:00
parent 76dd8b1379
commit 8557daecac
14 changed files with 1330 additions and 20 deletions

View File

@@ -92,6 +92,10 @@ For block number `KKKKKK`:
block_KKKKKK.summary.tsv
block_KKKKKK.beta.f64.bin
block_KKKKKK.cov.f64.bin
block_KKKKKK.fixed_se.f64.bin
block_KKKKKK.fixed_stat.f64.bin
block_KKKKKK.fixed_ddf.f64.bin
block_KKKKKK.fixed_p.f64.bin
block_KKKKKK.complete
```
@@ -112,10 +116,22 @@ logL
iterations
line_search_steps
grad_inf
fixed_test_method
fixed_test_status
fixed_test_offset
extra_joint_num_df
extra_joint_den_df
extra_joint_f
extra_joint_p
fixed_test_error
error
```
`beta_offset` and `cov_offset` count `float64` elements, not bytes. A negative offset indicates that no estimates were emitted for that task.
`beta_offset`, `cov_offset`, and `fixed_test_offset` count `float64`
elements, not bytes. A negative beta/covariance offset means that no estimates
were emitted. A negative fixed-test offset means that no valid coefficient-wise
fixed-effect tests were emitted; successful REML estimates are retained even
when inference fails.
The covariance array uses the row-wise packed lower triangle:
@@ -126,11 +142,12 @@ The covariance array uses the row-wise packed lower triangle:
The `.complete` marker is written last and contains tab-separated key/value rows:
```text
format spectra-reml-block-v1
format spectra-reml-block-v2
block 0
tasks 256
beta_elements 4096
cov_elements 34816
fixed_test_elements 4096
```
Consumers must ignore blocks without `.complete`.
@@ -150,6 +167,35 @@ numerical_error
`converged_boundary` is a successful residual-only solution accepted after the one-sided variance-component score and likelihood checks.
## Fixed-effect inference
`--fixed-effect-test` selects `satterthwaite` (the default),
`kenward-roger`, or `none`.
The four `fixed_*` arrays have the same offsets and coefficient order as
`beta`. They contain standard errors, statistics, denominator degrees of
freedom, and p-values. With Satterthwaite inference, a coefficient statistic is
a signed t statistic. With Kenward-Roger inference, it is an F statistic with
one numerator degree of freedom. For every task with extra covariates, the
summary also contains an F test of the joint null that all task-specific fixed
effects are zero.
`fixed_test_status` is one of:
```text
not_requested
ok
boundary_conditional
fit_not_converged
invalid_contrast
information_singular
numerical_error
```
At `converged_boundary`, inference conditions on the accepted active set
`sigma_g2=0`; `fixed_test_status` is `boundary_conditional` and only residual
variance uncertainty contributes to the small-sample adjustment.
Phenotypes are scaled internally by their task-specific OLS residual RMS before
optimization. Reported fixed effects, fixed-effect covariance, variance
components, and restricted likelihood are transformed back to the original
@@ -168,6 +214,13 @@ The Python CLI exports one TSV row per task. It includes the full summary plus:
```text
beta_json
covariance_packed_lower_json
fixed_effect_se_json
fixed_effect_statistic_json
fixed_effect_denominator_df_json
fixed_effect_p_value_json
```
Project-specific software can attach coefficient names and derive contrasts without changing the numerical engine.
Project-specific software can attach coefficient names. The public C++
inference API also accepts general linear hypotheses `L beta = rhs`; the batch
format currently emits coefficient-wise tests and the joint extra-covariate
test.