
Nonoverlap of all pairs for single-case phase contrasts
nap_computation.RdComputes nonoverlap of all pairs (NAP) and a tie-corrected U-statistic variance under independent observations.
Arguments
- data
Data frame containing repeated observations.
- studyID, subjectID, outcome_name, phase_name
Character strings naming the study, case, outcome, and phase columns.
- phase_order
Character vector giving the baseline and intervention labels, in that order. If
NULL, factor-level or alphabetical order is used.- improvement
Whether an increase or decrease in the outcome is beneficial.
- variance_correction
Either
"none"or"autocorrelation". The latter applies an AR(1)-style design-effect multiplier estimated from the outcome sequence within each case.- na_option
Currently only
"listwise"is supported.
Details
NAP is the proportion of baseline-intervention pairs for which the intervention observation is better, counting ties as one-half. The reported variance is the tie-corrected null variance of the corresponding Mann-Whitney U statistic, divided by the squared number of pairs. It is an approximation and should be interpreted cautiously for serially dependent observations.
Examples
dat <- data.frame(study = "S1", case = "A", phase = rep(c("A", "B"), each = 3),
outcome = c(1, 2, 2, 3, 4, 5))
nap_computation(dat, "study", "case", "outcome", "phase")
#> study_id case_id effect_id metric yi vi n_baseline n_intervention
#> S1.A S1 A NAP NAP 1 0.06296296 3 3
#> autocorrelation variance_correction variance_multiplier
#> S1.A 0.9417419 none 1