R/dii.R

Defines functions dii

Documented in dii

#' calculate dietary inflammatory index
#'
#' @param component one componet name
#' @param x value
#' @references Shivappa, N, Steck, et al. Designing and developing a literature-derived, population-based dietary inflammatory index[J]. Public Health Nutrition Cab International, 2014.
#' @return DII
#' @export
#'
dii <- function(component,x){
    diitable <- list(
        "alcohol" = c(-0.278, 13.98, 3.72,-0.278),
        "anthocyanidins" = c(-0.131, 18.05, 21.14,-0.449),
        "b_carotene" = c(-0.584, 3718, 1720, -0.584),
        "caffeine" = c(-0.11, 8.05, 6.67, -0.124),
        "carbohydrates" = c(0.097, 272.2, 40, 0.109),
        "cholesterol" = c(0.11, 279.4, 51.2, 0.347),
        "energy" = c(0.18,2056, 338, 0.180),
        "eugenol" = c(-0.14, 0.01, 0.08, -0.868),
        "fibre" = c(-0.663, 18.8, 4.9, -0.663),
        "flavan-3-ol" = c(-0.415, 95.8, 85.9,-0.415),
        "flavones" = c(-0.616, 1.55, 0.07,-0.616),
        "flavonols" = c(-0.467, 17.7, 6.79,-0.467),
        "flavonones" = c(-0.25, 11.7, 3.82,-0.908),
        "folic_acid" = c(-0.19, 273, 70.7, -0.207),
        "Fe" = c(0.032, 13.35, 3.71, 0.032),
        "garlic" = c(-0.412, 4.35, 2.9, -0.412),
        "ginger" = c(-0.453, 59, 63.2, -0.588),
        "green/black_tea" = c(-0.536, 1.69, 1.53,-0.536),
        "isoflavones" = c(-0.593, 1.2, 0.2,-0.593),
        "Mg" = c(-0.484,310.1, 139.4, -0.484),
        "MUFA" = c(-0.009, 27, 6.1, -0.019),
        "niacin" = c(-0.246, 25.9, 11.77, -1),
        "n-3_fatty_acids" = c(-0.436, 1.06, 1.06, -0.436),
        "n-6_fatty_acids" = c(-0.159, 10.8, 7.5, -0.159),
        "onion" = c(-0.301, 35.9, 18.4, -0.49),
        "pepper" = c(-0.131, 10, 7.07,-0.397),
        "protein" = c(0.021, 79.4, 13.9, 0.049),
        "PUFA" = c(-0.337, 13.88, 3.76, -0.337),
        "riboflavin" = c(-0.068, 1.7, 0.79, -0.727),
        "rosemary" = c(-0.013, 1, 15, -0.333),
        "saffron" = c(-0.14, 0.37, 1.78,1),
        "saturated_fat" = c(0.373, 28.6, 8, 0.429),
        "selenium" = c(-0.191, 67, 25.1, -0.191),
        "tfat" = c(0.298, 71.4, 19.4, 0.298),
        "thiamin" = c(-0.098, 1.7, 0.66,-0.354),
        "thyme/oregano" = c(-0.102, 0.33, 0.99,-1),
        "trans_fat" = c(0.229, 3.15, 3.75,0.432),
        "turmeric" = c(-0.785, 533.6, 754.3,-0.785),
        "vb12" = c(0.106, 5.15, 2.7,0.205),
        "vb6" = c(-0.365, 1.47, 0.74, -0.379),
        "vitamin_A" = c(-0.401, 983.9, 518.6,-0.401),
        "vitamin_C" = c(-0.424, 118.2, 43.46,-0.424),
        "vitamin_D" = c(-0.446, 6.26, 2.21,-0.446),
        "vitamin_E" = c(-0.419, 8.73, 1.49,-0.419),
        "zinc" = c(-0.313, 9.84, 2.19,-0.313)
    )
    if (missing(component)){
        df <- data.frame(diitable) |> t() |> as.data.frame()
        colnames(df) <- c('Overall inflammatory effect score',
                          'Global daily mean intake(units/d)',
                          'SD','Raw inflammatory effect score')
        return(df[,c(4,1,2,3)])
    }
    if (!component %in% names(diitable)){
        component <- select.list(names(diitable),multiple = FALSE,
                                 title = ifelse(do::cnOS(),
                                                tmcn::toUTF8("\u8BF7\u9009\u62E9\u4E00\u4E2A\u5BF9\u5E94\u7684\u5E8F\u53F7,\u7136\u540E\u6309\u56DE\u8F66\u952E"),
                                                'Select one choice number'))
    }
    d <- diitable[[component]]
    (pnorm((x-d[2])/d[3])*2-1)*d[1]
}
yikeshu0611/nhanesR documentation built on Jan. 29, 2022, 6:08 a.m.