sim_count_panel: Simulate Count Panel Data with Staggered Treatment

View source: R/simulate.R

sim_count_panelR Documentation

Simulate Count Panel Data with Staggered Treatment

Description

Generates simulated panel data with a count outcome (Poisson-distributed) and staggered treatment adoption. Treatment effect is multiplicative (rate ratio) on the count scale.

Usage

sim_count_panel(
  n = 500L,
  nperiods = 6L,
  prop_treated = 0.5,
  n_cohorts = 3L,
  true_rr = 1.5,
  base_rate = 5,
  overdispersion = FALSE,
  seed = NULL
)

Arguments

n

Integer. Number of units. Default 500.

nperiods

Integer. Number of time periods. Default 6.

prop_treated

Numeric. Proportion of units ever treated. Default 0.5.

n_cohorts

Integer. Number of treatment cohorts. Default 3.

true_rr

Numeric or vector. True rate ratio for each cohort. Default 1.5 (50 percent increase in count).

base_rate

Numeric. Baseline Poisson rate. Default 5.

overdispersion

Logical. Add overdispersion (negative binomial). Default FALSE.

seed

Integer. Random seed.

Value

Long-format data frame with columns: id, period, y, g, D, x1.

Examples

dat <- sim_count_panel(n = 400, nperiods = 6, true_rr = 1.8)
summary(dat$y)


NonlinearDiD documentation built on May 6, 2026, 1:06 a.m.