msm ( formula, qmatrix, misc = FALSE, ematrix, inits, subject,
covariates = NULL, constraint = NULL,
misccovariates = NULL, miscconstraint = NULL,
covmatch = "previous", initprobs = NULL,
data = list(), fromto = FALSE, fromstate, tostate, timelag,
death = FALSE, tunit = 1.0, exacttimes = FALSE,
fixedpars = NULL, ... )states ~ times See fromto for an alternative way to specify the data.
qmatrix should have $(r,s)$ entry 1, otherwise
it should have $(r,s)$ entry 0. The diagonal of qmatrix
misc = TRUE if misclassification between
observed and underlying states is to be modelled.misc == TRUE) Matrix of indicators for the allowed
misclassifications.
The rows represent underlying states, and the columns represent
observed states.
If an observation of state $s$ is possible when the subject
- transition intensities (reading across first rows of intensity matrix, then second row ... )
- covariate effects on log transition inte
formula. If missing, then all observations
are assumed to be on the same subject. Ignored if fromto == TRUE. ~ age + sex + treatment
constracovariates.constraint."previous", then time-dependent covariate
values are taken from the observation at the start of the
transition. If "next", then the covariate value is taken from
the end of the transition.c(1, rep(0, nstates-1)), that is, in state 1 with a
probability of 1.TRUE, then the data are given as three vectors, from-state, to-state, time-difference
representing the set of observed transitions between states, and the time taken by each one. Otherwise, the data are given by
fromto == TRUE ).fromto == TRUE ).fromstate
and tostate (required if fromto == TRUE ).TRUE, then the final state represents
death. This means that the time of entry into this state is known to
within one day, and that the individual remains in this state for
ever after. Defaults to FALSE. Only one adeath == TRUE).TRUE, then the times are assumed to
represent the exact times of transition of the Markov
process. Otherwise the transitions are assumed to take place at
unknown occasions in between the observation times.inits vector, whose order is
specified above.optim. Useful options include
method="BFGS" for using a quasi-Newton optimisation
algorithm, which can often be fastermsm, with components:baseline, is the estimated
transition intensity matrix with any covariates fixed at their means
in the data. Each remaining component is a matrix giving the linear
effects of the labelled covariate on the matrix of log
intensities.Qmatrices.baseline, is the estimated
misclassification probability matrix with any covariates fixed at their means
in the data. Each remaining component is a matrix giving the linear
effects of the labelled covariate on the matrix of logit
misclassification probabilities.Ematrices mean = estimated mean sojourn times in the transient states
se = corresponding standard errors.
time, returning the
estimated transition probability matrix within the interval
time.optim, with intensities on the log scale.estimates.For models with misclassification, the likelihood for an individual with $k$ observations is calculated by summing over the unknown state at each time, producing a product of $k$ matrices. The calculation is adapted from that in Satten and Longini (1996), and is also given by Jackson and Sharples (2002).
There must be enough information in the data on each state to estimate each transition rate, otherwise the likelihood will be flat and the maximum will not be found. It will often be appropriate to reduce the number of states in the model to aid convergence.
Choosing an appropriate set of initial values for the optimisation can also be important. For flat likelihoods, 'informative' initial values will often be required.
Satten, G.A. and Longini, I.M. Markov chains with measurement error: estimating the 'true' course of a marker of the progression of human immunodeficiency virus disease (with discussion) Applied Statistics 45(3): 275-309 (1996)
simmulti.msm, print.msm, plot.msm,
summary.msmdata("aneur",aneur)
### four states corresponding to increasing disease severity,
### with progressive transitions only
qmat <- rbind( c(0, 1, 0, 0), c(0, 0, 1, 0), c(0, 0, 0, 1), c(0, 0, 0,
0))
aneurysm.msm <- msm(data=aneur, fromto=TRUE, fromstate=from, tostate=to,
qmatrix=qmat, timelag=dt, death=FALSE, inits=c(0.001,
0.03, 0.3), method="BFGS", control=list(trace=2))
print(aneurysm.msm)Run the code above in your browser using DataLab