Package 'heiscore'

Title: Score and Plot the Healthy Eating Index from NHANES Data
Description: Calculate and visualize Healthy Eating Index (HEI) scores from National Health and Nutrition Examination Survey 24-hour dietary recall data utilizing three methods recommended by the National Cancer Institute (2024) <https://epi.grants.cancer.gov/hei/hei-methods-and-calculations.html#:~:text=To%20use%20the%20simple%20HEI,the%20total%20scores%20across%20individuals.>. Effortlessly analyze HEI scores across different demographic groups and years.
Authors: Vijetha Ramdas [aut, cre], Berkeley Ho [aut], Abhra Sarkar [aut]
Maintainer: Vijetha Ramdas <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2024-11-04 22:34:04 UTC
Source: https://github.com/abhrastat/heiscore

Help Index


Plot Healthy Eating Index (HEI) scores from NHANES data

Description

This function plots HEI component or total scores using the inputted scoring method and graph type. The user can subset the data to only include subjects in specific demographic groups

Usage

plotScore(
  graph = NULL,
  method,
  years,
  component,
  demo = NULL,
  sex = c("Female", "Male"),
  race = c("Asian", "White", "Black", "Other", "Mexican American", "Other Hispanic"),
  age = c(2, 100),
  income = c("[0, 5000)", "[5000, 10000)", "[10000, 15000)", "[15000, 20000)",
    "[20000, 25000)", "[25000, 35000)", "[35000, 45000)", "[45000, 55000)",
    "[55000, 65000)", "[65000, 75000)", "75000+", "[75000, 100000)", ">100000", ">20000",
    "<20000", "Refused", "Don't know", "NA")
)

Arguments

graph

A single character string with the desired graph type. Choose "histogram" when method = "simple". Choose "bar" when method = "pop ratio" or "mean ratio" and component is not "total score". Choose "bar" or "radar" when method = "pop ratio" or "mean ratio" and component = "total score"

method

A single character string with the HEI scoring method to use. Choose from "simple", "pop ratio", or "mean ratio".

years

A single character string representing the NHANES cycle to select, choose from: "0506", "0708", "0910", "1112", "1314", "1516", "1718", or "1720".

component

A single character string with the HEI component to score and plot. Options include "total score", "total fruit", "whole fruits", "total vegetables", "greens and beans", "whole grains", "total dairy", "total protein", "seafood and plant proteins", "fatty acids", "refined grains", "sodium", "added sugars", and "saturated fat".

demo

A single character string with the demographic grouping by which the data should be scored or NULL. If method = "simple", choose NULL as the demo. Otherwise, choose from "sex", "race", "age", or "income". If the "1720" cycle is selected, "income" is not a valid demo choice since this variable is not provided in the NHANES 2017-March 2020 data.

sex

A vector of the sexes in the desired subpopulation. Provide a vector with the character strings "Female", "Male", or both.

race

A vector of races/ethnicities in the desired subpopulation. Provide a vector including any combination of the following character strings: "Asian", "White", "Black", "Other", "Mexican American", and "Other Hispanic".

age

A vector in the form c(min, max) with two integers specifying the desired age range to analyze. Both integers should either be ones (to represent the toddler age group including ages 12-23 months) or 2 and above.

income

A vector of family income brackets in the desired subpopulation. Provide a vector including any combination of the following character strings: "[0, 5000)","[5000, 10000)","[10000, 15000)","[15000, 20000)","[20000, 25000)","[25000, 35000)", "[35000, 45000)","[45000, 55000)","[55000, 65000)","[65000, 75000)","[75000, 100000)", "75000+",">100000", ">20000","<20000","Refused","Don't know", "NA". For the "1720" cycle, all observations have "NA" as the FAMINC variable since this variable is not provided in the NHANES 2017-March 2020 data.

Value

A base R plot or a ggplot object with the specified plot

Examples

# Plot the Total Dairy component score from the 2005-06 NHANES data using the
# "simple" method.

dairy_plot <- plotScore(graph = "histogram",
                        method = "simple",
                        years = "0506",
                        component = "total dairy")
dairy_plot

