% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/synthetic_control.R
\name{synthetic_control}
\alias{synthetic_control}
\title{Synthetic Control Weights for a Single Treated Unit}
\usage{
synthetic_control(Y)
}
\arguments{
\item{Y}{Numeric matrix (\eqn{N \times T}).
The first row is the treated unit; remaining rows are donor (control)
units.  Each column is a pre-treatment time period.}
}
\value{
A list with components
\describe{
  \item{a_hat}{Scalar intercept
    \eqn{\hat a = \bar Y_1 - \bar X' \hat b}.}
  \item{b_hat}{Numeric vector of length \eqn{N}.  Entry 1 is 0 (the
    treated unit's self-weight); entries \eqn{2, \dots, N} are the
    non-negative weights summing to 1.}
}
}
\description{
Estimate synthetic control weights by solving a constrained quadratic
program on demeaned pre-treatment outcomes: minimise
\eqn{\|\tilde Y_1 - \tilde X b\|^2} subject to
\eqn{\sum b_j = 1, \; b_j \ge 0}, where \eqn{\tilde Y_1} and
\eqn{\tilde X} are time-demeaned series for the treated unit and controls.
}
\details{
The QP is solved by \code{\link[quadprog]{solve.QP}}.  A small ridge term
(\eqn{10^{-6} I}) is added to the Hessian for numerical stability when
\eqn{T} is close to or smaller than \eqn{N-1}.
}
\examples{
set.seed(1)
Y <- matrix(rnorm(5 * 20), 5, 20)  # 5 units, 20 pre-treatment periods
res <- synthetic_control(Y)
res$b_hat   # SC weights for unit 1

}
