% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/validate_intervals.R
\name{validate_intervals}
\alias{validate_intervals}
\title{Strictly Validate Multistate Data in Interval Format}
\usage{
validate_intervals(data, tmat, tol = 1e-09)
}
\arguments{
\item{data}{A data frame with columns \code{id}, \code{Tstart},
\code{Tstop}, \code{Sstart}, \code{Sstop}.}

\item{tmat}{A K x K transition matrix from \code{\link{trans_mat}()}.}

\item{tol}{Numeric tolerance for temporal-contiguity checks.
Default 1e-9.}
}
\value{
Invisibly returns \code{TRUE} if all checks pass. Stops with
  an error otherwise.
}
\description{
Performs strict validation on a data frame of multistate data in interval
format (the output of \code{\link{parse_msm_formula}()}). Stops with
an informative error on the first violation.
}
\details{
Validation rules, applied in order:
\enumerate{
  \item Required columns are present and of correct type.
  \item Every row has \code{Tstart < Tstop}.
  \item All states are integers in \code{1..K}.
  \item Within each subject, rows are sorted by time.
  \item Within each subject, rows are temporally contiguous:
    \code{Tstop[k] == Tstart[k+1]}.
  \item Within each subject, rows are spatially contiguous:
    \code{Sstop[k] == Sstart[k+1]}.
  \item No row has \code{Sstart} equal to an absorbing state.
  \item No row follows one whose \code{Sstop} is absorbing.
  \item Each non-censored transition (\code{Sstart != Sstop}) is
    allowed by \code{tmat}.
  \item \code{Sstart == Sstop} (censoring) is permitted only on the
    final row of a subject's record.
}
}
\examples{
data(example_msm)
tmat <- trans_mat(list(c(2, 3), c(1, 3), integer(0)),
                  names = c("Healthy", "Ill", "Dead"))
validate_intervals(example_msm, tmat)

}
\keyword{internal}
