% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
\name{sim_binary_panel}
\alias{sim_binary_panel}
\title{Simulate Binary Panel Data with Staggered Treatment}
\usage{
sim_binary_panel(
  n = 500L,
  nperiods = 6L,
  prop_treated = 0.5,
  n_cohorts = 3L,
  true_att = 0.3,
  base_prob = 0.3,
  unit_fe_sd = 0.5,
  add_covariates = TRUE,
  seed = NULL
)
}
\arguments{
\item{n}{Integer. Number of units. Default 500.}

\item{nperiods}{Integer. Number of time periods. Default 6.}

\item{prop_treated}{Numeric. Proportion of units ever treated. Default 0.5.}

\item{n_cohorts}{Integer. Number of treatment cohorts (groups). Default 3.}

\item{true_att}{Numeric or vector. True ATT for each cohort. Default 0.3.}

\item{base_prob}{Numeric. Baseline probability P(Y=1) for untreated.
Default 0.3.}

\item{unit_fe_sd}{Numeric. Std. dev. of unit fixed effects. Default 0.5.}

\item{add_covariates}{Logical. Add pre-treatment covariates. Default TRUE.}

\item{seed}{Integer. Random seed. Default NULL.}
}
\value{
A data frame in long format. Columns: \code{id} (unit identifier),
  \code{period} (time period 1 to nperiods), \code{y} (binary outcome 0/1),
  \code{g} (treatment cohort; 0 = never treated), \code{D} (treatment
  indicator), \code{x1} and \code{x2} (covariates, if
  \code{add_covariates = TRUE}), and \code{alpha_i} (true unit fixed effect,
  for validation).
}
\description{
Generates a simulated panel dataset with staggered treatment adoption and
a binary outcome. Useful for testing and illustrating nonlinear DiD methods.

The data-generating process is:
\deqn{Y_{it} = \mathbf{1}\{ \alpha_i + \lambda_t + \delta_{it} \cdot D_{it} + \epsilon_{it} > 0 \}}

where \eqn{\alpha_i} is a unit fixed effect, \eqn{\lambda_t} is a time
fixed effect, \eqn{\delta_{it}} is the treatment effect (heterogeneous
across cohorts), and \eqn{\epsilon_{it}} is logistic noise.
}
\examples{
dat <- sim_binary_panel(n = 1000, nperiods = 8, prop_treated = 0.6,
                         n_cohorts = 4, true_att = c(0.2, 0.4, 0.3, 0.5))
head(dat)
table(dat$g)

}
