% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/attgt.R
\name{nonlinear_attgt}
\alias{nonlinear_attgt}
\title{Nonlinear Staggered DiD: Group-Time ATT Estimation}
\usage{
nonlinear_attgt(
  data,
  yname,
  tname,
  gname,
  idname = NULL,
  data_type = c("panel", "repeated_cross_section"),
  weightsname = NULL,
  cluster_var = NULL,
  xformla = ~1,
  outcome_model = c("logit", "probit", "poisson", "negbin", "linear"),
  estimand = c("att", "ape", "odds_ratio"),
  control_group = c("nevertreated", "notyetreated"),
  doubly_robust = TRUE,
  boot = FALSE,
  nboot = 999,
  boot_type = c("multiplier", "empirical"),
  alpha = 0.05,
  parallel = FALSE,
  pl_cores = 2L,
  anticipation = 0L
)
}
\arguments{
\item{data}{A data frame in long format.}

\item{yname}{Character. Outcome variable column.}

\item{tname}{Character. Time period column.}

\item{gname}{Character. Treatment cohort column (the period when a
unit/group first receives treatment; 0 or Inf for never-treated).}

\item{idname}{Character or \code{NULL}. Unit identifier column.
Required for \code{data_type = "panel"}. Optional for
\code{data_type = "repeated_cross_section"}.}

\item{data_type}{Character. \code{"panel"} (default) or
\code{"repeated_cross_section"}.}

\item{weightsname}{Character or \code{NULL}. Column name of sampling
weights (e.g. survey design weights). Used in all model fits
(outcome regression, propensity score, pooled QMLE) when supplied.
Default \code{NULL} (equal weights).}

\item{cluster_var}{Character or \code{NULL}. Column name to cluster
standard errors on (e.g. \code{"state"}). Analytical SEs use
\code{sandwich::vcovCL()} and the bootstrap resamples whole
clusters. Default \code{NULL} (HC1 robust SEs / row resampling).}

\item{xformla}{A one-sided formula for covariates (e.g. \code{~ x1 + x2}).
Default \code{~ 1}.}

\item{outcome_model}{Character. One of \code{"logit"}, \code{"probit"},
\code{"poisson"}, \code{"negbin"}, \code{"linear"}.}

\item{estimand}{Character. \code{"att"} (default), \code{"ape"} (average
partial effect on probability scale), or \code{"odds_ratio"}.}

\item{control_group}{Character. \code{"nevertreated"} (default) or
\code{"notyetreated"}.}

\item{doubly_robust}{Logical. Use the doubly-robust estimator. Default TRUE.}

\item{boot}{Logical. Bootstrap inference. Default FALSE.}

\item{nboot}{Integer. Bootstrap iterations. Default 999.}

\item{boot_type}{Character. \code{"multiplier"} or \code{"empirical"}.}

\item{alpha}{Numeric. Significance level. Default 0.05.}

\item{parallel}{Logical. Parallel bootstrap. Default FALSE.}

\item{pl_cores}{Integer. Cores for parallel bootstrap.}

\item{anticipation}{Integer. Periods of anticipation allowed. Default 0.}
}
\value{
An object of class \code{nonlinear_attgt}.
}
\description{
Computes group-time average treatment effects on the treated (ATT(g,t)) for
staggered difference-in-differences designs with nonlinear outcomes.
Supports both \strong{panel} data (same units across periods) and
\strong{repeated cross-section} (RCS) data (independent samples per period).

For panel data the package follows Callaway & Sant'Anna (2021) and uses
within-unit outcome changes to estimate counterfactual trends. For repeated
cross-sections it uses the Wooldridge (2023) pooled QMLE with a
treatment-by-period interaction (non-DR) or an IPW-augmented version
(doubly-robust). Both modes optionally accept sampling weights and a
clustering variable.
}
\examples{
# ---- Panel example (v0.1.0 syntax — unchanged) ----
set.seed(42)
dat <- sim_binary_panel(n = 500, nperiods = 6, prop_treated = 0.4)
result <- nonlinear_attgt(
  data = dat, yname = "y", tname = "period",
  idname = "id", gname = "g",
  outcome_model = "logit"
)
summary(result)

# ---- Repeated cross-section example ----
set.seed(7)
rcs <- sim_binary_rcs(n_per_period = 400, nperiods = 6, prop_treated = 0.4)
res_rcs <- nonlinear_attgt(
  data = rcs, yname = "y", tname = "period", gname = "g",
  outcome_model = "logit",
  data_type = "repeated_cross_section"
)
summary(res_rcs)

}
\references{
Callaway, B., & Sant'Anna, P. H. C. (2021). Difference-in-differences with
multiple time periods. \emph{Journal of Econometrics}, 225(2), 200-230.

Wooldridge, J. M. (2023). Simple approaches to nonlinear
difference-in-differences with panel data. \emph{The Econometrics Journal}, 26(3).

Roth, J., & Sant'Anna, P. H. C. (2023). When is parallel trends sensitive
to functional form? \emph{Econometrica}, 91(2), 737-747.

Sant'Anna, P. H. C., & Zhao, J. (2020). Doubly robust
difference-in-differences estimators. \emph{Journal of Econometrics},
219(1), 101-122.
}
