This is something I've been doing a bit recently and have done in the past. Have also had conversations with other people where they have needed to do the same thing.
University of Edinburgh do it here https://github.com/SurgicalInformatics/chiTools which I think is a pretty fast implementation (although could probably be faster with gsub instead of stringr) but would need some modification to align with phsmethods other CHI related functions.
I like the idea of the UoE cutoff_year param, could also have a max_age param which would serve the same purpose but obviously take input slightly differently.
This is something I've been doing a bit recently and have done in the past. Have also had conversations with other people where they have needed to do the same thing.
University of Edinburgh do it here https://github.com/SurgicalInformatics/chiTools which I think is a pretty fast implementation (although could probably be faster with gsub instead of stringr) but would need some modification to align with phsmethods other CHI related functions.
I think my implementation https://github.com/Health-SocialCare-Scotland/cocin-scotland/blob/master/functions/fix_age_sex_from_chi.R is probably slower, it also has a fixed max age.
I like the idea of the UoE cutoff_year param, could also have a max_age param which would serve the same purpose but obviously take input slightly differently.