% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ccm.R
\name{ccm}
\alias{ccm}
\title{Cohort Component Model for Projecting Population.}
\usage{
ccm(
  Mx.f,
  Mx.m = NULL,
  Fx,
  Ix.f = NULL,
  Ix.m = NULL,
  age.mx,
  age.fx,
  N0.f,
  N0.m = NULL,
  srb = 100/205,
  ...
)
}
\arguments{
\item{Mx.f}{Matrix or dataframe with mx for females, where row represents age, column represents a forecasted period. Thus, first column should be the first projected period, while each row represents age-specific mortality rate.}

\item{Mx.m}{Optional. Matrix or dataframe with mx for males, where row represents age, column represents a forecasted period. Thus, first column should be the first projected period, while each row represents age-specific mortality rate.}

\item{Fx}{Matrix or dataframe with fx, where row represents age, column represents a forecasted period. Thus, first column should be the first projected period, while each row represents age-specific fertility rate.}

\item{Ix.f}{Optional. Matrix or dataframe with net number of female migrants, where row represents age, column represents a forecasted period. Thus, first column should be the first projected period, while each row represents net number of migrants.}

\item{Ix.m}{Optional. Matrix or dataframe with net number of male migrants, where row represents age, column represents a forecasted period. Thus, first column should be the first projected period, while each row represents net number of migrants.}

\item{age.mx}{Numeric vector. Age groups for Mx.f rows.}

\item{age.fx}{Numeric vector. Age groups for Fx rows.}

\item{N0.f}{Numeric vector. Female population in the initial period by age groups.}

\item{N0.m}{Optional. Numeric vector. Male population in the initial period by age groups.}

\item{srb}{Numeric. Sex ratio at birth for females. By default, it is 100/205.}

\item{...}{Optional. Additional arguments for \code{\link[=leslie]{leslie()}} function.}
}
\value{
If \code{Mx.m} is \code{NULL}, a numeric matrix with projected female
population, where rows are age groups and columns are periods \code{0:h}. If
male mortality is supplied, a list with matrices \code{female}, \code{male}, and
\code{all}, each with the same row/column structure.
}
\description{
Cohort Component Model for Projecting Population.
}
\details{
The model is calculated in matrix form as
\deqn{\mathbf{N}_{t+h} = \mathbf{L}_t(\mathbf{N}_{t} + \mathbf{I}_{t}/2) + \mathbf{I}_{t}/2}
where \eqn{\mathbf{N}_t} is a column vector of population for time \eqn{t} with \eqn{h} as a step of projection (it is the length of age interval), \eqn{\mathbf{L}_t} is Leslie matrix and \eqn{\mathbf{I}_{t}} is a column vector of net migration.

Note that the model assumes that in \eqn{\mathbf{N}} all age intervals are the same (i.e. \eqn{age = \{0-1, 1-4, 5-9, ...\}} is not permitted). Fortunately (and thanks to me), the function handles such situations automatically by transforming all age groups into a unified standard.
}
\examples{
age.mx <- seq(0, 80, 5)
age.fx <- seq(15, 45, 5)
Mx.f <- matrix(
  rep(seq(0.005, 0.12, length.out = length(age.mx)), 2),
  nrow = length(age.mx),
  ncol = 2
)
Fx <- matrix(
  rep(c(0.02, 0.08, 0.11, 0.09, 0.05, 0.02, 0.005), 2),
  nrow = length(age.fx),
  ncol = 2
)
N0.f <- round(100000 * exp(-0.04 * age.mx))
ccm(Mx.f = Mx.f, Fx = Fx, age.mx = age.mx, age.fx = age.fx, N0.f = N0.f)
}
