% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/msm.R
\name{msm}
\alias{msm}
\title{Construct a Multistate Interval Object for Use in patp() Formulas}
\usage{
msm(Tstart, Tstop, Sstart, Sstop)
}
\arguments{
\item{Tstart}{Numeric vector. Start time of each interval.}

\item{Tstop}{Numeric vector. End time of each interval.}

\item{Sstart}{Integer-valued numeric vector. State occupied at
\code{Tstart}. States must be whole numbers; the matrix backing
stores them as double (matrices have a single storage mode), but
values are validated to be integer-valued.}

\item{Sstop}{Integer-valued numeric vector. State occupied at
\code{Tstop}. Same storage caveat as \code{Sstart}. If
\code{Sstart == Sstop}, the row represents a censored interval;
this is permitted only on the final row of a subject's record.}
}
\value{
A four-column matrix of class \code{"msm"} with columns
  \code{Tstart}, \code{Tstop}, \code{Sstart}, \code{Sstop}.
}
\description{
Packages four columns -- interval start time, interval end time,
starting state, and ending state -- into a single object suitable
for use as the response in a \code{\link{patp}} formula.
Conceptually analogous to \code{\link[survival]{Surv}()} in survival
analysis: the user calls it inside a formula
(\code{msm(Tstart, Tstop, Sstart, Sstop) ~ ...}).
}
\details{
Used inside a model formula passed to \code{\link{patp}}, e.g.
\code{patp(msm(Tstart, Tstop, Sstart, Sstop) ~ 1, ...)}. The four
arguments can be named anything in the user's data -- the formula
machinery looks them up in the supplied \code{data}.
}
\examples{
Tstart <- c(0,   1.5, 0,   0)
Tstop  <- c(1.5, 3.0, 2.0, 1.2)
Sstart <- c(1,   2,   1,   1)
Sstop  <- c(2,   3,   3,   1)   # last row censored (S unchanged)
obj <- msm(Tstart, Tstop, Sstart, Sstop)
head(obj)

}
\seealso{
\code{\link{patp}}, \code{\link{validate_intervals}}.
}
