diff --git a/.Rbuildignore b/.Rbuildignore index 22e5b00..0a3aefc 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,6 +5,8 @@ README.html ^\.github$ ^\.git$ +^CITATION\.cff$ +^llms\.txt$ ^validate_package\.R$ ^validate_report\.json$ ^AGENTS\.md$ diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..470f1f6 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,14 @@ +cff-version: 1.2.0 +message: "If you use this software, please cite it as below." +authors: +- family-names: "Merino-Soto" + given-names: "César" + orcid: "https://orcid.org/0000-0002-1407-8306" +- family-names: "Livia-Segovia" + given-names: "José" +- family-names: "Livia-Ortiz" + given-names: "Diego" +title: "ValCont: R package for content validity analysis" +version: 0.1.1 +date-released: 2026-10-13 +url: "https://github.com/Diegolivia/ValCont/" diff --git a/DESCRIPTION b/DESCRIPTION index f2f5ac7..6cd6101 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: ValCont Type: Package Title: Content Validation Using Vaiken and Other Functions -Version: 0.1.0 +Version: 0.1.1 Authors@R: c( person( "Cesar", "Merino-Soto", diff --git a/NAMESPACE b/NAMESPACE index 0b8766c..c096975 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -17,7 +17,6 @@ export(CVRcut.Wilson) export(CVplot) export(ColquittHT) export(D2) -export(HTmult) export(Haiken) export(LuAgree) export(MDScontent) diff --git a/NEWS.md b/NEWS.md index 2310409..ea82964 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,32 @@ # ValCont News +## ValCont 0.1.1 + +### Added + +- Added `RobinsonA()` for generalized Robinson agreement coefficients, bootstrap confidence intervals, and leave-one-out diagnostics for judges and items. +- Added Cohen's h, with optional confidence intervals, to `CID()` for standardized comparisons of content-validity coefficients. +- Added grouped analyses and pairwise MOVER comparisons to `LuAgree()`, together with percentile, normal, and BCa bootstrap confidence intervals. +- Added project citation metadata in `CITATION.cff` and `llms.txt`. + +### Changed + +- Expanded `CVC()` with global and Hernandez overall estimates, configurable Wilson or MER confidence intervals, and support for missing-value handling. +- Improved `Haiken()` bootstrap inference with percentile, basic, normal, BCa, and automatic interval selection, plus clear guidance for small panels. +- Updated `MDScontent()` aggregation and plotting behavior, documentation, and examples. +- Clarified interpretation of negative SVC values in `SVALmult()`. +- Updated `LuAgree()`, `Vaiken()`, and related function documentation and missing-value handling. +- Excluded `CITATION.cff` and `llms.txt` from source-package builds. + +### Removed + +- Removed the deprecated `HTmult()` implementation and its exported namespace entry and documentation. + +### Fixed + +- Corrected the `MDScontent()` example so CRAN checks can parse and run it. +- Improved missing-value validation and complete-case handling in CVC, CID, Haiken, LuAgree, MDS, and substantive-validity functions. + ## ValCont 0.1.0 ### Added diff --git a/R/CID.R b/R/CID.R index bdbf2bc..6703164 100644 --- a/R/CID.R +++ b/R/CID.R @@ -1,158 +1,189 @@ -#'@title Confidence interval for diference of content validity coefficients -#'@description Calculates confidence interval for the difference of content validity coefficients, based on Method of Variance Estimates Recovery (MOVER). -#' -#'@param group1 Output dataframe 1 of one of the 'ValCont' functions to obtain content validity coefficients. -#'@param group2 Output Output dataframe 2 of one of the 'ValCont' functions to obtain content validity coefficients. -#'@param coef.col Name of the column in the dataframe storing the calculated coefficient -#'@param lwr.col Name of the column in the dataframe that stores the lower bound of the confidence interval -#'@param upr.col Name of the column in the dataframe that stores the upper limit of the confidence interval -#'@param na.rm Logical. If FALSE (default) the function stops when missing values are detected. -#' If TRUE rows with missing values in the relevant columns are removed before processing. -#'@return -#'dataframe with four columns: label of the items, difference between the coefficients, the upper and upper limit of the confidence interval of the difference. +#'@title Confidence interval for difference of content validity coefficients +#'@description Calculates confidence interval for the difference of content validity +#' coefficients (MOVER; Zou & Donner, 2008) and, optionally, the standardized +#' difference via Cohen's h (arcsine transformation). +#' +#'@param group1 Output dataframe 1 of one of the 'ValCont' functions. +#'@param group2 Output dataframe 2 of one of the 'ValCont' functions. +#'@param coef.col Name of the column storing the coefficient. +#'@param lwr.col Name of the column storing the lower CI bound. +#'@param upr.col Name of the column storing the upper CI bound. +#'@param n1 Optional. Number of judges in group 1 (single positive number). +#' Required, together with \code{n2}, to compute the CI of Cohen's h. +#'@param n2 Optional. Number of judges in group 2 (single positive number). +#'@param conf.level Confidence level for the CI of Cohen's h (default .95). +#' Should match the level used to build the input CIs (e.g., .90 or .95). +#' Ignored when \code{n1} or \code{n2} are \code{NULL}. +#'@param na.rm Logical. If FALSE (default) the function stops when missing +#' values are detected in the required columns. If TRUE, those rows are removed. +#' +#'@return A data.frame with columns: +#' \item{Delta}{Difference between the coefficients (group1 - group2).} +#' \item{lwr.ci, upr.ci}{MOVER CI for Delta.} +#' \item{h}{Cohen's h (standardized difference, arcsine scale).} +#' \item{h.lwr, h.upr}{CI for h. Only present if \code{n1} and \code{n2} are supplied.} +#' Row names preserve the item labels. #' #'@details -#'`CID` uses Method of Variance Estimates Recovery (MOVER; Zou, & Donner, 2008). -#'Because data produced by judges' judgments tend to be asymmetrically distributed (if the item is rated, on a scale of 1 to 5, as predominantly valid then its values will be > 3), MOVER is appropriate for non-normal distributions. -#'MOVER depends on the quality or precision of the confidence intervals calculated for the coefficients in each group. -#'The application of MOVER for content validity coefficient was initially published by Merino-Soto (2018) for the difference between V coefficients (Aiken, 1980, 1985). Later, Merino-Soto (2023) extended this approach for Aiken's V by adding a point estimator of the difference, based on the standardized difference between proportions. -#'The compared content validity coefficients obtained should be of the same type, and the estimated confidence intervals for these coefficients should also come from the same level; for example, at .95 or .90. -#'Singer (2010) observed that at extremely low values (e.g., proportions near .0), the coverage of this method is not as good. In the context of comparing content validity coefficients, treated as proportions, it is rare to find such very low coefficients (and their confidence intervals). Unless the items are extremely poor in content. +#'\code{CID} uses the Method of Variance Estimates Recovery (MOVER; Zou & Donner, 2008) +#'for the difference of two content validity coefficients. +#' +#'When \code{n1} and \code{n2} are supplied, the function also returns Cohen's h +#'(Cohen, 1988), the arcsine-transformed standardized difference: +#'\deqn{h = 2\arcsin(\sqrt{p_1}) - 2\arcsin(\sqrt{p_2})} +#'with variance approximated by \eqn{1/n_1 + 1/n_2}. The factor 2 makes the +#'effect size comparable to Cohen's benchmarks (0.2 small, 0.5 medium, 0.8 large). +#'Cohen's h is especially appropriate for proportions near 0 or 1, where the +#'raw difference and its CI become unstable. The benchmarks are generic; +#'interpret them in the substantive context of the instrument. #' #'@references -#'Aiken, L. R. (1980). Content validity and reliability of single items or questionnaires. \emph{Educational and. Psychological Measurement, 40}, 955-959. \doi{10.1177/001316448004000419} -#' -#'Aiken, L. R. (1985). Three coefficients for analyzing the reliability and validity of ratings. \emph{Educational and Psychological Measurement, 45}, 131-142. \doi{10.1177/0013164485451012} -#' -#'Merino-Soto, C. (2018) Confidence interval for difference between coefficients of content validity (Aiken's V): a SPSS syntax. \emph{Anales de Psicologia, 34}(3), 587-590. \doi{10.6018/analesps.34.3.283481} +#'Cohen, J. (1988). \emph{Statistical power analysis for the behavioral sciences} +#'(2nd ed.). Lawrence Erlbaum. #' -#'Merino-Soto, C. (2023). Coeficientes V de Aiken: diferencias en los juicios de validez de contenido. \emph{MHSalud, 20}(1), 23-32. \doi{10.15359/mhs.20-1.3} +#'Merino-Soto, C. (2018). Confidence interval for difference between coefficients +#'of content validity (Aiken's V): a SPSS syntax. \emph{Anales de Psicologia, 34}(3), +#'587-590. \doi{10.6018/analesps.34.3.283481} #' -#'Singer, J. (2010). Construction of confidence limits about effect measures: A general approach, by G. Y. Zou and A. Donner, Statistics in Medicine 2008; 27:1693-1702. Statistics in Medicine, 29(16), 1757-1759. https://doi.org/10.1002/sim.3887 +#'Merino-Soto, C. (2023). Coeficientes V de Aiken: diferencias en los juicios de +#'validez de contenido. \emph{MHSalud, 20}(1), 23-32. \doi{10.15359/mhs.20-1.3} #' -#'Zou, G.Y. and Donner, A. (2008) Construction of confidence limits about effect measures: a general approach. Stat. Med. 27, 1693-1702. https://doi.org//10.1002/sim.3095 +#'Zou, G.Y., & Donner, A. (2008). Construction of confidence limits about effect +#'measures: A general approach. \emph{Statistics in Medicine, 27}, 1693-1702. +#'\doi{10.1002/sim.3095} #' -#'@author -#'Cesar Merino-Soto (\email{sikayax@yahoo.cam.ar}) +#'@author Cesar Merino-Soto (\email{sikayax@yahoo.cam.ar}) #' -#'@seealso -#'\code{\link[ratesci:moverci]{ratesci::moverci}} -#'\code{\link[ValCont:CIDsingle]{ValCont::CIDsingle}} +#'@seealso \code{\link[ratesci:moverci]{ratesci::moverci}} #' #'@examples -#' -#'### Example 1 ----------- -#' -#'## Group 1 output -#' #'Vgroup1 <- data.frame( -#' V = c(0.85, 0.78, 0.90), -#' lwr.ci = c(0.80, 0.75, 0.88), -#' upr.ci = c(0.90, 0.82, 0.92) +#' V = c(0.85, 0.78, 0.90), +#' lwr.ci = c(0.80, 0.75, 0.88), +#' upr.ci = c(0.90, 0.82, 0.92) #') #'rownames(Vgroup1) <- c("Item1", "Item2", "Item3") #' -#'## Group 2 output -#' #'Vgroup2 <- data.frame( -#' V = c(0.80, 0.75), -#' lwr.ci = c(0.76, 0.70), -#' upr.ci = c(0.84, 0.78) +#' V = c(0.80, 0.75), +#' lwr.ci = c(0.76, 0.70), +#' upr.ci = c(0.84, 0.78) #') #'rownames(Vgroup2) <- c("Item1", "Item2") #' -#'## Run -#'CID(Vgroup1, Vgroup2,"V","lwr.ci","upr.ci") -#' -#'### Example 2 ----------- -#' -#'## Random data (Low ratings): 11 items (rows), 4 raters (columns) -#' -#'random_data2 <- data.frame( -#' juez1 = sample(1:2, 11, replace = TRUE), -#' juez2 = sample(2:3, 11, replace = TRUE), -#' juez3 = sample(1:2, 11, replace = TRUE), -#' juez4 = sample(1:3, 11, replace = TRUE)) -#' -#'## Random data (High ratings): 10 items (rows), 6 raters (columns) -#' -#'random_data3 <- data.frame( -#' obs1 = sample(5:7, 10, replace = TRUE), -#' obs2 = sample(4:7, 10, replace = TRUE), -#' obs3 = sample(4:7, 10, replace = TRUE), -#' obs4 = sample(5:7, 10, replace = TRUE), -#' obs5 = sample(5:7, 10, replace = TRUE), -#' obs6 = sample(6:7, 10, replace = TRUE)) -#' -#'## Saving results from Aiken's V analysis, for each group -#' -#'output.V1 <- Vaiken(data = random_data2, min = 1, max = 7, conf.level = .90) -#'output.V2 <- Vaiken(data = random_data3, min = 1, max = 7, conf.level = .90) -#' -#'## Run CID -#' -#'CID(group1 = output.V2, -#' group2 = output.V1, -#' coef.col = "V", -#' lwr.col = "lwr.ci", -#' upr.col = "upr.ci") +#'## Without n: Delta + h (point estimate only) +#'CID(Vgroup1, Vgroup2, "V", "lwr.ci", "upr.ci") #' +#'## With n: Delta + h + CI for h +#'CID(Vgroup1, Vgroup2, "V", "lwr.ci", "upr.ci", n1 = 10, n2 = 12, conf.level = .90) #' #'@export -CID <- function(group1, group2, coef.col = "coef", lwr.col = "lwr.ci", upr.col = "upr.ci", na.rm = FALSE) { - # Verify that the arguments are DataFrames +CID <- function(group1, group2, + coef.col = "coef", lwr.col = "lwr.ci", upr.col = "upr.ci", + n1 = NULL, n2 = NULL, conf.level = .95, na.rm = FALSE) { + + # ---- 1. Basic validation ---- if (!is.data.frame(group1) || !is.data.frame(group2)) { - stop("Both the 'group1' and 'group2' arguments must be data.frames.") + stop("Both 'group1' and 'group2' must be data.frames.") } - # Detection of Missing Values - if (!na.rm) { - if (any(is.na(group1)) || any(is.na(group2))) { - stop("Missing values detected. Use na.omit() first, or set na.rm=TRUE.") - } - } else { - group1 <- na.omit(group1) - group2 <- na.omit(group2) + required_cols <- c(coef.col, lwr.col, upr.col) + miss_g1 <- setdiff(required_cols, colnames(group1)) + miss_g2 <- setdiff(required_cols, colnames(group2)) + if (length(miss_g1) > 0) { + stop("'group1' is missing required columns: ", paste(miss_g1, collapse = ", ")) + } + if (length(miss_g2) > 0) { + stop("'group2' is missing required columns: ", paste(miss_g2, collapse = ", ")) } - # Verify that the necessary columns exist in the data frames - required_cols <- c(coef.col, lwr.col, upr.col) - if (!all(required_cols %in% colnames(group1))) { - stop("The 'group1' data.frame does not contain the required columns.") + # ---- 2. Validate n1 / n2 ---- + has_n1 <- !is.null(n1) + has_n2 <- !is.null(n2) + if (xor(has_n1, has_n2)) { + stop("Provide both 'n1' and 'n2', or neither.") + } + compute_h_ci <- has_n1 && has_n2 + + if (compute_h_ci) { + if (!is.numeric(n1) || length(n1) != 1 || is.na(n1) || n1 <= 0) { + stop("'n1' must be a single positive number.") + } + if (!is.numeric(n2) || length(n2) != 1 || is.na(n2) || n2 <= 0) { + stop("'n2' must be a single positive number.") + } + if (!is.numeric(conf.level) || length(conf.level) != 1 || + conf.level <= 0 || conf.level >= 1) { + stop("'conf.level' must be a number between 0 and 1 (exclusive).") + } } - if (!all(required_cols %in% colnames(group2))) { - stop("The 'group2' data.frame does not contain the required columns.") + + # ---- 3. Missing values (only in required columns) ---- + na_g1 <- any(is.na(group1[, required_cols, drop = FALSE])) + na_g2 <- any(is.na(group2[, required_cols, drop = FALSE])) + + if (na_g1 || na_g2) { + if (!na.rm) { + stop("Missing values detected. Use na.omit() first, or set na.rm = TRUE.") + } + group1 <- group1[complete.cases(group1[, required_cols, drop = FALSE]), , drop = FALSE] + group2 <- group2[complete.cases(group2[, required_cols, drop = FALSE]), , drop = FALSE] + warning("Rows with missing values in the required columns were removed.") } - # Combine the data to make comparisons + # ---- 4. Merge by item label (rownames) ---- combined_data <- merge( - group1, - group2, + group1, group2, by = "row.names", suffixes = c("_1", "_2") ) rownames(combined_data) <- combined_data$Row.names combined_data$Row.names <- NULL - # Check whether there were any exclusions due to missing items in a group if (nrow(combined_data) < nrow(group1) || nrow(combined_data) < nrow(group2)) { - warning("Some items do not have a match across the groups and have been excluded from the comparison.") + warning("Some items do not match across groups and were excluded.") } - # Calculate the difference between the coefficients and the confidence intervals - combined_data <- within(combined_data, { - Delta <- round(get(paste0(coef.col, "_1")) - get(paste0(coef.col, "_2")), 3) - lwr.ci <- round( - Delta - sqrt((get(paste0(coef.col, "_1")) - get(paste0(lwr.col, "_1")))^2 + - (get(paste0(upr.col, "_2")) - get(paste0(coef.col, "_2")))^2), 3) - upr.ci <- round( - Delta + sqrt((get(paste0(upr.col, "_1")) - get(paste0(coef.col, "_1")))^2 + - (get(paste0(coef.col, "_2")) - get(paste0(lwr.col, "_2")))^2), 3) - }) + # ---- 5. MOVER CI for Delta ---- + coef_1 <- paste0(coef.col, "_1") + coef_2 <- paste0(coef.col, "_2") + lwr_1 <- paste0(lwr.col, "_1") + upr_1 <- paste0(upr.col, "_1") + lwr_2 <- paste0(lwr.col, "_2") + upr_2 <- paste0(upr.col, "_2") + + combined_data$Delta <- round( + combined_data[[coef_1]] - combined_data[[coef_2]], 3) + + combined_data$lwr.ci <- round( + combined_data$Delta - + sqrt((combined_data[[coef_1]] - combined_data[[lwr_1]])^2 + + (combined_data[[upr_2]] - combined_data[[coef_2]])^2), + 3) - # Select the final columns for the report and reset the row labels - result <- combined_data[, c("Delta", "lwr.ci", "upr.ci")] - row.names(result) <- NULL + combined_data$upr.ci <- round( + combined_data$Delta + + sqrt((combined_data[[upr_1]] - combined_data[[coef_1]])^2 + + (combined_data[[coef_2]] - combined_data[[lwr_2]])^2), + 3) + + # ---- 6. Cohen's h (point estimate, always) ---- + p1 <- pmin(pmax(combined_data[[coef_1]], 0), 1) + p2 <- pmin(pmax(combined_data[[coef_2]], 0), 1) + h_raw <- 2 * asin(sqrt(p1)) - 2 * asin(sqrt(p2)) + combined_data$h <- round(h_raw, 3) + + # ---- 7. CI for Cohen's h (optional) ---- + if (compute_h_ci) { + z <- qnorm(1 - (1 - conf.level) / 2) + se <- sqrt(1 / n1 + 1 / n2) + combined_data$h.lwr <- round(h_raw - z * se, 3) + combined_data$h.upr <- round(h_raw + z * se, 3) + out_cols <- c("Delta", "lwr.ci", "upr.ci", "h", "h.lwr", "h.upr") + } else { + out_cols <- c("Delta", "lwr.ci", "upr.ci", "h") + } - return(result) + # Preserve item labels as rownames (consistent with the documented return) + return(combined_data[, out_cols, drop = FALSE]) } diff --git a/R/CVC.R b/R/CVC.R index b55e84b..16535a9 100644 --- a/R/CVC.R +++ b/R/CVC.R @@ -1,15 +1,42 @@ #'@title CVC #'@description Calculates the content validity coefficient (CVC; Hernandez-Nieto, 2002). CVC makes an adjustment for random response. -#'@param data dataframe, with n columns (judges or scorers), and k rows (evaluated items). -#'@param max maximum possible rating value used. -#'@param conf.level confidence level for confidence intervals (eg., .90, .95, .99). -#'@param na.rm Logical. If FALSE (default) the function stops when missing values are detected. +#' +#' @param data dataframe, with n columns (judges or scorers), and k rows (evaluated items). +#' @param max maximum possible rating value used. +#' @param min minimum possible rating value used (default = 1). Required for the MER method. +#' @param conf.level confidence level for confidence intervals (eg., .90, .95, .99). +#' @param na.rm Logical. If FALSE (default) the function stops when missing values are detected. #' If TRUE rows with missing values in the relevant columns are removed before processing. +#' @param overall Logical. If TRUE, computes an overall CVC. +#' @param overall.method Character. Method for the overall CVC: +#' \itemize{ +#' \item \code{"global"}: treats the entire matrix as a single "super-item" (all ratings pooled). +#' \item \code{"Hernandez"}: computes CVC for each item and then averages them (traditional approach). +#' } +#' @param overall.ci Character. Method for the overall confidence interval: +#' \itemize{ +#' \item \code{"MER"}: score interval for the mean of ratings, then transformed to CVC (Penfield, 2003). Recommended for \code{"global"}. +#' \item \code{"Wilson"}: Wilson score interval directly on the CVC estimate. +#' } +#' Note: When \code{overall.method = "Hernandez"}, only \code{"Wilson"} is used (others ignored). #' -#'@return dataframe with CVC coefficients and confidence intervals. +#'@return dataframe with CVC coefficients and confidence intervals. If overall = TRUE, an extra row with the global index is included. #' #'@details -#'This function calculates the content validity coefficient CVC (Hernandez-Nieto, 2002). Asymmetric confidence intervals are also calculated (Wilson, 1927; Penfield & Giacobbi, 2004). CVC' is the second coefficient that adjusts for possible random response of the raters, while another proposal for the CVI coefficient was created by Polit, & Beck (2007). +#'This function calculates the content validity coefficient CVC (Hernandez-Nieto, 2002). Asymmetric confidence intervals are also calculated (Wilson, 1927; Penfield & Giacobbi, 2004). +#' +#' **Overall CVC and confidence intervals**: +#' When `overall = TRUE`, the function computes a global CVC using one of two approaches: +#' +#' \itemize{ +#' \item With \code{overall.method = "global"}, the entire matrix of ratings is treated as a single "super-item". The workflow is: +#' 1. The matrix is flattened into a single vector (all items × all judges). +#' 2. The global mean of all ratings is computed. +#' 3. The random agreement correction (Pe) is applied using the original formula (1/J)^J. +#' 4. The global CVC is obtained as (Global Mean / Vmax) - Pe. +#' 5. For the confidence interval, the **MER method** is recommended because it respects the nature of the CVC as a linear transformation of the mean, avoids treating the CVC as an exact proportion when it is not, and is consistent with the MER approach already implemented for the global Aiken's V. The MER method first constructs an asymmetric confidence interval for the mean of all ratings (Penfield, 2003) and then transforms the lower and upper bounds to the CVC metric using the same linear transformation. +#' \item With \code{overall.method = "Hernandez"}, the CVC is computed for each item and then averaged (traditional approach). The confidence interval is based on the Wilson score method applied to the mean CVC. +#' } #' #'@references #'Hernandez-Nieto, R. A. (2002). \emph{Contributions to Statistical Analysis}. Merida, Venezuela: Universidad de Los Andes. @@ -27,9 +54,6 @@ #' Cesar Merino-Soto (\email{sikayax@yahoo.com.ar}) #' #'@examples -#'### Example 1 -#'### Fictitious data Ej1: 15 judges, and 15 items evaluated by the judges -#' #'Ej1 <- data.frame( #' J1 = c(5, 5, 6, 6, 6, 6, 6, 6, 5, 6, 5, 6, 3, 4, 4), #' J2 = c(5, 2, 6, 6, 6, 6, 6, 5, 4, 6, 5, 6, 4, 4, 3), @@ -47,19 +71,18 @@ #' J14 = c(5, 5, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 5, 4, 5), #' J15 = c(5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 3, 4)) #' -#'## Run CVC. -#'CVC(Ej1,max = 6, conf.level = .90) -#' -#'### Example 2 -#'### Random data -#'## Aritificial data -#'random_data <- data.frame(replicate(n = 6,sample(1:5,12,rep=TRUE))) +#'## Global CVC with MER CI +#'CVC(Ej1, max = 6, min = 1, conf.level = .90, overall = TRUE, overall.method = "global") #' -#'## Run CVC -#'CVC(random_data,max = 5, conf.level = .90) +#'## Traditional Hernandez CVC with Wilson CI +#'CVC(Ej1, max = 6, min = 1, conf.level = .90, overall = TRUE, overall.method = "Hernandez") #' #' @export -CVC <- function(data, max, conf.level, na.rm = FALSE) { +CVC <- function(data, max, min = 1, conf.level = 0.90, na.rm = FALSE, + overall = FALSE, + overall.method = c("global", "Hernandez"), + overall.ci = c("MER", "Wilson")) { + # Check whether the data.frame contains only numeric values if (!all(sapply(data, is.numeric))) { stop("The data.frame must contain only numeric values.") @@ -68,28 +91,29 @@ CVC <- function(data, max, conf.level, na.rm = FALSE) { # Detection of Missing Values if (!na.rm) { if (any(is.na(data))) { - stop("Valores perdidos detectados. Usa na.omit() primero o establece na.rm=TRUE.") + stop("Missing values detected. Use na.omit() first or set na.rm=TRUE.") } } else { data <- na.omit(data) } - # Number of judges (columns) + # Number of judges (columns) and items (rows) num_jueces <- ncol(data) + n_items <- nrow(data) - # Calculate Pe using the given formula + # Calculate Pe using the corrected formula (Hernandez-Nieto) + # Pe = (1 / J) ^ J Pe <- (1 / num_jueces) ^ num_jueces # Calculate the average for each item (row) medias_items <- rowMeans(data) - # Calculate the CVC for each item - CVC_items <- round((medias_items - Pe) / max, 3) - - # Calculate Wilson's confidence intervals for each CVC + # Calculate the CVC for each item (CORRECTED FORMULA) + CVC_items <- round((medias_items / max) - Pe, 3) + # Calculate Wilson's confidence intervals for each CVC item get_wilson_CI <- function(x, n, conf.level) { - p_hat <- x + p_hat <- max(1e-10, min(1 - 1e-10, x)) SE_hat_sq <- p_hat * (1 - p_hat) / n crit <- qnorm(1 - (1 - conf.level) / 2) omega <- n / (n + crit^2) @@ -101,14 +125,95 @@ CVC <- function(data, max, conf.level, na.rm = FALSE) { } intervalos_CI <- t(sapply(CVC_items, get_wilson_CI, n = num_jueces, conf.level = conf.level)) - # data.frame with the results + # data.frame with the item-level results resultado_df <- data.frame( - Item = 1:nrow(data), + Item = 1:n_items, CVC = round(CVC_items, 3), - lwr.ci = round(intervalos_CI[, "lower"],3), - upr.ci = round(intervalos_CI[, "upper"],3) + lwr.ci = round(intervalos_CI[, "lower"], 3), + upr.ci = round(intervalos_CI[, "upper"], 3) ) + # ---- Overall Calculation ---- + if (overall) { + overall.method <- match.arg(overall.method) + overall.ci <- match.arg(overall.ci) + + # If overall.method == "Hernandez", force overall.ci = "Wilson" + if (overall.method == "Hernandez" && overall.ci != "Wilson") { + warning("For overall.method = 'Hernandez', only 'Wilson' CI is available. Switching to 'Wilson'.") + overall.ci <- "Wilson" + } + + if (overall.method == "global") { + # ---- Global super-item approach ---- + all_scores <- as.vector(as.matrix(data)) + M_total <- mean(all_scores) + CVC_total <- (M_total / max) - Pe + + if (overall.ci == "Wilson") { + # Wilson directo sobre CVC_total + n <- num_jueces + p_hat <- max(1e-10, min(1 - 1e-10, CVC_total)) + crit <- qnorm(1 - (1 - conf.level) / 2) + SE_hat_sq <- p_hat * (1 - p_hat) / n + omega <- n / (n + crit^2) + A <- p_hat + crit^2 / (2 * n) + B <- crit * sqrt(SE_hat_sq + crit^2 / (4 * n^2)) + lwr_total <- omega * (A - B) + upr_total <- omega * (A + B) + etiqueta <- "Total (global, Wilson)" + + } else { # overall.ci == "MER" + z <- qnorm(1 - (1 - conf.level) / 2) + k <- max - min + + p <- (M_total - min) / k + p <- max(1e-10, min(1 - 1e-10, p)) + + n <- num_jueces + term1 <- 2 * p * n * k + z^2 + term2 <- z * sqrt(4 * n * k * p * (1 - p) + z^2) + denom <- 2 * (n * k + z^2) + pi_L <- (term1 - term2) / denom + pi_U <- (term1 + term2) / denom + + LCL_mean <- M_total - z * sqrt(k * pi_L * (1 - pi_L) / n) + UCL_mean <- M_total + z * sqrt(k * pi_U * (1 - pi_U) / n) + + LCL_mean <- max(min, min(max, LCL_mean)) + UCL_mean <- max(min, min(max, UCL_mean)) + + lwr_total <- (LCL_mean / max) - Pe + upr_total <- (UCL_mean / max) - Pe + etiqueta <- "Total (global, MER)" + } + + } else { # overall.method == "Hernandez" + # ---- Traditional approach: average of item-level CVCs ---- + CVC_total <- mean(CVC_items) + + # Wilson CI on the mean CVC + n <- num_jueces + p_hat <- max(1e-10, min(1 - 1e-10, CVC_total)) + crit <- qnorm(1 - (1 - conf.level) / 2) + SE_hat_sq <- p_hat * (1 - p_hat) / n + omega <- n / (n + crit^2) + A <- p_hat + crit^2 / (2 * n) + B <- crit * sqrt(SE_hat_sq + crit^2 / (4 * n^2)) + lwr_total <- omega * (A - B) + upr_total <- omega * (A + B) + etiqueta <- "Total (Hernandez, Wilson)" + } + + # Add overall row to results + fila_total <- data.frame( + Item = etiqueta, + CVC = round(CVC_total, 3), + lwr.ci = round(lwr_total, 3), + upr.ci = round(upr_total, 3) + ) + resultado_df <- rbind(resultado_df, fila_total) + } + return(resultado_df) } - diff --git a/R/HAiken.R b/R/HAiken.R index de76cd4..29b3daa 100644 --- a/R/HAiken.R +++ b/R/HAiken.R @@ -1,121 +1,161 @@ #' Coefficient of Homogeneity of Response (Aiken's H) #' #' @description -#' Calculates Aiken's H coefficient of homogeneity for each item and, optionally, -#' an overall H (total) across all items. The function uses bootstrap resampling -#' of judges to obtain confidence intervals. +#' Calculates Aiken's H coefficient of homogeneity for each item and, +#' optionally, an overall H (total) across all items, together with +#' bootstrap confidence intervals. #' #' @param data A data frame with judges in columns and items in rows. #' @param ncat Number of response categories. #' @param conf.level Confidence level for the intervals (e.g., .90, .95). #' @param na.rm Logical. If TRUE, rows with missing values are removed. -#' @param overall Logical. If TRUE (default), the overall H (total) is added as the last row. +#' @param overall Logical. If TRUE (default), the overall H is added as the +#' last row. #' @param B Integer. Number of bootstrap resamples (default = 1000). -#' @param ci.type Character: "logit" (default, recommended), "perc" (percentile), or "norm" (normal approximation). -#' The "logit" method transforms the bootstrap H values to the logit scale, -#' computes percentiles there, and back-transforms, ensuring the CI lies within [0,1]. +#' @param ci.type Character. Confidence-interval method: +#' \describe{ +#' \item{\code{"auto"}}{(default) Uses \code{"bca"} when the number of +#' judges \eqn{m \ge 8}, and \code{"norm"} otherwise.} +#' \item{\code{"bca"}}{Bias-corrected and accelerated bootstrap +#' (Efron, 1987). Recommended for reliability coefficients when +#' \eqn{m \ge 8}.} +#' \item{\code{"norm"}}{Normal approximation using the bootstrap +#' standard error, centered on the point estimate.} +#' \item{\code{"perc"}}{Percentile bootstrap.} +#' \item{\code{"basic"}}{Basic (reverse-percentile) bootstrap.} +#' } #' #' @details -#' The procedure for obtaining confidence intervals with ci.type = "logit" is as follows: -#' \enumerate{ -#' \item Compute the point estimate of H for each item and for the total (if overall = TRUE). -#' \item Generate B bootstrap samples by resampling the judges (columns) with replacement. -#' For each bootstrap sample, recompute H for each item and the total. -#' \item Apply the logit transformation to each bootstrap H value: -#' \deqn{L = \log(H / (1 - H))}. -#' To avoid infinities when H = 0 or H = 1, a small constant \eqn{\varepsilon = 10^{-6}} -#' is added (or subtracted) so that \eqn{H^* = \max(\varepsilon, \min(1-\varepsilon, H))}. -#' \item Obtain the percentiles of the logit-transformed bootstrap distribution: -#' \eqn{L_{\text{inf}} = \text{percentile}_{\alpha/2}(L)}, \eqn{L_{\text{sup}} = \text{percentile}_{1-\alpha/2}(L)}. -#' \item Back-transform to the original scale: -#' \eqn{H_{\text{inf}} = \exp(L_{\text{inf}}) / (1 + \exp(L_{\text{inf}}))}, -#' \eqn{H_{\text{sup}} = \exp(L_{\text{sup}}) / (1 + \exp(L_{\text{sup}}))}. -#' } -#' This ensures that the confidence interval respects the [0,1] bounds and is asymmetric when appropriate. +#' The H coefficient (Aiken, 1985, p. 140) is +#' \deqn{H = 1 - \frac{4S}{(c - 1)(k^2 - j)},} +#' where \eqn{S} is the sum of the \eqn{k(k-1)/2} absolute differences among +#' the \eqn{k} ratings, \eqn{c} is the number of categories, and +#' \eqn{j = 0} if \eqn{k} is even and \eqn{j = 1} if \eqn{k} is odd. +#' The coefficient ranges from 0 (maximum disagreement) to 1 (perfect +#' agreement). #' -#' The methods "perc" and "norm" use the bootstrap percentiles or normal approximation directly on H, -#' which may produce limits outside [0,1] in extreme cases; they are provided for comparison but are not recommended. +#' \strong{Confidence-interval methods.} With few judges, the bootstrap +#' distribution of \eqn{H} is discrete and biased upward (because each +#' resample omits on average \eqn{m/e \approx 0.37m} distinct judges). The +#' choice of interval method matters: +#' \itemize{ +#' \item \code{"perc"} inherits the bias; the lower limit can cling to +#' the point estimate. +#' \item \code{"basic"} reverses the percentiles around the estimate, +#' moving the "peg" to the upper limit. +#' \item \code{"norm"} recenters on the point estimate, forcing +#' symmetry; may leave \eqn{[0,1]} for extreme cases. +#' \item \code{"bca"} corrects both bias and skewness via jackknife; +#' recommended when \eqn{m \ge 8}. +#' } +#' With fewer than 6 judges, all bootstrap intervals are unreliable and +#' should be interpreted as rough guides, not as formal inference. #' #' @return A data frame with columns: -#' \item{Item}{Item number, or "Total" for the overall coefficient.} +#' \item{Item}{Item number, or "Total".} #' \item{H}{Aiken's H coefficient.} -#' \item{lwr.ci}{Lower bound of the confidence interval.} -#' \item{upr.ci}{Upper bound of the confidence interval.} -#' \item{n.jueces}{Number of judges (same for all rows).} +#' \item{lwr.ci}{Lower confidence bound.} +#' \item{upr.ci}{Upper confidence bound.} +#' \item{n.jueces}{Number of judges.} +#' +#' \strong{Note on inference.} The normal-approximation bootstrap interval +#' is not the same as the Z-test for the mean of H described by Aiken +#' (1985). The former estimates a confidence interval for H centered on the +#' observed value; the latter tests a null hypothesis using the theoretical +#' mean and standard deviation of H under random ratings. +#' +#' More precisely, the theoretical mean of H under random ratings is a +#' fixed quantity, +#' \deqn{\mu_H = \frac{2(c + 1) + (k + j)(c - 2)}{3c(k + j)},} +#' which anchors hypothesis testing about the calculated H. It does not +#' enter the construction of bootstrap confidence intervals. The bias and +#' asymmetry observed in small-sample bootstrap intervals—such as the +#' lower limit coinciding with the point estimate—are properties of the +#' resampling distribution of H, not of the theoretical null value. The +#' two frameworks answer different questions: the Z-test asks whether the +#' observed H departs from what random ratings would produce, whereas the +#' bootstrap interval estimates the sampling variability of H around the +#' observed value. #' #' @references -#' Aiken, L. R. (1980). Content validity and reliability of single items or questionnaires. -#' \emph{Educational and Psychological Measurement, 40}, 955-959. +#' Aiken, L. R. (1980). Content validity and reliability of single items +#' or questionnaires. \emph{Educational and Psychological Measurement, +#' 40}, 955--959. #' -#' Aiken, L. R. (1985). Three coefficients for analyzing the reliability and validity of ratings. -#' \emph{Educational and Psychological Measurement, 45}, 131-142. +#' Aiken, L. R. (1985). Three coefficients for analyzing the reliability +#' and validity of ratings. \emph{Educational and Psychological +#' Measurement, 45}, 131--142. +#' +#' Efron, B. (1987). Better bootstrap confidence intervals. \emph{Journal +#' of the American Statistical Association, 82}(397), 171--185. +#' +#' Efron, B., & Tibshirani, R. J. (1993). \emph{An introduction to the +#' bootstrap}. Chapman & Hall. #' #' @examples #' \dontrun{ -#' # Sample data: 8 items, 18 judges, ratings 1-4 -#' datos <- data.frame(t(file1[, c("claA6", "claA18", "claA2", "claA16", -#' "claA4", "claA12", "claA9", "claA21")])) -#' Haiken(datos, ncat = 4, conf.level = .90, overall = TRUE, B = 1000, ci.type = "logit") +#' Haiken(randata_high, ncat = 7, conf.level = .90, +#' overall = TRUE, B = 1000, ci.type = "auto") #' } #' #' @export -#' @importFrom stats median quantile +#' @importFrom stats median quantile sd qnorm pnorm na.omit Haiken <- function(data, ncat, conf.level = .95, na.rm = FALSE, overall = TRUE, B = 1000, - ci.type = c("logit", "perc", "norm")) { - - ci.type <- match.arg(ci.type) + ci.type = c("auto", "bca", "norm", "perc", "basic")) { + # --- Validación --------------------------------------------------------- if (!is.data.frame(data)) data <- as.data.frame(data) - - if (!na.rm && anyNA(data)) { + if (!na.rm && anyNA(data)) stop("Missing values found. Set na.rm=TRUE or handle them first.") - } if (na.rm) data <- na.omit(data) n_items <- nrow(data) m <- ncol(data) if (n_items < 1 || m < 2) stop("Need at least 1 item and 2 judges.") - delta <- ifelse(m %% 2 == 0, 1, 0) - denom_item <- (ncat - 1) * (m^2 - delta) - denom_total <- (ncat - 1) * n_items * (m^2 - delta) + # --- Auto-selección de método ------------------------------------------- + if (ci.type == "auto") { + ci.type <- if (m >= 8) "bca" else "norm" + message("ci.type auto-selected: '", ci.type, "' (m = ", m, ")") + } - # --- Internal function to compute H (individual and total) --- + # --- Warnings de confiabilidad ------------------------------------------ + if (m < 6) { + warning("Bootstrap CIs unreliable with < 6 judges; interpret as ", + "rough guides, not formal inference.") + } + if (ci.type == "bca" && m < 8) { + warning("BCa with < 8 judges has unstable acceleration; the interval ", + "may be wide or asymmetric. Consider ci.type = 'norm'.") + } + + # --- j = 0 si k par, j = 1 si k impar (Aiken 1985, p. 140) -------------- + .delta <- function(k) ifelse(k %% 2 == 0, 0, 1) + + # --- H para un panel ---------------------------------------------------- calc_H <- function(mat) { - ni <- nrow(mat) - mi <- ncol(mat) - delta_i <- ifelse(mi %% 2 == 0, 1, 0) + ni <- nrow(mat); mi <- ncol(mat) + delta_i <- .delta(mi) denom_i <- (ncat - 1) * (mi^2 - delta_i) - denom_total_i <- (ncat - 1) * ni * (mi^2 - delta_i) + denom_total_i <- denom_i * ni H_ind <- numeric(ni) sum_diffs_total <- 0 all_valid <- TRUE for (i in 1:ni) { - # Convert row to numeric robustly row_i <- as.numeric(mat[i, ]) - # If any NA, try to convert from factor/character - if (anyNA(row_i)) { - row_i <- as.numeric(as.character(mat[i, ])) - } - # If still any NA, impute with median of non-NA values (or skip) - if (anyNA(row_i)) { - row_i[is.na(row_i)] <- median(row_i, na.rm = TRUE) - } + if (anyNA(row_i)) row_i <- as.numeric(as.character(mat[i, ])) + if (anyNA(row_i)) row_i[is.na(row_i)] <- median(row_i, na.rm = TRUE) - # Compute pairwise absolute differences diffs <- tryCatch( combn(row_i, 2, function(p) abs(p[1] - p[2])), error = function(e) rep(NA, choose(mi, 2)) ) if (anyNA(diffs)) { - all_valid <- FALSE - H_ind[i] <- NA - sum_diffs_total <- NA - break + all_valid <- FALSE; H_ind[i] <- NA; sum_diffs_total <- NA; break } else { sum_diffs <- sum(diffs, na.rm = TRUE) sum_diffs_total <- sum_diffs_total + sum_diffs @@ -123,138 +163,133 @@ Haiken <- function(data, ncat, conf.level = .95, na.rm = FALSE, } } - H_total <- if (anyNA(H_ind) || !all_valid) { - NA - } else { + H_total <- if (anyNA(H_ind) || !all_valid) NA else 1 - (4 * sum_diffs_total) / denom_total_i - } list(H_individual = H_ind, H_total = H_total, valid = all_valid) } - # --- Point estimates --- + # --- Estimaciones puntuales -------------------------------------------- est <- calc_H(data) H_ind <- est$H_individual H_total <- est$H_total - if (anyNA(H_ind)) stop("Point estimates contain NA. Check data and ncat.") if (overall && is.na(H_total)) stop("Total H is NA. Check data.") - # --- Bootstrap over judges (columns) with resampling until valid --- - boot_H_ind <- matrix(NA, nrow = B, ncol = n_items) + # --- Bootstrap ---------------------------------------------------------- + boot_H_ind <- matrix(NA, B, n_items) boot_H_total <- numeric(B) - for (b in 1:B) { - valid_boot <- FALSE - attempts <- 0 - while (!valid_boot && attempts < 10) { - idx_col <- sample(1:m, size = m, replace = TRUE) - boot_data <- data[, idx_col, drop = FALSE] - boot_est <- calc_H(boot_data) - if (boot_est$valid && !anyNA(boot_est$H_individual) && !is.na(boot_est$H_total)) { - valid_boot <- TRUE - boot_H_ind[b, ] <- boot_est$H_individual - boot_H_total[b] <- boot_est$H_total - } - attempts <- attempts + 1 - } - if (!valid_boot) { - # Fallback: use point estimates - boot_H_ind[b, ] <- H_ind - boot_H_total[b] <- H_total - } + idx <- sample(1:m, m, replace = TRUE) + est_b <- calc_H(data[, idx, drop = FALSE]) + boot_H_ind[b, ] <- est_b$H_individual + boot_H_total[b] <- est_b$H_total } - # --- Helper to compute confidence intervals (robust) --- - get_ci <- function(boot_vals, point_est, conf.level, ci.type) { - boot_vals <- boot_vals[!is.na(boot_vals)] - if (length(boot_vals) == 0) { - return(c(lwr = point_est, upr = point_est)) - } - if (length(unique(boot_vals)) == 1) { - return(c(lwr = point_est, upr = point_est)) + # --- Jackknife (solo para BCa) ----------------------------------------- + jack_ind <- NULL; jack_total <- NULL + if (ci.type == "bca" && m >= 3) { + jack_ind <- matrix(NA, m, n_items) + jack_total <- numeric(m) + for (j in 1:m) { + est_j <- calc_H(data[, -j, drop = FALSE]) + jack_ind[j, ] <- est_j$H_individual + jack_total[j] <- est_j$H_total } + } + # --- Constructor de IC -------------------------------------------------- + get_ci <- function(boot_vals, theta_hat, jack_vals, conf.level, ci.type) { + boot_vals <- boot_vals[is.finite(boot_vals)] + if (length(boot_vals) < 20) return(c(lwr = NA, upr = NA)) alpha <- 1 - conf.level if (ci.type == "perc") { - lwr <- quantile(boot_vals, probs = alpha/2, na.rm = TRUE, names = FALSE) - upr <- quantile(boot_vals, probs = 1 - alpha/2, na.rm = TRUE, names = FALSE) - if (is.na(lwr)) lwr <- min(boot_vals) - if (is.na(upr)) upr <- max(boot_vals) - return(c(lwr = lwr, upr = upr)) + lwr <- quantile(boot_vals, alpha/2, names = FALSE) + upr <- quantile(boot_vals, 1 - alpha/2, names = FALSE) + + } else if (ci.type == "basic") { + q_lo <- quantile(boot_vals, alpha/2, names = FALSE) + q_hi <- quantile(boot_vals, 1 - alpha/2, names = FALSE) + lwr <- 2 * theta_hat - q_hi + upr <- 2 * theta_hat - q_lo } else if (ci.type == "norm") { - se <- sd(boot_vals, na.rm = TRUE) - z <- qnorm(1 - alpha/2) - lwr <- point_est - z * se - upr <- point_est + z * se - return(c(lwr = lwr, upr = upr)) + se <- sd(boot_vals) + z <- qnorm(1 - alpha/2) + lwr <- theta_hat - z * se + upr <- theta_hat + z * se - } else { # "logit" (default) - eps <- 1e-6 - vals <- boot_vals - vals[vals <= 0] <- eps - vals[vals >= 1] <- 1 - eps + } else { # bca + z0 <- qnorm(sum(boot_vals < theta_hat) / length(boot_vals)) + z0 <- max(min(z0, 2), -2) - logit_vals <- log(vals / (1 - vals)) - lwr_logit <- quantile(logit_vals, probs = alpha/2, na.rm = TRUE, names = FALSE) - upr_logit <- quantile(logit_vals, probs = 1 - alpha/2, na.rm = TRUE, names = FALSE) - if (is.na(lwr_logit)) lwr_logit <- min(logit_vals) - if (is.na(upr_logit)) upr_logit <- max(logit_vals) + if (!is.null(jack_vals) && length(jack_vals) >= 3 && + all(is.finite(jack_vals))) { + d <- mean(jack_vals) - jack_vals + num <- sum(d^3) + den <- 6 * (sum(d^2))^1.5 + a <- if (den > 0) num / den else 0 + a <- max(min(a, 0.5), -0.5) + } else { + a <- 0 + } + + z_lo <- qnorm(alpha/2) + z_hi <- qnorm(1 - alpha/2) + al <- pnorm(z0 + (z0 + z_lo) / (1 - a * (z0 + z_lo))) + au <- pnorm(z0 + (z0 + z_hi) / (1 - a * (z0 + z_hi))) + al <- max(min(al, 0.49), 0.001) + au <- min(max(au, 0.51), 0.999) - lwr <- exp(lwr_logit) / (1 + exp(lwr_logit)) - upr <- exp(upr_logit) / (1 + exp(upr_logit)) - return(c(lwr = lwr, upr = upr)) + lwr <- quantile(boot_vals, al, names = FALSE) + upr <- quantile(boot_vals, au, names = FALSE) } + c(lwr = lwr, upr = upr) } - # --- Compute CIs for each item --- - lwr_ind <- numeric(n_items) - upr_ind <- numeric(n_items) + # --- IC por ítem -------------------------------------------------------- + lwr_ind <- numeric(n_items); upr_ind <- numeric(n_items) for (i in 1:n_items) { - ci <- get_ci(boot_H_ind[, i], H_ind[i], conf.level, ci.type) - lwr_ind[i] <- ci["lwr"] - upr_ind[i] <- ci["upr"] + jv <- if (!is.null(jack_ind)) jack_ind[, i] else NULL + ci <- get_ci(boot_H_ind[, i], H_ind[i], jv, conf.level, ci.type) + lwr_ind[i] <- ci["lwr"]; upr_ind[i] <- ci["upr"] } - # --- CI for the total H (if overall = TRUE) --- + # --- IC del total ------------------------------------------------------- if (overall) { - ci_total <- get_ci(boot_H_total, H_total, conf.level, ci.type) - lwr_total <- ci_total["lwr"] - upr_total <- ci_total["upr"] + jv <- if (!is.null(jack_total)) jack_total else NULL + ci_total <- get_ci(boot_H_total, H_total, jv, conf.level, ci.type) + lwr_total <- ci_total["lwr"]; upr_total <- ci_total["upr"] } else { - lwr_total <- NA - upr_total <- NA + lwr_total <- NA; upr_total <- NA } - # --- Build results data.frame --- + # --- Salida ------------------------------------------------------------ resultados <- data.frame( - Item = 1:n_items, - H = round(H_ind, 3), - lwr.ci = round(lwr_ind, 3), - upr.ci = round(upr_ind, 3), + Item = 1:n_items, + H = round(H_ind, 3), + lwr.ci = round(lwr_ind, 3), + upr.ci = round(upr_ind, 3), n.jueces = m, stringsAsFactors = FALSE, row.names = NULL ) if (overall) { - fila_total <- data.frame( - Item = "Total", - H = round(H_total, 3), - lwr.ci = if (is.na(lwr_total)) NA else round(lwr_total, 3), - upr.ci = if (is.na(upr_total)) NA else round(upr_total, 3), + resultados <- rbind(resultados, data.frame( + Item = "Total", + H = round(H_total, 3), + lwr.ci = if (is.na(lwr_total)) NA else round(lwr_total, 3), + upr.ci = if (is.na(upr_total)) NA else round(upr_total, 3), n.jueces = m, stringsAsFactors = FALSE, row.names = NULL - ) - resultados <- rbind(resultados, fila_total) + )) } - attr(resultados, "ci.type") <- ci.type - attr(resultados, "B") <- B - attr(resultados, "conf.level") <- conf.level - + attr(resultados, "ci.type") <- ci.type + attr(resultados, "B") <- B + attr(resultados, "conf.level") <- conf.level return(resultados) } diff --git a/R/HT.R b/R/HT.R deleted file mode 100644 index 177a5db..0000000 --- a/R/HT.R +++ /dev/null @@ -1,440 +0,0 @@ -#' Hinkin-Tracey Content Validity Indices for Multiple Items -#' -#' @description -#' Computes Hinkin and Tracey (1999) content validity indices for multiple items -#' when judges rate how well each item corresponds to several construct -#' definitions in the same judgement task. For each item, the function returns: -#' \itemize{ -#' \item Descriptive means of ratings for each construct. -#' \item \code{htc}: correspondence index based on the mean rating of the -#' target construct. -#' \item \code{htd}: distinctiveness index based on the mean rating -#' difference between the target construct and all orbiting constructs. -#' \item \code{htd} computed pairwise between the target construct and each -#' orbiting construct. -#' } -#' -#' Ratings are assumed to be given on a discrete Likert-type scale from -#' 1 to \code{anchors}. Confidence intervals for the indices are based on -#' a t-based interval for the mean, truncated to the possible rating range, -#' and then rescaled to the \code{htc}/\code{htd} metrics. -#' -#' @param data A data frame or matrix in wide format, where each column -#' corresponds to one item-construct combination. Columns are expected -#' to follow the pattern \code{"item.construct"}, e.g., -#' \code{"item1.c1"}, \code{"item1.c2"}, \code{"item1.c3"}. -#' @param items Character vector with the base names of the items to be -#' analyzed (i.e., the prefixes before the dot), e.g. -#' \code{c("item1", "item2", "item3")}. -#' @param constructs Character vector with the construct labels (suffixes -#' after the dot), e.g. \code{c("c1", "c2", "c3")}. The function will -#' search for columns \code{paste0(item, ".", construct)} for every -#' combination of \code{items} and \code{constructs}. -#' @param key Named character vector mapping each item to its target -#' construct. The names must match \code{items}, and the values must be -#' one of the \code{constructs}. For example: -#' \code{c(item1 = "c2", item2 = "c1", item3 = "c3")}. -#' @param anchors Integer. Number of response options in the rating scale -#' (e.g., 5 or 7). Ratings are assumed to range from 1 to \code{anchors}. -#' @param ci Logical. If \code{TRUE}, asymmetric confidence intervals are -#' computed for \code{htc}, \code{htd} and the pairwise \code{htd} indices. -#' Default is \code{FALSE}. -#' @param conf.level Confidence level for the confidence intervals (e.g., -#' \code{0.90}, \code{0.95}, \code{0.99}). Used only if \code{ci = TRUE}. -#' Default is \code{0.95}. -#' @param na.rm Logical. If \code{TRUE} (default), missing values are removed -#' when computing means and differences. If \code{FALSE}, missing values -#' will propagate \code{NA} in the corresponding statistics. -#' @param nd Integer. Number of decimal places to use when rounding -#' the numeric results. Default is \code{3}. -#' -#' @details -#' For each item, the function extracts the ratings for each construct from -#' columns named \code{"item.construct"}. The target construct is specified -#' via the \code{key} argument. -#' -#' \strong{Item-level descriptive statistics} -#' -#' For each item, \code{$Item.descriptive} reports: -#' \itemize{ -#' \item \code{item}: item name (base). -#' \item \code{target}: target construct for that item. -#' \item \code{nj}: number of judges with a non-missing rating on the -#' target construct. -#' \item \code{M.}: mean rating for each construct. -#' } -#' -#' \strong{Item-level criteria} -#' -#' For each item, \code{$Item.criteria} reports: -#' \itemize{ -#' \item \code{htc}: the correspondence index, defined as the mean rating -#' on the target construct divided by \code{anchors}. -#' \item \code{htd}: the distinctiveness index, defined as: -#' \eqn{\text{htd} = \bar{D} / (a - 1)}, where \eqn{\bar{D}} is the -#' mean (over judges) of the average difference between the rating -#' on the target construct and the ratings on all orbiting -#' constructs, and \eqn{a} is \code{anchors}. -#' \item If \code{ci = TRUE}, lower and upper confidence limits -#' (\code{htc.lci}, \code{htc.uci}, \code{htd.lci}, \code{htd.uci}) -#' based on a t-interval for the mean truncated to the possible -#' rating range and then rescaled. -#' } -#' -#' \strong{Pairwise distinctiveness} -#' -#' For each item and each orbiting construct (i.e., each construct other -#' than the target), \code{$Pairwise.criteria} reports: -#' \itemize{ -#' \item \code{item}: item name. -#' \item \code{target}: target construct for that item. -#' \item \code{orbiting}: the orbiting construct. -#' \item \code{htd}: a pairwise distinctiveness index defined as: -#' \eqn{\text{htd}_{c} = \bar{D}_c / (a - 1)}, where \eqn{\bar{D}_c} -#' is the mean (over judges) of the difference between the rating on -#' the target construct and the rating on the orbiting construct -#' \eqn{c}. -#' \item If \code{ci = TRUE}, \code{htd.lci} and \code{htd.uci} as -#' truncated t-based confidence intervals rescaled to the -#' \code{htd} metric. -#' } -#' -#' This function is intended for the Hinkin and Tracey (1999) method of -#' content validation, where judges rate how well each item corresponds -#' to each construct definition. The same wide format can also be useful -#' for implementing criteria inspired by Colquitt et al. (2019). -#' -#' Ratings are assumed to be coded from 1 to \code{anchors}. If another -#' coding scheme is used, users should recode the ratings before calling -#' the function. -#' -#' @return -#' A list with three components: -#' \describe{ -#' \item{\code{Item.descriptive}}{A data frame with one row per item, -#' containing item-level descriptive statistics: -#' \code{item}, \code{target}, \code{nj}, and the construct means -#' (\code{M.} columns).} -#' \item{\code{Item.criteria}}{A data frame with one row per item, -#' containing the global Hinkin-Tracey indices: -#' \code{item}, \code{htc}, \code{htc.lci}, \code{htc.uci}, -#' \code{htd}, \code{htd.lci}, \code{htd.uci}. If \code{ci = FALSE}, -#' the confidence interval columns are filled with \code{NA}.} -#' \item{\code{Pairwise.criteria}}{A data frame in long format, with one -#' row per item-orbiting construct combination, containing: -#' \code{item}, \code{target}, \code{orbiting}, \code{htd}, -#' \code{htd.lci}, \code{htd.uci}. If \code{ci = FALSE}, the confidence -#' interval columns are filled with \code{NA}.} -#' } -#' -#' @references -#' Hinkin, T. R., & Tracey, J. B. (1999). An analysis of variance approach -#' to content validation. \emph{Organizational Research Methods, 2}(2), 175-186. -#' -#' Colquitt, J. A., Sabey, T. B., Rodell, J. B., & Hill, E. T. (2019). -#' Content validation guidelines: Evaluation criteria for definitional -#' correspondence and definitional distinctiveness. \emph{Journal of Applied -#' Psychology, 104}(10), 1243-1265. -#' -#' Penfield, R. D., & Miller, J. M. (2004). Improving content validation -#' studies using an asymmetric confidence interval for the mean of expert -#' ratings. \emph{Applied Measurement in Education, 17}(4), 359-370. -#' -#' @examples -#' \dontrun{ -#' ## Example structure (toy data) -#' set.seed(123) -#' HTmult.data <- data.frame( -#' item1.c1 = sample(1:5, 50, replace = TRUE), -#' item1.c2 = sample(1:5, 50, replace = TRUE), -#' item1.c3 = sample(1:5, 50, replace = TRUE), -#' item2.c1 = sample(1:5, 50, replace = TRUE), -#' item2.c2 = sample(1:5, 50, replace = TRUE), -#' item2.c3 = sample(1:5, 50, replace = TRUE) -#' ) -#' -#'HTmult( -#' data = dat, -#' items = c("item1", "item2"), -#' constructs = c("c1", "c2", "c3"), -#' key = c(item1 = "c2", item2 = "c3"), -#' anchors = 5, -#' ci = TRUE, -#' conf.level = 0.95) -#' } -#' -#' @export -HTmult <- function( - data, - items, - constructs, - key, - anchors, - ci = FALSE, - conf.level = 0.95, - na.rm = TRUE, - nd = 3 -) { - # --- Basic checks and setup --- - if (!is.data.frame(data)) { - data <- as.data.frame(data) - } - - if (!is.character(items) || length(items) == 0) { - stop("'items' must be a non-empty character vector.") - } - - if (!is.character(constructs) || length(constructs) < 2) { - stop("'constructs' must be a character vector with at least two constructs.") - } - - if (missing(key) || is.null(key)) { - stop("'key' must be provided as a named character vector mapping items to target constructs.") - } - - if (is.null(names(key)) || any(names(key) == "")) { - stop("'key' must have names corresponding to item names.") - } - - if (!all(items %in% names(key))) { - stop("All 'items' must appear as names in 'key'.") - } - - if (!all(key[items] %in% constructs)) { - stop("All target constructs in 'key' must be included in 'constructs'.") - } - - if (!is.numeric(anchors) || length(anchors) != 1 || anchors <= 1) { - stop("'anchors' must be a numeric value > 1 (e.g., 5 or 7).") - } - - if (!is.logical(ci) || length(ci) != 1) { - stop("'ci' must be a single logical value (TRUE/FALSE).") - } - - if (!is.numeric(conf.level) || conf.level <= 0 || conf.level >= 1) { - stop("'conf.level' must be a numeric value between 0 and 1.") - } - - # Helper: t-based CI for mean with truncation to [lower, upper] - mean_ci_truncated <- function(x, lower, upper, conf.level) { - x <- x[!is.na(x)] - n <- length(x) - if (n == 0) { - return(list(mean = NA_real_, lwr = NA_real_, upr = NA_real_)) - } - m <- mean(x) - if (n == 1 || is.na(sd(x)) || sd(x) == 0) { - # No variability or single observation: CI collapses to the truncated mean - lwr <- max(min(m, upper), lower) - upr <- lwr - } else { - alpha <- 1 - conf.level - se <- sd(x) / sqrt(n) - tcrit <- stats::qt(1 - alpha / 2, df = n - 1) - lwr <- m - tcrit * se - upr <- m + tcrit * se - # truncate to possible range - lwr <- max(lwr, lower) - upr <- min(upr, upper) - } - list(mean = m, lwr = lwr, upr = upr) - } - - item_desc_list <- list() - item_crit_list <- list() - pairwise_list <- list() - - idx_desc <- 1L - idx_crit <- 1L - idx_pair <- 1L - - # --- Loop over items --- - for (item in items) { - - target <- key[[item]] - - # Build column names for this item - item_cols <- paste0(item, ".", constructs) - - # Check that all required columns exist - missing_cols <- setdiff(item_cols, colnames(data)) - if (length(missing_cols) > 0) { - stop( - "For item '", item, "', the following columns are missing in 'data': ", - paste(missing_cols, collapse = ", ") - ) - } - - # Extract ratings per construct - ratings_list <- lapply(item_cols, function(nm) data[[nm]]) - names(ratings_list) <- constructs - - # Target ratings - target_vec <- ratings_list[[target]] - - # Number of judges (non-missing in target) - if (na.rm) { - nj <- sum(!is.na(target_vec)) - } else { - nj <- length(target_vec) - } - - # --- Item.descriptive row --- - means_c <- sapply( - ratings_list, - function(v) if (na.rm) mean(v, na.rm = TRUE) else mean(v) - ) - - desc_row <- data.frame( - item = item, - target = target, - nj = nj, - t(means_c), - check.names = FALSE - ) - # Rename construct mean columns to M. - mean_col_names <- paste0("M.", constructs) - colnames(desc_row)[(ncol(desc_row) - length(constructs) + 1):ncol(desc_row)] <- mean_col_names - - item_desc_list[[idx_desc]] <- desc_row - idx_desc <- idx_desc + 1L - - # --- Item.criteria row: HTC and HTD global --- - # HTC - mean_target <- means_c[target] - htc <- mean_target / anchors - - htc_lci <- htc_uci <- NA_real_ - if (ci) { - # Ratings assumed 1..anchors - ci_target <- mean_ci_truncated( - x = target_vec, - lower = 1, - upper = anchors, - conf.level = conf.level - ) - if (!is.na(ci_target$lwr)) { - htc_lci <- ci_target$lwr / anchors - htc_uci <- ci_target$upr / anchors - } - } - - # HTD global: average difference target - orbiting (over constructs), - # then averaged over judges and normalized by (anchors - 1) - orbiting_constructs <- setdiff(constructs, target) - # For each judge, compute mean difference across orbiting constructs - D_vec <- rep(NA_real_, length(target_vec)) - for (i in seq_along(target_vec)) { - t_i <- target_vec[i] - if (is.na(t_i)) next - orbit_vals <- vapply( - orbiting_constructs, - function(cc) ratings_list[[cc]][i], - FUN.VALUE = NA_real_ - ) - if (na.rm) { - orbit_vals <- orbit_vals[!is.na(orbit_vals)] - } - if (length(orbit_vals) == 0) next - D_vec[i] <- t_i - mean(orbit_vals) - } - - # Range of D: [-(anchors-1), +(anchors-1)] - D_mean <- if (na.rm) mean(D_vec, na.rm = TRUE) else mean(D_vec) - htd <- D_mean / (anchors - 1) - - htd_lci <- htd_uci <- NA_real_ - if (ci) { - ci_D <- mean_ci_truncated( - x = D_vec, - lower = -(anchors - 1), - upper = (anchors - 1), - conf.level = conf.level - ) - if (!is.na(ci_D$lwr)) { - htd_lci <- ci_D$lwr / (anchors - 1) - htd_uci <- ci_D$upr / (anchors - 1) - } - } - - crit_row <- data.frame( - item = item, - htc = htc, - htc.lci = htc_lci, - htc.uci = htc_uci, - htd = htd, - htd.lci = htd_lci, - htd.uci = htd_uci, - check.names = FALSE - ) - - item_crit_list[[idx_crit]] <- crit_row - idx_crit <- idx_crit + 1L - - # --- Pairwise.criteria: HTD per orbiting construct --- - for (cc in orbiting_constructs) { - vec_c <- ratings_list[[cc]] - - # Differences per judge for this pair - if (na.rm) { - idx_valid <- !is.na(target_vec) & !is.na(vec_c) - d_c <- target_vec[idx_valid] - vec_c[idx_valid] - } else { - d_c <- target_vec - vec_c - } - - D_c_mean <- if (na.rm) mean(d_c, na.rm = TRUE) else mean(d_c) - htd_c <- D_c_mean / (anchors - 1) - - htd_c_lci <- htd_c_uci <- NA_real_ - if (ci) { - ci_dc <- mean_ci_truncated( - x = d_c, - lower = -(anchors - 1), - upper = (anchors - 1), - conf.level = conf.level - ) - if (!is.na(ci_dc$lwr)) { - htd_c_lci <- ci_dc$lwr / (anchors - 1) - htd_c_uci <- ci_dc$upr / (anchors - 1) - } - } - - pair_row <- data.frame( - item = item, - target = target, - orbiting = cc, - htd = htd_c, - htd.lci = htd_c_lci, - htd.uci = htd_c_uci, - check.names = FALSE - ) - - pairwise_list[[idx_pair]] <- pair_row - idx_pair <- idx_pair + 1L - } - } - - # Bind results - Item.descriptive <- do.call(rbind, item_desc_list) - Item.criteria <- do.call(rbind, item_crit_list) - Pairwise.criteria <- do.call(rbind, pairwise_list) - - # Round numeric columns - round_numeric_df <- function(df, digits) { - is_num <- vapply(df, is.numeric, logical(1)) - df[is_num] <- lapply(df[is_num], round, digits = digits) - df - } - - Item.descriptive <- round_numeric_df(Item.descriptive, nd) - Item.criteria <- round_numeric_df(Item.criteria, nd) - Pairwise.criteria <- round_numeric_df(Pairwise.criteria, nd) - - list( - Item.descriptive = Item.descriptive, - Item.criteria = Item.criteria, - Pairwise.criteria = Pairwise.criteria - ) -} diff --git a/R/LuAgree.R b/R/LuAgree.R index b04f780..bae9625 100644 --- a/R/LuAgree.R +++ b/R/LuAgree.R @@ -186,7 +186,7 @@ #' \emph{Educational and Psychological Measurement}, 31(1), 57-68. #' https://doi.org/10.1177/001316447103100105 #' -#' Rovinelli, Richard J.; Hambleton, Ronald K. (1976). On the Use of Content +#' Rovinelli, R J., Hambleton, R. K. (1976). On the Use of Content #' Specialists in the Assessment of Criterion-Referenced Test Item Validity.Paper #' presented at the Annual Meeting of the American Educational Research #' Association (60th, San Francisco, California, April 19-23, 1976). @@ -352,10 +352,9 @@ LuAgree <- function(data, Sw2 <- Sw2_num / (n_i * (m_i - 1L)) # Maximum-entropy reference variance S_{w0}^2 - p_unif <- rep(1 / t_cat, t_cat) - y_unif <- (seq_len(t_cat) - 0.5) / t_cat - mu0 <- sum(y_unif * p_unif) - Sw0_2 <- sum((y_unif - mu0)^2 * p_unif) + p_unif <- rep(1 / t_cat, t_cat) + mu0 <- sum(y_emp * p_unif) + Sw0_2 <- sum((y_emp - mu0)^2 * p_unif) A_val <- 1 - Sw2 / Sw0_2 diff --git a/R/MDScontent.R b/R/MDScontent.R index 1dd560f..043a99c 100644 --- a/R/MDScontent.R +++ b/R/MDScontent.R @@ -49,7 +49,7 @@ #' for each item. Each item must be evaluated against several attributes (not just one), #' and the judge must rate how well each item corresponds to each attribute. This format #' is consistent with the substantive validity method (\code{\link[ValCont:CIDsingle]{ValCont::CIDsingle}}) -#' and Hinkey's approach \code{\link[ValCont:HTmult]{ValCont::HTmult}} +#' and Hinkey's approach \code{\link[ValCont:ColquittHT]{ValCont::ColquittHT}} #' #' ## Conceptual rationale #' The function provides a **geometric visualization** of content validity structure. @@ -93,6 +93,16 @@ #' Therefore, `MDScontent()` should be interpreted as a structural visualization tool #' that complements coefficient-based evidence. #' +#' @references +#' Sireci, S. G. (1998). Gathering and Analyzing Content Validity Data. \emph{Educational Assessment, 5}(4), 299–321. https://doi.org/10.1207/s15326977ea0504_2 +#' +#' Li, X., & Sireci, S. G. (2013). A New Method for Analyzing Content Validity Data Using Multidimensional Scaling. \emph{Educational and Psychological Measurement, 73}(3), 365-385. https://doi.org/10.1177/0013164412473825 +#' +#' Sireci, S. G., & Geisinger, K. F. (1995). Using Subject-Matter Experts to Assess Content Representation: An MDS Analysis. \emph{Applied Psychological Measurement, 19}(3), 241-255. https://doi.org/10.1177/014662169501900303 +#' +#' Sireci, S. G., & Geisinger, K. F. (1992). Analyzing Test Content Using Cluster Analysis and Multidimensional Scaling. \emph{Applied Psychological Measurement, 16}(1), 17-31. https://doi.org/10.1177/014662169201600102 +#' + #' @importFrom rlang .data #' @examples #' # This simulated data has the following structure: 12 judges evaluated the fit @@ -105,14 +115,14 @@ #' #' # item item1.trait1 item1.trait2 item1.trait3 item1.trait4 item2.trait1 ... #' -#' # The theoretical correspondence used below is: +#' # For this example: +#' # Item1 (Fit to Trait 1) +#' # Item2 (Fit to Trait 1) +#' # Item3 (Fit to Trait 2) +#' # Item4 (Fit to Trait 2) +#' # Item5 (Approximate fit to Trait 3) +#' # Item6 (Approximate fit to Trait 4) #' -#' # Item 1 -> Trait 1 -#' # Item 2 -> Trait 1 -#' # Item 3 -> Trait 2 -#' # Item 4 -> Trait 2 -#' # Item 5 -> Trait 3 -#' # Item 6 -> Trait 4 #' #' dat2 <- matrix(c( #' 5,2,2,1, 5,1,2,1, 2,5,1,2, 1,5,2,1, 2,1,5,2, 1,2,2,5, diff --git a/R/RobinsonA.R b/R/RobinsonA.R new file mode 100644 index 0000000..1ddfcf1 --- /dev/null +++ b/R/RobinsonA.R @@ -0,0 +1,296 @@ +# Helper operator +`%||%` <- function(x, y) if (is.null(x)) y else x + +#' Robinson's A Agreement Coefficient (Generalized and Diagnostic) +#' +#' Computes Robinson's (1957) agreement coefficient A, generalized to K judges +#' via its linear relation to the intraclass correlation coefficient for +#' absolute agreement, ICC(A,1). Optionally returns bootstrap confidence +#' intervals and leave-one-out (LOO) diagnostics by judge and by item. +#' +#' @details +#' Robinson (1957) defined agreement as *correlation without regression*: +#' perfect agreement has only one form (X1 = X2), whereas correlation allows +#' any linear (or functional) adjustment. His coefficient is: +#' +#' A = 1 - D / D.max +#' +#' where D is the total within-family sum of squares (disagreement) and +#' D.max is the sum of squares of all observations around the grand mean. +#' A = 1 indicates perfect agreement; A = 0 indicates maximum disagreement. +#' +#' For K > 2 judges, Robinson (Eq. 9-10) showed that A relates linearly to the +#' intraclass correlation r.i: +#' +#' r.i = (K * A - 1) / (K - 1) <=> A = ((K - 1) / K) * r.i + 1 / K +#' +#' This function uses ICC(A,1) -- the absolute-agreement form of the two-way +#' random-effects intraclass correlation (McGraw & Wong, 1996) -- because +#' Robinson's A penalizes both mean (level) and variance (scale) differences +#' between judges. Consistency-only forms (e.g., ICC(C,1)) would lose this +#' property and are therefore not appropriate here. +#' +#' For K = 2, ICC(A,1) = 2A - 1, recovering Robinson's Eq. (7). +#' +#' @section Bootstrap resampling scheme: +#' Three bootstrap procedures are implemented, each resampling the unit that +#' defines the relevant population of generalization: +#' +#' \itemize{ +#' \item CI for A (global): resamples items (rows). The population of +#' interest is the universe of items from which the observed items +#' were drawn. +#' \item CI for Diff.A at the judge level: resamples items (rows). Each +#' judge's LOO effect is generalized across the item universe, holding +#' the set of judges fixed (the judges are the actual raters, not a +#' random sample). +#' \item CI for Diff.A at the item level: resamples judges (columns, via +#' transposition). Each item's LOO effect is generalized across the +#' universe of raters, holding the set of items fixed. +#' } +#' +#' @section Leave-One-Out (LOO) diagnostics: +#' The LOO strategy re-estimates A after removing each judge (column) or each +#' item (row). A positive `Diff.A` (A.omit - Am) indicates that omitting that +#' judge/item *increases* agreement, flagging it as a source of disagreement. +#' `Ratio = A.omit / Am` is also reported for interpretability. Judge-level +#' LOO is usually the most informative in content-validity applications, since +#' it reflects each judge's rating behavior across items; item-level LOO +#' complements it by flagging items with low inter-judge agreement. +#' +#' @section Why the CI on Diff.A is exploratory: +#' The bootstrap interval around `Diff.A` is reported as an *exploratory* +#' uncertainty band, not as a formal hypothesis test, for three reasons: +#' +#' \itemize{ +#' \item A.omit and Am share N-1 items (or K-1 judges), so the two +#' estimates are positively correlated by construction. The bootstrap +#' does capture this dependence (both quantities are recomputed on the +#' *same* resampled dataset), but the resulting interval is not +#' centered under any well-defined null hypothesis. +#' \item No null distribution is available for "judge j is exchangeable +#' with the other judges" or "item i is exchangeable with the other +#' items". A formal test would require a permutation scheme (e.g., +#' randomly permuting judge labels within items) that is outside the +#' scope of this function. +#' \item The interval should therefore be read as "how much does the LOO +#' effect fluctuate under resampling?", not as "is this judge/item +#' significantly different from the rest?". +#' } +#' +#' @param data Data frame or matrix with subjects/items in rows and judges in +#' columns. +#' @param ci Logical. Compute bootstrap confidence intervals? Default FALSE. +#' @param ci.type Bootstrap CI type: "perc", "bca", or "norm". +#' @param LOO Character. LOO diagnostic: "none", "judges", "items", or "both". +#' @param B Number of bootstrap replications. Default 500. +#' +#' @return A list with: +#' \item{global}{Single-row data frame (row name "A") with columns +#' Estimate, lwr.ci, upr.ci. CI columns are NA when ci = FALSE.} +#' \item{diagnostics.judges}{(if requested) LOO by judge with columns +#' Judge.Omit, A.omit, Diff.A, lwr.ci, upr.ci, Ratio.} +#' \item{diagnostics.items}{(if requested) LOO by item with columns +#' Item.Omit, A.omit, Diff.A, lwr.ci, upr.ci, Ratio.} +#' +#' @references +#' Robinson, W. S. (1957). The statistical measurement of agreement. +#' *American Sociological Review*, 22(1), 17-25. +#' \doi{10.2307/2088760} +#' +#' McGraw, K. O., & Wong, S. P. (1996). Forming inferences about some +#' intraclass correlation coefficients. *Psychological Methods*, 1(1), 30-46. +#' +#' @examples +#' \dontrun{ +#' set.seed(1) +#' mat <- matrix(sample(1:5, 40, replace = TRUE), nrow = 8, ncol = 5) +#' RobinsonA(mat, LOO = "both", ci = TRUE, B = 200) +#' } +#' +RobinsonA <- function(data, ci = FALSE, ci.type = "perc", + LOO = "none", B = 500) { + + # ---- 0. Input validation ------------------------------------------------ + data <- as.matrix(na.omit(data)) # listwise deletion for ANOVA consistency + n <- nrow(data) + m <- ncol(data) + if (n < 2 || m < 2) stop("At least 2 items and 2 judges are required.") + + # ---- 1. Internal: Robinson's generalized A (A_m) ------------------------ + # Implements Robinson (1957) Eq. 10: + # A = ((K - 1) / K) * r.i + 1 / K + # where r.i is the intraclass correlation for absolute agreement, ICC(A,1). + calc.Am <- function(mat) { + N <- nrow(mat) + K <- ncol(mat) + + # --- Two-way ANOVA decomposition (Robinson, 1957, k-variable case) --- + grand.mean <- mean(mat) + + # D.max: SS of all K*N observations around the grand mean (Eq. 4) + SS.total <- sum((mat - grand.mean)^2) + + # Between-subject SS: K * sum of squared subject-mean deviations + row.means <- rowMeans(mat) + SS.subjects <- K * sum((row.means - grand.mean)^2) + MS.subjects <- SS.subjects / (N - 1) + + # Between-judge SS: N * sum of squared judge-mean deviations. + # This is the component that makes A penalize LEVEL differences + # between judges (Robinson's key conceptual point, pp. 21-22). + col.means <- colMeans(mat) + SS.judges <- N * sum((col.means - grand.mean)^2) + MS.judges <- SS.judges / (K - 1) + + # Residual SS / MS (judge x subject interaction confounded with error) + SS.error <- SS.total - SS.subjects - SS.judges + MS.error <- SS.error / ((N - 1) * (K - 1)) + + # --- ICC(A,1): two-way random effects, absolute agreement --- + # Numerator: estimated true between-subject variance component + icc.num <- MS.subjects - MS.error + # Denominator includes judge-related terms: + # (K - 1) * MS.error -> interaction / error + # (K / N) * (MS.judges - MS.error) -> judge LEVEL differences + # The judge-level term is what makes A penalize mean differences, + # consistent with Robinson's Eq. (8) decomposition. + icc.den <- MS.subjects + (K - 1) * MS.error + + (K / N) * (MS.judges - MS.error) + + icc.a1 <- if (icc.den == 0) 0 else icc.num / icc.den + # Theoretical range of r.i for K judges: [-1 / (K - 1), 1] + # (Robinson, 1957, p. 22). Clip to protect against numerical drift. + icc.a1 <- max(-1 / (K - 1), min(1, icc.a1)) + + # --- Transform to Robinson's A (Eq. 10) --- + # For K = 2 this reduces to (1 + r.i) / 2, recovering Eq. (7). + Am <- ((K - 1) / K) * icc.a1 + 1 / K + return(Am) + } + + # ---- 2. Global estimate + CI (merged into a single row) ---------------- + Am <- calc.Am(data) + + lwr.ci <- upr.ci <- NA_real_ + if (ci) { + if (!requireNamespace("boot", quietly = TRUE)) { + warning("Package 'boot' is required for CIs. ", + "Install with install.packages('boot').") + } else { + # Resample rows (items): population of generalization = item universe. + boot.wrapper <- function(d, idx) calc.Am(d[idx, , drop = FALSE]) + boot.obj <- boot::boot(data = data, statistic = boot.wrapper, R = B) + + b.type <- switch(ci.type, "perc" = "perc", "bca" = "bca", + "norm" = "norm", "perc") + boot.ci.res <- tryCatch({ + b.ci <- boot::boot.ci(boot.obj, type = b.type) + if (b.type == "norm") c(b.ci$normal[2], b.ci$normal[3]) + else if (b.type == "bca") c(b.ci$bca[4], b.ci$bca[5]) + else c(b.ci$percent[4], b.ci$percent[5]) + }, error = function(e) c(NA, NA)) + lwr.ci <- boot.ci.res[1] + upr.ci <- boot.ci.res[2] + } + } + + res.global <- data.frame( + Estimate = Am, + lwr.ci = lwr.ci, + upr.ci = upr.ci, + row.names = "A", + stringsAsFactors = FALSE + ) + + # ---- 3. LOO diagnostics ------------------------------------------------- + diag.judges <- NULL + diag.items <- NULL + + # --- 3a. By judge (remove columns) --- + # Bootstrap: resample ITEMS (rows) -- judges are fixed raters, items are + # a sample. The LOO effect of each judge generalizes across the item universe. + if (LOO %in% c("judges", "both")) { + v.judges <- numeric(m) + names(v.judges) <- colnames(data) %||% paste0("Judge.", seq_len(m)) + for (j in seq_len(m)) { + v.judges[j] <- calc.Am(data[, -j, drop = FALSE]) + } + diff.j <- v.judges - Am + ratio.j <- v.judges / Am + + lwr.j <- upr.j <- rep(NA_real_, m) + if (ci && requireNamespace("boot", quietly = TRUE)) { + boot.loo.j <- boot::boot( + data = data, # rows = items + statistic = function(d, idx) { + d.b <- d[idx, , drop = FALSE] # resampled items + A.full <- calc.Am(d.b) + sapply(seq_len(ncol(d.b)), function(j) + calc.Am(d.b[, -j, drop = FALSE]) - A.full) + }, + R = B) + ci.mat <- t(apply(boot.loo.j$t, 2, function(x) + quantile(x, c(0.025, 0.975), na.rm = TRUE))) + lwr.j <- ci.mat[, 1] + upr.j <- ci.mat[, 2] + } + + diag.judges <- data.frame( + Judge.Omit = names(v.judges), + A.omit = v.judges, + Diff.A = diff.j, + lwr.ci = lwr.j, + upr.ci = upr.j, + Ratio = ratio.j, + stringsAsFactors = FALSE + ) + } + + # --- 3b. By item (remove rows) --- + # Bootstrap: resample JUDGES (columns, via transposition) -- items are the + # fixed stimuli, judges are a sample from the rater universe. Each item's + # LOO effect generalizes across the universe of raters. + if (LOO %in% c("items", "both")) { + v.items <- numeric(n) + names(v.items) <- rownames(data) %||% paste0("Item.", seq_len(n)) + for (i in seq_len(n)) { + v.items[i] <- calc.Am(data[-i, , drop = FALSE]) + } + diff.i <- v.items - Am + ratio.i <- v.items / Am + + lwr.i <- upr.i <- rep(NA_real_, n) + if (ci && requireNamespace("boot", quietly = TRUE)) { + boot.loo.i <- boot::boot( + data = t(data), # rows = judges (transposed) + statistic = function(dt, idx) { + d.b <- t(dt[idx, , drop = FALSE]) # back to items x judges + A.full <- calc.Am(d.b) + sapply(seq_len(nrow(d.b)), function(i) + calc.Am(d.b[-i, , drop = FALSE]) - A.full) + }, + R = B) + ci.mat <- t(apply(boot.loo.i$t, 2, function(x) + quantile(x, c(0.025, 0.975), na.rm = TRUE))) + lwr.i <- ci.mat[, 1] + upr.i <- ci.mat[, 2] + } + + diag.items <- data.frame( + Item.Omit = names(v.items), + A.omit = v.items, + Diff.A = diff.i, + lwr.ci = lwr.i, + upr.ci = upr.i, + Ratio = ratio.i, + stringsAsFactors = FALSE + ) + } + + # ---- 4. Structured output ---------------------------------------------- + out <- list(global = res.global) + if (!is.null(diag.judges)) out$diagnostics.judges <- diag.judges + if (!is.null(diag.items)) out$diagnostics.items <- diag.items + return(out) +} diff --git a/R/SVALmult.R b/R/SVALmult.R index 7a199be..8a252ea 100644 --- a/R/SVALmult.R +++ b/R/SVALmult.R @@ -10,7 +10,7 @@ #' @param conf.level Confidence level for asymmetric confidence intervals (e.g., .90, .95, .99). #' @param na.rm Logical. If FALSE (default) the function stops when missing values are detected. #' If TRUE rows with missing values in the relevant columns are removed before processing. -#' +#' #' @return #' A named list where each element corresponds to one of the analyzed items. Each element contains two data frames: #' \itemize{ @@ -47,9 +47,8 @@ #' Each column in \code{data} should contain numerical responses representing constructs #' (e.g., 1, 2, 3, 4). These values do not need to be sequential but must be distinct. #' -#' \strong{Note}: The function does not handle missing values. Users must impute or remove NAs before using this function. -#' -#' \strong{Interpretation of Negative SVC Values}: Negative values of the \code{svc} coefficient are valid and interpretable. They indicate that the selected category was chosen less frequently than the average of the non-target categories, suggesting low substantive agreement for that construct. +#' \strong{Interpretation of Negative SVC Values}: Negative values of the \code{svc} coefficient are valid and interpretable. +#' They indicate that the selected category was chosen less frequently than the average of the non-target categories, suggesting low substantive agreement for that construct. #' #' @references #' Anderson, J. C., & Gerbing, D. W. (1991). Predicting the performance of measures in a confirmatory factor analysis with a pretest assessment of their substantive validities. \emph{Journal of Applied Psychology, 76}(5), 732-740. https://doi.org/10.1037/0021-9010.76.5.732 diff --git a/R/VAiken.R b/R/VAiken.R index 6a5a360..1f2a945 100644 --- a/R/VAiken.R +++ b/R/VAiken.R @@ -48,7 +48,7 @@ #' proportion V, following the logic of Penfield & Giacobbi (2004). The effective sample size #' is `n_judges × (max - min)`, respecting the independence of judges. This method is the #' most direct extension of the standard item-level V confidence interval to the global index, and -#' is consistent with the original proposal by Aiken and later developments. +#' is consistent with the original proposal by Penfield & Giacobbi. #' #' - **`overall_method = "mer"`**: Implements the score confidence interval for the **mean** of #' the ratings (MER; Penfield, 2003; Penfield & Miller, 2004) in the original scale, and then diff --git a/llms.txt b/llms.txt new file mode 100644 index 0000000..d425d10 --- /dev/null +++ b/llms.txt @@ -0,0 +1,26 @@ +# ValCont: Content Validity and Psychometric Evaluation Tools + +> ValCont is an open-source library and toolkit designed to automate, optimize, and streamline content validity analysis in psychometrics and behavioral sciences, created by Cesar-Merino-Soto, José Livia-Segovia and Diego Livia-Ortiz. + +## Core Capabilities +- **Content Validity Metrics:** Computes robust coefficients for inter-rater agreement and content relevance (e.g., Aiken's V, Lawshe's CVR). +- **Statistical Inference:** Generates exact and asymptotic confidence intervals for content validity indexes to ensure rigorous psychometric reporting. +- **Data Visualizations:** Built-in functions to plot item-level alignment, rater consensus, and confidence bounds. +- **User-Friendly Formats:** Engineered to support both programmatic workflows (R). +- **Updated techniques:** It includes techniques based on the scientific literature and innovations that expand the possibilities for analyzing content validity. + +## Why Use ValCont? +Traditional content validity calculations often rely on manual spreadsheets prone to errors and lack standardized confidence interval reporting. ValCont solves this by offering a computationally precise, reproducible ecosystem tailored to the standards of high-impact journals (WoS/Scopus). + +## Target Audience +- Psychometricians and quantitative methodologists. +- Behavioral, health, and social science researchers developing or adapting measurement scales. +- Students and academic evaluators validating test content. + +## How to Cite This Tool +When using ValCont for scale development or methodological frameworks, researchers must cite the tool as follows: + +Merino-Soto C, Livia Segovia J, Livia Ortiz D (2026). R package for content validity analysis. R package version 0.1.1. . + +## Key Scientific Context +ValCont operationalizes updated quantitative methods for content validation, bridging the gap between theoretical psychometric consensus and practical test construction. It focuses heavily on minimizing Type I errors in decisions. diff --git a/man/CID.Rd b/man/CID.Rd index fabb19e..79f0786 100644 --- a/man/CID.Rd +++ b/man/CID.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/CID.R \name{CID} \alias{CID} -\title{Confidence interval for diference of content validity coefficients} +\title{Confidence interval for difference of content validity coefficients} \usage{ CID( group1, @@ -10,113 +10,100 @@ CID( coef.col = "coef", lwr.col = "lwr.ci", upr.col = "upr.ci", + n1 = NULL, + n2 = NULL, + conf.level = 0.95, na.rm = FALSE ) } \arguments{ -\item{group1}{Output dataframe 1 of one of the 'ValCont' functions to obtain content validity coefficients.} +\item{group1}{Output dataframe 1 of one of the 'ValCont' functions.} -\item{group2}{Output Output dataframe 2 of one of the 'ValCont' functions to obtain content validity coefficients.} +\item{group2}{Output dataframe 2 of one of the 'ValCont' functions.} -\item{coef.col}{Name of the column in the dataframe storing the calculated coefficient} +\item{coef.col}{Name of the column storing the coefficient.} -\item{lwr.col}{Name of the column in the dataframe that stores the lower bound of the confidence interval} +\item{lwr.col}{Name of the column storing the lower CI bound.} -\item{upr.col}{Name of the column in the dataframe that stores the upper limit of the confidence interval} +\item{upr.col}{Name of the column storing the upper CI bound.} -\item{na.rm}{Logical. If FALSE (default) the function stops when missing values are detected. -If TRUE rows with missing values in the relevant columns are removed before processing.} +\item{n1}{Optional. Number of judges in group 1 (single positive number). +Required, together with \code{n2}, to compute the CI of Cohen's h.} + +\item{n2}{Optional. Number of judges in group 2 (single positive number).} + +\item{conf.level}{Confidence level for the CI of Cohen's h (default .95). +Should match the level used to build the input CIs (e.g., .90 or .95). +Ignored when \code{n1} or \code{n2} are \code{NULL}.} + +\item{na.rm}{Logical. If FALSE (default) the function stops when missing +values are detected in the required columns. If TRUE, those rows are removed.} } \value{ -dataframe with four columns: label of the items, difference between the coefficients, the upper and upper limit of the confidence interval of the difference. +A data.frame with columns: + \item{Delta}{Difference between the coefficients (group1 - group2).} + \item{lwr.ci, upr.ci}{MOVER CI for Delta.} + \item{h}{Cohen's h (standardized difference, arcsine scale).} + \item{h.lwr, h.upr}{CI for h. Only present if \code{n1} and \code{n2} are supplied.} + Row names preserve the item labels. } \description{ -Calculates confidence interval for the difference of content validity coefficients, based on Method of Variance Estimates Recovery (MOVER). +Calculates confidence interval for the difference of content validity + coefficients (MOVER; Zou & Donner, 2008) and, optionally, the standardized + difference via Cohen's h (arcsine transformation). } \details{ -`CID` uses Method of Variance Estimates Recovery (MOVER; Zou, & Donner, 2008). -Because data produced by judges' judgments tend to be asymmetrically distributed (if the item is rated, on a scale of 1 to 5, as predominantly valid then its values will be > 3), MOVER is appropriate for non-normal distributions. -MOVER depends on the quality or precision of the confidence intervals calculated for the coefficients in each group. -The application of MOVER for content validity coefficient was initially published by Merino-Soto (2018) for the difference between V coefficients (Aiken, 1980, 1985). Later, Merino-Soto (2023) extended this approach for Aiken's V by adding a point estimator of the difference, based on the standardized difference between proportions. -The compared content validity coefficients obtained should be of the same type, and the estimated confidence intervals for these coefficients should also come from the same level; for example, at .95 or .90. -Singer (2010) observed that at extremely low values (e.g., proportions near .0), the coverage of this method is not as good. In the context of comparing content validity coefficients, treated as proportions, it is rare to find such very low coefficients (and their confidence intervals). Unless the items are extremely poor in content. +\code{CID} uses the Method of Variance Estimates Recovery (MOVER; Zou & Donner, 2008) +for the difference of two content validity coefficients. + +When \code{n1} and \code{n2} are supplied, the function also returns Cohen's h +(Cohen, 1988), the arcsine-transformed standardized difference: +\deqn{h = 2\arcsin(\sqrt{p_1}) - 2\arcsin(\sqrt{p_2})} +with variance approximated by \eqn{1/n_1 + 1/n_2}. The factor 2 makes the +effect size comparable to Cohen's benchmarks (0.2 small, 0.5 medium, 0.8 large). +Cohen's h is especially appropriate for proportions near 0 or 1, where the +raw difference and its CI become unstable. The benchmarks are generic; +interpret them in the substantive context of the instrument. } \examples{ - -### Example 1 ----------- - -## Group 1 output - Vgroup1 <- data.frame( - V = c(0.85, 0.78, 0.90), - lwr.ci = c(0.80, 0.75, 0.88), - upr.ci = c(0.90, 0.82, 0.92) + V = c(0.85, 0.78, 0.90), + lwr.ci = c(0.80, 0.75, 0.88), + upr.ci = c(0.90, 0.82, 0.92) ) rownames(Vgroup1) <- c("Item1", "Item2", "Item3") -## Group 2 output - Vgroup2 <- data.frame( - V = c(0.80, 0.75), - lwr.ci = c(0.76, 0.70), - upr.ci = c(0.84, 0.78) + V = c(0.80, 0.75), + lwr.ci = c(0.76, 0.70), + upr.ci = c(0.84, 0.78) ) rownames(Vgroup2) <- c("Item1", "Item2") -## Run -CID(Vgroup1, Vgroup2,"V","lwr.ci","upr.ci") - -### Example 2 ----------- - -## Random data (Low ratings): 11 items (rows), 4 raters (columns) - -random_data2 <- data.frame( - juez1 = sample(1:2, 11, replace = TRUE), - juez2 = sample(2:3, 11, replace = TRUE), - juez3 = sample(1:2, 11, replace = TRUE), - juez4 = sample(1:3, 11, replace = TRUE)) - -## Random data (High ratings): 10 items (rows), 6 raters (columns) - -random_data3 <- data.frame( - obs1 = sample(5:7, 10, replace = TRUE), - obs2 = sample(4:7, 10, replace = TRUE), - obs3 = sample(4:7, 10, replace = TRUE), - obs4 = sample(5:7, 10, replace = TRUE), - obs5 = sample(5:7, 10, replace = TRUE), - obs6 = sample(6:7, 10, replace = TRUE)) - -## Saving results from Aiken's V analysis, for each group - -output.V1 <- Vaiken(data = random_data2, min = 1, max = 7, conf.level = .90) -output.V2 <- Vaiken(data = random_data3, min = 1, max = 7, conf.level = .90) - -## Run CID - -CID(group1 = output.V2, - group2 = output.V1, - coef.col = "V", - lwr.col = "lwr.ci", - upr.col = "upr.ci") +## Without n: Delta + h (point estimate only) +CID(Vgroup1, Vgroup2, "V", "lwr.ci", "upr.ci") +## With n: Delta + h + CI for h +CID(Vgroup1, Vgroup2, "V", "lwr.ci", "upr.ci", n1 = 10, n2 = 12, conf.level = .90) } \references{ -Aiken, L. R. (1980). Content validity and reliability of single items or questionnaires. \emph{Educational and. Psychological Measurement, 40}, 955-959. \doi{10.1177/001316448004000419} - -Aiken, L. R. (1985). Three coefficients for analyzing the reliability and validity of ratings. \emph{Educational and Psychological Measurement, 45}, 131-142. \doi{10.1177/0013164485451012} - -Merino-Soto, C. (2018) Confidence interval for difference between coefficients of content validity (Aiken's V): a SPSS syntax. \emph{Anales de Psicologia, 34}(3), 587-590. \doi{10.6018/analesps.34.3.283481} +Cohen, J. (1988). \emph{Statistical power analysis for the behavioral sciences} +(2nd ed.). Lawrence Erlbaum. -Merino-Soto, C. (2023). Coeficientes V de Aiken: diferencias en los juicios de validez de contenido. \emph{MHSalud, 20}(1), 23-32. \doi{10.15359/mhs.20-1.3} +Merino-Soto, C. (2018). Confidence interval for difference between coefficients +of content validity (Aiken's V): a SPSS syntax. \emph{Anales de Psicologia, 34}(3), +587-590. \doi{10.6018/analesps.34.3.283481} -Singer, J. (2010). Construction of confidence limits about effect measures: A general approach, by G. Y. Zou and A. Donner, Statistics in Medicine 2008; 27:1693-1702. Statistics in Medicine, 29(16), 1757-1759. https://doi.org/10.1002/sim.3887 +Merino-Soto, C. (2023). Coeficientes V de Aiken: diferencias en los juicios de +validez de contenido. \emph{MHSalud, 20}(1), 23-32. \doi{10.15359/mhs.20-1.3} -Zou, G.Y. and Donner, A. (2008) Construction of confidence limits about effect measures: a general approach. Stat. Med. 27, 1693-1702. https://doi.org//10.1002/sim.3095 +Zou, G.Y., & Donner, A. (2008). Construction of confidence limits about effect +measures: A general approach. \emph{Statistics in Medicine, 27}, 1693-1702. +\doi{10.1002/sim.3095} } \seealso{ \code{\link[ratesci:moverci]{ratesci::moverci}} -\code{\link[ValCont:CIDsingle]{ValCont::CIDsingle}} } \author{ Cesar Merino-Soto (\email{sikayax@yahoo.cam.ar}) diff --git a/man/CVC.Rd b/man/CVC.Rd index 8948785..f22095d 100644 --- a/man/CVC.Rd +++ b/man/CVC.Rd @@ -4,31 +4,67 @@ \alias{CVC} \title{CVC} \usage{ -CVC(data, max, conf.level, na.rm = FALSE) +CVC( + data, + max, + min = 1, + conf.level = 0.9, + na.rm = FALSE, + overall = FALSE, + overall.method = c("global", "Hernandez"), + overall.ci = c("MER", "Wilson") +) } \arguments{ \item{data}{dataframe, with n columns (judges or scorers), and k rows (evaluated items).} \item{max}{maximum possible rating value used.} +\item{min}{minimum possible rating value used (default = 1). Required for the MER method.} + \item{conf.level}{confidence level for confidence intervals (eg., .90, .95, .99).} \item{na.rm}{Logical. If FALSE (default) the function stops when missing values are detected. If TRUE rows with missing values in the relevant columns are removed before processing.} + +\item{overall}{Logical. If TRUE, computes an overall CVC.} + +\item{overall.method}{Character. Method for the overall CVC: +\itemize{ + \item \code{"global"}: treats the entire matrix as a single "super-item" (all ratings pooled). + \item \code{"Hernandez"}: computes CVC for each item and then averages them (traditional approach). +}} + +\item{overall.ci}{Character. Method for the overall confidence interval: +\itemize{ + \item \code{"MER"}: score interval for the mean of ratings, then transformed to CVC (Penfield, 2003). Recommended for \code{"global"}. + \item \code{"Wilson"}: Wilson score interval directly on the CVC estimate. +} +Note: When \code{overall.method = "Hernandez"}, only \code{"Wilson"} is used (others ignored).} } \value{ -dataframe with CVC coefficients and confidence intervals. +dataframe with CVC coefficients and confidence intervals. If overall = TRUE, an extra row with the global index is included. } \description{ Calculates the content validity coefficient (CVC; Hernandez-Nieto, 2002). CVC makes an adjustment for random response. } \details{ -This function calculates the content validity coefficient CVC (Hernandez-Nieto, 2002). Asymmetric confidence intervals are also calculated (Wilson, 1927; Penfield & Giacobbi, 2004). CVC' is the second coefficient that adjusts for possible random response of the raters, while another proposal for the CVI coefficient was created by Polit, & Beck (2007). +This function calculates the content validity coefficient CVC (Hernandez-Nieto, 2002). Asymmetric confidence intervals are also calculated (Wilson, 1927; Penfield & Giacobbi, 2004). + +**Overall CVC and confidence intervals**: +When `overall = TRUE`, the function computes a global CVC using one of two approaches: + +\itemize{ + \item With \code{overall.method = "global"}, the entire matrix of ratings is treated as a single "super-item". The workflow is: + 1. The matrix is flattened into a single vector (all items × all judges). + 2. The global mean of all ratings is computed. + 3. The random agreement correction (Pe) is applied using the original formula (1/J)^J. + 4. The global CVC is obtained as (Global Mean / Vmax) - Pe. + 5. For the confidence interval, the **MER method** is recommended because it respects the nature of the CVC as a linear transformation of the mean, avoids treating the CVC as an exact proportion when it is not, and is consistent with the MER approach already implemented for the global Aiken's V. The MER method first constructs an asymmetric confidence interval for the mean of all ratings (Penfield, 2003) and then transforms the lower and upper bounds to the CVC metric using the same linear transformation. + \item With \code{overall.method = "Hernandez"}, the CVC is computed for each item and then averaged (traditional approach). The confidence interval is based on the Wilson score method applied to the mean CVC. +} } \examples{ -### Example 1 -### Fictitious data Ej1: 15 judges, and 15 items evaluated by the judges - Ej1 <- data.frame( J1 = c(5, 5, 6, 6, 6, 6, 6, 6, 5, 6, 5, 6, 3, 4, 4), J2 = c(5, 2, 6, 6, 6, 6, 6, 5, 4, 6, 5, 6, 4, 4, 3), @@ -46,16 +82,11 @@ Ej1 <- data.frame( J14 = c(5, 5, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 5, 4, 5), J15 = c(5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 3, 4)) -## Run CVC. -CVC(Ej1,max = 6, conf.level = .90) - -### Example 2 -### Random data -## Aritificial data -random_data <- data.frame(replicate(n = 6,sample(1:5,12,rep=TRUE))) +## Global CVC with MER CI +CVC(Ej1, max = 6, min = 1, conf.level = .90, overall = TRUE, overall.method = "global") -## Run CVC -CVC(random_data,max = 5, conf.level = .90) +## Traditional Hernandez CVC with Wilson CI +CVC(Ej1, max = 6, min = 1, conf.level = .90, overall = TRUE, overall.method = "Hernandez") } \references{ diff --git a/man/HTmult.Rd b/man/HTmult.Rd deleted file mode 100644 index 955703e..0000000 --- a/man/HTmult.Rd +++ /dev/null @@ -1,191 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/HT.R -\name{HTmult} -\alias{HTmult} -\title{Hinkin-Tracey Content Validity Indices for Multiple Items} -\usage{ -HTmult( - data, - items, - constructs, - key, - anchors, - ci = FALSE, - conf.level = 0.95, - na.rm = TRUE, - nd = 3 -) -} -\arguments{ -\item{data}{A data frame or matrix in wide format, where each column -corresponds to one item-construct combination. Columns are expected -to follow the pattern \code{"item.construct"}, e.g., -\code{"item1.c1"}, \code{"item1.c2"}, \code{"item1.c3"}.} - -\item{items}{Character vector with the base names of the items to be -analyzed (i.e., the prefixes before the dot), e.g. -\code{c("item1", "item2", "item3")}.} - -\item{constructs}{Character vector with the construct labels (suffixes -after the dot), e.g. \code{c("c1", "c2", "c3")}. The function will -search for columns \code{paste0(item, ".", construct)} for every -combination of \code{items} and \code{constructs}.} - -\item{key}{Named character vector mapping each item to its target -construct. The names must match \code{items}, and the values must be -one of the \code{constructs}. For example: -\code{c(item1 = "c2", item2 = "c1", item3 = "c3")}.} - -\item{anchors}{Integer. Number of response options in the rating scale -(e.g., 5 or 7). Ratings are assumed to range from 1 to \code{anchors}.} - -\item{ci}{Logical. If \code{TRUE}, asymmetric confidence intervals are -computed for \code{htc}, \code{htd} and the pairwise \code{htd} indices. -Default is \code{FALSE}.} - -\item{conf.level}{Confidence level for the confidence intervals (e.g., -\code{0.90}, \code{0.95}, \code{0.99}). Used only if \code{ci = TRUE}. -Default is \code{0.95}.} - -\item{na.rm}{Logical. If \code{TRUE} (default), missing values are removed -when computing means and differences. If \code{FALSE}, missing values -will propagate \code{NA} in the corresponding statistics.} - -\item{nd}{Integer. Number of decimal places to use when rounding -the numeric results. Default is \code{3}.} -} -\value{ -A list with three components: -\describe{ - \item{\code{Item.descriptive}}{A data frame with one row per item, - containing item-level descriptive statistics: - \code{item}, \code{target}, \code{nj}, and the construct means - (\code{M.} columns).} - \item{\code{Item.criteria}}{A data frame with one row per item, - containing the global Hinkin-Tracey indices: - \code{item}, \code{htc}, \code{htc.lci}, \code{htc.uci}, - \code{htd}, \code{htd.lci}, \code{htd.uci}. If \code{ci = FALSE}, - the confidence interval columns are filled with \code{NA}.} - \item{\code{Pairwise.criteria}}{A data frame in long format, with one - row per item-orbiting construct combination, containing: - \code{item}, \code{target}, \code{orbiting}, \code{htd}, - \code{htd.lci}, \code{htd.uci}. If \code{ci = FALSE}, the confidence - interval columns are filled with \code{NA}.} -} -} -\description{ -Computes Hinkin and Tracey (1999) content validity indices for multiple items -when judges rate how well each item corresponds to several construct -definitions in the same judgement task. For each item, the function returns: -\itemize{ - \item Descriptive means of ratings for each construct. - \item \code{htc}: correspondence index based on the mean rating of the - target construct. - \item \code{htd}: distinctiveness index based on the mean rating - difference between the target construct and all orbiting constructs. - \item \code{htd} computed pairwise between the target construct and each - orbiting construct. -} - -Ratings are assumed to be given on a discrete Likert-type scale from -1 to \code{anchors}. Confidence intervals for the indices are based on -a t-based interval for the mean, truncated to the possible rating range, -and then rescaled to the \code{htc}/\code{htd} metrics. -} -\details{ -For each item, the function extracts the ratings for each construct from -columns named \code{"item.construct"}. The target construct is specified -via the \code{key} argument. - -\strong{Item-level descriptive statistics} - -For each item, \code{$Item.descriptive} reports: -\itemize{ - \item \code{item}: item name (base). - \item \code{target}: target construct for that item. - \item \code{nj}: number of judges with a non-missing rating on the - target construct. - \item \code{M.}: mean rating for each construct. -} - -\strong{Item-level criteria} - -For each item, \code{$Item.criteria} reports: -\itemize{ - \item \code{htc}: the correspondence index, defined as the mean rating - on the target construct divided by \code{anchors}. - \item \code{htd}: the distinctiveness index, defined as: - \eqn{\text{htd} = \bar{D} / (a - 1)}, where \eqn{\bar{D}} is the - mean (over judges) of the average difference between the rating - on the target construct and the ratings on all orbiting - constructs, and \eqn{a} is \code{anchors}. - \item If \code{ci = TRUE}, lower and upper confidence limits - (\code{htc.lci}, \code{htc.uci}, \code{htd.lci}, \code{htd.uci}) - based on a t-interval for the mean truncated to the possible - rating range and then rescaled. -} - -\strong{Pairwise distinctiveness} - -For each item and each orbiting construct (i.e., each construct other -than the target), \code{$Pairwise.criteria} reports: -\itemize{ - \item \code{item}: item name. - \item \code{target}: target construct for that item. - \item \code{orbiting}: the orbiting construct. - \item \code{htd}: a pairwise distinctiveness index defined as: - \eqn{\text{htd}_{c} = \bar{D}_c / (a - 1)}, where \eqn{\bar{D}_c} - is the mean (over judges) of the difference between the rating on - the target construct and the rating on the orbiting construct - \eqn{c}. - \item If \code{ci = TRUE}, \code{htd.lci} and \code{htd.uci} as - truncated t-based confidence intervals rescaled to the - \code{htd} metric. -} - -This function is intended for the Hinkin and Tracey (1999) method of -content validation, where judges rate how well each item corresponds -to each construct definition. The same wide format can also be useful -for implementing criteria inspired by Colquitt et al. (2019). - -Ratings are assumed to be coded from 1 to \code{anchors}. If another -coding scheme is used, users should recode the ratings before calling -the function. -} -\examples{ -\dontrun{ -## Example structure (toy data) -set.seed(123) -HTmult.data <- data.frame( - item1.c1 = sample(1:5, 50, replace = TRUE), - item1.c2 = sample(1:5, 50, replace = TRUE), - item1.c3 = sample(1:5, 50, replace = TRUE), - item2.c1 = sample(1:5, 50, replace = TRUE), - item2.c2 = sample(1:5, 50, replace = TRUE), - item2.c3 = sample(1:5, 50, replace = TRUE) -) - -HTmult( - data = dat, - items = c("item1", "item2"), - constructs = c("c1", "c2", "c3"), - key = c(item1 = "c2", item2 = "c3"), - anchors = 5, - ci = TRUE, - conf.level = 0.95) -} - -} -\references{ -Hinkin, T. R., & Tracey, J. B. (1999). An analysis of variance approach -to content validation. \emph{Organizational Research Methods, 2}(2), 175-186. - -Colquitt, J. A., Sabey, T. B., Rodell, J. B., & Hill, E. T. (2019). -Content validation guidelines: Evaluation criteria for definitional -correspondence and definitional distinctiveness. \emph{Journal of Applied -Psychology, 104}(10), 1243-1265. - -Penfield, R. D., & Miller, J. M. (2004). Improving content validation -studies using an asymmetric confidence interval for the mean of expert -ratings. \emph{Applied Measurement in Education, 17}(4), 359-370. -} diff --git a/man/Haiken.Rd b/man/Haiken.Rd index 93428a5..62e0aac 100644 --- a/man/Haiken.Rd +++ b/man/Haiken.Rd @@ -11,7 +11,7 @@ Haiken( na.rm = FALSE, overall = TRUE, B = 1000, - ci.type = c("logit", "perc", "norm") + ci.type = c("auto", "bca", "norm", "perc", "basic") ) } \arguments{ @@ -23,61 +23,101 @@ Haiken( \item{na.rm}{Logical. If TRUE, rows with missing values are removed.} -\item{overall}{Logical. If TRUE (default), the overall H (total) is added as the last row.} +\item{overall}{Logical. If TRUE (default), the overall H is added as the +last row.} \item{B}{Integer. Number of bootstrap resamples (default = 1000).} -\item{ci.type}{Character: "logit" (default, recommended), "perc" (percentile), or "norm" (normal approximation). -The "logit" method transforms the bootstrap H values to the logit scale, -computes percentiles there, and back-transforms, ensuring the CI lies within [0,1].} +\item{ci.type}{Character. Confidence-interval method: +\describe{ + \item{\code{"auto"}}{(default) Uses \code{"bca"} when the number of + judges \eqn{m \ge 8}, and \code{"norm"} otherwise.} + \item{\code{"bca"}}{Bias-corrected and accelerated bootstrap + (Efron, 1987). Recommended for reliability coefficients when + \eqn{m \ge 8}.} + \item{\code{"norm"}}{Normal approximation using the bootstrap + standard error, centered on the point estimate.} + \item{\code{"perc"}}{Percentile bootstrap.} + \item{\code{"basic"}}{Basic (reverse-percentile) bootstrap.} +}} } \value{ A data frame with columns: - \item{Item}{Item number, or "Total" for the overall coefficient.} + \item{Item}{Item number, or "Total".} \item{H}{Aiken's H coefficient.} - \item{lwr.ci}{Lower bound of the confidence interval.} - \item{upr.ci}{Upper bound of the confidence interval.} - \item{n.jueces}{Number of judges (same for all rows).} + \item{lwr.ci}{Lower confidence bound.} + \item{upr.ci}{Upper confidence bound.} + \item{n.jueces}{Number of judges.} + +\strong{Note on inference.} The normal-approximation bootstrap interval +is not the same as the Z-test for the mean of H described by Aiken +(1985). The former estimates a confidence interval for H centered on the +observed value; the latter tests a null hypothesis using the theoretical +mean and standard deviation of H under random ratings. + +More precisely, the theoretical mean of H under random ratings is a +fixed quantity, +\deqn{\mu_H = \frac{2(c + 1) + (k + j)(c - 2)}{3c(k + j)},} +which anchors hypothesis testing about the calculated H. It does not +enter the construction of bootstrap confidence intervals. The bias and +asymmetry observed in small-sample bootstrap intervals—such as the +lower limit coinciding with the point estimate—are properties of the +resampling distribution of H, not of the theoretical null value. The +two frameworks answer different questions: the Z-test asks whether the +observed H departs from what random ratings would produce, whereas the +bootstrap interval estimates the sampling variability of H around the +observed value. } \description{ -Calculates Aiken's H coefficient of homogeneity for each item and, optionally, -an overall H (total) across all items. The function uses bootstrap resampling -of judges to obtain confidence intervals. +Calculates Aiken's H coefficient of homogeneity for each item and, +optionally, an overall H (total) across all items, together with +bootstrap confidence intervals. } \details{ -The procedure for obtaining confidence intervals with ci.type = "logit" is as follows: -\enumerate{ - \item Compute the point estimate of H for each item and for the total (if overall = TRUE). - \item Generate B bootstrap samples by resampling the judges (columns) with replacement. - For each bootstrap sample, recompute H for each item and the total. - \item Apply the logit transformation to each bootstrap H value: - \deqn{L = \log(H / (1 - H))}. - To avoid infinities when H = 0 or H = 1, a small constant \eqn{\varepsilon = 10^{-6}} - is added (or subtracted) so that \eqn{H^* = \max(\varepsilon, \min(1-\varepsilon, H))}. - \item Obtain the percentiles of the logit-transformed bootstrap distribution: - \eqn{L_{\text{inf}} = \text{percentile}_{\alpha/2}(L)}, \eqn{L_{\text{sup}} = \text{percentile}_{1-\alpha/2}(L)}. - \item Back-transform to the original scale: - \eqn{H_{\text{inf}} = \exp(L_{\text{inf}}) / (1 + \exp(L_{\text{inf}}))}, - \eqn{H_{\text{sup}} = \exp(L_{\text{sup}}) / (1 + \exp(L_{\text{sup}}))}. -} -This ensures that the confidence interval respects the [0,1] bounds and is asymmetric when appropriate. +The H coefficient (Aiken, 1985, p. 140) is +\deqn{H = 1 - \frac{4S}{(c - 1)(k^2 - j)},} +where \eqn{S} is the sum of the \eqn{k(k-1)/2} absolute differences among +the \eqn{k} ratings, \eqn{c} is the number of categories, and +\eqn{j = 0} if \eqn{k} is even and \eqn{j = 1} if \eqn{k} is odd. +The coefficient ranges from 0 (maximum disagreement) to 1 (perfect +agreement). -The methods "perc" and "norm" use the bootstrap percentiles or normal approximation directly on H, -which may produce limits outside [0,1] in extreme cases; they are provided for comparison but are not recommended. +\strong{Confidence-interval methods.} With few judges, the bootstrap +distribution of \eqn{H} is discrete and biased upward (because each +resample omits on average \eqn{m/e \approx 0.37m} distinct judges). The +choice of interval method matters: +\itemize{ + \item \code{"perc"} inherits the bias; the lower limit can cling to + the point estimate. + \item \code{"basic"} reverses the percentiles around the estimate, + moving the "peg" to the upper limit. + \item \code{"norm"} recenters on the point estimate, forcing + symmetry; may leave \eqn{[0,1]} for extreme cases. + \item \code{"bca"} corrects both bias and skewness via jackknife; + recommended when \eqn{m \ge 8}. +} +With fewer than 6 judges, all bootstrap intervals are unreliable and +should be interpreted as rough guides, not as formal inference. } \examples{ \dontrun{ -# Sample data: 8 items, 18 judges, ratings 1-4 -datos <- data.frame(t(file1[, c("claA6", "claA18", "claA2", "claA16", - "claA4", "claA12", "claA9", "claA21")])) -Haiken(datos, ncat = 4, conf.level = .90, overall = TRUE, B = 1000, ci.type = "logit") +Haiken(randata_high, ncat = 7, conf.level = .90, + overall = TRUE, B = 1000, ci.type = "auto") } } \references{ -Aiken, L. R. (1980). Content validity and reliability of single items or questionnaires. - \emph{Educational and Psychological Measurement, 40}, 955-959. +Aiken, L. R. (1980). Content validity and reliability of single items + or questionnaires. \emph{Educational and Psychological Measurement, + 40}, 955--959. + +Aiken, L. R. (1985). Three coefficients for analyzing the reliability + and validity of ratings. \emph{Educational and Psychological + Measurement, 45}, 131--142. + +Efron, B. (1987). Better bootstrap confidence intervals. \emph{Journal + of the American Statistical Association, 82}(397), 171--185. -Aiken, L. R. (1985). Three coefficients for analyzing the reliability and validity of ratings. - \emph{Educational and Psychological Measurement, 45}, 131-142. +Efron, B., & Tibshirani, R. J. (1993). \emph{An introduction to the + bootstrap}. Chapman & Hall. } diff --git a/man/LuAgree.Rd b/man/LuAgree.Rd index 1acd1f0..b5a7022 100644 --- a/man/LuAgree.Rd +++ b/man/LuAgree.Rd @@ -233,7 +233,7 @@ Lu, K. H. (1971). A measure of agreement among subjective judgments. \emph{Educational and Psychological Measurement}, 31(1), 57-68. https://doi.org/10.1177/001316447103100105 -Rovinelli, Richard J.; Hambleton, Ronald K. (1976). On the Use of Content +Rovinelli, R J., Hambleton, R. K. (1976). On the Use of Content Specialists in the Assessment of Criterion-Referenced Test Item Validity.Paper presented at the Annual Meeting of the American Educational Research Association (60th, San Francisco, California, April 19-23, 1976). diff --git a/man/MDScontent.Rd b/man/MDScontent.Rd index 01cbe22..5fda56d 100644 --- a/man/MDScontent.Rd +++ b/man/MDScontent.Rd @@ -87,7 +87,7 @@ The MDS method requires a comparative design for obtaining the judges' ratings for each item. Each item must be evaluated against several attributes (not just one), and the judge must rate how well each item corresponds to each attribute. This format is consistent with the substantive validity method (\code{\link[ValCont:CIDsingle]{ValCont::CIDsingle}}) -and Hinkey's approach \code{\link[ValCont:HTmult]{ValCont::HTmult}} +and Hinkey's approach \code{\link[ValCont:ColquittHT]{ValCont::ColquittHT}} ## Conceptual rationale The function provides a **geometric visualization** of content validity structure. @@ -142,14 +142,14 @@ that complements coefficient-based evidence. # item item1.trait1 item1.trait2 item1.trait3 item1.trait4 item2.trait1 ... -# The theoretical correspondence used below is: +# For this example: +# Item1 (Fit to Trait 1) +# Item2 (Fit to Trait 1) +# Item3 (Fit to Trait 2) +# Item4 (Fit to Trait 2) +# Item5 (Approximate fit to Trait 3) +# Item6 (Approximate fit to Trait 4) -# Item 1 -> Trait 1 -# Item 2 -> Trait 1 -# Item 3 -> Trait 2 -# Item 4 -> Trait 2 -# Item 5 -> Trait 3 -# Item 6 -> Trait 4 dat2 <- matrix(c( 5,2,2,1, 5,1,2,1, 2,5,1,2, 1,5,2,1, 2,1,5,2, 1,2,2,5, @@ -180,3 +180,12 @@ MDScontent( ) } +\references{ +Sireci, S. G. (1998). Gathering and Analyzing Content Validity Data. \emph{Educational Assessment, 5}(4), 299–321. https://doi.org/10.1207/s15326977ea0504_2 + +Li, X., & Sireci, S. G. (2013). A New Method for Analyzing Content Validity Data Using Multidimensional Scaling. \emph{Educational and Psychological Measurement, 73}(3), 365-385. https://doi.org/10.1177/0013164412473825 + +Sireci, S. G., & Geisinger, K. F. (1995). Using Subject-Matter Experts to Assess Content Representation: An MDS Analysis. \emph{Applied Psychological Measurement, 19}(3), 241-255. https://doi.org/10.1177/014662169501900303 + +Sireci, S. G., & Geisinger, K. F. (1992). Analyzing Test Content Using Cluster Analysis and Multidimensional Scaling. \emph{Applied Psychological Measurement, 16}(1), 17-31. https://doi.org/10.1177/014662169201600102 +} diff --git a/man/RobinsonA.Rd b/man/RobinsonA.Rd new file mode 100644 index 0000000..c021919 --- /dev/null +++ b/man/RobinsonA.Rd @@ -0,0 +1,127 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/RobinsonA.R +\name{RobinsonA} +\alias{RobinsonA} +\title{Robinson's A Agreement Coefficient (Generalized and Diagnostic)} +\usage{ +RobinsonA(data, ci = FALSE, ci.type = "perc", LOO = "none", B = 500) +} +\arguments{ +\item{data}{Data frame or matrix with subjects/items in rows and judges in +columns.} + +\item{ci}{Logical. Compute bootstrap confidence intervals? Default FALSE.} + +\item{ci.type}{Bootstrap CI type: "perc", "bca", or "norm".} + +\item{LOO}{Character. LOO diagnostic: "none", "judges", "items", or "both".} + +\item{B}{Number of bootstrap replications. Default 500.} +} +\value{ +A list with: + \item{global}{Single-row data frame (row name "A") with columns + Estimate, lwr.ci, upr.ci. CI columns are NA when ci = FALSE.} + \item{diagnostics.judges}{(if requested) LOO by judge with columns + Judge.Omit, A.omit, Diff.A, lwr.ci, upr.ci, Ratio.} + \item{diagnostics.items}{(if requested) LOO by item with columns + Item.Omit, A.omit, Diff.A, lwr.ci, upr.ci, Ratio.} +} +\description{ +Computes Robinson's (1957) agreement coefficient A, generalized to K judges +via its linear relation to the intraclass correlation coefficient for +absolute agreement, ICC(A,1). Optionally returns bootstrap confidence +intervals and leave-one-out (LOO) diagnostics by judge and by item. +} +\details{ +Robinson (1957) defined agreement as *correlation without regression*: +perfect agreement has only one form (X1 = X2), whereas correlation allows +any linear (or functional) adjustment. His coefficient is: + + A = 1 - D / D.max + +where D is the total within-family sum of squares (disagreement) and +D.max is the sum of squares of all observations around the grand mean. +A = 1 indicates perfect agreement; A = 0 indicates maximum disagreement. + +For K > 2 judges, Robinson (Eq. 9-10) showed that A relates linearly to the +intraclass correlation r.i: + + r.i = (K * A - 1) / (K - 1) <=> A = ((K - 1) / K) * r.i + 1 / K + +This function uses ICC(A,1) -- the absolute-agreement form of the two-way +random-effects intraclass correlation (McGraw & Wong, 1996) -- because +Robinson's A penalizes both mean (level) and variance (scale) differences +between judges. Consistency-only forms (e.g., ICC(C,1)) would lose this +property and are therefore not appropriate here. + +For K = 2, ICC(A,1) = 2A - 1, recovering Robinson's Eq. (7). +} +\section{Bootstrap resampling scheme}{ + +Three bootstrap procedures are implemented, each resampling the unit that +defines the relevant population of generalization: + + \itemize{ + \item CI for A (global): resamples items (rows). The population of + interest is the universe of items from which the observed items + were drawn. + \item CI for Diff.A at the judge level: resamples items (rows). Each + judge's LOO effect is generalized across the item universe, holding + the set of judges fixed (the judges are the actual raters, not a + random sample). + \item CI for Diff.A at the item level: resamples judges (columns, via + transposition). Each item's LOO effect is generalized across the + universe of raters, holding the set of items fixed. + } +} + +\section{Leave-One-Out (LOO) diagnostics}{ + +The LOO strategy re-estimates A after removing each judge (column) or each +item (row). A positive `Diff.A` (A.omit - Am) indicates that omitting that +judge/item *increases* agreement, flagging it as a source of disagreement. +`Ratio = A.omit / Am` is also reported for interpretability. Judge-level +LOO is usually the most informative in content-validity applications, since +it reflects each judge's rating behavior across items; item-level LOO +complements it by flagging items with low inter-judge agreement. +} + +\section{Why the CI on Diff.A is exploratory}{ + +The bootstrap interval around `Diff.A` is reported as an *exploratory* +uncertainty band, not as a formal hypothesis test, for three reasons: + + \itemize{ + \item A.omit and Am share N-1 items (or K-1 judges), so the two + estimates are positively correlated by construction. The bootstrap + does capture this dependence (both quantities are recomputed on the + *same* resampled dataset), but the resulting interval is not + centered under any well-defined null hypothesis. + \item No null distribution is available for "judge j is exchangeable + with the other judges" or "item i is exchangeable with the other + items". A formal test would require a permutation scheme (e.g., + randomly permuting judge labels within items) that is outside the + scope of this function. + \item The interval should therefore be read as "how much does the LOO + effect fluctuate under resampling?", not as "is this judge/item + significantly different from the rest?". + } +} + +\examples{ +\dontrun{ +set.seed(1) +mat <- matrix(sample(1:5, 40, replace = TRUE), nrow = 8, ncol = 5) +RobinsonA(mat, LOO = "both", ci = TRUE, B = 200) +} + +} +\references{ +Robinson, W. S. (1957). The statistical measurement of agreement. + *American Sociological Review*, 22(1), 17-25. + \doi{10.2307/2088760} + +McGraw, K. O., & Wong, S. P. (1996). Forming inferences about some + intraclass correlation coefficients. *Psychological Methods*, 1(1), 30-46. +} diff --git a/man/SVALmult.Rd b/man/SVALmult.Rd index fe4554a..f9f8455 100644 --- a/man/SVALmult.Rd +++ b/man/SVALmult.Rd @@ -58,9 +58,8 @@ Examples of use can be founded in Cabedo et al. (2024), and Merino-Soto et al. ( Each column in \code{data} should contain numerical responses representing constructs (e.g., 1, 2, 3, 4). These values do not need to be sequential but must be distinct. -\strong{Note}: The function does not handle missing values. Users must impute or remove NAs before using this function. - -\strong{Interpretation of Negative SVC Values}: Negative values of the \code{svc} coefficient are valid and interpretable. They indicate that the selected category was chosen less frequently than the average of the non-target categories, suggesting low substantive agreement for that construct. +\strong{Interpretation of Negative SVC Values}: Negative values of the \code{svc} coefficient are valid and interpretable. +They indicate that the selected category was chosen less frequently than the average of the non-target categories, suggesting low substantive agreement for that construct. } \examples{ data.gais <- data.frame( diff --git a/man/Vaiken.Rd b/man/Vaiken.Rd index 11ffbf1..bf354b6 100644 --- a/man/Vaiken.Rd +++ b/man/Vaiken.Rd @@ -74,7 +74,7 @@ Two methods are available to construct the asymmetric confidence interval for th proportion V, following the logic of Penfield & Giacobbi (2004). The effective sample size is `n_judges × (max - min)`, respecting the independence of judges. This method is the most direct extension of the standard item-level V confidence interval to the global index, and - is consistent with the original proposal by Aiken and later developments. + is consistent with the original proposal by Penfield & Giacobbi. - **`overall_method = "mer"`**: Implements the score confidence interval for the **mean** of the ratings (MER; Penfield, 2003; Penfield & Miller, 2004) in the original scale, and then