% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{panel_to_matrices}
\alias{panel_to_matrices}
\title{Convert Long-Format Panel Data to Matrices}
\usage{
panel_to_matrices(data, unit, time, outcome, treatment)
}
\arguments{
\item{data}{A data frame.}

\item{unit}{Character: name of the unit identifier column.}

\item{time}{Character: name of the time period column.}

\item{outcome}{Character: name of the outcome variable column.}

\item{treatment}{Character: name of the treatment indicator column
(must be 0/1).}
}
\value{
A list with components
\describe{
  \item{Y}{Numeric \eqn{N \times T} outcome matrix.}
  \item{D}{Numeric \eqn{N \times T} treatment matrix.}
  \item{units}{Sorted vector of unique unit identifiers.}
  \item{times}{Sorted vector of unique time periods.}
}
}
\description{
Transform a data frame in long format (one row per unit-period) into
the \eqn{N \times T} matrices \code{Y} and \code{D} expected by
\code{\link{ssc}}.
}
\examples{
df <- data.frame(
  id   = rep(1:4, each = 6),
  time = rep(1:6, times = 4),
  Y    = rnorm(24),
  D    = c(rep(0, 12), rep(c(0,0,0,1,1,1), 2))
)
mat <- panel_to_matrices(df, unit = "id", time = "time",
                         outcome = "Y", treatment = "D")

}
