#' @title {Scoring the Eating Disorder Examination Questionnaire, short form (EDE-Q8)}
#' @description \emph{The Eating Disorder Examination-Questionnaire (EDE-Q) is a well-established self-report
#' questionnaire for the comprehensive assessment of eating disorder (ED) psychopathology.
#' It is based on the Eating Disorder Examination (EDE2), a structured clinical interview,
#' considered the method of choice for diagnosis and assessment of EDs.}
#' EDE-Q8 is a short form containing 8 items (Kliem et al. 2016).
#' @details
#' \itemize{
#' \item \code{Number of items:} {8}
#' \item \code{Item range:} {0 to 6}
#' \item \code{Reverse items:} {none}
#' \item \code{Score range:} {0 to 6}
#' \item \code{Cut-off-values:} {none}
#' \item \code{Minimal clinically important difference:} {none}
#' \item \code{Treatment of missing values:} {At least 4 valid items are required for calculating the score (Hilbert, Tuschen-Caffier 2016)}
#' }
#' @references
#' Kliem et al. 2016 (\url{http://doi.wiley.com/10.1002/eat.22487})
#'
#' Hilbert, Tuschen-Caffier 2016 (\url{http://dgvt-verlag.de/e-books/2_Hilbert_Tuschen-Caffier_EDE-Q_2016.pdf})
#' @return The function returns 2 variables:
#' \itemize{
#' \item \code{nvalid.edeq:} Number of valid values (MAX=8)
#' \item \code{score.edeq:} EDE-Q8 Score
##' }
#' @examples
#' \dontrun{
#' library(dplyr)
#' items.edeq8 <- paste0("EDEQ_", seq(1, 8, 1))
#' scoring_edeq8(mydata, items = items.edeq8)
#' }
#' @param data a \code{\link{data.frame}} containing the EDE-Q8 items
#' orderd from 1 to 8
#' @param items A character vector with the EDE-Q8 item names ordered from 1 to 8,
#' or a numeric vector indicating the column numbers of the EDE-Q8 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.
#' @param nvalid A numeric value indicating the number of non-missing items required for score
#' calculations. The default is 4.
#' @param digits Integer of length one: value to round to. No rounding by default.
#' @export
scoring_edeq8 <- function(data, items = 1:8, keep = TRUE, nvalid = 4, digits = NULL) {
library(dplyr, warn.conflicts = FALSE)
if (min(data[, items], na.rm = T) < 0) {
stop("Minimum possible value for EDE-Q8 items is 0")
} else if (max(data[, items], na.rm = T) > 6) {
stop("Maximum possible value for EDE-Q8 items is 6")
}
# check for number of specified items
if (length(items) != 8) {
stop("Number of items must be 8!")
}
data <- data %>%
mutate(
nvalid.edeq8 = rowSums(!is.na(select(., items))),
score.temp = rowSums(select(., items), na.rm = TRUE) / nvalid.edeq8,
score.edeq8 = ifelse(nvalid.edeq8 >= nvalid, score.temp, NA)
) %>%
select(-score.temp)
# Keep single items and nvalid variables
if (keep == FALSE) {
data <- data %>% select(-items, -nvalid.edeq8)
} else {
data <- data
}
# Rounding
if (is.numeric(digits) == TRUE) {
data <- data %>% mutate_at(vars(score.edeq8), list(~ round(., digits)))
} else {
data <- data
}
data
}
NULL
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.