An R package for the analysis of relational dynamics through Transition Network Analysis (TNA). TNA provides tools for building TNA models, plotting transition networks, calculating centrality measures, and identifying dominant events and patterns. TNA statistical techniques (e.g., bootstrapping and permutation tests) ensure the reliability of observed insights and confirm that identified dynamics are meaningful. See (Saqr et al., 2025) for more details on TNA.
Check out our tutorials:
You can also try our Shiny app.
You can install the most recent stable version of tna
from
CRAN or the development
version from GitHub by running one of the
following:
install.packages("tna")
# install.packages("devtools")
# devtools::install_github("sonsoleslp/tna")
Load the library
library("tna")
Example data
data("group_regulation", package = "tna")
Build a Markov model
tna_model <- tna(group_regulation)
summary(tna_model)
metric | value |
---|---|
Node Count | 9.00 |
Edge Count | 78.00 |
Network Density | 1.00 |
Mean Distance | 0.05 |
Mean Out-Strength | 1.00 |
SD Out-Strength | 0.81 |
Mean In-Strength | 1.00 |
SD In-Strength | 0.00 |
Mean Out-Degree | 8.67 |
SD Out-Degree | 0.71 |
Centralization (Out-Degree) | 0.02 |
Centralization (In-Degree) | 0.02 |
Reciprocity | 0.99 |
Plot the transition network
# Default plot
plot(tna_model)
# Optimized plot
plot(
tna_model, cut = 0.2, minimum = 0.05,
edge.label.position = 0.8, edge.label.cex = 0.7
)
cent <- centralities(tna_model)
state | OutStrength | InStrength | ClosenessIn | ClosenessOut | Closeness | Betweenness | BetweennessRSP | Diffusion | Clustering |
---|---|---|---|---|---|---|---|---|---|
adapt | 1.0000000 | 0.3445778 | 13.406025 | 2.333065 | 18.546309 | 17 | 1 | 5.586292 | 0.3369839 |
cohesion | 0.9728614 | 0.8116478 | 3.651321 | 2.791075 | 13.812739 | 0 | 19 | 5.208633 | 0.2996487 |
consensus | 0.9179965 | 2.6672185 | 0.797502 | 4.344062 | 11.481098 | 0 | 103 | 4.659728 | 0.1607773 |
coregulate | 0.9766497 | 0.5665811 | 4.546876 | 2.308867 | 5.973798 | 5 | 27 | 5.147938 | 0.3057842 |
discuss | 0.8051126 | 1.1882315 | 1.954285 | 2.680996 | 7.308377 | 0 | 53 | 4.627577 | 0.2397108 |
emotion | 0.9231583 | 0.8941312 | 1.568289 | 3.132785 | 14.538635 | 0 | 36 | 5.069888 | 0.2904793 |
monitor | 0.9818562 | 0.3457150 | 6.243045 | 2.210039 | 7.757314 | 3 | 11 | 5.156837 | 0.2888819 |
plan | 0.6257918 | 1.1937843 | 5.474533 | 2.913798 | 17.593057 | 10 | 61 | 3.487529 | 0.2874904 |
synthesis | 1.0000000 | 0.1915394 | 12.270650 | 2.183927 | 15.900927 | 14 | 3 | 5.582502 | 0.3586136 |
Plot the centrality measures
plot(cent, ncol = 3)
Estimate centrality stability
estimate_centrality_stability(tna_model)
#> Centrality Stability Coefficients
#>
#> InStrength OutStrength Betweenness
#> 0.9 0.9 0.7
Identify and plot communities
coms <- communities(tna_model)
plot(coms)
Find and plot cliques
cqs <- cliques(tna_model, threshold = 0.12)
plot(cqs)
Compare high achievers (first 1000) with low achievers (last 1000)
tna_model_start_high <- tna(group_regulation[1:1000, ])
tna_model_start_low <- tna(group_regulation[1001:2000, ])
comparison <- permutation_test(
tna_model_start_high,
tna_model_start_low,
measures = c("InStrength")
)
Simple comparison vs. permutation test comparison
plot_compare(tna_model_start_high, tna_model_start_low)
plot(comparison)
Compare centralities
print(comparison$centralities$stats)
state | centrality | diff_true | effect_size | p_value |
---|---|---|---|---|
adapt | InStrength | -0.23693341 | -6.8131390 | 0.000 |
cohesion | InStrength | 0.01634987 | 0.3218349 | 0.751 |
consensus | InStrength | 0.53680793 | 7.5039077 | 0.000 |
coregulate | InStrength | -0.25275371 | -7.4748752 | 0.000 |
discuss | InStrength | -0.09009651 | -1.8726678 | 0.051 |
emotion | InStrength | 0.19288376 | 4.0752947 | 0.000 |
monitor | InStrength | -0.09192991 | -3.3529720 | 0.001 |
plan | InStrength | 0.12225988 | 2.8214020 | 0.003 |
synthesis | InStrength | -0.04909607 | -3.2129876 | 0.001 |