If data only contains one row per transition that took place, this function adds additional rows for each transition that was possible at that time (for each subject in the data).

add_counterfactual_transitions(
  data,
  from_to_pairs = list(),
  from_col = "from",
  to_col = "to",
  transition_col = "transition"
)

Arguments

data

Data set that only contains rows for transitions that took place.

from_to_pairs

A list with one element for each possible initial state. The values of each list element indicate possible transitions from that state. Will be calculated from the data if unspecified.

from_col

Name of the column that stores initial state.

to_col

Name of the column that stores end state.

transition_col

Name of the column that contains the transition identifier (factor variable).