weasel v0.4.1
Wave-based Extraction and Selection for Longitudinal Data

weasel turns wave-and-respondent selection in longitudinal panels into an explicit, reproducible workflow.

Which workflow do you need? Answer one question at a time to reach the right recipe. The address bar follows along, so any step or recipe can be shared as a direct link.

What the package does

  • Maps wave participation patterns across respondents
  • Compares selection scenarios with explicit structural constraints
  • Produces analysis-ready long-format data frames
  • Generates prose justifications suitable for methods sections

Two core pipelines

Scope Exploratory. Map the missingness landscape before committing to any selection rule.
Plan Comparative. Enforce explicit constraints, score trade-offs, and extract a reproducible sample.

Reading participation patterns

The figures below use the notation of weasel's own pattern tables: a number is an observed wave (a row exists in the long data), a dot is a missed wave (the row is simply absent).

Observed and missed waves
1 2 3 · 5 6 · 8

Wave-level missingness is row absence: waves 4 and 7 are not NA rows, they simply do not exist in the data. NA values inside observed rows are item nonresponse and never affect selection.

Span and grid
grid = "consecutive"
span 4:9 (L = 6)
1 2 3 4 5 6 7 8 9 10
grid = "observed" (biennial)
span 2010:2016 (4 observed waves)
2008 2010 2012 2014 2016 2018

The span is the analysis window, lower:upper. The grid decides which waves inside it count as scheduled: every integer ("consecutive") or only wave values that occur in the data ("observed"), so 2011 is never a missed wave in a biennial panel.

Endpoints and interior gaps
▾ ▾
· · 3 4 5 · ·
entry
exit
1 2 · · 5 6 7
gap (length 2)

An interior gap is a run of missing waves strictly between a respondent's first and last observed wave. The top row misses both endpoints (▾) yet contains no gap; the bottom row keeps both endpoints and has exactly one gap of length 2.

Constraints select the subset
require_endpoints max_missing = 1 n_gap_max = 1 max_gap_len = 1
1234567
✓ kept
12·4567
✓ kept
12··567
✗ gap of 2
·234567
✗ endpoint missed
planning population 4 → retained 2 (retention 0.50)

The built-in anchored_balanced scenario applied to four respondents observed in the span (the planning population). Retention is always reported against that denominator, here 2 of 4.

Key definitions

  • Observed wave: a row for that (id, wave) pair exists in the long data; a missed wave is an absent row.
  • Span and grid: the analysis window and its scheduled waves; grid = "observed" uses only waves that occur in the data (biennial panels, waves recorded as years).
  • Endpoints: observed at the first and last wave of the span. .. 3 4 5 .. misses both endpoints yet has no interior gap.
  • Interior gap: a run of missing waves strictly between a respondent's first and last observed wave. 1 2 .. 5 6 7 has one gap of length 2; 1 . 3 . 5 . 7 has three gaps of length 1; late entry and early exit are not gaps.
  • Constraints: min_present, max_missing, n_gap_max, max_gap_len, require_endpoints; the same names work in the scope and in plan scenario tables.
  • Planning population: respondents observed at least once inside the span; every retention figure is relative to it, and plans report it.
  • Recommendation: the highest composite score under declared, overridable weights; near-ties are flagged, and the score decomposition travels with the table.

Decisions the package does not make

  • What the causal estimand is, or which substantive variables must be observed for your analysis.
  • Whether attrition is ignorable (missing at random) or whether a complete-case restriction biases your estimates; weasel_selectivity() helps you check, it does not decide.
  • Whether an automatically selected core window matches the substantive time period your question needs.
  • Whether the highest-scoring scenario is optimal for your analysis; the score is a transparent heuristic, not a validated decision rule.
  • Whether weighting or imputation should follow selection.
weasel R package · MIT License · remotes::install_github("siardv/weasel") · Run weasel_example() for a quick-start demonstration
GitHub · Report a bug