Defines states and possible transitions
Defines states and possible transitions
Public fields
matrix
a binary N x N matrix where
matrix[i,j] is 1 if transition
from state i to j is possible
states
a character vector of state names (length N)
Methods
Method new()
Create graph
Arguments
matrix
a binary N x N matrix where
matrix[i,j] is 1 if transition
from state i to j is possible
states
a character vector of state names (length N)
Method num_states()
Get number of states
Usage
TransitionMatrix$num_states()
Method num_trans()
Get number of transitions
Usage
TransitionMatrix$num_trans()
Method num_trans_types()
Get number of different transition types.
Usage
TransitionMatrix$num_trans_types()
Method as_matrix()
As a matrix
Usage
TransitionMatrix$as_matrix()
Returns
An N x N matrix with named columns and rows
Method as_transition_index_matrix()
As a matrix indexing the transitions
Usage
TransitionMatrix$as_transition_index_matrix()
Returns
An N x N matrix with named columns and rows
Method as_mstate_transmat()
Transition index matrix to format used by 'mstate'
Usage
TransitionMatrix$as_mstate_transmat()
Method possible_transitions_from()
Get indices of possible transitions from given state
Usage
TransitionMatrix$possible_transitions_from(state)
Method target_state()
Get target state of a transition
Usage
TransitionMatrix$target_state(trans_idx)
Arguments
trans_idx
Index of the transition
Method at_risk()
Get states that are at risk when at given state
Usage
TransitionMatrix$at_risk(state)
Arguments
state
index of current state
Returns
indices of states at risk
Method states_df()
A data frame of states
Usage
TransitionMatrix$states_df()
Method trans_df()
A data frame of transitions ("legend")
Usage
TransitionMatrix$trans_df()
Visualize the matrix as a graph
Usage
TransitionMatrix$plot(edge_labs = FALSE, ...)
Method absorbing_states()
Get states that cannot be transitioned from
Usage
TransitionMatrix$absorbing_states(names = TRUE)
Arguments
names
Return names of the states? Otherwise returns indices.
Method source_states()
Get states that cannot be transitioned to
Usage
TransitionMatrix$source_states(names = TRUE)
Arguments
names
Return names of the states? Otherwise returns indices.
Method clone()
The objects of this class are cloneable with this method.
Usage
TransitionMatrix$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.