Handle boundary and line-search fixed-effect inference

This commit is contained in:
2026-08-14 16:54:57 +08:00
parent 48ab77f9ab
commit 9033201948
10 changed files with 220 additions and 41 deletions

View File

@@ -13,9 +13,11 @@ struct FixedEffectHypothesis {
std::vector<double> rhs;
};
// Computes coefficient-wise tests and any supplied general linear hypotheses
// at an already fitted REML solution. Inputs must use the same (possibly GRM-
// rotated) coordinate system and phenotype scale as the supplied fit.
// Computes coefficient-wise tests and any supplied general linear hypotheses.
// At an interior or retained line-search iterate it uses the requested REML
// small-sample method. A sigma_g2=0 boundary fit is refitted and tested as
// ordinary least squares without a GRM term. Inputs must use the same
// orthogonally rotated coordinate system and phenotype scale as the fit.
[[nodiscard]] FixedEffectInferenceResult infer_fixed_effects_spectral(
const std::vector<double>& y_star, const ColMajorMatrix& x_star,
const std::vector<double>& eigenvalues, const RemlResult& fit,

View File

@@ -66,6 +66,7 @@ enum class FitStatus {
enum class FixedEffectTestMethod {
none,
ordinary_least_squares,
satterthwaite,
kenward_roger
};
@@ -75,7 +76,8 @@ enum class FixedEffectTestMethod {
enum class FixedEffectInferenceStatus {
not_requested,
ok,
boundary_conditional,
boundary_ols,
line_search_conditional,
fit_not_converged,
invalid_contrast,
information_singular,
@@ -99,8 +101,9 @@ struct FixedEffectInferenceResult {
FixedEffectTestMethod method = FixedEffectTestMethod::none;
FixedEffectInferenceStatus status =
FixedEffectInferenceStatus::not_requested;
// One test per beta, in design-matrix column order. Satterthwaite reports
// a signed t statistic; Kenward-Roger reports an F statistic with 1 NumDF.
// One test per beta, in design-matrix column order. OLS and
// Satterthwaite report signed t statistics; Kenward-Roger reports an F
// statistic with 1 NumDF.
std::vector<FixedEffectTestResult> coefficient_tests;
// Optional general linear hypotheses requested by the caller.
std::vector<FixedEffectTestResult> hypothesis_tests;