models.fit_kdm

models.fit_kdm(reference, markers, age_col='age', s_ba2=None)

Fit the KDM reference regressions, as BioAge’s kdm_calc does.

Each step follows BioAge (Kwon and Belsky, GeroScience 2021;43:2795-2808), and together they reproduce the kdm0 column BioAge ships with its NHANES III extract to 0.0007 years mean absolute difference (maximum 0.007 years, n = 9,583), where FALCONAge 1.0.0 was 1.77 years out:

  1. Each biomarker is regressed on age on the rows where that biomarker is present (svyglm per marker, missing rows dropped per model), not on the rows where every biomarker is present.
  2. The residual SD is sd(residuals), divisor n - 1, as BioAge’s get_effs takes it for a glm fit.
  3. r_char weights the absolute correlation, the square root of R-squared.
  4. s_R uses the age range of the whole reference.
  5. s_BA^2 is the variance of BA_E - CA on the reference rows with every biomarker present, minus s_R, and is kept with the fit.

s_ba2 overrides step 5. Pass a value to put several fits on one scale.