R/attach_ZJU.R

Defines functions attach_ZJU

Documented in attach_ZJU

#' ZJU index
#' a novel model for detecting NAFLD (nonalcoholic fatty liver disease)
#'
#' @param data data
#' @param years years
#' @param Year logical
#' @details
#' ZJU = BMI(kg/m2) + fasting plasma glucose (mmol/L) + TG(mmol/L) +3 × ALT/AST ratio (+2, if female)
#' @return ZJU index
#' @export
#'
attach_ZJU <- function(data,years,Year=FALSE){
    years <- data_years(data,years)
    d <- attach_HemalBiochemistry(years = years,
                                  fast_glucose2 = 'fast_glucose',
                                  fast_triglyceride2 = 'fast_triglyceride',
                                  Alt = TRUE,Ast = TRUE,
                                  Year = TRUE) |>
        attach_bodyMeasure(BMI = TRUE) |>
        attach_demo(sex = TRUE)
    d$sex <- tolower(d$sex)
    d$sex <- ifelse(d$sex=='female',2,0)
    d$ratio <- d$Alt/d$Ast * 3

    d$ZJU <- rowSums(d[,c("BMI","fast_glucose","fast_triglyceride","ratio","sex")])
    d <- d[,c("Year","seqn","ZJU")]
    attach_return_data(data,d,Year,join='seqn')
}
yikeshu0611/nhanesR documentation built on Jan. 29, 2022, 6:08 a.m.