install.packages("tna")1 Introduction
Before building a TNA model, your raw event data needs to be reshaped into sequences. The prepare_data() function does this in one call. For most data, the call is three arguments and you are done.
This tutorial has two parts:
- Quick Start — the three-argument call that covers 90% of use cases. Start here.
- Detailed Guide — session splitting, time parsing, output anatomy, edge cases. Only needed when the defaults don’t fit your data.
Other tutorials:
- TNA Main Tutorial — building and analyzing a TNA model
- TNA Group Analysis — group comparisons, permutation testing, bootstrapping
- TNA Clustering — data-driven clustering of sequences
- TNA Compare — comparing two TNA models numerically
1.1 Installation
Or the development version:
# install.packages("remotes")
remotes::install_github("sonsoleslp/tna")2 Quick Start
2.1 Load your data
Your data should be in long format: one row per event, with columns for what happened, who did it, and when.
We use the built-in dataset as an example:
# Built-in dataset: coded collaborative regulation behaviors
data("group_regulation_long")
group_regulation_longThe columns that matter for prepare_data():
- Action — what happened (the behavioral state). These become network nodes.
- Actor — who did it (participant ID). One sequence per actor.
- Time — when it happened (timestamp). Used for sorting and session splitting.
Everything else (Achiever, Group, Course) is kept automatically as metadata.
2.2 Prepare the data
# Three arguments: action, actor, time. That's it.
pd <- prepare_data(
group_regulation_long,
action = "Action",
actor = "Actor",
time = "Time"
)That’s the whole call. Events are sorted by time within each actor, split into sessions when gaps exceed 15 minutes, and pivoted into wide format. Metadata columns are preserved automatically.
2.3 Build a model
# Build a TNA model from the prepared data
model <- tna(pd)
plot(model)2.4 Group comparisons
Any column you did not assign to action, actor, or time is preserved as metadata. You can use it for group comparisons without any extra work:
# The Achiever column was preserved automatically
group_models <- group_tna(pd, group = "Achiever")
plot(group_models)