Title: | Transition Network Analysis (TNA) |
Version: | 1.0.0 |
Description: | Provides tools for performing Transition Network Analysis (TNA) to study relational dynamics, including functions for building and plotting TNA models, 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) <doi:10.1145/3706468.3706513> for more details on TNA. |
License: | MIT + file LICENSE |
URL: | https://github.com/sonsoleslp/tna/, http://sonsoles.me/tna/ |
BugReports: | https://github.com/sonsoleslp/tna/issues/ |
Depends: | R (≥ 4.1.0) |
Imports: | checkmate, cli, colorspace, dplyr, ggplot2, graphics, igraph, qgraph, RColorBrewer, rlang, stats, tibble, tidyr, tidyselect |
Suggests: | gt, knitr, mclust, pracma, rmarkdown, seqHMM, testthat (≥ 3.0.0) |
VignetteBuilder: | knitr |
Config/testthat/edition: | 3 |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
LazyData: | true |
Config/Needs/website: | rmarkdown |
NeedsCompilation: | no |
Packaged: | 2025-07-15 08:23:50 UTC; tna |
Author: | Mohammed Saqr [aut], Santtu Tikka [aut], Sonsoles López-Pernas [aut, cre] |
Maintainer: | Sonsoles López-Pernas <sonsoles.lopez@uef.fi> |
Repository: | CRAN |
Date/Publication: | 2025-07-15 08:50:02 UTC |
The tna
Package.
Description
Provides tools for performing transition network analysis (TNA),
including functions for building TNA models, plotting transition networks,
and calculating centrality measures. The package relies on the qgraph
and igraph
for network plotting and centrality measure calculations.
Author(s)
Sonsoles López-Pernas, Santtu Tikka, Mohammed Saqr
References
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), 351-361.
Banerjee A., Chandrasekhar A., Duflo E., Jackson M. (2014). Gossip: Identifying Central Individuals in a Social Network. Working Paper.
Kivimaki, I., Lebichot, B., Saramaki, J., Saerens, M. (2016). Two betweenness centrality measures based on Randomized Shortest Paths. Scientific Reports, 6, 19668.
Serrano, M. A., Boguna, M., Vespignani, A. (2009). Extracting the multiscale backbone of complex weighted networks. Proceedings of the National Academy of Sciences, 106, 6483-6488.
Zhang, B., Horvath, S. (2005). A general framework for weighted gene co-expression network analysis. Statistical Applications in Genetics and Molecular Biology, 4(1).
See Also
Useful links:
Report bugs at https://github.com/sonsoleslp/tna/issues/
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
Coerce a Specific Group from a group_tna
Object into an igraph
Object.
Description
Coerce a Specific Group from a group_tna
Object into an igraph
Object.
Usage
## S3 method for class 'group_tna'
as.igraph(x, which, ...)
Arguments
x |
The object to convert. |
which |
The number or name of the group. |
... |
Additional arguments. None currently. |
Value
An igraph
object.
See Also
Helper functions
as.igraph.matrix()
,
as.igraph.tna()
Coerce a Weight Matrix into an igraph
Object.
Description
Coerce a Weight Matrix into an igraph
Object.
Usage
## S3 method for class 'matrix'
as.igraph(x, mode = "directed", ...)
Arguments
x |
A |
mode |
Character scalar, specifies how igraph should interpret the
supplied matrix. See also the |
... |
Ignored. |
Value
An igraph
object.
See Also
Helper functions
as.igraph.group_tna()
,
as.igraph.tna()
Coerce a tna
Object into an igraph
Object.
Description
Coerce a tna
Object into an igraph
Object.
Usage
## S3 method for class 'tna'
as.igraph(x, mode = "directed", ...)
Arguments
x |
A |
mode |
Character scalar, specifies how igraph should interpret the
supplied matrix. See also the |
... |
Ignored. |
Value
An igraph
object.
See Also
Helper functions
as.igraph.group_tna()
,
as.igraph.matrix()
Build and Visualize a Network with Edge Betweenness
Description
This function builds a network from a transition matrix in a tna
object
and computes edge betweenness for the network.
Usage
betweenness_network(x, ...)
## S3 method for class 'tna'
betweenness_network(x, ...)
Arguments
x |
A |
... |
Ignored. |
Value
A tna
object where the edge weights are edge betweenness values.
See Also
Centrality measure functions
centralities()
,
plot.group_tna_centralities()
,
plot.tna_centralities()
,
print.group_tna_centralities()
,
print.tna_centralities()
Examples
model <- tna(group_regulation)
betweenness_network(model)
Bootstrap Transition Networks from Sequence Data
Description
Perform bootstrapping on transition networks created from
sequence data stored in a tna
object. Bootstrapped estimates
of edge weights are returned with confidence intervals and significance
testing.
Usage
bootstrap(x, ...)
## S3 method for class 'tna'
bootstrap(
x,
iter = 1000,
level = 0.05,
method = "stability",
threshold,
consistency_range = c(0.75, 1.25),
...
)
## S3 method for class 'group_tna'
bootstrap(
x,
iter = 1000,
level = 0.05,
method = "stability",
threshold,
consistency_range = c(0.75, 1.25),
...
)
Arguments
x |
A |
... |
Ignored. |
iter |
An |
level |
A |
method |
A |
threshold |
A |
consistency_range |
A |
Details
The function first computes the original edge weights for the specified
cluster from the tna
object. It then performs bootstrapping by resampling
the sequence data and recalculating the edge weights for each
bootstrap sample. The mean and standard deviation of the transitions are
computed, and confidence intervals are derived. The function also estimates
p-values for each edge and identifies significant edges based on
the specified significance level. A matrix of significant edges
(those with estimated p-values below the significance level) is generated.
Additional statistics on removed edges (those not considered
significant) are provided.
All results, including the original transition matrix, bootstrapped estimates, and summary statistics for removed edges, are returned in a structured list.
Value
A tna_bootstrap
object which is a list
containing the
following elements:
-
weights_orig
: The original edge weightmatrix
. -
weights_sig
: Thematrix
of significant transitions (those with estimated p-values below the significance level). -
weights_mean
: The mean weightmatrix
from the bootstrap samples. -
weights_sd
: The standard deviationmatrix
from the bootstrap samples. -
cr_lower
: The lower boundmatrix
of the consistency range for the edge weights. -
cr_upper
: The upper boundmatrix
of the consistency range for the edge weights. -
ci_lower
: The lower boundmatrix
of the bootstrap confidence intervals for the edge weights. -
ci_upper
: The upper boundmatrix
of the bootstrap confidence intervals for the edge weights. -
p_values
: Thematrix
of estimated p-values for the edge weights. -
summary
: Adata.frame
summarizing the edges, their weights, p-values, statistical significance, consistency ranges, and confidence intervals.
If x
is a group_tna
object, the output is a group_tna_bootstrap
object, which is a list
of tna_bootstrap
objects.
See Also
Validation functions
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- tna(group_regulation)
# Small number of iterations for CRAN
bootstrap(model, iter = 10)
Build a Transition Network Analysis Model
Description
Construct a transition network analysis (TNA) model from sequence data. The function takes a data set of sequence of events or states as input and builds a TNA model. It extracts the edge weights and initial probabilities from the data along with the state labels. THe function also accepts weight matrices and initial state probabilities directly.
Usage
build_model(x, type = "relative", scaling = character(0L), ...)
## Default S3 method:
build_model(
x,
type = "relative",
scaling = character(0L),
inits,
params = list(),
...
)
## S3 method for class 'matrix'
build_model(x, type = "relative", scaling = character(0L), inits, ...)
## S3 method for class 'stslist'
build_model(
x,
type = "relative",
scaling = character(0L),
cols = seq(1, ncol(x)),
params = list(),
...
)
## S3 method for class 'data.frame'
build_model(
x,
type = "relative",
scaling = character(0L),
cols = seq(1, ncol(x)),
params = list(),
...
)
## S3 method for class 'tna_data'
build_model(x, type = "relative", scaling = character(0), params = list(), ...)
tna(x, ...)
ftna(x, ...)
ctna(x, ...)
atna(x, ...)
Arguments
x |
A |
type |
A
|
scaling |
A
|
... |
Ignored. For the |
inits |
An optional |
params |
A
|
cols |
An |
Value
An object of class tna
which is a list
containing the
following elements:
-
weights
: An adjacencymatrix
of the model (weight matrix). -
inits
: Anumeric
vector of initial values for each state. Formatrix
typex
, this element will beNULL
ifinits
is not directly provided -
labels
: Acharacter
vector of the state labels, orNULL
if there are no labels. -
data
: The original sequence data that has been converted to an internal format used by the package whenx
is astslist
or adata.frame
object. OtherwiseNULL
.
See Also
Basic functions
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
model <- build_model(group_regulation)
print(model)
model <- tna(group_regulation)
model <- ftna(group_regulation)
model <- ctna(group_regulation)
model <- atna(group_regulation)
Calculate Centrality Measures for a Transition Matrix
Description
Calculates several centrality measures. See 'Details' for information about the measures.
Usage
centralities(x, loops = FALSE, normalize = FALSE, measures, ...)
## S3 method for class 'tna'
centralities(x, loops = FALSE, normalize = FALSE, measures, ...)
## S3 method for class 'matrix'
centralities(x, loops = FALSE, normalize = FALSE, measures, ...)
## S3 method for class 'group_tna'
centralities(x, loops = FALSE, normalize = FALSE, measures, ...)
Arguments
x |
A |
loops |
A |
normalize |
A |
measures |
A |
... |
Ignored. |
Details
The following measures are provided:
-
OutStrength
: Outgoing strength centrality, calculated usingigraph::strength()
withmode = "out"
. It measures the total weight of the outgoing edges from each node. -
InStrength
: Incoming strength centrality, calculated usingigraph::strength()
withmode = "in"
. It measures the total weight of the incoming edges to each node. -
ClosenessIn
: Closeness centrality (incoming), calculated usingigraph::closeness()
withmode = "in"
. It measures how close a node is to all other nodes based on the incoming paths. -
ClosenessOut
: Closeness centrality (outgoing), calculated usingigraph::closeness()
withmode = "out"
. It measures how close a node is to all other nodes based on the outgoing paths. -
Closeness
: Closeness centrality (overall), calculated usingigraph::closeness()
withmode = "all"
. It measures how close a node is to all other nodes based on both incoming and outgoing paths. -
Betweenness
: Betweenness centrality defined by the number of geodesics calculated usingigraph::betweenness()
. -
BetweennessRSP
: Betweenness centrality based on randomized shortest paths (Kivimäki et al. 2016). It measures the extent to which a node lies on the shortest paths between other nodes. -
Diffusion
: Diffusion centrality of Banerjee et.al. (2014). It measures the influence of a node in spreading information through the network. -
Clustering
: Signed clustering coefficient of Zhang and Horvath (2005) based on the symmetric adjacency matrix (sum of the adjacency matrix and its transpose). It measures the degree to which nodes tend to cluster together.
Value
A tna_centralities
object which is a tibble (tbl_df
).
containing centrality measures for each state.
See Also
Centrality measure functions
betweenness_network()
,
plot.group_tna_centralities()
,
plot.tna_centralities()
,
print.group_tna_centralities()
,
print.tna_centralities()
Examples
model <- tna(group_regulation)
# Centrality measures including loops in the network
centralities(model)
# Centrality measures excluding loops in the network
centralities(model, loops = FALSE)
# Centrality measures normalized
centralities(model, normalize = TRUE)
Identify Cliques in a Transition Network
Description
This function identifies cliques of a specified size in a transition network.
It searches for cliques, i.e., complete subgraphs where every pair of nodes
is connected, of size n
in the transition matrix for the specified cluster
in the tna
object.
Usage
cliques(x, ...)
## S3 method for class 'tna'
cliques(x, size = 2, threshold = 0, sum_weights = FALSE, ...)
## S3 method for class 'group_tna'
cliques(x, size = 2, threshold = 0, sum_weights = FALSE, ...)
Arguments
x |
A |
... |
Ignored. |
size |
An |
threshold |
A |
sum_weights |
A |
Value
A tna_cliques
object which is a list
of two elements:
-
weights
is amatrix
of the edge weights in the clique. -
inits
is anumeric
vector of initial weights for the clique.
If x
is a group_tna
object, a group_tna_cliques
object is returned
instead, which is a list
or tna_cliques
objects.
See Also
Clique-related functions
plot.group_tna_cliques()
,
plot.tna_cliques()
,
print.group_tna_cliques()
,
print.tna_cliques()
Examples
model <- tna(group_regulation)
# Find 2-cliques (dyads)
cliq <- cliques(model, size = 2)
model <- group_tna(engagement_mmm)
cliques(model)
Community Detection for Transition Networks
Description
This function detects communities within the transition networks
(represented by the tna
object).
It uses various algorithms to find communities in the graph representation
of transitions and returns a list
of communities for each cluster or a
specified cluster. If multiple transition matrices exist, the function
iterates over each cluster in the tna
object to find communities using
different algorithms. The function uses the igraph
package to convert
the transition matrices into graphs and then applies community detection
algorithms (e.g., Walktrap, Fast Greedy, Label Propagation, Infomap,
Edge Betweenness, Leading Eigenvector, and Spin Glass).
Usage
communities(x, ...)
## S3 method for class 'tna'
communities(x, methods, gamma = 1, ...)
## S3 method for class 'group_tna'
communities(x, methods, gamma = 1, ...)
Arguments
x |
A |
... |
Ignored. |
methods |
A
If not provided, all methods are applied. |
gamma |
A |
Value
An object of class tna_communities
which is a list
with an
element for each cluster containing:
-
counts
: Alist
with the number of communities found by each algorithm. -
assignments
: Adata.frame
where each row corresponds to a node and each column to a community detection algorithm, with color-coded community assignments.
If x
is a group_tna
object, a group_tna_communities
object is returned
instead, which is a list
of tna_communities
objects.
See Also
Community detection functions
plot.group_tna_communities()
,
plot.tna_communities()
,
print.group_tna_communities()
,
print.tna_communities()
Cluster-related functions
group_model()
,
mmm_stats()
,
rename_groups()
Examples
model <- tna(group_regulation)
comm <- communities(model)
Compare Two Matrices or TNA Models with Comprehensive Metrics
Description
Various distances, measures of dissimilarity and similarity, correlations and other metrics are computed to compare the models. Optionally, the weight matrices of the models can be scaled before comparison. The resulting object can be used to produce heatmap plots and scatterplots to further illustrate the differences.
Usage
compare(x, ...)
## S3 method for class 'tna'
compare(x, y, scaling = "none", ...)
## S3 method for class 'matrix'
compare(x, y, scaling = "none", ...)
Arguments
x |
A |
... |
Ignored. |
y |
A |
scaling |
A
|
Value
A tna_comparison
object, which is a list
containing the
following elements:
-
matrices
: Alist
containing the scaled matrices of the inputtna
objects or the scaled inputs themselves in the case of matrices. -
difference_matrix
: Amatrix
of differencesx - y
. -
edge_metrics
: Adata.frame
of edge-level metrics about the differences. -
summary_metrics
: Adata.frame
of summary metrics of the differences across all edges. -
network_metrics
: Adata.frame
of network metrics for bothx
andy
. -
centrality_differences
: Adata.frame
of differences in centrality measures computes fromx
andy
. -
centrality_correlations
: Anumeric
vector of correlations of the centrality measures betweenx
andy
.
See Also
Model comparison functions
compare.group_tna()
,
plot.tna_comparison()
,
plot_compare()
,
plot_compare.group_tna()
,
print.tna_comparison()
Examples
# Comparing TNA models
model_x <- tna(group_regulation[1:200, ])
model_y <- tna(group_regulation[1001:1200, ])
comp1 <- compare(model_x, model_y)
# Comparing matrices
mat_x <- model_x$weights
mat_y <- model_y$weights
comp2 <- compare(mat_x, mat_y)
# Comparing a matrix to a TNA model
comp3 <- compare(mat_x, model_y)
Compare TNA Clusters with Comprehensive Metrics
Description
Compare TNA Clusters with Comprehensive Metrics
Usage
## S3 method for class 'group_tna'
compare(x, i = 1L, j = 2L, scaling = "none", ...)
Arguments
x |
A |
i |
An |
j |
An |
scaling |
See |
... |
Additional arguments passed to |
Value
A tna_comparison
object. See compare.tna()
for details.
See Also
Model comparison functions
compare()
,
plot.tna_comparison()
,
plot_compare()
,
plot_compare.group_tna()
,
print.tna_comparison()
Examples
model <- group_model(engagement_mmm)
compare(model, i = 1, j = 2)
Restore a Pruned Transition Network Analysis Model
Description
Restore a Pruned Transition Network Analysis Model
Usage
deprune(x, ...)
## S3 method for class 'tna'
deprune(x, ...)
## S3 method for class 'tna'
reprune(x, ...)
## S3 method for class 'group_tna'
deprune(x, ...)
Arguments
x |
A |
... |
Ignored. |
Value
A tna
or group_tna
object that has not been pruned.
See Also
Validation functions
bootstrap()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- tna(group_regulation)
pruned_model <- prune(model, method = "threshold", threshold = 0.1)
depruned_model <- deprune(pruned_model) # restore original model
Example Data on Student Engagement
Description
Students' engagement states (Active / Average / Disengaged) throughout a whole study program. The data was generated synthetically based on the article "The longitudinal association between engagement and achievement varies by time, students' profiles, and achievement state: A full program study"
Usage
engagement
Format
A stslist
object (sequence data).
Source
doi:10.1016/j.compedu.2023.104787
See Also
Datasets
engagement_mmm
,
group_regulation
,
group_regulation_long
Example Mixed Markov Model Fitted to the engagement
Data
Description
Example Mixed Markov Model Fitted to the engagement
Data
Usage
engagement_mmm
Format
A mhmm
object.
Source
The data was generated via mixed_markov_model.R
in
https://github.com/sonsoleslp/tna/tree/main/data-raw/
See Also
Datasets
engagement
,
group_regulation
,
group_regulation_long
Estimate Centrality Stability
Description
Estimates the stability of centrality measures in a network using subset sampling without replacement. It allows for dropping varying proportions of cases and calculates correlations between the original centralities and those computed using sampled subsets.
Usage
estimate_cs(x, ...)
estimate_centrality_stability(x, ...)
## S3 method for class 'tna'
estimate_cs(
x,
loops = FALSE,
normalize = FALSE,
measures = c("InStrength", "OutStrength", "Betweenness"),
iter = 1000,
method = "pearson",
drop_prop = seq(0.1, 0.9, by = 0.1),
threshold = 0.7,
certainty = 0.95,
progressbar = FALSE,
...
)
## S3 method for class 'tna'
estimate_centrality_stability(
x,
loops = FALSE,
normalize = FALSE,
measures = c("InStrength", "OutStrength", "Betweenness"),
iter = 1000,
method = "pearson",
drop_prop = seq(0.1, 0.9, by = 0.1),
threshold = 0.7,
certainty = 0.95,
progressbar = FALSE,
...
)
## S3 method for class 'group_tna'
estimate_cs(
x,
loops = FALSE,
normalize = FALSE,
measures = c("InStrength", "OutStrength", "Betweenness"),
iter = 1000,
method = "pearson",
drop_prop = seq(0.1, 0.9, by = 0.1),
threshold = 0.7,
certainty = 0.95,
progressbar = FALSE,
...
)
## S3 method for class 'group_tna'
estimate_centrality_stability(
x,
loops = FALSE,
normalize = FALSE,
measures = c("InStrength", "OutStrength", "Betweenness"),
iter = 1000,
method = "pearson",
drop_prop = seq(0.1, 0.9, by = 0.1),
threshold = 0.7,
certainty = 0.95,
progressbar = FALSE,
...
)
Arguments
x |
A |
... |
Ignored. |
loops |
A |
normalize |
A |
measures |
A |
iter |
An |
method |
A |
drop_prop |
A |
threshold |
A |
certainty |
A |
progressbar |
A |
Details
The function works by repeatedly resampling the data, dropping varying proportions of cases, and calculating centrality measures on the subsets. The correlation between the original centralities and the resampled centralities is calculated for each drop proportion. The stability of each centrality measure is then summarized using a centrality stability (CS) coefficient, which represents the proportion of dropped cases at which the correlations drop below a given threshold (default 0.7).
The results can be visualized by plotting the output object showing the stability of the centrality measures across different drop proportions, along with confidence intervals. The CS-coefficients are displayed in the subtitle.
Value
A tna_stability
object which is a list
with an element for each
measure
with the following elements:
-
cs_coefficient
: The centrality stability (CS) coefficient of the measure. -
correlations
: Amatrix
of correlations between the original centrality and the resampled centralities for each drop proportion.
If x
is a group_tna
object, a group_tna_stability
object is returned
instead, which is a list
of tna_stability
objects.
See Also
Validation functions
bootstrap()
,
deprune()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- tna(group_regulation)
# Small number of iterations and drop proportions for CRAN
estimate_cs(
model,
drop_prop = seq(0.3, 0.9, by = 0.2),
measures = c("InStrength", "OutStrength"),
iter = 10
)
Build a Grouped Transition Network Analysis Model
Description
This function constructs a transition network analysis (TNA) model for each cluster from a given sequence, wide-format dataframe, or a mixture Markov model.
Usage
group_model(x, ...)
## Default S3 method:
group_model(
x,
group,
type = "relative",
scaling = character(0L),
groupwise = FALSE,
cols,
params = list(),
na.rm = TRUE,
...
)
## S3 method for class 'mhmm'
group_model(
x,
type = "relative",
scaling = character(0L),
groupwise = FALSE,
cols,
params = list(),
na.rm = TRUE,
...
)
group_tna(x, ...)
group_ftna(x, ...)
group_ctna(x, ...)
group_atna(x, ...)
Arguments
x |
An |
... |
Ignored. |
group |
A vector indicating the cluster assignment of each
row of the data / sequence. Must have the same length as the number of
rows/sequences of |
type |
A
|
scaling |
A
|
groupwise |
A |
cols |
An |
params |
A
|
na.rm |
A |
Value
An object of class group_tna
which is a list
containing one
element per cluster. Each element is a tna
object.
See Also
Cluster-related functions
communities()
,
mmm_stats()
,
rename_groups()
Examples
# Manually specified groups
group <- c(rep("High", 1000), rep("Low", 1000))
model <- group_model(group_regulation, group = group)
# Groups defined by a mixed Markov model
model <- group_model(engagement_mmm)
model <- group_tna(group_regulation, group = gl(2, 1000))
model <- group_ftna(group_regulation, group = gl(2, 1000))
model <- group_ctna(group_regulation, group = gl(2, 1000))
model <- group_atna(group_regulation, group = gl(2, 1000))
Example Wide Data on Group Regulation
Description
Students' regulation during collaborative learning. Students' interactions were coded as: "adapt", "cohesion", "consensus", "coregulate", "discuss", "emotion", "monitor", "plan", "synthesis"
Usage
group_regulation
Format
A data.frame
object.
Source
The data was generated synthetically.
See Also
Datasets
engagement
,
engagement_mmm
,
group_regulation_long
Example Long Data on Group Regulation
Description
Students' regulation during collaborative learning. This is the same dataset
as group_regulation
but in long format. In addition to students'
actions (Action
), it contains the student identifier (Actor
),
timestamp (Time
), Course
name, and collaboration Group
. It
also includes a column (Achiever
) indicating whether the student
is a high or low achiever.
Usage
group_regulation_long
Format
A data.frame
object.
Source
The data was generated synthetically from group_regulation
See Also
Datasets
engagement
,
engagement_mmm
,
group_regulation
Plot a Histogram of Edge Weights for a group_tna
Object.
Description
Plot a Histogram of Edge Weights for a group_tna
Object.
Usage
## S3 method for class 'group_tna'
hist(x, ...)
Arguments
x |
A |
... |
Additional arguments passed to |
Value
A list
(invisibly) of histogram
objects of the edge weights of
each cluster.
See Also
Basic functions
build_model()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
model <- group_model(engagement_mmm)
hist(model)
Plot a Histogram of Edge Weights in the Network
Description
Plot a Histogram of Edge Weights in the Network
Usage
## S3 method for class 'tna'
hist(x, breaks, col = "lightblue", main, xlab, border = "white", ...)
Arguments
x |
a vector of values for which the histogram is desired. |
breaks |
one of:
In the last three cases the number is a suggestion only; as the
breakpoints will be set to |
col |
a colour to be used to fill the bars. |
main |
A |
xlab |
A |
border |
the color of the border around the bars. The default is to use the standard foreground color. |
... |
Additional arguments passed to |
Value
A histogram
object of edge weights.
See Also
Basic functions
build_model()
,
hist.group_tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
model <- tna(group_regulation)
hist(model)
Import Wide Format Sequence Data as Long Format Sequence Data
Description
This function transforms wide format data where features are in separate columns into a long format suitable for sequence analysis. It creates windows of data based on row order and generates sequence order within these windows.
Usage
import_data(data, cols, id_cols, window_size = 1, replace_zeros = TRUE)
Arguments
data |
A |
cols |
An |
id_cols |
A |
window_size |
An |
replace_zeros |
A |
Value
A data.frame
in long format with added columns for window and
sequence order.
See Also
Other data:
prepare_data()
,
print.tna_data()
,
simulate.tna()
Examples
data <- data.frame(
ID = c("A", "A", "B", "B"),
Time = c(1, 2, 1, 2),
feature1 = c(10, 0, 15, 20),
feature2 = c(5, 8, 0, 12),
feature3 = c(2, 4, 6, 8),
other_col = c("X", "Y", "Z", "W")
)
# Using a vector
long_data1 <- import_data(
data = data,
cols = c(feature1, feature2),
id_cols = c("ID", "Time"),
window_size = 2,
replace_zeros = TRUE
)
# Using a column range
long_data2 <- import_data(
data = data,
cols = feature1:feature3,
id_cols = c("ID", "Time"),
window_size = 2,
replace_zeros = TRUE
)
Retrieve Statistics from a Mixture Markov Model (MMM)
Description
Retrieve Statistics from a Mixture Markov Model (MMM)
Usage
mmm_stats(x, level = 0.05)
Arguments
x |
A |
level |
A |
Value
A data.frame
object.
See Also
Cluster-related functions
communities()
,
group_model()
,
rename_groups()
Examples
mmm_stats(engagement_mmm)
Compare Two Networks from Sequence Data using a Permutation Test
Description
This function compares two networks built from sequence data using permutation tests. The function builds Markov models for two sequence objects, computes the transition probabilities, and compares them by performing permutation tests. It returns the differences in transition probabilities, effect sizes, estimated p-values, and confidence intervals.
Usage
permutation_test(x, ...)
## S3 method for class 'tna'
permutation_test(
x,
y,
adjust = "none",
iter = 1000,
paired = FALSE,
level = 0.05,
measures = character(0),
...
)
Arguments
x |
A |
... |
Additional arguments passed to |
y |
A |
adjust |
A |
iter |
An |
paired |
A |
level |
A |
measures |
A |
Value
A tna_permutation
object which is a list
with two elements:
edges
and centralities
, both containing the following elements:
-
stats
: Adata.frame
of original differences, effect sizes, and estimated p-values for each edge or centrality measure. The effect size is computed as the observed difference divided by the standard deviation of the differences of the permuted samples. -
diffs_true
: Amatrix
of differences in the data. -
diffs_sig
: Amatrix
showing the significant differences.
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model_x <- tna(group_regulation[1:200, ])
model_y <- tna(group_regulation[1001:1200, ])
# Small number of iterations for CRAN
permutation_test(model_x, model_y, iter = 20)
Compare Networks using a Permutation Test
Description
Test edge weight differences between all pairs or a subset of pairs of
a group_tna
object. See permutation_test.tna()
for more details.
Usage
## S3 method for class 'group_tna'
permutation_test(
x,
groups,
adjust = "none",
iter = 1000,
paired = FALSE,
level = 0.05,
measures = character(0),
...
)
Arguments
x |
A |
groups |
An |
adjust |
A |
iter |
An |
paired |
A |
level |
A |
measures |
A |
... |
Additional arguments passed to |
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- group_model(engagement_mmm)
# Small number of iterations for CRAN
permutation_test(model, iter = 20)
Plot a Grouped Transition Network Analysis Model
Description
Plots a transition network of each cluster using qgraph
.
Usage
## S3 method for class 'group_tna'
plot(x, title, which, ...)
Arguments
x |
A |
title |
A title for each plot. It can be a single string (the same one will be used for all plots) or a list (one per group) |
which |
An optional |
... |
Arguments passed on to
|
Value
NULL
(invisibly).
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
model <- group_model(engagement_mmm)
plot(model)
Plot a Bootstrapped Grouped Transition Network Analysis Model
Description
Plot a Bootstrapped Grouped Transition Network Analysis Model
Usage
## S3 method for class 'group_tna_bootstrap'
plot(x, title = names(x), ...)
Arguments
x |
A |
title |
A |
... |
Additional arguments passed to |
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- group_model(engagement_mmm)
# Small number of iterations for CRAN
boot <- bootstrap(model, iter = 50)
plot(boot)
Plot Centrality Measures
Description
Plot Centrality Measures
Usage
## S3 method for class 'group_tna_centralities'
plot(
x,
reorder = TRUE,
ncol = 3,
scales = c("free_x", "fixed"),
colors,
palette = "Set2",
labels = TRUE,
...
)
Arguments
x |
A |
reorder |
A |
ncol |
Number of columns to use for the facets. The default is 3. |
scales |
Either |
colors |
The colors for each node (default is the model colors
if the |
palette |
A color palette to be applied if |
labels |
A |
... |
Ignored. |
Value
A ggplot
object displaying a line chart for each centrality
with one line per cluster.
See Also
Centrality measure functions
betweenness_network()
,
centralities()
,
plot.tna_centralities()
,
print.group_tna_centralities()
,
print.tna_centralities()
Examples
model <- group_model(engagement_mmm)
cm <- centralities(model)
plot(cm)
Plot Found Cliques
Description
Plot Found Cliques
Usage
## S3 method for class 'group_tna_cliques'
plot(x, title, ...)
Arguments
x |
A |
title |
A |
... |
Arguments passed to |
Value
A list
(invisibly) with one element per cluster. Each element
contains a qgraph
plot when only one clique is present per cluster,
otherwise the element is NULL
.
See Also
Clique-related functions
cliques()
,
plot.tna_cliques()
,
print.group_tna_cliques()
,
print.tna_cliques()
Examples
model <- group_model(engagement_mmm)
cliq <- cliques(model, size = 2)
plot(cliq, ask = FALSE)
Plot Detected Communities
Description
Plot Detected Communities
Usage
## S3 method for class 'group_tna_communities'
plot(x, title = names(x), colors, ...)
Arguments
x |
A |
title |
A |
colors |
A |
... |
Arguments passed to |
Value
A list
(invisibly) of qgraph
objects in which the nodes are
colored by community for each cluster.
See Also
Community detection functions
communities()
,
plot.tna_communities()
,
print.group_tna_communities()
,
print.tna_communities()
Examples
model <- group_model(engagement_mmm)
comm <- communities(model)
plot(comm)
Plot Permutation Test Results
Description
Plot Permutation Test Results
Usage
## S3 method for class 'group_tna_permutation'
plot(x, title, ...)
Arguments
x |
A |
title |
An optional |
... |
Arguments passed to |
Value
A list
(invisibly) of qgraph
objects depicting the significant
difference between each pair.
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- group_tna(engagement_mmm)
# Small number of iterations for CRAN
perm <- permutation_test(model, iter = 20)
plot(perm)
Plot Centrality Stability Results
Description
Plot Centrality Stability Results
Usage
## S3 method for class 'group_tna_stability'
plot(x, ...)
Arguments
x |
A |
... |
Arguments passed to |
Value
A list
(invisibly) of ggplot
objects displaying the stability
analysis plot.
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- group_model(engagement_mmm)
# Low number of iterations for CRAN
stability <- estimate_cs(
model,
drop_prop = c(0.3, 0.5, 0.7, 0.9),
iter = 10
)
plot(stability)
Plot a Transition Network Analysis Model
Description
This function plots a transition network analysis (TNA) model using
the qgraph
package. The nodes in the graph represent states, with node
sizes corresponding to initial state probabilities. Edge labels represent
the edge weights of the network.
Usage
## S3 method for class 'tna'
plot(
x,
labels,
colors,
pie,
cut,
show_pruned = TRUE,
pruned_edge_color = "pink",
edge.color = NA,
edge.labels = TRUE,
edge.label.position = 0.65,
layout = "circle",
layout_args = list(),
scale_nodes,
scaling_factor = 0.5,
mar = rep(5, 4),
theme = "colorblind",
...
)
Arguments
x |
A |
labels |
See |
colors |
See |
pie |
See |
cut |
Edge color and width emphasis cutoff value. The default is
the median of the edge weights. See |
show_pruned |
A |
pruned_edge_color |
A |
edge.color |
See |
edge.labels |
See |
edge.label.position |
See |
layout |
One of the following:
|
layout_args |
A |
scale_nodes |
A |
scaling_factor |
A |
mar |
See |
theme |
See |
... |
Additional arguments passed to |
Value
A qgraph
plot of the transition network.
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
model <- tna(group_regulation)
plot(model)
Plot a Bootstrapped Transition Network Analysis Model
Description
Plot a Bootstrapped Transition Network Analysis Model
Usage
## S3 method for class 'tna_bootstrap'
plot(x, ...)
Arguments
x |
A |
... |
Additional arguments passed to |
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- tna(group_regulation)
# Small number of iterations for CRAN
boot <- bootstrap(model, iter = 50)
plot(boot)
Plot Centrality Measures
Description
Plots the centrality measures of a tna_centralities
object as a
lollipop chart. The resulting plot includes facets for each centrality
measure, showing the values for each state. The returned plot is a
ggplot2
object, so it can be easily modified and styled. See
centralities()
for details on the centrality measures.
Usage
## S3 method for class 'tna_centralities'
plot(
x,
reorder = TRUE,
ncol = 3,
scales = c("free_x", "fixed"),
colors,
labels = TRUE,
...
)
Arguments
x |
An object of class |
reorder |
A |
ncol |
Number of columns to use for the facets. The default is 3. |
scales |
Either |
colors |
The colors for each node (default is the model colors
if the |
labels |
A |
... |
Ignored. |
Value
A ggplot
object displaying the lollipop charts for each centrality
measure.
See Also
Centrality measure functions
betweenness_network()
,
centralities()
,
plot.group_tna_centralities()
,
print.group_tna_centralities()
,
print.tna_centralities()
Examples
tna_model <- tna(group_regulation)
cm <- centralities(tna_model)
plot(cm, ncol = 3, reorder = TRUE)
Plot Cliques of a TNA Network
Description
Plot Cliques of a TNA Network
Usage
## S3 method for class 'tna_cliques'
plot(
x,
n = 6,
first = 1,
show_loops = FALSE,
edge.labels = TRUE,
edge.label.position = 0.65,
minimum = 1e-05,
mar = rep(5, 4),
layout = "circle",
layout_args = list(),
cut = 0.01,
normalize = TRUE,
ask = TRUE,
colors,
theme = "colorblind",
...
)
Arguments
x |
A |
n |
An |
first |
An |
show_loops |
A |
edge.labels |
See |
edge.label.position |
See |
minimum |
See |
mar |
See |
layout |
One of the following:
|
layout_args |
A |
cut |
See |
normalize |
See |
ask |
A |
colors |
See |
theme |
See |
... |
Ignored. |
Value
NULL
(invisibly).
See Also
Clique-related functions
cliques()
,
plot.group_tna_cliques()
,
print.group_tna_cliques()
,
print.tna_cliques()
Examples
model <- tna(group_regulation)
cliq <- cliques(model, size = 2)
plot(cliq, n = 1, ask = FALSE)
Plot Communities
Description
This function visualizes the communities detected within a tna
object
based on different community detection algorithms and their corresponding
color mappings.
Usage
## S3 method for class 'tna_communities'
plot(x, colors, method = "spinglass", ...)
Arguments
x |
A |
colors |
A |
method |
A |
... |
Additional arguments passed to |
Value
A qgraph
object in which the nodes are colored by community.
See Also
Community detection functions
communities()
,
plot.group_tna_communities()
,
print.group_tna_communities()
,
print.tna_communities()
Examples
model <- tna(group_regulation)
comm <- communities(model)
plot(comm, method = "leading_eigen")
Plot the Comparison of Two TNA Models or Matrices
Description
Plot the Comparison of Two TNA Models or Matrices
Usage
## S3 method for class 'tna_comparison'
plot(
x,
type = "heatmap",
population = "difference",
method = "pearson",
name_x = "x",
name_y = "y",
...
)
Arguments
x |
A |
type |
A |
population |
A |
method |
A |
name_x |
An optional |
name_y |
An optional |
... |
Ignored. |
Value
A ggplot
object.
References
Szekely, G.J., Rizzo, M.L., and Bakirov, N.K. (2007), Measuring and Testing Dependence by Correlation of Distances, Annals of Statistics, Vol. 35 No. 6, pp. 2769-2794. doi:10.1214/009053607000000505
See Also
Model comparison functions
compare()
,
compare.group_tna()
,
plot_compare()
,
plot_compare.group_tna()
,
print.tna_comparison()
Examples
model_x <- tna(group_regulation[1:200, ])
model_y <- tna(group_regulation[1001:1200, ])
comp <- compare(model_x, model_y)
plot(comp)
Plot the Significant Differences from a Permutation Test
Description
Plot the Significant Differences from a Permutation Test
Usage
## S3 method for class 'tna_permutation'
plot(x, colors, posCol = "#009900", negCol = "red", ...)
Arguments
x |
A |
colors |
See |
posCol |
Color for plotting edges
the difference in edge weights is positive. See |
negCol |
Color for plotting edges when
the the difference in edge weights is negative. See |
... |
Arguments passed to |
Value
A qgraph
object containing only the significant edges according
to the permutation test.
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model_x <- tna(group_regulation[1:200, ])
model_y <- tna(group_regulation[1001:1200, ])
# Small number of iterations for CRAN
perm <- permutation_test(model_x, model_y, iter = 20)
plot(perm)
Plot Centrality Stability Results
Description
This function visualizes the centrality stability results produced by the
estimate_centrality_stability
function. It shows how different centrality
measures' correlations change as varying proportions of cases are dropped,
along with their confidence intervals (CIs).
Usage
## S3 method for class 'tna_stability'
plot(x, level = 0.05, ...)
Arguments
x |
A |
level |
A |
... |
Ignored. |
Details
The function aggregates the results for each centrality measure across multiple proportions of dropped cases (e.g., 0.1, 0.2, ..., 0.9) and calculates the mean and the desired quantiles for each proportion. The confidence intervals (CIs) are computed based on the quantiles and displayed in the plot.
If no valid data is available for a centrality measure (e.g., missing or NA values), the function skips that measure with a warning.
The plot includes:
The mean correlation for each centrality measure as a function of the proportion of dropped cases.
Shaded confidence intervals representing CIs for each centrality measure.
A horizontal dashed line at the threshold value used for calculating the CS-coefficient.
A subtitle listing the CS-coefficients for each centrality measure.
Value
A ggplot
object displaying the stability analysis plot.
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- tna(group_regulation)
cs <- estimate_cs(model, iter = 10)
plot(cs)
Plot the Difference Network Between Two Models
Description
Plots the difference network between model x
and model y
. The edges are
computed from subtracting the two models. The pie chart is the difference in
initial probabilities between model x
and model y
. Green color indicates
that x
is greater than y
and red indicates otherwise.
Usage
plot_compare(x, ...)
## S3 method for class 'tna'
plot_compare(
x,
y,
theme = NULL,
palette = "colorblind",
posCol = "#009900",
negCol = "red",
...
)
Arguments
x |
A |
... |
Additional arguments passed to |
y |
A |
theme |
See |
palette |
See |
posCol |
Color for plotting edges and pie when
the first group has a higher value. See |
negCol |
Color for plotting edges and pie when
the second group has a higher value. See |
Value
A qgraph
object displaying the difference network between the
two models.
See Also
Model comparison functions
compare()
,
compare.group_tna()
,
plot.tna_comparison()
,
plot_compare.group_tna()
,
print.tna_comparison()
Examples
model_x <- tna(group_regulation[group_regulation[, 1] == "plan", ])
model_y <- tna(group_regulation[group_regulation[, 1] != "plan", ])
plot_compare(model_x, model_y)
Plot the Difference Network Between Two Groups
Description
Plot the Difference Network Between Two Groups
Usage
## S3 method for class 'group_tna'
plot_compare(x, i = 1L, j = 2L, ...)
Arguments
x |
A |
i |
An |
j |
An |
... |
Additional arguments passed to |
Value
A qgraph
object displaying the difference network between the
two clusters
See Also
Model comparison functions
compare()
,
compare.group_tna()
,
plot.tna_comparison()
,
plot_compare()
,
print.tna_comparison()
Examples
model <- group_model(engagement_mmm)
plot_compare(model)
Plot the Frequency Distribution of States
Description
Plot the Frequency Distribution of States
Usage
plot_frequencies(x, ...)
## S3 method for class 'tna'
plot_frequencies(x, width = 0.7, hjust = 1.2, show_label = TRUE, colors, ...)
Arguments
x |
A |
... |
Ignored. |
width |
A |
hjust |
A |
show_label |
A |
colors |
A |
Value
A ggplot
object.
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
model <- tna(group_regulation)
plot_frequencies(model)
plot_frequencies(model, width = 0.5, colors = "pink")
Plot the Frequency Distribution of States
Description
Plot the Frequency Distribution of States
Usage
## S3 method for class 'group_tna'
plot_frequencies(
x,
label,
colors,
width = 0.7,
palette = "Set2",
show_label = TRUE,
position = "dodge",
hjust = 1.2,
...
)
Arguments
x |
A |
label |
An optional |
colors |
A vector of colors to be used in the plot (one per group) |
width |
Width of the bars. Default is 0.7. |
palette |
A palette to be used if colors are not passed. |
show_label |
Boolean indicating whether to show a label with the
frequency counts. Default is |
position |
Position of the bars: "dodge", "dodge2", "fill" or "stack" |
hjust |
Horizontal adjustment of the labels. Default is 1.2. |
... |
Ignored. |
Value
A ggplot
object.
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
model <- group_model(engagement_mmm)
# Default
plot_frequencies(model)
# Default labels outside and custom colors
plot_frequencies(
model,
width = 0.9,
hjust = -0.3,
colors = c("#218516", "#f9c22e", "#53b3cb")
)
# Stacked with no labels
plot_frequencies(model, position = "stack", show_label = FALSE)
# Fill
plot_frequencies(model, position = "fill", hjust = 1.1)
Plot a Transition Network Model from a Matrix of Edge Weights
Description
Plot a Transition Network Model from a Matrix of Edge Weights
Usage
plot_model(
x,
labels,
colors,
cut,
edge.labels = TRUE,
edge.label.position = 0.65,
layout = "circle",
layout_args = list(),
mar = rep(5, 4),
theme = "colorblind",
...
)
Arguments
x |
A square |
labels |
See |
colors |
See |
cut |
Edge color and width emphasis cutoff value. The default is
the median of the edge weights. See |
edge.labels |
See |
edge.label.position |
See |
layout |
One of the following:
|
layout_args |
A |
mar |
See |
theme |
See |
... |
Additional arguments passed to |
Value
See plot.tna()
.
Examples
m <- matrix(rexp(25), 5, 5)
plot_model(m)
Create a Mosaic Plot of Transitions or Events
Description
Create a Mosaic Plot of Transitions or Events
Usage
plot_mosaic(x, ...)
## S3 method for class 'tna'
plot_mosaic(x, digits = 1, ...)
Arguments
x |
A |
... |
Ignored. |
digits |
An |
Value
A ggplot
object.
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
ftna_model <- ftna(group_regulation)
plot_mosaic(ftna_model)
Plot State Frequencies as a Mosaic Between Two Groups
Description
Plot State Frequencies as a Mosaic Between Two Groups
Usage
## S3 method for class 'group_tna'
plot_mosaic(x, label, digits = 1, ...)
Arguments
x |
A |
label |
An optional |
digits |
An |
... |
Ignored. |
Value
A ggplot
object.
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
model <- group_model(engagement_mmm)
plot_mosaic(model)
Plot State Frequencies as a Mosaic Between Two Groups
Description
Plot State Frequencies as a Mosaic Between Two Groups
Usage
## S3 method for class 'tna_data'
plot_mosaic(x, group, label = "Group", digits = 1, ...)
Arguments
x |
A |
group |
A |
label |
An optional |
digits |
An |
... |
Ignored. |
Value
A ggplot
object.
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
d <- data.frame(
time = rep(1:5, rep = 4),
group = rep(1:4, each = 5),
event = sample(LETTERS[1:3], 20, replace = TRUE)
)
sequence_data <- prepare_data(
d,
time = "time",
actor = "group",
action = "event"
)
plot_mosaic(sequence_data, group = "group")
Create a Sequence Index Plot or a Distribution Plot
Description
Create a Sequence Index Plot or a Distribution Plot
Usage
plot_sequences(x, ...)
## S3 method for class 'tna'
plot_sequences(
x,
group,
type = "index",
scale = "proportion",
geom = "bar",
include_na = FALSE,
na_color = "white",
sort_by,
show_n = TRUE,
border,
title,
legend_title,
xlab,
ylab,
tick = 5,
ncol = 2L,
...
)
## S3 method for class 'tna_data'
plot_sequences(
x,
group,
type = "index",
scale = "proportion",
geom = "bar",
include_na = FALSE,
colors,
na_color = "white",
sort_by,
show_n = TRUE,
border,
title,
legend_title,
xlab,
ylab,
tick = 5,
ncol = 2L,
...
)
## Default S3 method:
plot_sequences(
x,
cols,
group,
type = "index",
scale = "proportion",
geom = "bar",
include_na = FALSE,
colors,
na_color = "white",
sort_by,
show_n = TRUE,
border,
title,
legend_title,
xlab,
ylab,
tick = 5,
ncol = 2L,
...
)
## S3 method for class 'group_tna'
plot_sequences(
x,
type = "index",
scale = "proportion",
geom = "bar",
include_na = FALSE,
na_color = "white",
sort_by,
show_n = TRUE,
border,
title,
legend_title,
xlab,
ylab,
tick = 1,
ncol = 2L,
...
)
Arguments
x |
A |
... |
Ignored. |
group |
A vector indicating the group assignment of each
row of the data. Must have the same length as the
number of rows of |
type |
A |
scale |
A |
geom |
A |
include_na |
A |
na_color |
A |
sort_by |
Either a |
show_n |
A |
border |
A |
title |
An optional |
legend_title |
An optional |
xlab |
A |
ylab |
A |
tick |
An |
ncol |
Number of columns to use for the facets. The default is 2. |
colors |
A named |
cols |
A |
Examples
# Sequence index plot (default)
plot_sequences(
group_regulation,
group = rep(1:2, each = 1000),
)
# State distribution plot
plot_sequences(
group_regulation,
group = rep(1:2, each = 1000),
type = "distribution",
)
Compute User Sessions from Event Data
Description
Processes a dataset to create user sessions based on time gaps, ordering columns, or actor groupings. It supports different ways to understand order in user behavior and provides flexibility when widening the data.
Usage
prepare_data(
data,
actor,
time,
action,
order,
time_threshold = 900,
custom_format = NULL,
is_unix_time = FALSE,
unix_time_unit = "seconds",
unused_fn = dplyr::first
)
Arguments
data |
A |
actor |
A |
time |
A |
action |
A |
order |
A |
time_threshold |
An |
custom_format |
A |
is_unix_time |
A |
unix_time_unit |
A |
unused_fn |
How to handle extra columns when pivoting to wide format.
See |
Value
A tna_data
object, which is a list
with the following elements:
-
long_data
: The processed data in long format. -
sequence_data
: The processed data on the sequences in wide format, with actions/events as different variables structured with sequences. -
meta_data
: Other variables from the original data in wide format. -
statistics
: Alist
containing summary statistics: total sessions, total actions, unique users, time range (if applicable), and top sessions and user by activities.
See Also
Other data:
import_data()
,
print.tna_data()
,
simulate.tna()
Examples
results <- prepare_data(
group_regulation_long, actor = "Actor", time = "Time", action = "Action"
)
print(results$sequence_data)
print(results$meta_data)
print(results$statistics)
data_ordered <- tibble::tibble(
user = c("A", "A", "A", "B", "B", "C", "C", "C"),
order = c(1, 2, 3, 1, 2, 1, 2, 3),
action = c(
"view", "click", "add_cart", "view",
"checkout", "view", "click", "share"
)
)
results_ordered <- prepare_data(
data_ordered, actor = "user", order = "order", action = "action"
)
print(results_ordered$sequence_data)
print(results_ordered$meta_data)
print(results_ordered$statistics)
data_single_session <- tibble::tibble(
action = c(
"view", "click", "add_cart", "view",
"checkout", "view", "click", "share"
)
)
results_single <- prepare_data(data_single_session, action = "action")
print(results_single$sequence_data)
print(results_single$meta_data)
print(results_single$statistics)
Print a group_tna
Object
Description
Print a group_tna
Object
Usage
## S3 method for class 'group_tna'
print(x, ...)
Arguments
x |
A |
... |
Arguments passed to |
Value
x
(invisibly).
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
model <- group_model(engagement_mmm)
print(model)
Print group_tna
Bootstrap Results
Description
Print group_tna
Bootstrap Results
Usage
## S3 method for class 'group_tna_bootstrap'
print(x, ...)
Arguments
x |
A |
... |
Arguments passed to |
Value
x
(invisibly).
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- group_model(engagement_mmm)
# Low number of iteration for CRAN
boot <- bootstrap(model, iter = 10)
print(boot)
Print Centrality Measures
Description
Print Centrality Measures
Usage
## S3 method for class 'group_tna_centralities'
print(x, ...)
Arguments
x |
A |
... |
Ignored. |
Value
x
(invisibly).
See Also
Centrality measure functions
betweenness_network()
,
centralities()
,
plot.group_tna_centralities()
,
plot.tna_centralities()
,
print.tna_centralities()
Examples
model <- group_model(engagement_mmm)
cm <- centralities(model)
print(cm)
Print Found Cliques
Description
Print Found Cliques
Usage
## S3 method for class 'group_tna_cliques'
print(x, ...)
Arguments
x |
A |
... |
Arguments passed to |
Value
x
(invisibly).
See Also
Clique-related functions
cliques()
,
plot.group_tna_cliques()
,
plot.tna_cliques()
,
print.tna_cliques()
Examples
model <- group_model(engagement_mmm)
cliq <- cliques(model, size = 2)
print(cliq)
Print Detected Communities
Description
Print Detected Communities
Usage
## S3 method for class 'group_tna_communities'
print(x, ...)
Arguments
x |
A |
... |
Arguments passed to |
Value
x
(invisibly).
See Also
Community detection functions
communities()
,
plot.group_tna_communities()
,
plot.tna_communities()
,
print.tna_communities()
Examples
model <- group_model(engagement_mmm)
comm <- communities(model)
print(comm)
Print Permutation Test Results
Description
Print Permutation Test Results
Usage
## S3 method for class 'group_tna_permutation'
print(x, ...)
Arguments
x |
A |
... |
Arguments passed to |
Value
x
(invisibly).
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- group_model(engagement_mmm)
# Small number of iterations for CRAN
perm <- permutation_test(model, iter = 20)
print(perm)
Print Centrality Stability Results
Description
Print Centrality Stability Results
Usage
## S3 method for class 'group_tna_stability'
print(x, ...)
Arguments
x |
A |
... |
Arguments passed to |
Value
x
(invisibly).
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- group_model(engagement_mmm)
# Low number of iterations for CRAN
stability <- estimate_cs(
model,
drop_prop = c(0.3, 0.5, 0.7, 0.9),
iter = 10
)
print(stability)
Print a Summary of a Grouped Transition Network Analysis Model
Description
Print a Summary of a Grouped Transition Network Analysis Model
Usage
## S3 method for class 'summary.group_tna'
print(x, ...)
Arguments
x |
A |
... |
Arguments passed to |
Value
x
(invisibly).
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
model <- group_model(engagement_mmm)
print(summary(model))
Print a Bootstrap Summary for a Grouped Transition Network Model
Description
Print a Bootstrap Summary for a Grouped Transition Network Model
Usage
## S3 method for class 'summary.group_tna_bootstrap'
print(x, ...)
Arguments
x |
A |
... |
Arguments passed to the generic |
Value
x
(invisibly).
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- group_model(engagement_mmm)
# Low number of iteration for CRAN
boot <- bootstrap(model, iter = 10)
print(summary(boot))
Print a TNA Summary
Description
Print a TNA Summary
Usage
## S3 method for class 'summary.tna'
print(x, ...)
Arguments
x |
A |
... |
Ignored. |
Value
A summary.tna
object (invisibly) containing the TNA model network
metrics and values.
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
model <- tna(group_regulation)
print(summary(model))
Print a Bootstrap Summary
Description
Print a Bootstrap Summary
Usage
## S3 method for class 'summary.tna_bootstrap'
print(x, ...)
Arguments
x |
A |
... |
Arguments passed to the generic |
Value
A summary.tna_bootstrap
object (invisibly) containing the weight,
estimated p-value and confidence interval of each edge.
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- tna(group_regulation)
# Small number of iterations for CRAN
boot <- bootstrap(model, iter = 10)
print(summary(boot))
Print a tna
Object
Description
Print a tna
Object
Usage
## S3 method for class 'tna'
print(x, digits = getOption("digits"), generic = FALSE, ...)
Arguments
x |
A |
digits |
An |
generic |
A |
... |
Ignored. |
Value
The tna
object passed as argument x
(invisibly).
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
model <- tna(group_regulation)
print(model)
Print Bootstrap Results
Description
Print Bootstrap Results
Usage
## S3 method for class 'tna_bootstrap'
print(x, digits = getOption("digits"), type = "both", ...)
Arguments
x |
A |
digits |
An |
type |
A |
... |
Ignored. |
Value
x
(invisibly).
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- tna(group_regulation)
# Small number of iterations for CRAN
boot <- bootstrap(model, iter = 10)
print(boot)
Print Centrality Measures
Description
Print Centrality Measures
Usage
## S3 method for class 'tna_centralities'
print(x, ...)
Arguments
x |
A |
... |
Ignored. |
Value
x
(invisibly).
See Also
Centrality measure functions
betweenness_network()
,
centralities()
,
plot.group_tna_centralities()
,
plot.tna_centralities()
,
print.group_tna_centralities()
Examples
model <- tna(group_regulation)
cm <- centralities(model)
print(cm)
Print Found Cliques of a TNA Network
Description
Print Found Cliques of a TNA Network
Usage
## S3 method for class 'tna_cliques'
print(x, n = 6, first = 1, digits = getOption("digits"), ...)
Arguments
x |
A |
n |
An |
first |
An |
digits |
An |
... |
Ignored. |
Value
x
(invisibly).
See Also
Clique-related functions
cliques()
,
plot.group_tna_cliques()
,
plot.tna_cliques()
,
print.group_tna_cliques()
Examples
model <- tna(group_regulation)
cliq <- cliques(model, size = 2)
print(cliq)
Print Detected Communities
Description
Print Detected Communities
Usage
## S3 method for class 'tna_communities'
print(x, ...)
Arguments
x |
A |
... |
Ignored. |
Value
x
(invisibly).
See Also
Community detection functions
communities()
,
plot.group_tna_communities()
,
plot.tna_communities()
,
print.group_tna_communities()
Examples
model <- tna(group_regulation)
comm <- communities(model)
print(comm)
Print Comparison Results
Description
Print Comparison Results
Usage
## S3 method for class 'tna_comparison'
print(x, ...)
Arguments
x |
A |
... |
Additional arguments passed to the tibble |
Value
x
(invisibly).
See Also
Model comparison functions
compare()
,
compare.group_tna()
,
plot.tna_comparison()
,
plot_compare()
,
plot_compare.group_tna()
Examples
model_x <- tna(group_regulation[1:200, ])
model_y <- tna(group_regulation[1001:1200, ])
comp <- compare(model_x, model_y)
print(comp)
Print a TNA Data Object
Description
Print a TNA Data Object
Usage
## S3 method for class 'tna_data'
print(x, data = "sequence", ...)
Arguments
x |
A |
data |
A |
... |
Arguments passed to the tibble |
Value
x
(invisibly).
See Also
Other data:
import_data()
,
prepare_data()
,
simulate.tna()
Examples
res <- prepare_data(group_regulation_long, action = "Action", actor = "Actor",
time = "Time")
print(res, which = "sequence")
print(res, which = "meta")
print(res, which = "long")
Print Permutation Test Results
Description
Print Permutation Test Results
Usage
## S3 method for class 'tna_permutation'
print(x, ...)
Arguments
x |
A |
... |
Additional arguments passed to the |
Value
x
(invisibly).
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model_x <- tna(group_regulation[1:200, ])
model_y <- tna(group_regulation[1001:1200, ])
# Small number of iterations for CRAN
perm <- permutation_test(model_x, model_y, iter = 20)
print(perm)
Print Centrality Stability Results
Description
Print Centrality Stability Results
Usage
## S3 method for class 'tna_stability'
print(x, ...)
Arguments
x |
A |
... |
Ignored. |
Value
x
(invisibly).
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- tna(group_regulation)
# Small number of iterations and drop proportions for CRAN
cs <- estimate_cs(
model,
measures = c("InStrength", "OutStrength"),
drop_prop = seq(0.3, 0.9, by = 0.2),
iter = 10
)
print(cs)
Prune a Transition Network based on Transition Probabilities
Description
Prunes a network represented by a tna
object by removing
edges based on a specified threshold, lowest percent of non-zero edge
weights, or the disparity filter algorithm (Serrano et al., 2009).
It ensures the network remains weakly connected.
Prunes a network represented by a tna
object by removing
edges based on a specified threshold, lowest percent of non-zero edge
weights, or the disparity filter algorithm (Serrano et al., 2009).
It ensures the network remains weakly connected.
Usage
prune(x, ...)
## S3 method for class 'tna'
prune(
x,
method = "threshold",
threshold = 0.1,
lowest = 0.05,
level = 0.5,
boot = NULL,
...
)
## S3 method for class 'group_tna'
prune(x, ...)
Arguments
x |
An object of class |
... |
Arguments passed to |
method |
A |
threshold |
A numeric value specifying the edge weight threshold. Edges with weights below or equal to this threshold will be considered for removal. |
lowest |
A |
level |
A |
boot |
A |
Value
A pruned tna
or group_tna
object. Details on the pruning can be
viewed with pruning_details()
. The original model can be restored with
deprune()
.
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- tna(group_regulation)
pruned_threshold <- prune(model, method = "threshold", threshold = 0.1)
pruned_percentile <- prune(model, method = "lowest", lowest = 0.05)
pruned_disparity <- prune(model, method = "disparity", level = 0.5)
Print Detailed Information on the Pruning Results
Description
Print Detailed Information on the Pruning Results
Usage
pruning_details(x, ...)
## S3 method for class 'tna'
pruning_details(x, ...)
## S3 method for class 'group_tna'
pruning_details(x, ...)
Arguments
x |
A |
... |
Ignored. |
Value
A data.frame
containing the removed edges if x
is a tna
object,
or a list
of data.frame
objects in the case of group_tna
object.
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
reprune()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- tna(group_regulation)
pruned_threshold <- prune(model, method = "threshold", threshold = 0.1)
pruning_details(pruned_threshold)
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
Rename Clusters
Description
Rename Clusters
Usage
rename_groups(x, new_names)
Arguments
x |
A |
new_names |
A |
Value
A renamed group_tna
object.
See Also
Cluster-related functions
communities()
,
group_model()
,
mmm_stats()
Examples
model <- group_model(engagement_mmm)
model_renamed <- rename_groups(model, c("A", "B", "C"))
Restore Previous Pruning of a Transition Network Analysis Model
Description
Restore Previous Pruning of a Transition Network Analysis Model
Usage
reprune(x, ...)
## S3 method for class 'group_tna'
reprune(x, ...)
Arguments
x |
A |
... |
Ignored. |
Value
A tna
or group_tna
object that has not been pruned. The previous
pruning result can be reactivated with reprune()
.
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
summary.group_tna_bootstrap()
,
summary.tna_bootstrap()
Examples
model <- tna(group_regulation)
pruned_model <- prune(model, method = "threshold", threshold = 0.1)
depruned_model <- deprune(pruned_model) # restore original model
repruned_model <- reprune(depruned_model) # reapply the previous pruning
Simulate Data from a Transition Network Analysis Model
Description
Simulate Data from a Transition Network Analysis Model
Usage
## S3 method for class 'tna'
simulate(
object,
nsim = 1,
seed = NULL,
max_len = 100L,
na_range = c(0L, 0L),
...
)
Arguments
object |
A |
nsim |
An |
seed |
Ignored. Please use |
max_len |
An |
na_range |
An |
... |
Ignored. |
Value
A data.frame
of the simulated sequence data with nsim
rows and
max_len
columns.
See Also
Other data:
import_data()
,
prepare_data()
,
print.tna_data()
Examples
model <- tna(group_regulation)
sim <- simulate(model, nsim = 10, max_len = 10)
Calculate Summary of Network Metrics for a grouped Transition Network
Description
This function calculates a variety of network metrics for a tna
object.
It computes key metrics such as node and edge counts, network density,
mean distance, strength measures, degree centrality, and reciprocity.
Usage
## S3 method for class 'group_tna'
summary(object, combined = TRUE, ...)
Arguments
object |
A |
combined |
A logical indicating whether the summary results should be
combined into a single data frame for all clusters (defaults to |
... |
Ignored |
Details
The function extracts the igraph
network for each cluster and
computes the following network metrics:
Node count: Total number of nodes in the network.
Edge count: Total number of edges in the network.
Network density: Proportion of possible edges that are present in the network.
Mean distance: The average shortest path length between nodes.
Mean and standard deviation of out-strength and in-strength: Measures of the total weight of outgoing and incoming edges for each node.
Mean and standard deviation of out-degree: The number of outgoing edges from each node.
Centralization of out-degree and in-degree: Measures of how centralized the network is based on the degrees of nodes.
Reciprocity: The proportion of edges that are reciprocated (i.e., mutual edges between nodes).
Value
A summary.group_tna
object which is a list
of list
s or a
combined data.frame
containing the following network metrics:
-
node_count
: The total number of nodes. -
edge_count
: The total number of edges. -
network_Density
: The density of the network. -
mean_distance
: The mean shortest path length. -
mean_out_strength
: The mean out-strength of nodes. -
sd_out_strength
: The standard deviation of out-strength. -
mean_in_strength
: The mean in-strength of nodes. -
sd_in_strength
: The standard deviation of in-strength. -
mean_out_degree
: The mean out-degree of nodes. -
sd_out_degree
: The standard deviation of out-degree. -
centralization_out_degree
: The centralization of out-degree. -
centralization_in_degree
: The centralization of in-degree. -
reciprocity
: The reciprocity of the network.
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.tna()
,
tna-package
Examples
group <- c(rep("High", 1000), rep("Low", 1000))
model <- group_model(group_regulation, group = group)
summary(model)
Summarize Bootstrap Results for a Grouped Transition Network
Description
Summarize Bootstrap Results for a Grouped Transition Network
Usage
## S3 method for class 'group_tna_bootstrap'
summary(object, ...)
Arguments
object |
A |
... |
Ignored. |
Value
A summary.group_tna_bootstrap
object containing the weight,
estimated p-value and confidence interval of each edge for each cluster.
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.tna_bootstrap()
Examples
model <- group_tna(engagement_mmm)
# Small number of iterations for CRAN
boot <- bootstrap(model, iter = 10)
summary(boot)
Calculate Summary of Network Metrics for a Transition Network
Description
This function calculates a variety of network metrics for a tna
object.
It computes key metrics such as node and edge counts, network density,
mean distance, strength measures, degree centrality, and reciprocity.
Usage
## S3 method for class 'tna'
summary(object, ...)
Arguments
object |
A |
... |
Ignored. |
Details
The function extracts the igraph
network and
computes the following network metrics:
Node count: Total number of nodes in the network.
Edge count: Total number of edges in the network.
Network density: Proportion of possible edges that are present in the network.
Mean distance: The average shortest path length between nodes.
Mean and standard deviation of out-strength and in-strength: Measures of the total weight of outgoing and incoming edges for each node.
Mean and standard deviation of out-degree: The number of outgoing edges from each node.
Centralization of out-degree and in-degree: Measures of how centralized the network is based on the degrees of nodes.
Reciprocity: The proportion of edges that are reciprocated (i.e., mutual edges between nodes).
A summary of the metrics is printed to the console.
Value
A named list
containing the following network metrics (invisibly):
-
node_count
: The total number of nodes. -
edge_count
: The total number of edges. -
network_Density
: The density of the network. -
mean_distance
: The mean shortest path length. -
mean_out_strength
: The mean out-strength of nodes. -
sd_out_strength
: The standard deviation of out-strength. -
mean_in_strength
: The mean in-strength of nodes. -
sd_in_strength
: The standard deviation of in-strength. -
mean_out_degree
: The mean out-degree of nodes. -
sd_out_degree
: The standard deviation of out-degree. -
centralization_out_degree
: The centralization of out-degree. -
centralization_in_degree
: The centralization of in-degree. -
reciprocity
: The reciprocity of the network.
See Also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_frequencies()
,
plot_frequencies.group_tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
plot_mosaic.tna_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
summary.group_tna()
,
tna-package
Examples
model <- tna(group_regulation)
summary(model)
Summarize Bootstrap Results
Description
Summarize Bootstrap Results
Usage
## S3 method for class 'tna_bootstrap'
summary(object, ...)
Arguments
object |
A |
... |
Ignored. |
Value
A summary.tna_bootstrap
object containing the weight,
estimated p-value and confidence interval of each edge.
See Also
Validation functions
bootstrap()
,
deprune()
,
estimate_cs()
,
permutation_test()
,
permutation_test.group_tna()
,
plot.group_tna_bootstrap()
,
plot.group_tna_permutation()
,
plot.group_tna_stability()
,
plot.tna_bootstrap()
,
plot.tna_permutation()
,
plot.tna_stability()
,
print.group_tna_bootstrap()
,
print.group_tna_permutation()
,
print.group_tna_stability()
,
print.summary.group_tna_bootstrap()
,
print.summary.tna_bootstrap()
,
print.tna_bootstrap()
,
print.tna_permutation()
,
print.tna_stability()
,
prune()
,
pruning_details()
,
reprune()
,
summary.group_tna_bootstrap()
Examples
model <- tna(group_regulation)
# Small number of iterations for CRAN
boot <- bootstrap(model, iter = 50)
summary(boot)