| fit_msm | R Documentation |
Fits the continuous-time Markov model implied by one of the seven built-in
structures, or by a user-supplied generator, by maximum likelihood, and
returns all primary inferential summaries in a single object. Likelihood
evaluation is delegated to msm.
fit_msm(data, process = NULL, state = "state", subject = "subject",
time = "time", t = NULL, Q = NULL, deathexact = NULL,
inits = c("crude", "user"), ci = c("normal", "none"), ...)
fit.msm(...)
data |
A data frame in long format, one row per subject-visit. |
process |
Character. One of |
state, subject, time |
Character. Column names in |
t |
Numeric. Horizon at which the transition probability matrix is evaluated. This has no effect on estimation. |
Q |
Optional user-supplied generator giving the permitted transitions. |
deathexact |
Integer vector of states whose entry times are recorded
exactly rather than interval-censored, passed to |
inits |
|
ci |
Interval type passed to |
... |
Further arguments passed to |
Mean sojourn times are per visit to a state, not total time occupied. Where a state can be re-entered, total occupancy exceeds the reported sojourn time by a factor equal to the expected number of visits.
State coding, duplicate visit times and observed transitions are validated against the assumed structure before the optimiser is called, and the optimiser's own convergence code is reported rather than inferred from the absence of an error.
The objective minimised by msm grows with the number of
observed intervals and can overflow during the search in large samples, so
that a well identified model fails with a numerical overflow. When that
happens the fit is repeated with the objective rescaled, which leaves the
maximum unchanged; a warning is issued and rescaled in the returned
object records it. The rescaling is applied only after an unscaled attempt
has failed, so a fit that succeeds without it is identical to the equivalent
hand-written msm() call.
fit.msm is a deprecated alias: the name is read by S3 dispatch as the
msm method of a generic called fit, and msm::msm returns
objects of class msm.
An object of class "modMStates_fit" with elements qmatrix
(estimates, se, ci.lower, ci.upper), sojourn,
pmatrix, counts, converged, convergence_code,
rescaled, loglik, npar, n_subjects,
n_observations, process, horizon and fit, the
underlying msm object.
Jackson CH (2011). Multi-state models for panel data: the msm package for R. Journal of Statistical Software 38(8), 1-29.
Kalbfleisch JD, Lawless JF (1985). The analysis of panel data under a Markov assumption. Journal of the American Statistical Association 80(392), 863-871.
sim_mspdata, ms_montecarlo
dat <- sim_mspdata("illness_death_3state", n = 200, t = 10)
fit <- fit_msm(dat, "illness_death_3state", t = 5)
fit
fit$counts
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.