#' @title {Scoring the Yale Food Addiction Scale, Version 2.0 (YFAS V2.0)}
#' @description {The Yale Food Addiction Scale, Version 2.0 (YFAS V2.0) measures addiction-like eating
#' of palatable foods based on the eleven diagnostic criteria for substance use disorder
#' in the fifth revision of the Diagnostic and Statistical Manual of Mental Disorders (DSM-5).}
#' @details
#' \itemize{
#' \item \code{Number of items:} {35}
#' \item \code{Item range:} {0 to 7}
#' \item \code{Reverse items:} {none}
#' \item \code{Score range:} {0 to 11 SUD (Substance Use Disorder) criteria}
#' \item \code{Cut-off-values:} {\code{mild} = 2–3 symptoms plus impairment or distress;
#' \code{moderate} = 4–5 symptoms plus impairment or distress;
#' \code{severe} = 6 or more symptoms plus impairment or distress}
#' \item \code{Minimal clinically important difference:} {none}
#' \item \code{Treatment of missing values:} {not reported}
#' }
#' @references
#' Schulte, Gearhardt 2017 (\url{http://doi.wiley.com/10.1002/erv.2515})
#'
#' Meule et al. 2017 (\url{https://doi.org/10.1026/0012-1924/a000047})
#' @return Based on the dichotomized YFAS items, the function returns 14 variables:
#' \itemize{
#' \item \code{score.yfas.act:} Activity Score (4 items)
#' \item \code{score.yfas.amo:} Amount Score (3 items)
#' \item \code{score.yfas.att:} Attempts Score (4 items)
#' \item \code{score.yfas.con:} Consequences Score (2 items)
#' \item \code{score.yfas.cra:} Craving Score (2 items)
#' \item \code{score.yfas.obl:} Obligations Score (2 items)
#' \item \code{score.yfas.pro:} Problems Score (3 items)
#' \item \code{score.yfas.sit:} Situations Score (3 items)
#' \item \code{score.yfas.tim:} Time Score (3 items)
#' \item \code{score.yfas.tol:} Tolerance Score (2 items)
#' \item \code{score.yfas.wit:} Withdrawal Score (5 items)
#' \item \code{score.yfas.imp:} Impairment Score (2 items)
#' \item \code{score.yfas.sympnum:} Number of Symptoms (MAX = 11)
#' \item \code{cutoff.yfas.foodadd:} Food Addiction, categorized
#' }
#' @examples
#' \dontrun{
#' library(dplyr)
#' items.yfas <- paste0("YFAS_", seq(1, 35, 1))
#' scoring_yfas(mydata, items = items.yfas)
#' }
#' @param data a \code{\link{data.frame}} containing the YFAS 2.0 items orderd from 1 to 35.
#' The \code{\link{data.frame}} may contain further variables.
#' @param items A character vector with the YFAS 2.0 item names ordered from 1 to 35,
#' or a numeric vector indicating the column numbers of the YFAS 2.0 items in \code{data}.
#' @param keep Logical, whether to keep the single items and whether to return variables containing
#' the number of non-missing items on each scale for each respondent. The default is TRUE.
#' @export
scoring_yfas <- function(data, items = 1:35, keep = TRUE) {
library(dplyr, warn.conflicts = FALSE)
if (min(data[, items], na.rm = T) < 0) {
stop("Minimum possible value for YFAS 2.0 items is 0")
} else if (max(data[, items], na.rm = T) > 7) {
stop("Maximum possible value for YFAS 2.0 items is 7")
}
# check for number of specified items
if (length(items) != 35) {
stop("Number of items must be 35!")
}
items <- items
data <- data %>%
mutate_at(
vars(items[c(9, 10, 19, 27, 33, 35)]),
list(~ifelse(. >= 2, 1, 0))
) %>%
mutate_at(
vars(items[c(8, 18, 20, 21, 34)]),
list(~ifelse(. >= 3, 1, 0))
) %>%
mutate_at(
vars(items[c(3, 11, 13, 14, 22, 28, 29)]),
list(~ifelse(. >= 4, 1, 0))
) %>%
mutate_at(
vars(items[c(5, 12, 16, 17, 23, 24, 26, 30, 31, 32)]),
list(~ifelse(. >= 5, 1, 0))
) %>%
mutate_at(
vars(items[c(1, 2, 4, 6, 7, 15, 25)]),
list(~ifelse(. >= 6, 1, 0))
) %>%
mutate(
nvalid.yfas = rowSums(!is.na(select(., items))),
score.yfas.act = ifelse(rowSums(select(., items[c(8, 10, 18, 20)]), na.rm = TRUE) >= 1, 1, 0),
score.yfas.amo = ifelse(rowSums(select(., items[c(1, 2, 3)]), na.rm = TRUE) >= 1, 1, 0),
score.yfas.att = ifelse(rowSums(select(., items[c(4, 25, 31, 32)]), na.rm = TRUE) >= 1, 1, 0),
score.yfas.con = ifelse(rowSums(select(., items[c(22, 23)]), na.rm = TRUE) >= 1, 1, 0),
score.yfas.cra = ifelse(rowSums(select(., items[c(29, 30)]), na.rm = TRUE) >= 1, 1, 0),
score.yfas.obl = ifelse(rowSums(select(., items[c(19, 27)]), na.rm = TRUE) >= 1, 1, 0),
score.yfas.pro = ifelse(rowSums(select(., items[c(9, 21, 35)]), na.rm = TRUE) >= 1, 1, 0),
score.yfas.sit = ifelse(rowSums(select(., items[c(28, 33, 34)]), na.rm = TRUE) >= 1, 1, 0),
score.yfas.tim = ifelse(rowSums(select(., items[c(5, 6, 7)]), na.rm = TRUE) >= 1, 1, 0),
score.yfas.tol = ifelse(rowSums(select(., items[c(24, 25)]), na.rm = TRUE) >= 1, 1, 0),
score.yfas.wit = ifelse(rowSums(select(., items[c(11:15)]), na.rm = TRUE) >= 1, 1, 0)
) %>%
mutate(
score.yfas.sympnum = rowSums(select(., starts_with("score.yfas")), na.rm = TRUE),
score.yfas.sympnum = ifelse(nvalid.yfas == 0, NA, score.yfas.sympnum),
score.yfas.imp = if_else(rowSums(select(., items[c(16, 17)])) >= 1, 1, 0, as.numeric(NA)),
cutoff.yfas.foodadd = case_when(
score.yfas.sympnum >= 6 & score.yfas.imp == 1 ~ "Severe",
score.yfas.sympnum >= 4 & score.yfas.imp == 1 ~ "Moderate",
score.yfas.sympnum >= 2 & score.yfas.imp == 1 ~ "Mild",
is.na(score.yfas.sympnum) | is.na(score.yfas.imp) ~ as.character(NA),
TRUE ~ "None"
),
cutoff.yfas.foodadd = factor(cutoff.yfas.foodadd, levels = c("Severe", "Moderate", "Mild", "None"))
)
if (keep == FALSE) {
data <- data %>% select(-items)
} else {
data <- data
}
}
NULL
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.