Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
README.html
^\.github$
^\.git$
^CITATION\.cff$
^llms\.txt$
^validate_package\.R$
^validate_report\.json$
^AGENTS\.md$
Expand Down
14 changes: 14 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -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/"
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export(CVRcut.Wilson)
export(CVplot)
export(ColquittHT)
export(D2)
export(HTmult)
export(Haiken)
export(LuAgree)
export(MDScontent)
Expand Down
27 changes: 27 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
261 changes: 146 additions & 115 deletions R/CID.R
Original file line number Diff line number Diff line change
@@ -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])
}
Loading
Loading