Skip to contents

Computes the log response ratio between intervention and baseline phase means and a delta-method sampling variance.

Usage

log_response_ratio_computation(
  data,
  studyID,
  subjectID,
  outcome_name,
  phase_name,
  phase_order = NULL,
  improvement = c("increase", "decrease"),
  continuity = 0,
  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.

continuity

Non-negative value added to every outcome before computing phase means. Use a positive value only when a documented continuity adjustment is appropriate for zero-valued rate or count outcomes.

na_option

Currently only "listwise" is supported.

Value

A data frame with yi = log(mean(intervention) / mean(baseline)) (or its sign-reversed version for decreasing outcomes) and delta-method variance vi.

Details

Both phases require at least two observations for variance estimation. Outcomes must be positive after adding continuity. The variance assumes independent observations within and between phases.

Examples

dat <- data.frame(study = "S1", case = "A", phase = rep(c("A", "B"), each = 3),
                  outcome = c(2, 3, 4, 4, 6, 8))
log_response_ratio_computation(dat, "study", "case", "outcome", "phase")
#>      study_id case_id effect_id             metric        yi         vi
#> S1.A       S1       A       LRR log_response_ratio 0.6931472 0.07407407
#>      n_baseline n_intervention continuity
#> S1.A          3              3          0