| Title: | What the Package Does (Title Case) |
|---|---|
| Description: | More about what it does (maybe more than one line). Continuation lines should be indented. |
| Authors: | Jane Doe [aut, cre] |
| Maintainer: | Jane Doe <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-04 10:03:18 UTC |
| Source: | https://github.com/infinitebstats/modmstates |
A unified interface to fit predefined continuous-time Markov multi-state models using the msm package. The function selects an appropriate model structure based on the specified process type and returns key inferential results including transition intensities, sojourn times, and transition probability matrices.
fit.msm(data, process, state, subject, time, t = 4)fit.msm(data, process, state, subject, time, t = 4)
data |
A data frame containing the multi-state panel data. |
process |
Character string specifying the MSM structure. One of:
|
state |
Character string. Name of the state variable in |
subject |
Character string. Name of the subject identifier in
|
time |
Character string. Name of the time variable in |
t |
Numeric. Time point at which transition probabilities are computed (default 4). |
The following process types map to predefined intensity matrix structures:
"two_state"1 -> 2 (absorbing).
"recurrent"1 <-> 2 (reversible).
"illness_death3"1 -> 2, 1 -> 3, 2 -> 3; state 3 absorbing.
"illness_death4"1 -> 2 -> 3 -> 4; state 4 absorbing.
"reversible_id"1 <-> 2, 1 -> 3, 2 -> 3; state 3 absorbing.
"competing_risks"1 -> 2, 1 -> 3; states 2 and 3 absorbing.
"complex"1 <-> 2, 1 -> 3, 1 -> 4, 2 -> 3, 2 -> 4; states 3 and 4 absorbing.
An object of class "msm_results", which is a named list
with the following components:
Summary of the fitted msm model object.
Observed transition frequency table.
Estimated transition intensity matrix with confidence intervals.
Estimated mean sojourn times in each transient state.
Transition probability matrix at time t.
sim.mspdata for simulating multi-state data,
msm for the underlying model fitting engine.
dat <- sim.mspdata(process = "two_state", n = 200, t = 10) res <- fit.msm( data = dat, process = "two_state", state = "state", subject = "subject", time = "time", t = 4 ) res$qmatrix res$sojourn res$pmatrixdat <- sim.mspdata(process = "two_state", n = 200, t = 10) res <- fit.msm( data = dat, process = "two_state", state = "state", subject = "subject", time = "time", t = 4 ) res$qmatrix res$sojourn res$pmatrix
A unified interface to simulate data from different continuous-time
Markov multi-state processes using predefined MSM structures.
Data are generated using simmulti.msm from the
msm package.
sim.mspdata(process, n, t)sim.mspdata(process, n, t)
process |
Character string specifying the MSM type. One of:
|
n |
Integer. Number of subjects to simulate. |
t |
Numeric. Maximum follow-up time (observations are generated at
integer times from 0 to |
The following process structures are available:
"two_state"Simple failure process: state 1 (alive) to state 2 (failure, absorbing).
"recurrent"Recurrent event process: individuals move between state 1 (no event) and state 2 (event) repeatedly.
"illness_death_3state"Three-state illness-death model: healthy, ill, and death (absorbing). Transitions from healthy to ill, healthy to death, and ill to death.
"illness_death_4state"Four-state illness-death model: healthy, mild illness, severe illness, and death (absorbing).
"reversible_illness_death"Reversible illness-death model: healthy and ill states are reversible, with death as absorbing.
"competing_risks"Competing risks process: state 1 (event-free) with two absorbing failure states.
"complex"Complex hybrid model combining recurrent illness, competing risks, and illness-dependent mortality.
A data frame containing simulated multi-state panel data with
columns subject, time, and state. Additional
attributes "process", "n", and "t" record the
simulation parameters.
fit.msm for fitting multi-state models to the
simulated data.
sim <- sim.mspdata(process = "two_state", n = 200, t = 10) head(sim) sim2 <- sim.mspdata(process = "recurrent", n = 150, t = 10) head(sim2)sim <- sim.mspdata(process = "two_state", n = 200, t = 10) head(sim) sim2 <- sim.mspdata(process = "recurrent", n = 150, t = 10) head(sim2)