tna

Transition Network Analysis R package

https://github.com/sonsoleslp/tna

Science Score: 39.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (19.8%) to scientific vocabulary

Keywords

cran-r educational-data-mining learning-analytics markov-model r temporal-analysis
Last synced: 6 months ago · JSON representation

Repository

Transition Network Analysis R package

Basic Info
  • Host: GitHub
  • Owner: sonsoleslp
  • License: other
  • Language: R
  • Default Branch: main
  • Homepage: http://sonsoles.me/tna/
  • Size: 177 MB
Statistics
  • Stars: 10
  • Watchers: 2
  • Forks: 1
  • Open Issues: 0
  • Releases: 4
Topics
cran-r educational-data-mining learning-analytics markov-model r temporal-analysis
Created almost 2 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "60%",
  fig.width = 5,
  fig.height = 5,
  fig.align = "center",
  dev = "svg",
  fig.ext = "svg",
  out.extra = "style='text-align: center; display: block; margin: auto;'"
)
```


# `tna`: An R package for Transition Network Analysis 


[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![R-CMD-check](https://github.com/sonsoleslp/tna/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/sonsoleslp/tna/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/sonsoleslp/tna/graph/badge.svg)](https://app.codecov.io/gh/sonsoleslp/tna)
[![tna CRAN badge](https://www.r-pkg.org/badges/version/tna)](https://cran.r-project.org/package=tna)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)



`tna` is 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)](https://doi.org/10.1145/3706468.3706513) for more details on TNA.


![](man/figures/method.png)


## Resources

Check out our tutorials:

 - [Basics of TNA](https://lamethods.org/book2/chapters/ch15-tna/ch15-tna.html)
 - [Frequency-based TNA](https://lamethods.org/book2/chapters/ch16-ftna/ch16-ftna.html)
 - [Clustering](https://lamethods.org/book2/chapters/ch17-tna-clusters/ch17-tna-clusters.html)
 
You can also try our [Shiny app](https://sonsoleslp.shinyapps.io/tna-app/).

## Installation

You can install the most recent stable version of `tna` from [CRAN](https://cran.r-project.org/package=tna) or the development version from [GitHub](https://github.com/) by running one of the following:

```{r, eval = FALSE}
install.packages("tna")

# install.packages("devtools")
# devtools::install_github("sonsoleslp/tna")
```

## Example

Load the package
```{r, echo=FALSE}
suppressPackageStartupMessages(library("tna"))
```
```{r, eval=FALSE}
library("tna")
```

Example data
```{r}
data("group_regulation", package = "tna")
```

Build a Markov model
```{r}
tna_model <- tna(group_regulation)
```

```{r, eval=FALSE}
summary(tna_model)
```
```{r, echo=FALSE}
summary(tna_model) |>
  gt::gt() |>
  gt::fmt_number(decimals = 2) |>
  gt::as_raw_html()
```

Plot the transition network
```{r tnaplot}
# 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
)
```
Calculate the centrality measures
```{r}
cent <- centralities(tna_model)
```

```{r, echo=FALSE}
cent |>
  gt::gt() |>
  gt::tab_options(table.font.size = 8) |>
  gt::fmt_number(decimals = 3) |>
  gt::as_raw_html()
```

Plot the centrality measures

```{r centralitiesplot, fig.width=12, fig.height=8, out.width="90%"}
plot(cent, ncol = 3)
```

Estimate centrality stability
```{r}
estimate_centrality_stability(tna_model)
```

Identify and plot communities
```{r}
coms <- communities(tna_model)
plot(coms)
```

Find and plot cliques
```{r, eval = F}
cqs <- cliques(tna_model, threshold = 0.12)
plot(cqs)
```

```{r, out.width="100%", fig.width=6, fig.height=2, echo = FALSE}
layout(t(1:3))
cqs <- cliques(tna_model, threshold = 0.12)
plot(cqs, vsize = 30, edge.label.cex = 3)
```

Compare high achievers (first 1000) with low achievers (last 1000)
```{r}
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
```{r, fig.width=10, fig.height=5, out.width="100%", echo = 2:3}
layout(t(1:2))
plot_compare(tna_model_start_high, tna_model_start_low)
plot(comparison)
```

Compare centralities
```{r, eval = FALSE}
print(comparison$centralities$stats)
```

```{r, echo = FALSE}
comparison$centralities$stats |>
  gt::gt() |>
  gt::as_raw_html()
```

Owner

  • Name: sonsoleslp
  • Login: sonsoleslp
  • Kind: user
  • Location: Madrid

Researcher at UPM

GitHub Events

Total
  • Create event: 10
  • Issues event: 4
  • Release event: 3
  • Watch event: 15
  • Issue comment event: 8
  • Push event: 238
  • Pull request review event: 1
  • Pull request event: 5
  • Fork event: 1
Last Year
  • Create event: 10
  • Issues event: 4
  • Release event: 3
  • Watch event: 15
  • Issue comment event: 8
  • Push event: 238
  • Pull request review event: 1
  • Pull request event: 5
  • Fork event: 1

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 2
  • Total pull requests: 3
  • Average time to close issues: 4 days
  • Average time to close pull requests: 3 days
  • Total issue authors: 2
  • Total pull request authors: 1
  • Average comments per issue: 3.0
  • Average comments per pull request: 1.0
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 3
  • Average time to close issues: 4 days
  • Average time to close pull requests: 3 days
  • Issue authors: 2
  • Pull request authors: 1
  • Average comments per issue: 3.0
  • Average comments per pull request: 1.0
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • hkayaduman (1)
  • learnasteve (1)
Pull Request Authors
  • santikka (6)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 147 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
cran.r-project.org: tna

Transition Network Analysis (TNA)

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 147 Last month
Rankings
Dependent packages count: 27.6%
Dependent repos count: 34.0%
Average: 49.5%
Downloads: 86.9%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.6.0 depends
  • TraMineR * imports
  • ggcharts * imports
  • ggplot2 * imports
  • igraph * imports
  • qgraph * imports
  • rlang * imports
  • seqHMM * imports
  • tibble * imports
  • knitr * suggests
  • rmarkdown * suggests