View source: R/define_states.R
| define_multistate | R Documentation |
Defines the state space, absorbing states, and allowed transitions for a multistate model.
define_multistate(state_names, absorbing, transitions)
state_names |
Character vector of state names. |
absorbing |
Character vector of absorbing state names (must be a subset
of |
transitions |
A named list where each element name is an origin state and the value is a character vector of destination states reachable from that origin. Absorbing states should not appear as list names. |
An object of class "mstate_structure" containing:
Character vector of all state names.
Integer, number of states.
Character vector of absorbing states.
Character vector of transient (non-absorbing) states.
Named list of allowed transitions.
Integer matrix where entry [i,j] is the
transition number for allowed transition i->j, or NA if not
allowed.
Total number of allowed transitions.
Data frame listing all transitions with columns
trans_id, from, to.
The unique graph root used as the common initial state.
State order used by the semi-Markov solver.
Only directed acyclic, non-recurrent structures with exactly one root and at least one absorbing state are supported. Every transient state must be reachable from the root and must have a directed path to absorption. Cycles, self-transitions, recurrent visits, disconnected states, and multiple subject-specific initial states are rejected.
ms <- define_multistate(
state_names = c("Baseline", "Responded", "Progressed", "Death"),
absorbing = "Death",
transitions = list(
Baseline = c("Responded", "Progressed", "Death"),
Responded = c("Progressed", "Death"),
Progressed = c("Death")
)
)
print(ms)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.