% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/prodint_AJ.R
\name{prodint_AJ}
\alias{prodint_AJ}
\title{Aalen-Johansen Product Integral for General Multistate Processes}
\usage{
prodint_AJ(haz_df, tmat, predt = 0, h = 1)
}
\arguments{
\item{haz_df}{Data frame with columns \code{time}, \code{Haz},
\code{trans}, typically the output of \code{fit_chaz()} or the
\code{$Haz} element of an \code{mstate::msfit} object. \code{Haz}
is the cumulative (not incremental) hazard.}

\item{tmat}{A K x K transition matrix from \code{trans_mat()}.
Cyclic transitions (both \code{[h, j]} and \code{[j, h]} non-NA)
are permitted.}

\item{predt}{Numeric scalar. Starting time s. Probabilities are
computed for t > predt. Default 0.}

\item{h}{Integer in 1..K. Starting state.}
}
\value{
A data frame with columns \code{time}, \code{pstate1}, ...,
  \code{pstateK}. Row k gives \eqn{P(predt, time_k)[h, ]}, the
  probabilities of being in each state at \code{time_k} given the
  process was in state \code{h} at \code{predt}.
}
\description{
Computes the row of the transition probability matrix
\deqn{P(s, t) = \prod_{u \in (s, t]} (I + dA(u))}
starting from state \code{h}, given Nelson-Aalen
transition hazard estimates.
}
\details{
At each unique jump time \eqn{u}, the increment matrix
\eqn{dA(u)} has off-diagonal entry \eqn{(h, j)} equal to the
Nelson-Aalen increment of the cumulative hazard for transition
\eqn{h \to j}, and diagonal entries equal to the negative row sums.
The transition probability matrix is then updated by
\eqn{P \leftarrow P (I + dA(u))}.

Computational complexity is O(J K^2) where J is the number of unique
jump times and K is the number of states.
}
\examples{
data(example_msm)
tmat <- trans_mat(list(c(2, 3), c(1, 3), integer(0)),
                  names = c("Healthy", "Ill", "Dead"))

long <- intervals_to_long(example_msm, tmat)
haz  <- fit_chaz(long, tmat)
P    <- prodint_AJ(haz, tmat, predt = 0, h = 1)
head(P)

}
