Create names for all elements of a transition probability matrix given names for the health states. This is useful for flattening a transition probability matrix (rowwise) into a vector and naming the resulting vector. The name of an element of the flattened vector representing a transition from the ith state to the jth state is of the form paste0(prefix, states[i], sep, states[j]).

tpmatrix_names(states, prefix = "p_", sep = "_")



A character vector of the names of health states in the transition matrix.


A prefix that precedes the described transitions between states used to name a transition. For example, if prefix = "p_" (and sep = "_"), then a transition between state i and state j will be of the form "p_states[i]_states[j]"; similarly, if prefix = "", then the same transition will be named "states[i]_states[j]".


A character string to separate the terms representing state i and state j. For instance, if sep = ".", the resulting name will be of the form "states[i].states[j]".


A character vector containing a name for each element of the transition probability matrix encompassing all possible transitions.

See also

See tpmatrix(), which uses tpmatrix_names() to name the columns of the returned object.


#> [1] "p_A_A" "p_A_B" "p_A_C" "p_A_D" "p_B_A" "p_B_B" "p_B_C" "p_B_D" "p_C_A" #> [10] "p_C_B" "p_C_C" "p_C_D" "p_D_A" "p_D_B" "p_D_C" "p_D_D"
tpmatrix_names(LETTERS[1:4], prefix = "")
#> [1] "A_A" "A_B" "A_C" "A_D" "B_A" "B_B" "B_C" "B_D" "C_A" "C_B" "C_C" "C_D" #> [13] "D_A" "D_B" "D_C" "D_D"
tpmatrix_names(LETTERS[1:4], prefix = "", sep = ".")
#> [1] "A.A" "A.B" "A.C" "A.D" "B.A" "B.B" "B.C" "B.D" "C.A" "C.B" "C.C" "C.D" #> [13] "D.A" "D.B" "D.C" "D.D"