
Discovering subgroups with sequence clustering and transition network analysis in the tna R package
Mohammed Saqr
University of Eastern FinlandSonsoles López-Pernas
University of Eastern Finland2026-02-06
Source:vignettes/articles/tna-clustering.Rmd
tna-clustering.RmdKeywords: sequence clustering; heterogeneity; subgroups; transition network analysis; R
Introduction
This tutorial covers data-driven clustering of
temporal sequences using the tna package. It is a companion
to the main TNA
tutorial and the group
comparison tutorial. We assume familiarity with the basics of
building and analyzing a TNA model.
Transition network analysis is part of Dynalytics (Saqr, López-Pernas, & Misiejuk, 2026), a framework for the rigorous analytics of dynamical systems in which analysis and validation are inseparable. TNA applies that rigour to transition networks: bootstrapping tests the stability of each edge, case-dropping tests the stability of centralities, split-half reliability tests the internal consistency of the network, and permutation tests compare groups, conditions, and phases. A pattern is reported or refuted based on a rigorous statistical test matching the claims.
When a meaningful grouping variable is available (e.g., achievement level, experimental condition), the group tutorial shows how to split data by that variable and compare group-specific models. But in many research settings, no such variable exists — or the researcher suspects that the true structure of behavioral differences does not align with any available categorical variable. In these cases, data-driven clustering discovers naturally occurring subgroups directly from the sequence data, without imposing predefined categories.
This tutorial demonstrates how to:
- Cluster sequences based on structural dissimilarity.
- Build group-specific TNA models from the discovered clusters.
- Compare and visualize cluster-specific networks.
- Validate cluster differences with permutation testing.
- Assess within-cluster edge reliability with bootstrapping.
- Choose an appropriate number of clusters.
Installation
The tna package is the only package required. It
provides all the functions needed for data preparation, model building,
visualization, clustering, permutation testing, and bootstrapping.
Install from CRAN:
install.packages("tna")Or install the development version from GitHub:
# install.packages("remotes")
remotes::install_github("sonsoleslp/tna")Data Preparation
We use the built-in group_regulation_long dataset, which
contains coded collaborative regulation behaviors from student groups.
The prepare_data() function converts this long-format event
log into the structure required for TNA.
# Load the built-in collaborative regulation dataset
data("group_regulation_long")
# Convert long-format event log into TNA data
prepared_data <- prepare_data(
group_regulation_long,
action = "Action", # behavioral states (network nodes)
actor = "Actor", # participant IDs (one sequence per actor)
time = "Time" # timestamps (for ordering and session splitting)
)
# Build the aggregate TNA model (all sequences combined)
model <- tna(prepared_data)| Argument | Description |
|---|---|
action |
(Required) Column containing the events or states to model. These become the network nodes. |
actor |
Column identifying who performed the action. Creates one sequence per actor. |
time |
Column with timestamps. Sorts events and splits sequences at temporal gaps (default: 15 minutes). |
order |
Numeric column for event ordering when timestamps are unavailable. |
time_threshold |
Gap duration in seconds that starts a new session (default:
900). |
Any columns not specified as action, actor,
time, or order are automatically preserved as
metadata.
This tutorial uses long-format event data, but tna()
accepts several other input formats:
| Input Format | Function | Description |
|---|---|---|
| Long event log |
prepare_data() then tna()
|
Timestamped events with actors |
| Wide data frame | tna(df) |
Rows = sequences, columns = time points |
| Pre-computed matrix | tna(mat) |
Square weight matrix with named rows and columns |
| TraMineR sequence | tna(seqobj) |
Object from TraMineR::seqdef()
|
| One-hot binary data | import_onehot() |
Co-occurrence model from binary feature data |
Why Cluster?
A single TNA model computed from all sequences describes the average transition dynamics across all individuals. But averages can mask substantial heterogeneity. If one subgroup of learners follows a strategic regulatory cycle (plan → monitor → adapt) while another subgroup is stuck in social loops (discuss → consensus → discuss), the aggregate model shows a blend of both patterns that accurately represents neither.
Clustering addresses this by partitioning sequences into subgroups with distinct transition structures, allowing each cluster to be modeled separately. The result is a set of group-specific TNA models — one per cluster — that capture the actual behavioral patterns present in the data rather than an uninformative average.
This is exploratory analysis: we let the data reveal structure rather than imposing predefined categories. The discovered clusters may correspond to meaningful behavioral profiles — different learning strategies, different levels of engagement, different regulatory styles — that would be invisible in an aggregate analysis.
Running cluster_sequences()
The cluster_sequences() function takes a sequence data
frame, computes pairwise dissimilarities between sequences, and
partitions them into k groups:
# Partition sequences into 2 clusters based on pairwise dissimilarity
clustering <- cluster_sequences(prepared_data$sequence_data, k = 2)
print(clustering)Clustering method: pam
Number of clusters: 2
Silhouette score: 0.18
Cluster sizes:
1 2
982 1018
The procedure has two steps:
- Compute pairwise dissimilarity between all sequences using a string distance metric. Each pair of sequences receives a dissimilarity score reflecting how structurally different they are.
-
Cluster the dissimilarity matrix using the chosen
algorithm and assign each sequence to one of
kgroups.
| Argument | Description | Default |
|---|---|---|
data |
Sequence data frame (e.g.,
prepared_data$sequence_data) |
— |
k |
Number of clusters | — |
dissimilarity |
Distance metric: "hamming", "lcs",
"cosine", "jaccard", "osa",
etc. |
"hamming" |
method |
Clustering algorithm: "pam", "ward.D2",
"complete", "average", etc. |
"pam" |
Dissimilarity metrics:
-
"hamming"— counts the number of positions where two sequences differ. Fast and interpretable; requires equal-length sequences. -
"lcs"— longest common subsequence. Handles variable-length sequences and is sensitive to ordering. -
"osa"— optimal string alignment. Allows insertions, deletions, and substitutions; flexible but slower. -
"cosine"/"jaccard"— set-based metrics that compare state compositions regardless of order.
Clustering algorithms:
-
"pam"— Partitioning Around Medoids. Robust to outliers; identifies a representative sequence (medoid) for each cluster. -
"ward.D2"— Ward’s hierarchical clustering. Minimizes within-cluster variance; produces compact clusters. -
"complete"/"average"— other hierarchical linkage methods for different cluster shape assumptions.
Building Group TNA from Clusters
The clustering result can be passed directly to
group_tna(), which builds a separate TNA model for each
cluster:
Once clusters are identified, we pass the clustering result directly
to group_tna(), which builds a separate TNA model for each
cluster. We also rename the clusters to give them more descriptive
labels.
# Build one TNA model per cluster and assign descriptive names
gtna_clust <- group_tna(clustering)
gtna_clust <- rename_groups(gtna_clust, c("Pattern A", "Pattern B"))Plotting the cluster-specific models side by side reveals how the discovered subgroups differ in their transition structures:
plot(gtna_clust, cut = 0.1, minimum = 0.05)
Transition networks by discovered cluster

