% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{pred}
\alias{pred}
\title{Predictor Specification for SCM}
\usage{
pred(vars, times, op = "mean")
}
\arguments{
\item{vars}{Character vector of variable names. All variables share the
same \code{times} window and \code{op} operator. Use separate \code{pred()} calls for
variables with different time windows.}

\item{times}{Numeric/integer vector of time values to aggregate over.}

\item{op}{Aggregation operator applied to each variable over \code{times}.
One of \code{"mean"} (default), \code{"median"}, or \code{"sum"}.}
}
\value{
A \code{pred_spec} object (a named list with class \code{"pred_spec"}).
}
\description{
Creates a single predictor specification for use in \code{\link[=scm_fit]{scm_fit()}} with
\code{method = "scm"}. Pass a \code{list()} of \code{pred()} calls as the \code{predictors}
argument to define the full covariate matrix.
}
\examples{
# Three variables averaged over the same window
pred(c("lnincome", "retprice", "age15to24"), 1980:1988)

# Single variable at a specific year
pred("cigsale", 1975)

# Single variable averaged over a range
pred("beer", 1984:1988)

# Abadie, Diamond & Hainmueller (2010) California Prop 99 style: combine
# several covariates aggregated over different windows plus three outcome
# lags at specific years. The resulting list is passed to
# scm_fit(..., predictors = predictors).
predictors <- list(
  pred(c("lnincome", "retprice", "age15to24"), 1980:1988),
  pred("beer",    1984:1988),
  pred("cigsale", 1988),
  pred("cigsale", 1980),
  pred("cigsale", 1975)
)
predictors
}
\seealso{
\code{\link[=scm_fit]{scm_fit()}} for the \code{predictors} argument that consumes a \code{list()}
of \code{pred_spec} objects.
}
