extract_transition_matrix: Extract Transition Matrix from Model

View source: R/extraction.R

extract_transition_matrixR Documentation

Extract Transition Matrix from Model

Description

Extract the transition probability matrix from a TNA model object.

Usage

extract_transition_matrix(model, type = c("raw", "scaled"))

Arguments

model

A TNA model object or a list containing a 'weights' element.

type

Character. Type of matrix to return:

"raw"

The raw weight matrix as stored in the model.

"scaled"

Row-normalized to ensure rows sum to 1.

Default: "raw".

Details

TNA models store transition weights in different locations depending on the model type. This function handles the extraction automatically.

For "scaled" type, each row is divided by its sum to create valid transition probabilities. This is useful when the original weights don't sum to 1.

Value

A square numeric matrix with row and column names as state names.

See Also

extract_initial_probs for extracting initial probabilities, extract_edges for extracting an edge list.

Examples

seqs <- data.frame(V1 = c("A","B","A"), V2 = c("B","A","C"), V3 = c("A","C","B"))
net <- build_network(seqs, method = "relative")
trans_mat <- extract_transition_matrix(net)
print(trans_mat)


Nestimate documentation built on April 20, 2026, 5:06 p.m.