Skip to contents

Computes nonoverlap of all pairs (NAP) and a tie-corrected U-statistic variance under independent observations.

Usage

nap_computation(
  data,
  studyID,
  subjectID,
  outcome_name,
  phase_name,
  phase_order = NULL,
  improvement = c("increase", "decrease"),
  variance_correction = c("none", "autocorrelation"),
  na_option = "listwise"
)

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.

Value

A data frame with NAP in yi and an approximate variance in vi.

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