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:
- Each biomarker is regressed on age on the rows where that biomarker is present (
svyglmper marker, missing rows dropped per model), not on the rows where every biomarker is present. - The residual SD is
sd(residuals), divisor n - 1, as BioAge’sget_effstakes it for aglmfit. r_charweights the absolute correlation, the square root of R-squared.s_Ruses the age range of the whole reference.s_BA^2is the variance ofBA_E - CAon the reference rows with every biomarker present, minuss_R, and is kept with the fit.
s_ba2 overrides step 5. Pass a value to put several fits on one scale.