Getting started with the tna package

knitr::opts_chunk$set(
  collapse = TRUE,
  fig.width = 6,
  fig.height = 4,
  dpi = 180,
  out.width = "100%",
  comment = "#>"
)
suppressPackageStartupMessages({
  library("tna")
  library("tibble")
  library("dplyr")
  library("gt")
})

This vignette showcases some basic usage of the tna package. For more tutorials, please visit the package website.

First we load the package that we will use for this example.

library("tna")
library("tibble")
library("dplyr")
library("gt")

We also load the group_regulation data available in the package (see ?group_regulation for further information)

data("group_regulation", package = "tna")

We build a TNA model using this data with the tna() function .

tna_model <- tna(group_regulation)

To visualize the model, we can use the standard plot() function.

plot(
  tna_model, cut = 0.2, minimum = 0.05, 
  edge.label.position = 0.8, edge.label.cex = 0.7
)

The initial state probabilities are

data.frame(`Initial prob.` = tna_model$inits, check.names = FALSE) |>
  rownames_to_column("Action") |>
  arrange(desc(`Initial prob.`)) |>
  gt() |>
  fmt_percent()

and the transitions probabilities are

tna_model$weights |>
  data.frame() |>
  rownames_to_column("From\\To") |>
  gt() |>
  fmt_percent()

The function centralities() can be used to compute various centrality measures (see ?centralities for more information). These measures can also be visualized with the plot() function.

centrality_measures <- c("BetweennessRSP", "Closeness", "InStrength", "OutStrength")
cents_withoutloops <- centralities(
  tna_model,
  measures = centrality_measures,
  loops = FALSE,
  normalize = TRUE
)
plot(cents_withoutloops, ncol = 2, model = tna_model)


Try the tna package in your browser

Any scripts or data that you put into this service are public.

tna documentation built on June 8, 2025, 10:33 a.m.