% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/did.R
\name{mb_did_2x2}
\alias{mb_did_2x2}
\title{Canonical 2x2 difference-in-differences estimator}
\usage{
mb_did_2x2(y, treated, post, cluster = NULL, alpha = 0.05, quiet = FALSE)
}
\arguments{
\item{y}{Numeric vector of outcomes.}

\item{treated}{Logical or 0/1 numeric vector. \code{TRUE} / \code{1} if
the unit is in the treated group, regardless of period.}

\item{post}{Logical or 0/1 numeric vector. \code{TRUE} / \code{1} if the
observation is in the post-treatment period.}

\item{cluster}{Optional vector identifying clusters for
cluster-robust standard errors (CR1 with finite-sample
correction). If \code{NULL}, conventional OLS SEs are returned.}

\item{alpha}{Numeric in \verb{(0, 1)}. Significance level for the
confidence interval. Default \code{0.05}.}

\item{quiet}{Logical. If \code{FALSE} (default), the print method
appends a one-line reminder that this is a canonical 2x2 DiD
and points to specialist tooling for staggered adoption or
heterogeneous treatment effects. Set to \code{TRUE} to suppress.}
}
\value{
An \code{mb_did} object: a list with \code{estimate}, \code{se},
\code{t_stat}, \code{p_value}, \code{ci_low}, \code{ci_high}, group means,
\code{cluster_robust}, \code{n}, \code{quiet}, and \code{vintage}.
}
\description{
Returns the simple two-period, two-group DiD estimate of an
average treatment effect on the treated, with optional
cluster-robust standard errors.
}
\details{
Computes
\deqn{\hat{\tau} = (\bar{Y}_{T,1} - \bar{Y}_{T,0}) - (\bar{Y}_{C,1} - \bar{Y}_{C,0})}
which equals the coefficient on the \code{treated:post} interaction in
\eqn{Y = \beta_0 + \beta_1 T + \beta_2 P + \tau (T \times P) + \epsilon}.

Cluster-robust SEs use the CR1 sandwich estimator with
finite-sample correction \eqn{(G/(G-1)) \cdot (N-1)/(N-K)}, where
\eqn{G} is the number of clusters, \eqn{N} the number of
observations, and \eqn{K} the number of regressors (4).

For staggered adoption, heterogeneous treatment effects, or
production estimation, use \pkg{fixest}, \pkg{did}, or
\pkg{Synth}. This function is for the canonical 2x2 case only.
}
\examples{
set.seed(1)
n <- 400
treated <- rep(c(0, 1), each = n / 2)
post    <- rep(c(0, 1), times = n / 2)
y       <- 0.5 * treated + 0.2 * post + 0.4 * treated * post + rnorm(n)
mb_did_2x2(y, treated, post)
}
\references{
Card, D., Krueger, A. B. (1994). Minimum Wages and Employment:
A Case Study of the Fast-Food Industry in New Jersey and
Pennsylvania. American Economic Review 84(4).
\url{doi:10.1257/aer.84.4.772}.

Cameron, A. C., Miller, D. L. (2015). A Practitioner's Guide to
Cluster-Robust Inference. Journal of Human Resources 50(2).
\url{doi:10.3368/jhr.50.2.317}.
}
\seealso{
\code{\link[=mb_its]{mb_its()}}, \code{\link[=mb_event_study]{mb_event_study()}}.

Other estimators: 
\code{\link{mb_event_study}()},
\code{\link{mb_its}()}
}
\concept{estimators}
