Package 'flexMatch'

Title: What the Package Does (One Line, Title Case)
Description: What the package does (one paragraph).
Authors: First Last [aut, cre]
Maintainer: First Last <[email protected]>
License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a license
Version: 0.0.0.9000
Built: 2026-10-22 10:09:29 UTC
Source: https://github.com/avkazakovgit/flexmatch

Help Index


Assess Matching Quality (Academic Standard)

Description

Assess Matching Quality (Academic Standard)

Usage

assess_match_quality(
  match_res,
  stack_candidates,
  dt,
  match_vars,
  id_col,
  time_col
)

Expand Matched Cross-Section to Full Stacks

Description

Expand Matched Cross-Section to Full Stacks

Usage

expand_matched_stacks(
  dt,
  matched_data,
  id_col,
  time_col,
  k_pre,
  k_post,
  match_by = -1
)

Flexmatch: The All-in-One Stacked DiD Wrapper

Description

Orchestrates the entire Stacked DiD pipeline: Scans candidates, Matches them, Expands to stacks, Assesses Quality, and Visualizes Events.

Usage

flexmatch(
  dt,
  id_col,
  time_col,
  event_col,
  k_pre,
  k_post,
  k_freeze,
  match_vars,
  match_by = -1,
  assess_quality = TRUE,
  plot_events = TRUE,
  verbose = TRUE,
  ...
)

Arguments

dt

The original panel data (data.table).

id_col

Character. Name of ID column.

time_col

Character. Name of time column (integer/numeric).

event_col

Character. Name of event dummy (1 = start of treatment).

k_pre

Integer. Required pre-periods.

k_post

Integer. Required post-periods.

k_freeze

Integer. Freeze/Cool-down periods after k_post.

match_vars

Character vector. Covariates to match on.

match_by

Integer. Relative period for matching (default -1).

assess_quality

Logical. If TRUE, runs balance checks. Default TRUE.

plot_events

Logical. If TRUE, runs the event dynamics plot. Default TRUE.

verbose

Logical. If TRUE, prints progress. Default TRUE.

...

Additional arguments passed directly to MatchIt (e.g., ratio, method, replace, caliper).

Value

A list containing:

  • final_expanded_data: The analysis-ready stacked dataset.

  • matched_cross_section: The matched pairs at time t.

  • stack_candidates: The full pool of eligible units.

  • quality_stats: List with Balance Table and Density Plots.

  • event_plot: The Lasagna plot object.

  • match_object: The raw MatchIt model.


Label Treatment and Control Stack Candidates

Description

Identifies valid stack candidates by enforcing strict data continuity and clean history/future constraints.

Usage

label_candidates(
  dt,
  id_col,
  time_col,
  event_col,
  k_pre,
  k_post,
  k_freeze,
  match_by = -1
)

Cross-Sectional Matching for Stacked DiD

Description

Performs exact cohort matching + 1-to-K matching using MatchIt.

Usage

match_candidates(dt, stack_candidates, id_col, time_col, match_vars, ...)

Plot Event Dynamics (Lasagna Plot with Overlay)

Description

Plot Event Dynamics (Lasagna Plot with Overlay)

Usage

plot_event_dynamics(
  dt,
  dt_matched = NULL,
  id_col,
  time_col,
  event_col,
  n_bins = 4L,
  sort_by_intensity = FALSE
)