# Create a radar plot to display the total HEI score by race/ethnicity using
# the mean ratio method for subjects that are male, more than 50 years old,
# with a family income in the range [65000, 75000) for the 2015-16 NHANES
# cycle.
radar_example_plot <- plotScore(graph = "radar",
                    method = "mean ratio",
                    years = "1516",
                    component = "total score",
                    demo = "race",
                    sex = "Male",
                    age = c(50, 150),
                    income = "[65000, 75000)")
radar_example_plot

Launch Shiny app to visualize Healthy Eating Index (HEI) scores

Description

This function launches a Shiny application that allows users to visualize HEI scores calculated from National Health and Nutrition Examination Survey (NHANES) 24-hour dietary recall data.

Usage

runShinyApp()

Value

No return value, launches interactive Shiny app

Shiny App Tab Information

Tab 1 - Variable Information: The Variable Information tab provides additional information on dietary components and constituents.

Tab 2 - Demographics: The Demographics tab displays a bar chart that illustrates the distribution of the NHANES sample across categories including sex, race, age, and income. The chart is weighted to ensure the distribution is aligned with the demographics of the entire United States.

Side Panel Options

  • Select Dataset: Choose the years that the data is from

  • Choose a Demographic: Pick a demographic category to view the distribution of

  • Select Sex/Race/Age Bracket/Income Bracket:Use the checkboxes to only use data from the desired demographic subgroup

Tab 3 - Recalls: The Recalls tab displays a histogram of the raw consumption of the selected food group, weighted to make the distribution representative of the United States.

Side Panel Options

  • Select Dataset: Choose the years that the data is from

  • Select Component Type: Choose to view dietary components or constituents (explained in the Variable Information tab)

  • Select Variable: Pick a specific dietary component or constituent to view the distribution of

  • Select Sex/Race/Age Bracket/Income Bracket: Use the checkboxes to only use data from the desired demographic subgroup

Below Plot Options

  • Select Plot Type: Choose the type of graph used to visualize the data

  • Options:

    • Adjusted per 1000 Calories: When the checkbox is selected, the histogram will show the distribution of the amount of the chosen dietary component consumed per 1000 kcal in each recall

    • Plot Average: When the checkbox is selected, the histogram will show the distribution of the average of participants’ two recalls, if the individual participated in both recalls. Otherwise, the participant’s single recall will be used instead.

  • X-Axis Options:

    • Keep X-Axis Constant for Recall Component: This option makes the x-axis bounds the same for the selected recall component across all years and demographic subsets.

    • Make X-Axis Proportional to Maximum: This option sets the x-axis bounds from 0 to 20. The maximum recall value of the chosen food group within the selected year and demographic subgroup is set as 20, and all other recall values are assigned proportionally to the maximum value on a scale from 0 to 20.

    • Raw Values: No adjustments are made to the x-axis bounds

  • Select Radar Plot Demographic: When the Plot Type is ‘Radar’, choose the demographic category by which the recalls will be categorized

Tab 4 - Scoring: The Scoring tab visualizes HEI scores from NHANES data. The graphs are weighted to make the distributions representative of the United States.

Side Panel Options

  • Choose a Scoring Method: Select which HEI scoring method to implement.

  • Select Dataset: Choose the years that the data is from

  • Compare with a Second Dataset: Choose the years that the data for the optional second plot is from

  • Select Variable: Pick to view the total HEI score or one of the 13 individual component scores.

  • Select Age Group: Choose to include data either from Toddlers from 12-23 months old or older individuals since these two age groups have different HEI scoring standards.

  • Choose a Demographic: When the Scoring Method is ‘Mean Ratio’ or ‘Population Ratio’, choose the demographic category by which the scores will be categorized

  • Select Sex/Race/Age Bracket/Income Bracket: Use the checkboxes to only use data from the desired demographic subgroup

Below Plot Options

  • Select a scoring display option: Choose the type of graph used to visualize the data

Examples

runShinyApp()

Calculate Healthy Eating Index (HEI) scores from NHANES data

Description

This function calculates HEI component or total scores using the inputted scoring method. The user can subset the data to only include subjects in specific demographic groups

Usage

