Skip to contents

This function computes the Global Dietary Quality Score (GDQS) from individual 24-hour dietary recall data. It maps reported food items to GDQS categories, aggregates intakes, applies scoring rules for each category, and calculates summary indices (GDQS+, GDQS-, overall GDQS, and risk classification). The function can either use the built-in food composition database (fct_db) from the dietrecallkitR GitHub repository or a user-supplied mapping table.

Usage

compute_gdqs(
  recall_data,
  id_col,
  food_item_col,
  actual_gram_intake_col = "actual_gram_intake",
  use_fct_db = FALSE,
  gdqs_map_data = NULL,
  gdqs_map_food = NULL,
  gdqs_map_col = NULL
)

Arguments

recall_data

A data frame containing at least an ID column, a food item column, and a numeric gram intake column.

id_col

Character string. Column name in recall_data identifying survey respondents or household IDs.

food_item_col

Character string. Column name in recall_data with reported food items.

actual_gram_intake_col

Character string. Column name in recall_data containing numeric gram intakes (default is "actual_gram_intake").

use_fct_db

Logical. If TRUE, mapping is automatically pulled from the built-in food composition database (fct_db). Cannot be used simultaneously with gdqs_map_data.

gdqs_map_data

Optional. A user-supplied mapping data frame that links food items to GDQS categories. Required if use_fct_db = FALSE.

gdqs_map_food

Character string. Column name in gdqs_map_data with food item names.

gdqs_map_col

Character string. Column name in gdqs_map_data with GDQS category names.

Value

A tibble with one row per respondent (ID). Output columns include:

  • gdqs_<category>: Numeric intakes per GDQS category.

  • gdqs_<category>_consumed: Binary indicator (0/1) if category consumed.

  • gdqs_<category>_points: Points allocated per GDQS scoring rules.

  • gdqs_plus: Sum of points from healthy GDQS categories.

  • gdqs_minus: Sum of points from unhealthy GDQS categories.

  • gdqs_overall: Total GDQS score (gdqs_plus + gdqs_minus).

  • gdqs_risk: Risk classification: "High" (<15), "Moderate" (15–22), or "Low" (>=23).

Details

The GDQS scoring algorithm follows established cutoffs for each category. Foods can belong to multiple GDQS categories, in which case their gram intake is divided equally across categories. If no mapped foods are found, the function returns zeros and assigns gdqs_risk = "High". Unmapped food items are listed via a warning message.

Examples

if (FALSE) { # \dontrun{
# Example with built-in fct_db
recall <- tibble::tibble(
  survey_id = 1:3,
  food_item = c("Beans, broad, dry, raw", "Sausage", "Orange (chungwa), pulp, raw"),
  actual_gram_intake = c(50, 100, 150)
)
result <- compute_gdqs(
  recall_data   = recall,
  id_col        = "survey_id",
  food_item_col = "food_item",
  use_fct_db    = TRUE
)

# Example with custom mapping
recall <- tibble::tibble(
  id = c(1, 2),
  food = c("Ugali", "Beans"),
  grams = c(200, 50)
)
gdqs_map <- tibble::tibble(
  item = c("Ugali", "Beans"),
  gdqs = c("Whole Grains", "Legumes")
)
result <- compute_gdqs(
  recall_data = recall,
  id_col = "id",
  food_item_col = "food",
  actual_gram_intake_col = "grams",
  use_fct_db = FALSE,
  gdqs_map_data = gdqs_map,
  gdqs_map_food = "item",
  gdqs_map_col = "gdqs"
)
} # }