% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sequence_terminal.R
\name{mark_terminal_state}
\alias{mark_terminal_state}
\title{Mark terminal-NA cells with an explicit state label}
\usage{
mark_terminal_state(data, state = "End", cols = NULL)
}
\arguments{
\item{data}{A wide-format matrix or data.frame (rows = actors,
cols = time steps) of state labels with \code{NA} for missing
observations.}

\item{state}{Character. Label to insert in terminal-NA cells.
Default \code{"End"}.}

\item{cols}{Optional state-column names; otherwise all columns.}
}
\value{
A \code{data.frame} of the same shape as \code{data} with terminal
NAs filled by \code{state}.
}
\description{
Replaces every cell after each row's last observed state with the
label given by \code{state}, leaving non-terminal NAs untouched. The
result, passed to \code{\link[=build_network]{build_network()}}, yields a Markov chain in
which the marked state is \strong{absorbing} by construction
(\code{P[state, state] = 1}).
}
\details{
This is the small piece of pre-processing required to turn
right-censored sequence data into an absorbing-chain model. The
chain on the resulting matrix has one extra state (\code{state})
which is structurally absorbing because every cell after the
actor's last observed step has been set to \code{state} - the chain
stays there forever once entered.

Use \code{\link[=chain_structure]{chain_structure()}} on the result to compute mean absorption
time, absorption probabilities, and per-state classification.
Note that \code{markov_stability()} is \emph{not} the right summary for
absorbing chains; its stationary distribution will collapse to
the absorbing state.
}
\examples{
M <- mark_terminal_state(trajectories, state = "Dropout")
net <- build_network(M, method = "relative")
chain_structure(net)

}
\seealso{
\code{\link[=actor_endpoints]{actor_endpoints()}}, \code{\link[=chain_structure]{chain_structure()}}, \code{\link[=build_network]{build_network()}}
}
