Learn R Programming

msm (version 0.5.2)

simmulti.msm: Simulate multiple trajectories from a multi-state Markov model with arbitrary observation times

Description

Simulate a number of individual realisations from a multi-state Markov process. Observations of the process are made at specified arbitrary times for each individual.

Usage

simmulti.msm(data, qmatrix, covariates=NULL, death = FALSE,  start,
ematrix=NULL, hmodel=NULL, hcovariates=NULL)

Arguments

data
A data frame with a mandatory column named time, representing observation times. The optional column named subject, corresponds to subject identification numbers. If not given, all observations are assumed to be o
qmatrix
The transition intensity matrix of the Markov process, with any covariates set to zero. The diagonal of qmatrix is ignored, and computed as appropriate so that the rows sum to zero. For example, a possible qmatrix
covariates
List of covariate effects on log transition intensities. Each element is a vector of the effects of one covariate on all the transition intensities. The intensities are ordered by reading across rows of the intensity matrix, starting with t
death
Vector of indices of the death states. A death state is an absorbing state whose time of entry is known exactly, but the individual is assumed to be in an unknown transient state ("alive") at the previous instant. This is the usual situat
start
A vector with the same number of elements as there are distinct subjects in the data, giving the states in which each corresponding individual begins. Defaults to state 1 for each subject.
ematrix
An optional misclassification matrix for generating observed states conditionally on the simulated true states. As defined in msm.
hmodel
An optional hidden Markov model for generating observed outcomes conditionally on the simulated true states. As defined in msm.
hcovariates
List of the same length as hmodel, defining any covariates governing the hidden Markov outcome models. Unlike in the msm function, this should also define the values of the covariate effects. Each element of the l

Value

  • A data frame with columns,
  • subjectSubject identification indicators
  • timeObservation times
  • stateSimulated (true) state at the corresponding time
  • obsObserved outcome at the corresponding time, if ematrix or hmodel was supplied
  • plus any supplied covariates.

concept

Simulation

Details

sim.msm is called repeatedly to produce a simulated trajectory for each individual. The state at each specified observation time is then taken to produce a new column state. The effect of time-dependent covariates on the transition intensity matrix for an individual is determined by assuming that the covariate is a step function which remains constant in between the individual's observation times. If the subject enters an absorbing state, then only the first observation in that state is kept in the data frame. Rows corresponding to future observations are deleted. The entry times into states given in death are assumed to be known exactly.

See Also

sim.msm

Examples

Run this code
### Simulate 100 individuals with common observation times
sim.df <- data.frame(subject = rep(1:100, rep(13,100)), time = rep(seq(0, 24, 2), 100))
qmatrix <- rbind(c(-0.11,   0.1,  0.01 ),
                 c(0.05,   -0.15,  0.1 ),
                 c(0.02,   0.07, -0.09))
simmulti.msm(sim.df, qmatrix)

Run the code above in your browser using DataLab