Transition networks by discovered cluster
The summary provides network-level statistics for each cluster, including density, reciprocity, and the number of sequences assigned to each group:
summary(gtna_clust)
[38;5;246m# A tibble: 13 × 3
[39m
metric `Pattern A` `Pattern B`
[3m
[38;5;246m<chr>
[39m
[23m
[3m
[38;5;246m<dbl>
[39m
[23m
[3m
[38;5;246m<dbl>
[39m
[23m
[38;5;250m 1
[39m Node Count 9 9
[38;5;250m 2
[39m Edge Count 78 78
[38;5;250m 3
[39m Network Density 1 1
[38;5;250m 4
[39m Mean Distance 0.046 0.047
[38;5;250m 5
[39m Mean Out-Strength 1 1
[38;5;250m 6
[39m SD Out-Strength 0 0
[38;5;250m 7
[39m Mean In-Strength 1 1
[38;5;250m 8
[39m SD In-Strength 0.781 0.823
[38;5;250m 9
[39m Mean Out-Degree 8.67 8.67
[38;5;250m10
[39m SD Out-Degree 0.707 0.707
[38;5;250m11
[39m Centralization (Out-Degree) 0.016 0.016
[38;5;250m12
[39m Centralization (In-Degree) 0.016 0.016
[38;5;250m13
[39m Reciprocity 0.986 0.986
Comparing Clusters
Difference Network
The difference plot highlights where the two clusters diverge. Edges are colored by direction: one color for transitions stronger in Pattern A, another for transitions stronger in Pattern B.
# Edges colored by which cluster has a stronger transition
plot_compare(gtna_clust$`Pattern A`, gtna_clust$`Pattern B`, minimum = 0.01, cut = 0.1)
Difference network between clusters
Community Structure
Community detection identifies groups of states that are more densely connected to each other than to the rest of the network. Comparing community structures across clusters reveals whether the modular organization of the process differs between subgroups:
# Detect community structure within each cluster's network
# igraph may override the `communities` function. That is why we use the prefix `tna::`
comm_clust <- tna::communities(gtna_clust)
plot(comm_clust, cut = 0.1, minimum = 0.01)

Communities by cluster
Centralities
Centrality measures summarize the structural importance of each state within each cluster. Comparing centrality profiles across clusters identifies states that play different roles in different subgroups:
# Compute and compare centrality measures across clusters
cent_clust <- centralities(gtna_clust)
plot(cent_clust)
Centralities by cluster
Permutation Test for Clusters
The tests in this tutorial treat every sequence as independent. When
sequences are nested in a higher unit, such as several sessions per
student or students in teams (the 2,000 students of
group_regulation_long work in 200 teams of 10, recorded in
Group), bootstrap(),
permutation_test(), estimate_cs() and
reliability() take an actor argument that
resamples whole units instead, and mosaic_test() gives the
tests of a mosaic that allow for the nesting. Their help pages, such as
bootstrap()
and mosaic_test(),
show how, and the tutorial Transition
network analysis of nested data with the tna R package works
through a complete example.
Why Permutation Testing Is Essential for Clusters
Permutation testing is particularly important for data-driven clusters. Unlike known groups (where group membership is defined independently of the transition data), clustering algorithms partition sequences to maximize between-group separation. Some degree of apparent difference is therefore guaranteed by construction. The permutation test provides the necessary corrective: by randomly reassigning sequences to groups while preserving internal sequential structure, it constructs the null distribution of differences expected under random partitioning. Only differences that exceed this null distribution constitute evidence of genuine structural divergence rather than algorithmic artifacts.
The permutation approach preserves the temporal dependency structure that parametric tests on summary statistics necessarily violate, and provides a principled basis for distinguishing substantive cluster differences from stochastic variation (van Borkulo et al., 2023).
set.seed(265) # for reproducibility
# Test whether cluster differences exceed what random partitioning would produce
perm_clust <- permutation_test(
gtna_clust$`Pattern A`, gtna_clust$`Pattern B`,
iter = 1000, # number of random reassignments
measures = c("InStrength", "OutStrength", "Betweenness")
)Results
Filtering for p < 0.05 identifies the transitions for which the observed cluster difference exceeds what would be expected under the null hypothesis:
# Filter for statistically significant edges and sort by effect size
sig_clust <- perm_clust$edges$stats[perm_clust$edges$stats$p_value < 0.05, ]
sig_clust <- sig_clust[order(-abs(sig_clust$effect_size)), ]
sig_clust edge_name diff_true effect_size p_value
66 consensus -> plan -0.0874 -7.2 0.001
39 consensus -> discuss 0.0491 4.6 0.001
71 plan -> plan -0.0586 -4.5 0.001
53 plan -> emotion 0.0320 3.5 0.001
67 coregulate -> plan -0.0652 -3.3 0.001
72 synthesis -> plan -0.0531 -2.7 0.007
70 monitor -> plan -0.0572 -2.6 0.013
76 coregulate -> synthesis 0.0145 2.4 0.016
24 emotion -> consensus 0.0401 2.3 0.027
75 consensus -> synthesis 0.0049 2.3 0.024
54 synthesis -> emotion 0.0459 2.3 0.025
62 plan -> monitor 0.0150 2.2 0.028
50 discuss -> emotion 0.0209 2.1 0.032
65 cohesion -> plan -0.0363 -2.1 0.040
3 consensus -> adapt 0.0034 1.9 0.048
79 monitor -> synthesis -0.0136 -1.9 0.044
| Column | Meaning | Interpretation |
|---|---|---|
edge_name |
The transition (from → to) | Which behavioral transition is being tested |
diff_true |
Observed difference (Pattern A minus Pattern B) | Direction and magnitude of the cluster difference |
effect_size |
Difference / SD of permuted differences | Standardized effect size (analogous to Cohen’s d). Values > 0.5 moderate; > 0.8 large |
p_value |
Proportion of permutations as extreme as observed | Statistical significance. Values < 0.05 are conventionally significant |
Visualization
The permutation plot displays only the edges that reached statistical significance:
# Only edges with p < 0.05 are displayed
plot(perm_clust, minimum = 0.01, cut = 0.1)
Significant differences between clusters
Bootstrap Validation of Clusters
Why Bootstrap Cluster Models?
The same replicability concern that applies to any TNA model applies with particular force to cluster-specific models. Because cluster assignments are derived from the data itself, cluster-specific transition estimates are susceptible to overfitting: edges that appear in the point-estimate model for a given cluster may not survive resampling.
Bootstrapping addresses this directly. By resampling sequences with replacement and reconstructing the transition matrix across a large number of iterations, the procedure generates empirical sampling distributions for each edge weight, thereby distinguishing transitions that are stable properties of the discovered pattern from those whose presence is contingent on the particular sample at hand (Saqr, Lopez-Pernas, & Tikka, 2025). Edges that do not consistently exceed a defined threshold are identified as non-significant, yielding a model in which every retained transition has demonstrated resampling support.
Permutation and Bootstrap: Complementary Confirmatory Roles
| Method | Inferential Target | What It Confirms |
|---|---|---|
| Permutation test | Between-cluster differences | Whether observed differences exceed what would be expected under random cluster assignment |
| Bootstrap | Within-cluster edge stability | Whether individual edges within each cluster model are replicable or sample-contingent |
Neither test subsumes the other. Together, they provide a complete inferential framework: the bootstrap identifies which transitions reliably exist within each cluster, and the permutation test identifies which transitions reliably differ between clusters.
Running the Bootstrap
We apply bootstrap() to each cluster model separately.
Each bootstrap resamples the sequences assigned to that cluster and
reconstructs the transition matrix, repeating 1,000 times to build
empirical sampling distributions for each edge.
Results
An edge marked sig = TRUE appeared consistently across
1,000 resampled datasets; an edge marked sig = FALSE did
not survive this replicability criterion:
Pattern A: significant edges
# Edges that survived the bootstrap stability criterion for Pattern A
boot_patA$summary[boot_patA$summary$sig == TRUE, ] from to weight p_value sig cr_lower cr_upper ci_lower
5 discuss adapt 0.075 0.016 TRUE 0.056 0.093 0.061
9 synthesis adapt 0.262 0.024 TRUE 0.197 0.328 0.205
10 adapt cohesion 0.311 0.023 TRUE 0.234 0.389 0.242
14 discuss cohesion 0.049 0.048 TRUE 0.037 0.062 0.038
15 emotion cohesion 0.322 0.001 TRUE 0.242 0.403 0.291
19 adapt consensus 0.449 0.005 TRUE 0.337 0.561 0.374
20 cohesion consensus 0.506 0.001 TRUE 0.379 0.632 0.461
21 consensus consensus 0.092 0.001 TRUE 0.069 0.115 0.079
22 coregulate consensus 0.122 0.025 TRUE 0.092 0.153 0.096
23 discuss consensus 0.324 0.001 TRUE 0.243 0.405 0.298
24 emotion consensus 0.348 0.001 TRUE 0.261 0.435 0.318
25 monitor consensus 0.152 0.027 TRUE 0.114 0.190 0.117
26 plan consensus 0.300 0.001 TRUE 0.225 0.375 0.276
27 synthesis consensus 0.437 0.003 TRUE 0.328 0.546 0.370
30 consensus coregulate 0.200 0.001 TRUE 0.150 0.251 0.182
32 discuss coregulate 0.079 0.013 TRUE 0.060 0.099 0.065
39 consensus discuss 0.223 0.001 TRUE 0.167 0.279 0.203
40 coregulate discuss 0.294 0.001 TRUE 0.221 0.368 0.256
41 discuss discuss 0.187 0.001 TRUE 0.140 0.234 0.164
42 emotion discuss 0.100 0.011 TRUE 0.075 0.125 0.081
43 monitor discuss 0.402 0.001 TRUE 0.301 0.502 0.357
44 plan discuss 0.074 0.004 TRUE 0.055 0.092 0.061
47 cohesion emotion 0.122 0.029 TRUE 0.091 0.152 0.094
48 consensus emotion 0.080 0.001 TRUE 0.060 0.100 0.068
49 coregulate emotion 0.194 0.005 TRUE 0.145 0.242 0.161
50 discuss emotion 0.120 0.002 TRUE 0.090 0.150 0.103
53 plan emotion 0.171 0.001 TRUE 0.128 0.214 0.153
57 consensus monitor 0.042 0.031 TRUE 0.032 0.053 0.033
62 plan monitor 0.087 0.004 TRUE 0.065 0.109 0.073
65 cohesion plan 0.116 0.049 TRUE 0.087 0.145 0.089
66 consensus plan 0.333 0.001 TRUE 0.250 0.417 0.314
67 coregulate plan 0.192 0.006 TRUE 0.144 0.240 0.158
69 emotion plan 0.090 0.018 TRUE 0.067 0.112 0.071
70 monitor plan 0.176 0.018 TRUE 0.132 0.220 0.139
71 plan plan 0.329 0.001 TRUE 0.247 0.412 0.307
77 discuss synthesis 0.138 0.001 TRUE 0.104 0.173 0.120
ci_upper
5 0.090
9 0.317
10 0.377
14 0.062
15 0.351
19 0.519
20 0.548
21 0.104
22 0.149
23 0.352
24 0.381
25 0.185
26 0.323
27 0.509
30 0.219
32 0.095
39 0.243
40 0.333
41 0.210
42 0.120
43 0.448
44 0.086
47 0.148
48 0.092
49 0.227
50 0.138
53 0.191
57 0.052
62 0.102
65 0.146
66 0.353
67 0.223
69 0.108
70 0.212
71 0.353
77 0.160
Pattern B: significant edges
# Edges that survived the bootstrap stability criterion for Pattern B
boot_patB$summary[boot_patB$summary$sig == TRUE, ] from to weight p_value sig cr_lower cr_upper ci_lower
5 discuss adapt 0.070 0.002 TRUE 0.052 0.087 0.060
9 synthesis adapt 0.222 0.009 TRUE 0.166 0.277 0.184
10 adapt cohesion 0.254 0.005 TRUE 0.191 0.318 0.211
12 consensus cohesion 0.016 0.031 TRUE 0.012 0.020 0.013
14 discuss cohesion 0.047 0.006 TRUE 0.035 0.058 0.039
15 emotion cohesion 0.327 0.001 TRUE 0.245 0.409 0.307
17 plan cohesion 0.026 0.006 TRUE 0.020 0.033 0.022
19 adapt consensus 0.491 0.001 TRUE 0.368 0.614 0.435
20 cohesion consensus 0.494 0.001 TRUE 0.371 0.618 0.468
21 consensus consensus 0.078 0.001 TRUE 0.059 0.098 0.070
22 coregulate consensus 0.139 0.003 TRUE 0.104 0.174 0.122
23 discuss consensus 0.320 0.001 TRUE 0.240 0.400 0.301
24 emotion consensus 0.308 0.001 TRUE 0.231 0.385 0.286
25 monitor consensus 0.162 0.003 TRUE 0.122 0.203 0.139
26 plan consensus 0.288 0.001 TRUE 0.216 0.359 0.275
27 synthesis consensus 0.480 0.001 TRUE 0.360 0.600 0.433
29 cohesion coregulate 0.121 0.002 TRUE 0.090 0.151 0.102
30 consensus coregulate 0.183 0.001 TRUE 0.137 0.228 0.171
32 discuss coregulate 0.087 0.001 TRUE 0.065 0.108 0.076
33 emotion coregulate 0.035 0.040 TRUE 0.027 0.044 0.027
35 plan coregulate 0.018 0.020 TRUE 0.014 0.023 0.015
38 cohesion discuss 0.054 0.049 TRUE 0.040 0.067 0.040
39 consensus discuss 0.174 0.001 TRUE 0.130 0.217 0.163
40 coregulate discuss 0.266 0.001 TRUE 0.199 0.332 0.244
41 discuss discuss 0.199 0.001 TRUE 0.149 0.248 0.184
42 emotion discuss 0.103 0.001 TRUE 0.077 0.128 0.090
43 monitor discuss 0.363 0.001 TRUE 0.273 0.454 0.333
44 plan discuss 0.066 0.001 TRUE 0.050 0.083 0.059
47 cohesion emotion 0.113 0.002 TRUE 0.085 0.141 0.096
48 consensus emotion 0.070 0.001 TRUE 0.052 0.087 0.062
49 coregulate emotion 0.164 0.001 TRUE 0.123 0.205 0.143
50 discuss emotion 0.099 0.001 TRUE 0.074 0.124 0.088
51 emotion emotion 0.081 0.002 TRUE 0.061 0.101 0.067
52 monitor emotion 0.085 0.008 TRUE 0.064 0.107 0.070
53 plan emotion 0.139 0.001 TRUE 0.104 0.174 0.130
57 consensus monitor 0.048 0.001 TRUE 0.036 0.061 0.042
58 coregulate monitor 0.086 0.008 TRUE 0.064 0.107 0.071
59 discuss monitor 0.024 0.038 TRUE 0.018 0.030 0.018
60 emotion monitor 0.036 0.023 TRUE 0.027 0.046 0.029
62 plan monitor 0.072 0.001 TRUE 0.054 0.090 0.065
65 cohesion plan 0.152 0.001 TRUE 0.114 0.190 0.130
66 consensus plan 0.421 0.001 TRUE 0.316 0.526 0.405
67 coregulate plan 0.257 0.001 TRUE 0.193 0.322 0.235
69 emotion plan 0.104 0.001 TRUE 0.078 0.130 0.092
70 monitor plan 0.234 0.001 TRUE 0.175 0.292 0.207
71 plan plan 0.388 0.001 TRUE 0.291 0.485 0.373
77 discuss synthesis 0.142 0.001 TRUE 0.107 0.178 0.130
ci_upper
5 0.080
9 0.264
10 0.298
12 0.020
14 0.056
15 0.348
17 0.031
19 0.546
20 0.524
21 0.087
22 0.157
23 0.338
24 0.328
25 0.186
26 0.300
27 0.528
29 0.139
30 0.194
32 0.098
33 0.044
35 0.022
38 0.067
39 0.186
40 0.288
41 0.213
42 0.116
43 0.395
44 0.074
47 0.129
48 0.077
49 0.184
50 0.109
51 0.094
52 0.101
53 0.149
57 0.055
58 0.100
59 0.029
60 0.045
62 0.080
65 0.174
66 0.435
67 0.280
69 0.119
70 0.261
71 0.401
77 0.155
| Column | Meaning |
|---|---|
from, to
|
The transition being evaluated |
mean |
Average edge weight across bootstrap resamples |
ci_lower, ci_upper
|
95% confidence interval for the edge weight |
sig |
TRUE if the edge demonstrated resampling stability |
Visualizing Bootstrapped Cluster Networks
The plots below display only the edges that survived the bootstrap procedure — the confirmed, replicable transition structure of each cluster:
# Side-by-side: only edges that survived the bootstrap are displayed
par(mfrow = c(1, 2))
plot(boot_patA, cut = 0.1)
plot(boot_patB, cut = 0.1)
Bootstrap-validated networks for each cluster
Choosing the Number of Clusters
The choice of k is a substantive decision. There is no
single “correct” number of clusters — the goal is to find a solution
where clusters have meaningfully different structures and each cluster
is interpretable.
A practical approach is to try several values and compare:
# Try several values of k and compare cluster summaries
for (k in 2:5) {
clust_k <- cluster_sequences(prepared_data$sequence_data, k = k)
gtna_k <- group_tna(clust_k)
cat("\n--- k =", k, "---\n")
print(summary(gtna_k))
}If increasing k only splits an existing cluster into two nearly identical subgroups, fewer clusters suffice. If a new k reveals a genuinely distinct behavioral pattern (e.g., a cluster with a strong plan → monitor → adapt cycle that was previously merged with a different pattern), the higher k may be warranted.
| Approach | When to Use | How |
|---|---|---|
| Known groups | Pre-existing grouping variable | group_tna(data, group = "Variable") |
| Data-driven clusters | No grouping variable, or exploring latent patterns |
cluster_sequences() then group_tna()
|
These are complementary. Cluster for exploration, then validate against known variables. If clusters align with a known variable (e.g., high vs. low achievers), this provides convergent evidence. If they do not, the clusters may reveal behavioral dimensions that the known variable does not capture.
Summary
This tutorial demonstrated a complete workflow for data-driven discovery of behavioral subgroups:
-
Cluster sequences with
cluster_sequences()based on structural dissimilarity. -
Build group-specific TNA models with
group_tna()and visualize them. - Compare clusters with difference plots, community detection, and centrality profiles.
-
Validate differences with
permutation_test()to confirm that cluster differences exceed what would be expected by chance. -
Validate edges with
bootstrap()to confirm that within-cluster transitions are replicable. - Report only edges and differences that survive the relevant inferential test.
For group comparisons using known variables (e.g., achievement group, experimental condition), see the group comparison tutorial.
How to cite this article
Saqr, M., & López-Pernas, S. (2026). Discovering subgroups with sequence clustering and transition network analysis in the tna R package. tna. https://doi.org/10.5281/zenodo.24581489 · HTML · PDF
Additional Resources
- Dynalytics — a framework for the rigorous analytics of dynamical systems: the packages, tutorials, papers, and book chapters behind it.
- Package sites and articles — documentation of the R packages of the Dynalytics framework, with their articles and tutorials.
- Nestimate — dynamic, probabilistic, and higher-order network analysis in R (CRAN).
If you prefer a visual interface to writing code, use CarmNote TNA. It runs transition network analysis in a single HTML file that opens in your browser: no installation, no internet connection needed, and your data never leave your computer. It covers network estimation, bootstrap and permutation validation, group comparison, clustering, pattern and process mining, and higher-order Markov models.
Get CarmNote TNA · Website · Documentation · All CarmNotes
Prefer jamovi? JTNA brings TNA to jamovi as a point-and-click module, with its own tutorial.
References
- Bakeman, R., & Gottman, J. M. (1997). Observing interaction: An introduction to sequential analysis (2nd ed.). Cambridge University Press. https://doi.org/10.1017/CBO9780511527685
- Davison, A. C., & Hinkley, D. V. (1997). Bootstrap methods and their application. Cambridge University Press. https://doi.org/10.1017/CBO9780511802843
- Efron, B. (1979). Bootstrap methods: Another look at the jackknife. The Annals of Statistics, 7(1), 1–26. https://doi.org/10.1214/aos/1176344552
- Efron, B., & Tibshirani, R. (1986). Bootstrap methods for standard errors, confidence intervals, and other measures of statistical accuracy. Statistical Science, 1(1), 54–75. https://doi.org/10.1214/ss/1177013815
- Efron, B., & Tibshirani, R. J. (1994). An introduction to the bootstrap. Chapman & Hall/CRC. https://doi.org/10.1201/9780429246593
- Helske, J., Helske, S., Saqr, M., López-Pernas, S., & Murphy, K. (2024). A modern approach to transition analysis and process mining with Markov models in education. In M. Saqr & S. López-Pernas (Eds.), Learning analytics methods and tutorials (pp. 381–427). Springer. https://doi.org/10.1007/978-3-031-54464-4_12
- Lambiotte, R., Rosvall, M., & Scholtes, I. (2019). From networks to optimal higher-order models of complex systems. Nature Physics, 15(4), 313–320. https://doi.org/10.1038/s41567-019-0459-y
- López-Pernas, S., Tikka, S., & Saqr, M. (2025). Mining patterns and clusters with transition network analysis: A heterogeneity approach. In M. Saqr & S. López-Pernas (Eds.), Advanced learning analytics methods: AI, precision and complexity. Springer. https://lamethods.org/book2/chapters/ch17-tna-clusters/ch17-tna-clusters.html
- Molenaar, I., & Järvelä, S. (2014). Sequential and temporal characteristics of self and socially regulated learning. Metacognition and Learning, 9(2), 75–85. https://doi.org/10.1007/s11409-014-9114-2
- Peeters, W., Saqr, M., & Viberg, O. (2020). Applying learning analytics to map students’ self-regulated learning tactics in an academic writing course. In Proceedings of the 28th International Conference on Computers in Education (ICCE 2020) (pp. 245–254). Asia-Pacific Society for Computers in Education. https://library.apsce.net/index.php/ICCE/article/view/3926
- Reimann, P. (2009). Time is precious: Variable- and event-centred approaches to process analysis in CSCL research. International Journal of Computer-Supported Collaborative Learning, 4(3), 239–257. https://doi.org/10.1007/s11412-009-9070-z
- Rosvall, M., Esquivel, A. V., Lancichinetti, A., West, J. D., & Lambiotte, R. (2014). Memory in network flows and its effects on spreading dynamics and community detection. Nature Communications, 5, 4630. https://doi.org/10.1038/ncomms5630
- Saqr, M., & López-Pernas, S. (2023). The temporal dynamics of online problem-based learning: Why and when sequence matters. International Journal of Computer-Supported Collaborative Learning, 18(1), 11–37. https://doi.org/10.1007/s11412-023-09385-1
- Saqr, M., López-Pernas, S., & Misiejuk, K. (2026). Dynalytics: The birth of a framework for rigorous analytics of dynamical systems [Preprint]. SSRN. https://doi.org/10.2139/ssrn.6832584
- Saqr, M., López-Pernas, S., Törmänen, T., Kaliisa, R., Misiejuk, K., & Tikka, S. (2025). Transition network analysis: A novel framework for modeling, visualizing, and identifying the temporal patterns of learners and learning processes. In Proceedings of the 15th International Learning Analytics and Knowledge Conference (LAK ’25) (pp. 351–361). ACM. https://doi.org/10.1145/3706468.3706513
- Saqr, M., Nouri, J., & Fors, U. (2019). Time to focus on the temporal dimension of learning: A learning analytics study of the temporal patterns of students’ interactions and self-regulation. International Journal of Technology Enhanced Learning, 11(4), 398–412. https://doi.org/10.1504/IJTEL.2019.102549
- Scholtes, I. (2017). When is a network a network? Multi-order graphical model selection in pathways and temporal networks. In Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (pp. 1037–1046). ACM. https://doi.org/10.1145/3097983.3098145
- Tikka, S., López-Pernas, S., & Saqr, M. (2025). tna: An R package for transition network analysis. Applied Psychological Measurement, 49(6), 326–328. https://doi.org/10.1177/01466216251348840
- Package website: https://sonsoles.me/tna/