score(
  method,
  years,
  component,
  demo = NULL,
  sex = c("Female", "Male"),
  race = c("Asian", "White", "Black", "Other", "Mexican American", "Other Hispanic"),
  age = c(2, 100),
  income = c("[0, 5000)", "[5000, 10000)", "[10000, 15000)", "[15000, 20000)",
    "[20000, 25000)", "[25000, 35000)", "[35000, 45000)", "[45000, 55000)",
    "[55000, 65000)", "[65000, 75000)", "[75000, 100000)", "75000+", ">100000", ">20000",
    "<20000", "Refused", "Don't know", "NA")
)

Arguments

method

A single character string with the HEI scoring method to use. Choose from "simple", "pop ratio", or "mean ratio".

years

A single character string representing the NHANES cycle to select, choose from: "0506", "0708", "0910", "1112", "1314", "1516", "1718", or "1720".

component

A single character string with the HEI component to score and plot. Options include "total score", "total fruit", "whole fruits", "total vegetables", "greens and beans", "whole grains", "total dairy", "total protein", "seafood and plant proteins", "fatty acids", "refined grains", "sodium", "added sugars", and "saturated fat".

demo

A single character string with the demographic grouping by which the data should be scored or NULL. If method = "simple", choose NULL as the demo. Otherwise, choose from "sex", "race", "age", or "income". If the "1720" cycle is selected, "income" is not a valid demo choice since this variable is not provided in the NHANES 2017-March 2020 data.

sex

A vector of the sexes in the desired subpopulation. Provide a vector with the character strings "Female", "Male", or both.

race

A vector of races/ethnicities in the desired subpopulation. Provide a vector including any combination of the following character strings: "Asian", "White", "Black", "Other", "Mexican American", and "Other Hispanic".

age

A vector in the form c(min, max) with two integers specifying the desired age range to analyze. Both integers should either be ones (to represent the toddler age group including ages 12-23 months) or 2 and above.

income

A vector of family income brackets in the desired subpopulation. Provide a vector including any combination of the following character strings: "[0, 5000)","[5000, 10000)","[10000, 15000)","[15000, 20000)","[20000, 25000)","[25000, 35000)", "[35000, 45000)","[45000, 55000)","[55000, 65000)","[65000, 75000)","[75000, 100000)", "75000+",">100000", ">20000","<20000","Refused","Don't know", "NA". For the "1720" cycle, all observations have "NA" as the FAMINC variable since this variable is not provided in the NHANES 2017-March 2020 data.

Value

A tibble with HEI scores for the selected component for each individual (when method = "simple") or by demographic grouping specified in demo.

Examples

# Calculate the Total Fruit component score from the 2017-18 NHANES data
# using the 'simple' method.
score(method = "simple",
                    years = "1718",
                    component = "Total Fruit",
                    demo = NULL)

# Calculate the total HEI score by sex using the population ratio method for
# White and Black individuals between ages 5 and 10 with a family income
# between 5000abd 15000 in the 2011-12 NHANES cycle.
score(method = "pop ratio",
                    years = "1112",
                    component = "total score",
                    demo = "sex",
                    race = c("White", "Black"),
                    age = c(5,10),
                    income = c("[5000, 10000)", "[10000, 15000)"))

Retrieve a tibble with WWEIA NHANES data

Description

This function retrieves a tibble containing the raw 24-hour recall data from the What We Eat in America (WWEIA), National Health and Nutrition Examination Survey (NHANES) converted to the U.S. Department of Agriculture (USDA) Food Patterns components from the NHANES cycle selected.

Usage

selectDataset(years)

Arguments

years

A single character string representing the NHANES cycle to select, choose from: "0506", "0708", "0910", "1112", "1314", "1516", "1718", and "1720".

Value

A tibble containing Food Patterns component consumption, sample weights, and demographic information for each subject in the selected NHANES cycle.

Examples

# Retrieve WWEIA NHANES data for the 2015-2016 cycle
FPED_1516 <- selectDataset(years = "1516")
FPED_1516

# Retrieve WWEIA NHANES data for the years 2017-2018
FPED_1718 <- selectDataset(years = "1718")
FPED_1718