% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
\name{sim_binary_rcs}
\alias{sim_binary_rcs}
\title{Simulate Binary Repeated Cross-Section Data with Staggered Treatment}
\usage{
sim_binary_rcs(
  n_per_period = 500L,
  nperiods = 6L,
  prop_treated = 0.5,
  n_cohorts = 3L,
  true_att = 0.3,
  base_prob = 0.3,
  add_covariates = TRUE,
  seed = NULL
)
}
\arguments{
\item{n_per_period}{Integer. Number of observations drawn per time period.
Default 500.}

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

\item{prop_treated}{Numeric. Proportion of individuals whose group is ever
treated. Default 0.5.}

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

\item{true_att}{Numeric or vector. True ATT (log-odds scale) for each
cohort. Default 0.3.}

\item{base_prob}{Numeric. Baseline P(Y=1) in the absence of treatment.
Default 0.3.}

\item{add_covariates}{Logical. Add individual-level covariates \code{x1}
(continuous) and \code{x2} (binary). Default TRUE.}

\item{seed}{Integer. Random seed. Default NULL.}
}
\value{
A data frame in long format. One row per observation. Columns:
  \describe{
    \item{obs_id}{Unique observation identifier.}
    \item{period}{Time period (1 to \code{nperiods}).}
    \item{y}{Binary outcome (0/1).}
    \item{g}{Treatment cohort of the observation's group (0 = never treated).}
    \item{D}{Treatment indicator: 1 if the group is treated in this period.}
    \item{x1, x2}{Individual-level covariates (if \code{add_covariates = TRUE}).}
  }
}
\description{
Generates a simulated repeated cross-section (RCS) dataset with staggered
treatment adoption and a binary outcome. At each time period an independent
random sample is drawn from the population; no unit is observed more than
once. This mirrors settings such as repeated population health surveys
(e.g. BRFSS, NHIS) or administrative records linked by group membership
rather than individual identifiers.

The data-generating process at period \eqn{t} for individual \eqn{i}
belonging to treatment cohort \eqn{g}:

\deqn{Y_{it} = \mathbf{1}\{ \mu_0 + \lambda_t + \delta_g \cdot D_{gt} +
  \beta x_{1i} + \epsilon_{it} > 0 \}}

where \eqn{\mu_0 = \text{logit}(\text{base\_prob})}, \eqn{\lambda_t} is
a common time trend, \eqn{\delta_g} is the cohort-specific treatment effect
(on the log-odds scale), and \eqn{\epsilon_{it} \sim \text{Logistic}(0,1)}
is i.i.d. noise.  No unit-level fixed effect is included because
individuals are not re-observed.
}
\details{
There is no \code{id} column that repeats across periods. Use
\code{nonlinear_attgt(..., data_type = "repeated_cross_section")} to
analyse data of this type.
}
\examples{
dat <- sim_binary_rcs(n_per_period = 500, nperiods = 6,
                       prop_treated = 0.5, true_att = 0.3, seed = 42)
head(dat)
table(dat$g, dat$period)  # each cell is an independent sample

# Estimate ATT(g,t) under repeated cross-section design
\donttest{
res <- nonlinear_attgt(
  data = dat, yname = "y", tname = "period", gname = "g",
  outcome_model = "logit", data_type = "repeated_cross_section"
)
summary(res)
}

}
