% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/coherent.R
\name{coherent_cmat}
\alias{coherent_cmat}
\title{Zero-constraint matrix for coherent time series}
\usage{
coherent_cmat(data, sparse = FALSE)
}
\arguments{
\item{data}{A data object which contains linearly related coherent structures.}

\item{sparse}{If \code{TRUE}, a sparse matrix (class \code{"dgCMatrix"} from the
\pkg{Matrix} package) is returned. Defaults to \code{FALSE}.}
}
\value{
An \eqn{n_a \times n} matrix (dense or sparse) whose rows encode
each aggregation constraint as \eqn{\mathbf{C}\boldsymbol{y}_t =
  \boldsymbol{0}_{n_a}}.
}
\description{
Constructs the \eqn{n_a \times n} zero-constraint matrix \eqn{\mathbf{C}}
for a set of linearly related time series, where \eqn{n_a = n - n_b}
is the number of aggregated series.
}
\details{
Given the aggregation matrix \eqn{\mathbf{A}} (see \code{\link[=coherent_smat]{coherent_smat()}}), the
constraint matrix is defined as

\deqn{\mathbf{C} = [\mathbf{I}_{n_a} \;\; {-\mathbf{A}}],}

so that \eqn{\mathbf{C}\boldsymbol{y}_t = \boldsymbol{0}_{n_a}} for all
coherent vectors \eqn{\boldsymbol{y}_t}. This zero-constrained representation
yields the mapping matrix

\deqn{\mathbf{M} = \mathbf{I}_n -
  \mathbf{W}\mathbf{C}'(\mathbf{C}\mathbf{W}\mathbf{C}')^{-1}\mathbf{C},}

which requires inverting an \eqn{n_a \times n_a} matrix rather than the
\eqn{n_b \times n_b} matrix in the structural form, and is therefore more
efficient when \eqn{n_a < n_b}.
}
\references{
Hyndman, R. J., & Athanasopoulos, G. (2022). \emph{Notation for forecast
reconciliation}. \url{https://robjhyndman.com/hyndsight/reconciliation-notation.html}

Di Fonzo, T., & Girolimetto, D. (2021). Cross-temporal forecast
reconciliation: Optimal combination method and heuristic alternatives.
\emph{International Journal of Forecasting}. \doi{10.1016/j.ijforecast.2021.08.004}
}
\seealso{
\code{\link[=coherent_smat]{coherent_smat()}} for the corresponding structural matrix
\eqn{\mathbf{S}} and \code{\link[=aggregate_key]{aggregate_key()}} for computing cross-sectional
aggregations with tsibble data sets.
}
