inst/doc/getting-started.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(wavecov)

## -----------------------------------------------------------------------------
dat <- data.frame(
  eeid   = c("a", "b", "c",  "a",  "b",  "c"),
  wave   = c(0,   0,   0,    1,    1,    1),
  metric = c(1.0, 2.0, 3.0,
             1.2, 2.1, 2.9)
)

dat

## -----------------------------------------------------------------------------
res_linked <- compare_waves(
  data       = dat,
  wave_0     = 0,
  wave_1     = 1,
  id_col     = "eeid",
  wave_col   = "wave",
  metric_col = "metric",
  method     = "linked"
)

res_linked

## -----------------------------------------------------------------------------
res_linked$estimate
res_linked$se
c(res_linked$ci_lower, res_linked$ci_upper)

## -----------------------------------------------------------------------------
dat_no_stayers <- data.frame(
  eeid   = c("a", "b", "c",  "d",  "e",  "f"),
  wave   = c(0,   0,   0,    1,    1,    1),
  metric = c(1.0, 2.0, 3.0,
             1.5, 2.2, 3.1)
)

# Auto will fall back to reliability or bounds as needed
res_auto <- compare_waves(
  data        = dat_no_stayers,
  wave_0      = 0,
  wave_1      = 1,
  id_col      = "eeid",
  wave_col    = "wave",
  metric_col  = "metric",
  method      = "auto",
  reliability = 0.8
)

res_auto$method
res_auto$estimate
c(res_auto$ci_lower, res_auto$ci_upper)

## -----------------------------------------------------------------------------
dat_bounds <- data.frame(
  eeid   = c("a", "b", "c",  "d",  "e",  "f"),
  wave   = c(0,   0,   0,    1,    1,    1),
  metric = c(1.0, 2.0, 3.0,
             1.5, 2.2, 3.1)
)

res_bounds <- compare_waves(
  data       = dat_bounds,
  wave_0     = 0,
  wave_1     = 1,
  id_col     = "eeid",
  wave_col   = "wave",
  metric_col = "metric",
  method     = "bounds",
  cov_sign   = "unrestricted",
  overlap_mode = "generic"
)

res_bounds

Try the wavecov package in your browser

Any scripts or data that you put into this service are public.

wavecov documentation built on Nov. 3, 2026, 5:07 p.m.