Skip to contents

Aggregates weighted `from` -> `to` transitions and normalizes each non-empty row so that it sums to one.

Usage

make_transition_matrix(
  dt,
  states_all,
  from_col = "from",
  to_col = "to",
  weight_col = "weight"
)

Arguments

dt

Data frame containing transition records.

states_all

Character vector defining the complete state order.

from_col

Name of the source-state column.

to_col

Name of the destination-state column.

weight_col

Name of the transition-weight column. If absent, each transition receives weight 1.

Value

A square numeric transition matrix with rows and columns ordered as `states_all`. States with no outgoing transitions remain zero rows.