Compute Household Food Insecurity Access (HFIA) Score and Category
Source:R/compute_hfias.R
compute_hfias.RdThis function computes the HFIA score and categorical classification (1-4) based on the standard HFIAS indicator framework developed by FANTA (Food and Nutrition Technical Assistance Project). The function assumes that the HFIAS-related variables are provided in the exact order they appear in the HFIAS questionnaire (occurrence and frequency pairs).
Details
The function expects 18 columns for the standard HFIAS tool: nine occurrence questions and nine corresponding frequency-of-occurrence questions, ordered as:
Occurrence Q1
Frequency Q1
Occurrence Q2
Frequency Q2
... up to Q9 and its frequency
Expected frequency responses:
"Rarely (1-2 times)" = 1
"Sometimes (3 to 10 times)" = 2
"Often (more than 10 times)" = 3
and occurrence responses:
"Yes" = 1
"No" = 0
Numeric inputs are accepted directly (0-3). Missing values are automatically replaced with 0, as frequency questions are typically skipped when occurrence is "No." After conversion, the function checks for any unexpected text entries and raises an informative error listing them for the user to clean.
Outputs:
hfia_score- The total sum of the nine frequency columns.hfia_category- A categorical classification:- 1
Food secure
- 2
Mildly food insecure
- 3
Moderately food insecure
- 4
Severely food insecure
References
Coates, J., Swindale, A., & Bilinsky, P. (2007). Household Food Insecurity Access Scale (HFIAS) for Measurement of Food Access: Indicator Guide (v3). Washington, D.C.: Food and Nutrition Technical Assistance Project (FANTA).
Examples
# Example dataset with respondent ID and realistic skip patterns
df <- tibble::tibble(
id = 1:3,
Q1 = c("Yes", "Yes", "No"),
F1 = c("Rarely (1-2 times)", "Often (more than 10 times)", NA),
Q2 = c("No", "Yes", "No"),
F2 = c(NA, "Sometimes (3 to 10 times)", NA),
Q3 = c("No", "Yes", "No"),
F3 = c(NA, "Rarely (1-2 times)", NA),
Q4 = c("No", "Yes", "No"),
F4 = c(NA, "Rarely (1-2 times)", NA),
Q5 = c("No", "Yes", "No"),
F5 = c(NA, "Often (more than 10 times)", NA),
Q6 = c("No", "Yes", "No"),
F6 = c(NA, "Rarely (1-2 times)", NA),
Q7 = c("No", "Yes", "No"),
F7 = c(NA, "Rarely (1-2 times)", NA),
Q8 = c("Yes", "Yes", "No"),
F8 = c("Sometimes (3 to 10 times)", "Rarely (1-2 times)", NA),
Q9 = c("No", "Yes", "No"),
F9 = c(NA, "Rarely (1-2 times)", NA)
)
# Compute HFIA score and category using the relevant columns only
compute_hfias(
df,
hfia_cols = c(
"Q1", "F1", "Q2", "F2", "Q3", "F3", "Q4", "F4",
"Q5", "F5", "Q6", "F6", "Q7", "F7", "Q8", "F8",
"Q9", "F9"
)
)
#> # A tibble: 3 × 21
#> id Q1 F1 Q2 F2 Q3 F3 Q4 F4 Q5 F5 Q6 F6
#> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int>
#> 1 1 1 1 0 0 0 0 0 0 0 0 0 0
#> 2 2 1 3 1 2 1 1 1 1 1 3 1 1
#> 3 3 0 0 0 0 0 0 0 0 0 0 0 0
#> # ℹ 8 more variables: Q7 <int>, F7 <int>, Q8 <int>, F8 <int>, Q9 <int>,
#> # F9 <int>, hfia_score <dbl>, hfia_category <int>