| Title: | Transition Network Analysis (TNA) |
|---|---|
| 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. |
| Authors: | Mohammed Saqr [aut], Santtu Tikka [aut], Sonsoles López-Pernas [aut, cre, cph] |
| Maintainer: | Sonsoles López-Pernas <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.5.8 |
| Built: | 2026-11-17 05:44:40 UTC |
| Source: | https://github.com/cran/tna |
tna Package.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 igraph
package for centrality measure calculations and on the cograph package
for plotting the networks.
Sonsoles López-Pernas, Santtu Tikka, Mohammed Saqr
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. doi:10.1145/3706468.3706513
Tikka, S., López-Pernas, S., & Saqr, M. (2025). tna: An R Package for Transition Network Analysis. Applied Psychological Measurement. doi:10.1177/01466216251348840
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. doi:10.1038/srep19668
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. doi:10.1073/pnas.0808904106
Zhang, B., Horvath, S. (2005). A general framework for weighted gene co-expression network analysis. Statistical Applications in Genetics and Molecular Biology, 4(1). doi:10.2202/1544-6115.1128
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()
group_tna Object into an igraph Object.Coerce a Specific Group from a group_tna Object into an igraph Object.
## S3 method for class 'group_tna' as.igraph(x, which, ...)## S3 method for class 'group_tna' as.igraph(x, which, ...)
x |
The object to convert. |
which |
The number or name of the group. |
... |
Additional arguments. None currently. |
An igraph object of the network of the group which (see
as.igraph.tna()).
Helper functions
as.igraph.matrix(),
as.igraph.tna()
model <- group_model(engagement_mmm) as.igraph(model, which = 1)model <- group_model(engagement_mmm) as.igraph(model, which = 1)
igraph Object.Coerce a Weight Matrix into an igraph Object.
## S3 method for class 'matrix' as.igraph(x, mode = "directed", ...)## S3 method for class 'matrix' as.igraph(x, mode = "directed", ...)
x |
A |
mode |
Character scalar, specifies how igraph should interpret the
supplied matrix. See also the |
... |
Ignored. |
An igraph object with one vertex per row of x and one
weighted edge per non-zero element of x.
Helper functions
as.igraph.group_tna(),
as.igraph.tna()
weights <- matrix(c(0, 0.6, 0.4, 0.5, 0, 0.5, 0.2, 0.8, 0), 3, 3) as.igraph(weights)weights <- matrix(c(0, 0.6, 0.4, 0.5, 0, 0.5, 0.2, 0.8, 0), 3, 3) as.igraph(weights)
tna Object into an igraph Object.Coerce a tna Object into an igraph Object.
## S3 method for class 'tna' as.igraph(x, mode = "directed", ...)## S3 method for class 'tna' as.igraph(x, mode = "directed", ...)
x |
A |
mode |
Character scalar, specifies how igraph should interpret the
supplied matrix. See also the |
... |
Ignored. |
An igraph object with one vertex per state and one weighted
edge per non-zero element of the weight matrix of x.
Helper functions
as.igraph.group_tna(),
as.igraph.matrix()
as.igraph(tna(group_regulation))as.igraph(tna(group_regulation))
This function builds a network from a transition matrix in a tna object
and computes edge betweenness for the network.
betweenness_network(x, directed = TRUE, invert = TRUE) ## S3 method for class 'tna' betweenness_network(x, directed = TRUE, invert = TRUE) ## S3 method for class 'group_tna' betweenness_network(x, directed = TRUE, invert = TRUE)betweenness_network(x, directed = TRUE, invert = TRUE) ## S3 method for class 'tna' betweenness_network(x, directed = TRUE, invert = TRUE) ## S3 method for class 'group_tna' betweenness_network(x, directed = TRUE, invert = TRUE)
x |
A |
directed |
A |
invert |
A |
The returned model remembers the model it was built from (its type and
scaling) and the values of directed and invert. The resampling
methods permutation_test(), bootstrap(), and estimate_cs() use
this information: every resample rebuilds the
original transition network from the resampled sequences and then
recomputes edge betweenness. For example, permutation_test() applied to
two edge betweenness networks tests the differences in edge betweenness
between the two groups. As for any network of a grouped model with
scaled edge weights, the edge betweenness networks of such a model are
not resampled.
A tna object where the edge weights are edge betweenness values.
For a group_tna object, a group_tna object of such networks, one per
group.
Centrality measure functions
centralities(),
plot.group_tna_centralities(),
plot.tna_centralities(),
print.group_tna_centralities(),
print.tna_centralities()
model <- tna(group_regulation) betweenness_network(model) # Compare edge betweenness between groups models <- group_tna( group_regulation, group = rep(c("first", "second"), each = 1000) ) # Small number of iterations for CRAN permutation_test(betweenness_network(models), iter = 20)model <- tna(group_regulation) betweenness_network(model) # Compare edge betweenness between groups models <- group_tna( group_regulation, group = rep(c("first", "second"), each = 1000) ) # Small number of iterations for CRAN permutation_test(betweenness_network(models), iter = 20)
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.
bootstrap( x, iter, level, method, threshold, consistency_range, seed = NULL, actor = NULL ) ## S3 method for class 'tna' bootstrap( x, iter = 1000, level = 0.05, method = "stability", threshold, consistency_range = c(0.75, 1.25), seed = NULL, actor = NULL ) ## S3 method for class 'group_tna' bootstrap( x, iter = 1000, level = 0.05, method = "stability", threshold, consistency_range = c(0.75, 1.25), seed = NULL, actor = NULL )bootstrap( x, iter, level, method, threshold, consistency_range, seed = NULL, actor = NULL ) ## S3 method for class 'tna' bootstrap( x, iter = 1000, level = 0.05, method = "stability", threshold, consistency_range = c(0.75, 1.25), seed = NULL, actor = NULL ) ## S3 method for class 'group_tna' bootstrap( x, iter = 1000, level = 0.05, method = "stability", threshold, consistency_range = c(0.75, 1.25), seed = NULL, actor = NULL )
x |
A |
iter |
An |
level |
A |
method |
A |
threshold |
A |
consistency_range |
A |
seed |
A single |
actor |
An optional actor identifier for sequences nested in actors
(for example, several sessions per student). Either a |
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.
A tna_bootstrap object which is a list containing the
following elements:
weights_orig: The original edge weight matrix.
weights_sig: The matrix of significant transitions
(those with estimated p-values below the significance level).
weights_mean: The mean weight matrix from the bootstrap samples.
weights_sd: The standard deviation matrix from the bootstrap samples.
cr_lower: The lower bound matrix of the consistency range for the
edge weights.
cr_upper: The upper bound matrix of the consistency range for the
edge weights.
ci_lower: The lower bound matrix of the bootstrap confidence
intervals for the edge weights.
ci_upper: The upper bound matrix of the bootstrap confidence
intervals for the edge weights.
p_values: The matrix of estimated p-values for the edge weights.
summary: A data.frame with one row per edge with a positive
weight and the columns from, to, weight, p_value, sig,
cr_lower, cr_upper, ci_lower, and ci_upper. The same table is
returned by summary.tna_bootstrap().
model: The tna model pruned to the significant edges (see
prune() with method = "bootstrap").
If x is a group_tna object, the output is a group_tna_bootstrap
object, which is a list of tna_bootstrap objects.
Davison, A. C., & Hinkley, D. V. (1997). Bootstrap Methods and their Application. Cambridge University Press.
Validation functions
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) # Small number of iterations for CRAN bootstrap(model, iter = 10)model <- tna(group_regulation) # Small number of iterations for CRAN bootstrap(model, iter = 10)
Bootstrap the edge weights of all cliques of a given size in a tna
model, producing per-clique mean weights, p-values, confidence intervals,
and consistency-range bounds. Each bootstrap sample draws as many
sequences as the data has, with replacement, and recomputes the clique
weights from them.
bootstrap_cliques( x, size, threshold, iter, level, consistency_range, seed = NULL ) ## S3 method for class 'tna' bootstrap_cliques( x, size = 2L, threshold = 0, iter = 1000, level = 0.05, consistency_range = c(0.75, 1.25), seed = NULL )bootstrap_cliques( x, size, threshold, iter, level, consistency_range, seed = NULL ) ## S3 method for class 'tna' bootstrap_cliques( x, size = 2L, threshold = 0, iter = 1000, level = 0.05, consistency_range = c(0.75, 1.25), seed = NULL )
x |
A |
size |
An |
threshold |
A |
iter |
An |
level |
A |
consistency_range |
A |
seed |
A single |
A data.frame (also of class tna_bootstrap_cliques) with
one row per clique and the columns clique, mean_weight, p_values,
sig, cr_lower, cr_upper, ci_lower, ci_upper.
model <- tna(group_regulation) # Small number of iterations for CRAN boot_cliq <- bootstrap_cliques(model, size = 2, iter = 10)model <- tna(group_regulation) # Small number of iterations for CRAN boot_cliq <- bootstrap_cliques(model, size = 2, iter = 10)
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.
build_model(x, ...) ## Default S3 method: build_model( x, type = "relative", scaling = character(0L), params = list(), inits, ... ) ## S3 method for class 'matrix' build_model( x, type = "relative", scaling = character(0L), params = list(), inits, ... ) ## S3 method for class 'stslist' build_model( x, type = "relative", scaling = character(0L), cols = tidyselect::everything(), params = list(), concat = 1L, begin_state, end_state, ... ) ## S3 method for class 'data.frame' build_model( x, type = "relative", scaling = character(0L), cols = tidyselect::everything(), concat = 1L, params = list(), begin_state, end_state, ... ) ## S3 method for class 'tna_data' build_model( x, type = "relative", scaling = character(0L), params = list(), concat = 1L, begin_state, end_state, ... ) ## S3 method for class 'tsn' build_model( x, type = "relative", scaling = character(0L), params = list(), concat = 1L, begin_state, end_state, ... ) tna(x, ...) ftna(x, ...) ctna(x, ...) atna(x, ...) tsn(x, ...)build_model(x, ...) ## Default S3 method: build_model( x, type = "relative", scaling = character(0L), params = list(), inits, ... ) ## S3 method for class 'matrix' build_model( x, type = "relative", scaling = character(0L), params = list(), inits, ... ) ## S3 method for class 'stslist' build_model( x, type = "relative", scaling = character(0L), cols = tidyselect::everything(), params = list(), concat = 1L, begin_state, end_state, ... ) ## S3 method for class 'data.frame' build_model( x, type = "relative", scaling = character(0L), cols = tidyselect::everything(), concat = 1L, params = list(), begin_state, end_state, ... ) ## S3 method for class 'tna_data' build_model( x, type = "relative", scaling = character(0L), params = list(), concat = 1L, begin_state, end_state, ... ) ## S3 method for class 'tsn' build_model( x, type = "relative", scaling = character(0L), params = list(), concat = 1L, begin_state, end_state, ... ) tna(x, ...) ftna(x, ...) ctna(x, ...) atna(x, ...) tsn(x, ...)
x |
A |
... |
Ignored. For the |
type |
A
|
scaling |
A
|
params |
A
|
inits |
An optional |
cols |
An |
concat |
An |
begin_state |
A |
end_state |
A |
An object of class tna which is a list containing the
following elements:
weights: The square adjacency matrix of the model (weight matrix),
with one row and one column per state. The element on row i and
column j is the weight of the edge from state i to state j.
inits: A numeric vector of initial values for each state.
For matrix type x, this element will be NULL if inits is not
directly provided.
labels: A character vector of the state labels, or NULL if
there are no labels.
data: The original sequence data that has been converted to an
internal format used by the package when x is sequence data
(a stslist, a data.frame, a tna_data, or a tsn object).
Otherwise NULL.
The model type, the scaling, and the params used are stored in the
attributes type, scaling, and params.
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
model <- build_model(group_regulation) print(model) model <- tna(group_regulation) model <- ftna(group_regulation) model <- ctna(group_regulation) model <- atna(group_regulation)model <- build_model(group_regulation) print(model) model <- tna(group_regulation) model <- ftna(group_regulation) model <- ctna(group_regulation) model <- atna(group_regulation)
Calculates several centrality measures. See 'Details' for information about the measures.
centralities(x, loops = FALSE, normalize = FALSE, invert = TRUE, measures) ## S3 method for class 'tna' centralities(x, loops = FALSE, normalize = FALSE, invert = TRUE, measures) ## S3 method for class 'matrix' centralities(x, loops = FALSE, normalize = FALSE, invert = TRUE, measures) ## S3 method for class 'group_tna' centralities(x, loops = FALSE, normalize = FALSE, invert = TRUE, measures)centralities(x, loops = FALSE, normalize = FALSE, invert = TRUE, measures) ## S3 method for class 'tna' centralities(x, loops = FALSE, normalize = FALSE, invert = TRUE, measures) ## S3 method for class 'matrix' centralities(x, loops = FALSE, normalize = FALSE, invert = TRUE, measures) ## S3 method for class 'group_tna' centralities(x, loops = FALSE, normalize = FALSE, invert = TRUE, measures)
x |
A |
loops |
A |
normalize |
A |
invert |
A |
measures |
A |
The following measures are provided:
OutStrength: Outgoing strength centrality, calculated using
igraph::strength() with mode = "out". It measures the total weight
of the outgoing edges from each node.
InStrength: Incoming strength centrality, calculated using
igraph::strength() with mode = "in". It measures the total weight
of the incoming edges to each node.
ClosenessIn: Closeness centrality (incoming), calculated using
igraph::closeness() with mode = "in". It measures how close a node
is to all other nodes based on the incoming paths.
ClosenessOut: Closeness centrality (outgoing), calculated using
igraph::closeness() with mode = "out". It measures how close a node
is to all other nodes based on the outgoing paths.
Closeness: Closeness centrality (overall), calculated using
igraph::closeness() with mode = "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 using igraph::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. Diffusion is always min-max normalized to the range
from 0 to 1, whatever the value of normalize, because its raw
values grow with powers of the edge weights (for a frequency model
they easily exceed 1e30). When the raw values are equal for every
state, for example in a relative transition network with
loops = TRUE where every row sums to one, the normalized values are
NaN: the measure does not distinguish the states.
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.
PageRank: Weighted PageRank centrality calculated using
igraph::page_rank() on the directed transition network.
A tna_centralities object, which is a tibble (tbl_df) with
one row per state, the column state, and one numeric column per
requested measure (in the order listed in 'Details'). For a group_tna
object, a group_tna_centralities object: the same table for every
group stacked, with the group name in the first column group.
Banerjee, A., Chandrasekhar, A. G., Duflo, E., & Jackson, M. O. (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. doi:10.1038/srep19668
Zhang, B., & Horvath, S. (2005). A general framework for weighted gene co-expression network analysis. Statistical Applications in Genetics and Molecular Biology, 4(1), Article 17. doi:10.2202/1544-6115.1128
Centrality measure functions
betweenness_network(),
plot.group_tna_centralities(),
plot.tna_centralities(),
print.group_tna_centralities(),
print.tna_centralities()
model <- tna(group_regulation) # Centrality measures excluding loops in the network (the default) centralities(model) # Centrality measures including loops in the network centralities(model, loops = TRUE) # Centrality measures normalized centralities(model, normalize = TRUE)model <- tna(group_regulation) # Centrality measures excluding loops in the network (the default) centralities(model) # Centrality measures including loops in the network centralities(model, loops = TRUE) # Centrality measures normalized centralities(model, normalize = TRUE)
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.
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, ...)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, ...)
x |
A |
... |
Ignored. |
size |
An |
threshold |
A |
sum_weights |
A |
A tna_cliques object which is a list of three elements, each
a list with one element per clique found:
weights: The matrix of the edge weights among the states of the
clique.
inits: The numeric vector of initial probabilities of the states
of the clique.
indices: The integer indices of the states of the clique.
If x is a group_tna object, a group_tna_cliques object is returned
instead, which is a list of tna_cliques objects.
Clique-related functions
plot.group_tna_cliques(),
plot.tna_cliques(),
print.group_tna_cliques(),
print.tna_cliques()
model <- tna(group_regulation) # Find 2-cliques (dyads) cliq <- cliques(model, size = 2) model <- group_tna(engagement_mmm) cliques(model)model <- tna(group_regulation) # Find 2-cliques (dyads) cliq <- cliques(model, size = 2) model <- group_tna(engagement_mmm) cliques(model)
Performs clustering using specified dissimilarity measures
and clustering methods. The rows of the data are first converted to strings
and compared using the dissimilarity measures available in the
stringdist package.
cluster_data( data, k, dissimilarity = "hamming", method = "pam", na_syms = c("*", "%"), weighted = FALSE, lambda = 1, ... ) cluster_sequences( data, k, dissimilarity = "hamming", method = "pam", na_syms = c("*", "%"), weighted = FALSE, lambda = 1, ... )cluster_data( data, k, dissimilarity = "hamming", method = "pam", na_syms = c("*", "%"), weighted = FALSE, lambda = 1, ... ) cluster_sequences( data, k, dissimilarity = "hamming", method = "pam", na_syms = c("*", "%"), weighted = FALSE, lambda = 1, ... )
data |
A |
k |
An |
dissimilarity |
A |
method |
A |
na_syms |
A |
weighted |
A |
lambda |
A |
... |
Additional arguments passed to |
A tna_clustering object which is a list containing:
data: The original data.
k: The number of clusters.
assignments: An integer vector of cluster assignments, one per
sequence (row of data).
silhouette: The average silhouette width of the clustering.
sizes: An integer vector of cluster sizes.
method: The clustering method used.
distance: The dissimilarity matrix (a dist object).
The result can be passed to group_model() to build a TNA model for
each cluster.
Kaufman, L., & Rousseeuw, P. J. (1990). Finding Groups in Data: An Introduction to Cluster Analysis. Wiley. doi:10.1002/9780470316801
Rousseeuw, P. J. (1987). Silhouettes: A graphical aid to the interpretation and validation of cluster analysis. Journal of Computational and Applied Mathematics, 20, 53–65. doi:10.1016/0377-0427(87)90125-7
Cluster-related functions
communities(),
group_model(),
mmm_stats(),
print.tna_clustering(),
rename_groups()
data <- data.frame( T1 = c("A", "B", "A", "C", "A", "B"), T2 = c("B", "A", "B", "A", "C", "A"), T3 = c("C", "C", "A", "B", "B", "C") ) # PAM clustering with the Hamming distance (the defaults) result <- cluster_sequences(data, k = 2) print(result) # Hierarchical clustering with the optimal string alignment distance result <- cluster_sequences(data, k = 2, dissimilarity = "osa", method = "complete")data <- data.frame( T1 = c("A", "B", "A", "C", "A", "B"), T2 = c("B", "A", "B", "A", "C", "A"), T3 = c("C", "C", "A", "B", "B", "C") ) # PAM clustering with the Hamming distance (the defaults) result <- cluster_sequences(data, k = 2) print(result) # Hierarchical clustering with the optimal string alignment distance result <- cluster_sequences(data, k = 2, dissimilarity = "osa", method = "complete")
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. For a group_tna object, the communities are detected in
the network of each cluster. 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).
communities(x, methods, gamma) ## S3 method for class 'tna' communities(x, methods, gamma = 1) ## S3 method for class 'group_tna' communities(x, methods, gamma = 1)communities(x, methods, gamma) ## S3 method for class 'tna' communities(x, methods, gamma = 1) ## S3 method for class 'group_tna' communities(x, methods, gamma = 1)
x |
A |
methods |
A
If not provided, all methods are applied. |
gamma |
A |
An object of class tna_communities which is a list with the
elements:
counts: A named integer vector with the number of communities
found by each algorithm.
assignments: A data.frame with one row per state, the column
state, and one column per algorithm giving the community (an
integer) that the state is assigned to.
If x is a group_tna object, a group_tna_communities object is returned
instead, which is a list of tna_communities objects.
Community detection functions
plot.group_tna_communities(),
plot.tna_communities(),
print.group_tna_communities(),
print.tna_communities()
Cluster-related functions
cluster_data(),
group_model(),
mmm_stats(),
print.tna_clustering(),
rename_groups()
model <- tna(group_regulation) comm <- communities(model)model <- tna(group_regulation) comm <- communities(model)
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.
compare(x, ...) ## S3 method for class 'tna' compare(x, y, scaling = "none", measures = character(0), network = TRUE, ...) ## S3 method for class 'matrix' compare(x, y, scaling = "none", measures = character(0), network = TRUE, ...)compare(x, ...) ## S3 method for class 'tna' compare(x, y, scaling = "none", measures = character(0), network = TRUE, ...) ## S3 method for class 'matrix' compare(x, y, scaling = "none", measures = character(0), network = TRUE, ...)
x |
A |
... |
Ignored. |
y |
A |
scaling |
A
|
measures |
A |
network |
A |
A tna_comparison object, which is a list containing the
following elements:
matrices: A list containing the scaled matrices of the input tna
objects or the scaled inputs themselves in the case of matrices.
difference_matrix: A matrix of differences x - y.
edge_metrics: A data.frame with one row per pair of states (columns
source and target), the weights weight_x and weight_y, and
edge-level metrics of their difference.
summary_metrics: A data.frame with one row per summary metric of the
differences across all edges, with the columns category, metric,
and value.
network_metrics: A data.frame with one row per network metric and
the columns metric, x, and y.
centrality_differences: A data.frame with one row per state and
centrality measure, with the columns state, centrality, x, y,
and difference. Only present when measures is not empty.
centrality_correlations: A data.frame with one row per centrality
measure and the correlation of the measure between x and y. Only
present when measures is not empty.
Model comparison functions
compare.group_tna(),
compare_sequences(),
plot.tna_comparison(),
plot.tna_sequence_comparison(),
plot_compare(),
plot_compare.group_tna(),
print.tna_comparison(),
print.tna_sequence_comparison()
# Comparing TNA models model_x <- tna(head(group_regulation, 200)) model_y <- tna(tail(group_regulation, 200)) comp1 <- compare(model_x, model_y) # Comparing weight matrices (with the states as row and column names) states <- c("A", "B") mat_x <- matrix(c(0.6, 0.3, 0.4, 0.7), 2, 2, dimnames = list(states, states)) mat_y <- matrix(c(0.5, 0.2, 0.5, 0.8), 2, 2, dimnames = list(states, states)) comp2 <- compare(mat_x, mat_y) print(comp2)# Comparing TNA models model_x <- tna(head(group_regulation, 200)) model_y <- tna(tail(group_regulation, 200)) comp1 <- compare(model_x, model_y) # Comparing weight matrices (with the states as row and column names) states <- c("A", "B") mat_x <- matrix(c(0.6, 0.3, 0.4, 0.7), 2, 2, dimnames = list(states, states)) mat_y <- matrix(c(0.5, 0.2, 0.5, 0.8), 2, 2, dimnames = list(states, states)) comp2 <- compare(mat_x, mat_y) print(comp2)
Performs comprehensive sequence comparison analysis between groups. All patterns of the sequences (subsequences of specific length) are extracted from all sequences in each group. The pattern frequencies are compared between the groups using a permutation test. The reported effect size is the difference between the observed test statistic (sum of squared differences between the observed and expected counts) and the mean value over the permutation samples divided by their standard deviation times square root of the number of observations.
compare_sequences(x, ...) ## Default S3 method: compare_sequences( x, group, sub, min_freq = 5L, test = TRUE, iter = 1000L, adjust = "bonferroni", actor = NULL, ... ) ## S3 method for class 'group_tna' compare_sequences( x, sub, min_freq = 5L, test = TRUE, iter = 1000L, adjust = "bonferroni", actor = NULL, ... )compare_sequences(x, ...) ## Default S3 method: compare_sequences( x, group, sub, min_freq = 5L, test = TRUE, iter = 1000L, adjust = "bonferroni", actor = NULL, ... ) ## S3 method for class 'group_tna' compare_sequences( x, sub, min_freq = 5L, test = TRUE, iter = 1000L, adjust = "bonferroni", actor = NULL, ... )
x |
A |
... |
Not used. A misspelled or unknown argument is an error. |
group |
A |
sub |
An |
min_freq |
An |
test |
A |
iter |
An |
adjust |
A |
actor |
An optional actor identifier for sequences nested in actors:
a |
A tna_sequence_comparison object, which is a data.frame with
one row per pattern that passes min_freq, and the columns pattern
(the states of the pattern joined by ->), freq_<group> (the count
of the pattern in each group), prop_<group> (its proportion among the
patterns of the same length in the group), and, when test = TRUE,
effect_size and p_value (adjusted with adjust).
Model comparison functions
compare(),
compare.group_tna(),
plot.tna_comparison(),
plot.tna_sequence_comparison(),
plot_compare(),
plot_compare.group_tna(),
print.tna_comparison(),
print.tna_sequence_comparison()
# A small subset (100 high and 100 low achievers) without the test sequences <- rbind(head(group_regulation, 100), tail(group_regulation, 100)) group <- rep(c("High", "Low"), each = 100) compare_sequences(sequences, group, test = FALSE) # With the permutation test (small number of iterations for CRAN) sequences <- rbind(head(group_regulation, 500), tail(group_regulation, 500)) group <- rep(c("High", "Low"), each = 500) compare_sequences(sequences, group, sub = 2:3, iter = 20)# A small subset (100 high and 100 low achievers) without the test sequences <- rbind(head(group_regulation, 100), tail(group_regulation, 100)) group <- rep(c("High", "Low"), each = 100) compare_sequences(sequences, group, test = FALSE) # With the permutation test (small number of iterations for CRAN) sequences <- rbind(head(group_regulation, 500), tail(group_regulation, 500)) group <- rep(c("High", "Low"), each = 500) compare_sequences(sequences, group, sub = 2:3, iter = 20)
Compare Grouped TNA Models with Comprehensive Metrics
## S3 method for class 'group_tna' compare( x, i = 1L, j = 2L, scaling = "none", measures = character(0), network = TRUE, ... )## S3 method for class 'group_tna' compare( x, i = 1L, j = 2L, scaling = "none", measures = character(0), network = TRUE, ... )
x |
A |
i |
An |
j |
An |
scaling |
A
|
measures |
A |
network |
A |
... |
Ignored. |
A tna_comparison object. See compare.tna() for details.
Model comparison functions
compare(),
compare_sequences(),
plot.tna_comparison(),
plot.tna_sequence_comparison(),
plot_compare(),
plot_compare.group_tna(),
print.tna_comparison(),
print.tna_sequence_comparison()
model <- group_model(engagement_mmm) compare(model, i = 1, j = 2)model <- group_model(engagement_mmm) compare(model, i = 1, j = 2)
Restore a Pruned Transition Network Analysis Model
deprune(x, ...) ## S3 method for class 'tna' deprune(x, ...) ## S3 method for class 'group_tna' deprune(x, ...)deprune(x, ...) ## S3 method for class 'tna' deprune(x, ...) ## S3 method for class 'group_tna' deprune(x, ...)
x |
A |
... |
Ignored. |
A tna or group_tna object that has not been pruned.
Validation functions
bootstrap(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) pruned_model <- prune(model, method = "threshold", threshold = 0.1) depruned_model <- deprune(pruned_model) # restore original modelmodel <- tna(group_regulation) pruned_model <- prune(model, method = "threshold", threshold = 0.1) depruned_model <- deprune(pruned_model) # restore original model
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"
engagementengagement
A stslist object (sequence data) with 1000 sequences (rows) and
25 time points (columns), over the states "Active", "Average", and
"Disengaged".
doi:10.1016/j.compedu.2023.104787
Datasets
engagement_mmm,
group_regulation,
group_regulation_long
engagement DataA tna_mmm object structurally equivalent to a fitted seqHMM
mixture Markov model, used by the package's examples for
group_model() and mmm_stats(). Generated deterministically by
random_tna_mmm() with engagement-flavored state labels and
three clusters; carries no foreign class references so it is safe
to bundle.
engagement_mmmengagement_mmm
A tna_mmm object containing three clusters over the
states "Engaged", "Moderate", "Disengaged", for 1000
sequences.
Re-generate via data-raw/engagement_mmm.R whenever the simulator
changes.
Generated by data-raw/engagement_mmm.R using
random_tna_mmm().
Datasets
engagement,
group_regulation,
group_regulation_long
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.
estimate_cs( x, loops, normalize, invert, measures, iter, method, drop_prop, threshold, certainty, progressbar = NULL, detailed = NULL, actor = NULL, edges = FALSE ) estimate_centrality_stability( x, loops, normalize, invert, measures, iter, method, drop_prop, threshold, certainty, progressbar = NULL, detailed = NULL, actor = NULL, edges = FALSE ) ## S3 method for class 'tna' estimate_cs( x, loops = FALSE, normalize = FALSE, invert = TRUE, 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, detailed = NULL, actor = NULL, edges = FALSE ) ## S3 method for class 'tna' estimate_centrality_stability( x, loops = FALSE, normalize = FALSE, invert = TRUE, 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, detailed = NULL, actor = NULL, edges = FALSE ) ## S3 method for class 'group_tna' estimate_cs( x, loops = FALSE, normalize = FALSE, invert = TRUE, 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, detailed = NULL, actor = NULL, edges = FALSE ) ## S3 method for class 'group_tna' estimate_centrality_stability( x, loops = FALSE, normalize = FALSE, invert = TRUE, 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, detailed = NULL, actor = NULL, edges = FALSE )estimate_cs( x, loops, normalize, invert, measures, iter, method, drop_prop, threshold, certainty, progressbar = NULL, detailed = NULL, actor = NULL, edges = FALSE ) estimate_centrality_stability( x, loops, normalize, invert, measures, iter, method, drop_prop, threshold, certainty, progressbar = NULL, detailed = NULL, actor = NULL, edges = FALSE ) ## S3 method for class 'tna' estimate_cs( x, loops = FALSE, normalize = FALSE, invert = TRUE, 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, detailed = NULL, actor = NULL, edges = FALSE ) ## S3 method for class 'tna' estimate_centrality_stability( x, loops = FALSE, normalize = FALSE, invert = TRUE, 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, detailed = NULL, actor = NULL, edges = FALSE ) ## S3 method for class 'group_tna' estimate_cs( x, loops = FALSE, normalize = FALSE, invert = TRUE, 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, detailed = NULL, actor = NULL, edges = FALSE ) ## S3 method for class 'group_tna' estimate_centrality_stability( x, loops = FALSE, normalize = FALSE, invert = TRUE, 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, detailed = NULL, actor = NULL, edges = FALSE )
x |
A |
loops |
A |
normalize |
A |
invert |
A |
measures |
A |
iter |
An |
method |
A |
drop_prop |
A |
threshold |
A |
certainty |
A |
progressbar |
A |
detailed |
Deprecated. This argument is ignored and will be removed in a future version. |
actor |
An optional actor identifier for sequences nested in actors:
a |
edges |
A |
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).
With edges = TRUE, the stability of the edge weights is estimated in the
same way: in each subsample the network is estimated again and its edge
weights are correlated with the edge weights of the original network
(Epskamp et al., 2018). Only the edges present in the original network
are compared, self-loops included. An edge that is absent from the
original data cannot appear in a subsample, so including the absent edges
would add pairs of zeros that always agree and inflate the correlation.
The loops, normalize, and invert arguments do not affect the edge
weights.
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.
A tna_stability object which is a list with an element for each
measure (and an element Edges when edges = TRUE) with the following
elements:
cs_coefficient: The centrality stability (CS) coefficient
of the measure.
correlations: A matrix of correlations between the original
centrality and the resampled centralities, with one row per resample
(iter rows) and one column per drop proportion.
The drop proportions and the correlation threshold are stored in the
attributes drop_prop and threshold. Use summary.tna_stability() for
the CS-coefficients as a table.
If x is a group_tna object, a group_tna_stability object is returned
instead, which is a list of tna_stability objects.
Epskamp, S., Borsboom, D., & Fried, E. I. (2018). Estimating psychological networks and their accuracy: A tutorial paper. Behavior Research Methods, 50(1), 195–212. doi:10.3758/s13428-017-0862-1
Validation functions
bootstrap(),
deprune(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
# A small subset and few iterations estimate_cs( tna(head(group_regulation, 200)), drop_prop = c(0.3, 0.6), measures = "InStrength", iter = 5 ) 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 ) # Stability of the edge weights alongside the centralities estimate_cs( model, drop_prop = seq(0.3, 0.9, by = 0.2), measures = "InStrength", iter = 10, edges = TRUE )# A small subset and few iterations estimate_cs( tna(head(group_regulation, 200)), drop_prop = c(0.3, 0.6), measures = "InStrength", iter = 5 ) 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 ) # Stability of the edge weights alongside the centralities estimate_cs( model, drop_prop = seq(0.3, 0.9, by = 0.2), measures = "InStrength", iter = 10, edges = TRUE )
This function constructs a transition network analysis (TNA) model for each group from a given sequence, wide-format dataframe or a mixture Markov model.
group_model(x, ...) ## Default S3 method: group_model( x, group, type = "relative", scaling = character(0L), groupwise = FALSE, cols = tidyselect::everything(), params = list(), concat = 1L, na.rm = TRUE, ... ) ## S3 method for class 'tna_mmm' group_model( x, type = "relative", scaling = character(0L), groupwise = FALSE, params = list(), na.rm = TRUE, ... ) ## S3 method for class 'mhmm' group_model( x, type = "relative", scaling = character(0L), groupwise = FALSE, params = list(), na.rm = TRUE, ... ) ## S3 method for class 'tna_clustering' group_model( x, type = "relative", scaling = character(0L), groupwise = FALSE, params = list(), na.rm = TRUE, ... ) group_tna(x, ...) group_ftna(x, ...) group_ctna(x, ...) group_atna(x, ...)group_model(x, ...) ## Default S3 method: group_model( x, group, type = "relative", scaling = character(0L), groupwise = FALSE, cols = tidyselect::everything(), params = list(), concat = 1L, na.rm = TRUE, ... ) ## S3 method for class 'tna_mmm' group_model( x, type = "relative", scaling = character(0L), groupwise = FALSE, params = list(), na.rm = TRUE, ... ) ## S3 method for class 'mhmm' group_model( x, type = "relative", scaling = character(0L), groupwise = FALSE, params = list(), na.rm = TRUE, ... ) ## S3 method for class 'tna_clustering' group_model( x, type = "relative", scaling = character(0L), groupwise = FALSE, params = list(), na.rm = TRUE, ... ) group_tna(x, ...) group_ftna(x, ...) group_ctna(x, ...) group_atna(x, ...)
x |
An |
... |
Ignored. |
group |
A |
type |
A
|
scaling |
A
|
groupwise |
A |
cols |
An |
params |
A
|
concat |
An |
na.rm |
A |
An object of class group_tna which is a named list containing
one element per group (cluster). Each element is a tna object (see
build_model()).
Cluster-related functions
cluster_data(),
communities(),
mmm_stats(),
print.tna_clustering(),
rename_groups()
# 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))# 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))
Students' regulation during collaborative learning. Students' interactions were coded as: "adapt", "cohesion", "consensus", "coregulate", "discuss", "emotion", "monitor", "plan", "synthesis"
group_regulationgroup_regulation
A data.frame with 2000 sequences (rows) and 26 time points
(columns T1 to T26). Shorter sequences end in missing values. The
first 1000 rows are the sequences of high achievers and the last 1000
rows those of low achievers (see group_regulation_long).
The data was generated synthetically.
Datasets
engagement,
engagement_mmm,
group_regulation_long
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.
group_regulation_longgroup_regulation_long
A tibble with 27533 rows (one per action) and 6 columns:
Actor (integer), Achiever ("High" or "Low"), Group
(numeric), Course (character), Time (POSIXct), and Action
(character).
The data was generated synthetically from group_regulation.
Datasets
engagement,
engagement_mmm,
group_regulation
group_tna Object.Plot a Histogram of Edge Weights for a group_tna Object.
## S3 method for class 'group_tna' hist(x, ...)## S3 method for class 'group_tna' hist(x, ...)
x |
A |
... |
Additional arguments passed to |
A list (invisibly) of histogram objects of the edge weights of
each cluster.
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
model <- group_model(engagement_mmm) hist(model)model <- group_model(engagement_mmm) hist(model)
Plot a Histogram of Edge Weights in the Network
## S3 method for class 'tna' hist(x, breaks, col = "lightblue", main, xlab, border = "white", ...)## S3 method for class 'tna' hist(x, breaks, col = "lightblue", main, xlab, border = "white", ...)
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 |
A histogram object of edge weights.
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
model <- tna(group_regulation) hist(model)model <- tna(group_regulation) hist(model)
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.
import_data(data, cols, id_cols, window_size = 1, replace_zeros = TRUE)import_data(data, cols, id_cols, window_size = 1, replace_zeros = TRUE)
data |
A |
cols |
An |
id_cols |
An |
window_size |
An |
replace_zeros |
A |
A tibble in long format with one row per non-missing value of
cols: the remaining columns of data, the id_cols, the columns
action (the name of the column in cols) and value, and the column
order (the position of the action within its window of rows and
combination of id_cols). Can be passed to prepare_data().
Other data:
import_onehot(),
list_random_state_pools(),
prepare_data(),
print.tna_data(),
random_group_tna(),
random_tna(),
random_tna_mmm(),
simulate.group_tna(),
simulate.tna()
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 )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 )
Import One-Hot Data
import_onehot( data, cols, actor, session, interval, window_size = 1L, window_type = "tumbling", aggregate = FALSE )import_onehot( data, cols, actor, session, interval, window_size = 1L, window_type = "tumbling", aggregate = FALSE )
data |
A |
cols |
An |
actor |
An optional |
session |
An optional |
interval |
An |
window_size |
An |
window_type |
A |
aggregate |
A |
A tibble in wide format with one row per actor/session
combination (or per interval windows) and one column per time point,
named W<window>_T<position>. Each cell holds the name of the column of
cols that was active, or NA. The result can be passed to
build_model(), for example with type = "co-occurrence".
Other data:
import_data(),
list_random_state_pools(),
prepare_data(),
print.tna_data(),
random_group_tna(),
random_tna(),
random_tna_mmm(),
simulate.group_tna(),
simulate.tna()
set.seed(1) d <- data.frame( actor = gl(100, 5), session = gl(10, 50), feature1 = rbinom(500, 1, prob = 0.33), feature2 = rbinom(500, 1, prob = 0.25), feature3 = rbinom(500, 1, prob = 0.50) ) onehot1 <- import_onehot(d, feature1:feature3) onehot2 <- import_onehot(d, feature1:feature3, "actor", "session")set.seed(1) d <- data.frame( actor = gl(100, 5), session = gl(10, 50), feature1 = rbinom(500, 1, prob = 0.33), feature2 = rbinom(500, 1, prob = 0.25), feature3 = rbinom(500, 1, prob = 0.50) ) onehot1 <- import_onehot(d, feature1:feature3) onehot2 <- import_onehot(d, feature1:feature3, "actor", "session")
random_tna()
Return the names of the curated state-label pools available to
random_tna() and random_group_tna(), with their sizes.
list_random_state_pools()list_random_state_pools()
A named integer vector mapping pool names to pool sizes.
Other data:
import_data(),
import_onehot(),
prepare_data(),
print.tna_data(),
random_group_tna(),
random_tna(),
random_tna_mmm(),
simulate.group_tna(),
simulate.tna()
list_random_state_pools()list_random_state_pools()
Tests whether the sequences of a model are described by a Markov chain of order one, the assumption of a transition network, or whether the next state also depends on states further back.
markov_order(x, max_order = 3L, iter = 1000L, level = 0.05, dof = "paths") ## S3 method for class 'tna' markov_order(x, max_order = 3L, iter = 1000L, level = 0.05, dof = "paths") ## S3 method for class 'group_tna' markov_order(x, max_order = 3L, iter = 1000L, level = 0.05, dof = "paths")markov_order(x, max_order = 3L, iter = 1000L, level = 0.05, dof = "paths") ## S3 method for class 'tna' markov_order(x, max_order = 3L, iter = 1000L, level = 0.05, dof = "paths") ## S3 method for class 'group_tna' markov_order(x, max_order = 3L, iter = 1000L, level = 0.05, dof = "paths")
x |
A |
max_order |
An |
iter |
An |
level |
A |
dof |
A |
For each order max_order, the test compares order
(the null hypothesis) with order . Every window of
consecutive states is split into the context (the
states before the next state), the state that order
adds ( steps back), and the next state . Under the
null hypothesis, is independent of given . This is
tested with the likelihood-ratio statistic
with degrees of freedom, where
and are the numbers of distinct states and
observed with context (Anderson & Goodman, 1957). For
the context is empty, and the test is whether the next state
depends on the current state at all.
The p-value comes from a conditional permutation test: within each context
, the next states are shuffled, which keeps every count that the
null hypothesis conditions on. The windows of a sequence overlap, so the
permutation distribution approximates the null distribution but is not
exact (an exact test would sample whole sequences with the same counts;
Besag & Mondal, 2013). The asymptotic p-value is reported
alongside.
The orders are tested in sequence: the order is raised while the test
rejects at level level. The selected order is the highest order whose
test, and the test of every lower order, rejected. Order 0 means that the
next state does not depend on the current state, and max_order means
that no test failed to reject.
The results also contain the log-likelihood, AIC, and BIC of the
multi-order model of each order (Scholtes, 2017). This model uses the
state frequencies for the first state of a sequence and the highest
available order for each following state. With dof = "paths", the
parameters of an order are all the transitions of the paths that the
first-order transitions allow, observed or not (Scholtes, 2017). With
dof = "observed", only the transitions observed in the data are counted.
The orders that minimize AIC and BIC are reported next to the selected
order, but they do not affect the test.
Because the tests stop at the first order that does not reject, a
dependence that skips an order (for example, on the state two steps back
but not on the current state) is not selected. A warning of class
tna_warning_markov_order is therefore raised, and a note is printed,
when the test of an order above the selected order plus one rejects, or
when AIC or BIC select a different order than the tests. The same class
of warning is raised when iter is too small for any p-value to fall
below level (fewer than floor(1 / level) permutations).
Sequences are split at missing values, so that no window spans a missing value, and the parts with fewer than two states are not used. The windows are treated as independent observations, so sequences nested in actors (for example, several sessions per student) are not taken into account.
A tna_markov_order object, which is a list with the elements:
stats: A data.frame with one row per order from 0 to max_order
and the columns order, loglik, aic, bic (the multi-order
model), g2 (the statistic), df (its degrees of freedom),
p_value (the permutation p-value), p_asymptotic (the
p-value), and significant (p_value < level). The test columns are
NA for order 0 and for an order whose statistic has no degrees of
freedom.
selected_order: The order selected by the sequential tests.
aic_order, bic_order: The orders that minimize AIC and BIC.
null: A list with the permutation distribution of for
each order.
states: The states observed in the data.
n_sequences, n_observations: The numbers of sequences (after
splitting at missing values) and states used.
max_order, iter, level, dof: The settings used.
For a group_tna object, a group_tna_markov_order object, which is a
list of tna_markov_order objects, one per group.
Anderson, T. W., & Goodman, L. A. (1957). Statistical inference about Markov chains. The Annals of Mathematical Statistics, 28(1), 89–110. doi:10.1214/aoms/1177707039
Besag, J., & Mondal, D. (2013). Exact goodness-of-fit tests for Markov chains. Biometrics, 69(2), 488–496. doi:10.1111/biom.12009
Scholtes, I. (2017). When is a network a network? Multi-order graphical model selection in pathways and temporal networks. In Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (pp. 1037–1046). doi:10.1145/3097983.3098145
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_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) # Small number of permutations for CRAN mo <- markov_order(model, max_order = 2, iter = 50) mo summary(mo) plot(mo) plot(mo, panel = "ic")model <- tna(group_regulation) # Small number of permutations for CRAN mo <- markov_order(model, max_order = 2, iter = 50) mo summary(mo) plot(mo) plot(mo, panel = "ic")
Retrieve Statistics from a Mixture Markov Model (MMM)
mmm_stats(x, level = 0.05) ## S3 method for class 'tna_mmm' mmm_stats(x, level = 0.05) ## S3 method for class 'mhmm' mmm_stats(x, level = 0.05)mmm_stats(x, level = 0.05) ## S3 method for class 'tna_mmm' mmm_stats(x, level = 0.05) ## S3 method for class 'mhmm' mmm_stats(x, level = 0.05)
x |
A |
level |
A |
A data.frame with one row per cluster (other than the reference
cluster) and covariate of the membership model, with the columns
cluster, variable, estimate, std_error, ci_lower, ci_upper
(the 1 - level confidence interval), z_value, and p_value.
Cluster-related functions
cluster_data(),
communities(),
group_model(),
print.tna_clustering(),
rename_groups()
mmm_stats(engagement_mmm)mmm_stats(engagement_mmm)
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.
permutation_test(x, ...) ## S3 method for class 'tna' permutation_test( x, y, adjust = "none", iter = 1000, paired = FALSE, level = 0.05, measures = character(0), actor = NULL, ... )permutation_test(x, ...) ## S3 method for class 'tna' permutation_test( x, y, adjust = "none", iter = 1000, paired = FALSE, level = 0.05, measures = character(0), actor = NULL, ... )
x |
A |
... |
Additional arguments passed to |
y |
A |
adjust |
A |
iter |
An |
paired |
A |
level |
A |
measures |
A |
actor |
An optional actor identifier for sequences nested in actors
(for example, several sessions per student). Either a |
A tna_permutation object which is a list with two elements:
edges and centralities (NULL when measures is empty). Both contain
the following elements:
stats: A data.frame of original differences, effect sizes, and
estimated p-values, with one row per edge (columns edge_name,
diff_true, effect_size, p_value) or per state and centrality
measure (columns state, centrality, diff_true, effect_size,
p_value). The effect size is the observed difference divided by the
standard deviation of the differences of the permuted samples, and
NA when the permuted differences do not vary.
diffs_true: The differences in the data: a matrix for the edges,
and a data.frame with one row per state and one column per measure
for the centralities.
diffs_sig: The same as diffs_true with the non-significant
differences set to zero.
Use summary.tna_permutation() for the results as a tidy table.
Good, P. (2005). Permutation, Parametric, and Bootstrap Tests of Hypotheses (3rd ed.). Springer.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model_x <- tna(head(group_regulation, 200)) model_y <- tna(tail(group_regulation, 200)) # Small number of iterations for CRAN permutation_test(model_x, model_y, iter = 20)model_x <- tna(head(group_regulation, 200)) model_y <- tna(tail(group_regulation, 200)) # Small number of iterations for CRAN permutation_test(model_x, model_y, iter = 20)
Test edge weight differences between all pairs or a subset of pairs of
a group_tna object. See permutation_test.tna() for more details.
## S3 method for class 'group_tna' permutation_test( x, groups, adjust = "none", iter = 1000, paired = FALSE, level = 0.05, measures = character(0), consecutive = FALSE, actor = NULL, ... )## S3 method for class 'group_tna' permutation_test( x, groups, adjust = "none", iter = 1000, paired = FALSE, level = 0.05, measures = character(0), consecutive = FALSE, actor = NULL, ... )
x |
A |
groups |
An |
adjust |
A |
iter |
An |
paired |
A |
level |
A |
measures |
A |
consecutive |
A |
actor |
An optional actor identifier for sequences nested in actors
(for example, several sessions per student). Either a |
... |
Additional arguments passed to |
A group_tna_permutation object, which is a list of
tna_permutation objects (see permutation_test()), one per compared
pair of groups, named after the pair.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- group_model(engagement_mmm) # Small number of iterations for CRAN permutation_test(model, iter = 20)model <- group_model(engagement_mmm) # Small number of iterations for CRAN permutation_test(model, iter = 20)
Plot an Association Network
plot_associations(x, ...) ## S3 method for class 'tna' plot_associations(x, edge_color, ...)plot_associations(x, ...) ## S3 method for class 'tna' plot_associations(x, edge_color, ...)
x |
A |
... |
Additional arguments passed to |
edge_color |
An optional |
A cograph_network object.
model <- ftna(group_regulation) plot_associations(model)model <- ftna(group_regulation) plot_associations(model)
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.
plot_compare(x, ...) ## S3 method for class 'tna' plot_compare(x, y, posCol = "#009900", negCol = "red", ...)plot_compare(x, ...) ## S3 method for class 'tna' plot_compare(x, y, posCol = "#009900", negCol = "red", ...)
x |
A |
... |
Additional arguments passed to |
y |
A |
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 |
The difference network is drawn, and a list is returned
invisibly with the elements weights (the matrix of edge weight
differences x - y) and inits (the differences in the initial
probabilities).
Model comparison functions
compare(),
compare.group_tna(),
compare_sequences(),
plot.tna_comparison(),
plot.tna_sequence_comparison(),
plot_compare.group_tna(),
print.tna_comparison(),
print.tna_sequence_comparison()
# Sequences that start with "plan" against the other sequences model_x <- tna(subset(group_regulation, T1 == "plan")) model_y <- tna(subset(group_regulation, T1 != "plan")) plot_compare(model_x, model_y)# Sequences that start with "plan" against the other sequences model_x <- tna(subset(group_regulation, T1 == "plan")) model_y <- tna(subset(group_regulation, T1 != "plan")) plot_compare(model_x, model_y)
Plot the Difference Network Between Two Groups
## S3 method for class 'group_tna' plot_compare(x, i = NULL, j = NULL, ...)## S3 method for class 'group_tna' plot_compare(x, i = NULL, j = NULL, ...)
x |
A |
i |
An |
j |
An |
... |
Additional arguments passed to |
The difference networks are drawn, and returned invisibly: for
one pair of clusters (two clusters, or i and j given), a list with
the elements weights and inits (the differences, see
plot_compare.tna()); otherwise a named list with such a list for
each pair of clusters.
Model comparison functions
compare(),
compare.group_tna(),
compare_sequences(),
plot.tna_comparison(),
plot.tna_sequence_comparison(),
plot_compare(),
print.tna_comparison(),
print.tna_sequence_comparison()
model <- group_model(engagement_mmm) plot_compare(model)model <- group_model(engagement_mmm) plot_compare(model)
Plot the Frequency Distribution of States
plot_frequencies(x, ...) ## S3 method for class 'tna' plot_frequencies(x, width = 0.7, hjust = 1.2, show_label = TRUE, colors, ...)plot_frequencies(x, ...) ## S3 method for class 'tna' plot_frequencies(x, width = 0.7, hjust = 1.2, show_label = TRUE, colors, ...)
x |
A |
... |
Ignored. |
width |
A |
hjust |
A |
show_label |
A |
colors |
A |
A ggplot object.
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
model <- tna(group_regulation) plot_frequencies(model) plot_frequencies(model, width = 0.5, colors = "pink")model <- tna(group_regulation) plot_frequencies(model) plot_frequencies(model, width = 0.5, colors = "pink")
Plot the Frequency Distribution of States
## S3 method for class 'group_tna' plot_frequencies( x, label, colors, width = 0.7, palette = "Set2", show_label = TRUE, position = "dodge", hjust = 1.2, ... )## S3 method for class 'group_tna' plot_frequencies( x, label, colors, width = 0.7, palette = "Set2", show_label = TRUE, position = "dodge", hjust = 1.2, ... )
x |
A |
label |
An optional |
colors |
A |
width |
A |
palette |
A |
show_label |
A |
position |
Position of the bars: |
hjust |
A |
... |
Ignored. |
A ggplot object.
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
model <- group_model(engagement_mmm) 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)model <- group_model(engagement_mmm) 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)
Create a Mosaic Plot of Transitions or Events
plot_mosaic(x, ...) ## S3 method for class 'tna' plot_mosaic(x, ...)plot_mosaic(x, ...) ## S3 method for class 'tna' plot_mosaic(x, ...)
x |
A |
... |
Ignored. |
A ggplot object.
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
ftna_model <- ftna(group_regulation) plot_mosaic(ftna_model)ftna_model <- ftna(group_regulation) plot_mosaic(ftna_model)
Plot State Frequencies as a Mosaic Between Two Groups
## S3 method for class 'group_tna' plot_mosaic(x, label, ...)## S3 method for class 'group_tna' plot_mosaic(x, label, ...)
x |
A |
label |
An optional |
... |
Ignored. |
A ggplot object.
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
model <- group_model(engagement, group = rep(1:3, length.out = 1000)) plot_mosaic(model)model <- group_model(engagement, group = rep(1:3, length.out = 1000)) plot_mosaic(model)
Plot State Frequencies as a Mosaic Between Two Groups
## S3 method for class 'tna_data' plot_mosaic(x, group, label = "Group", ...)## S3 method for class 'tna_data' plot_mosaic(x, group, label = "Group", ...)
x |
A |
group |
A |
label |
An optional |
... |
Ignored. |
A ggplot object.
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
set.seed(1) d <- data.frame( time = rep(1:5, times = 4), group = rep(1:4, each = 5), event = sample(c("A", "B", "C"), 20, replace = TRUE) ) sequence_data <- prepare_data( d, time = "time", actor = "group", action = "event" ) plot_mosaic(sequence_data, group = "group")set.seed(1) d <- data.frame( time = rep(1:5, times = 4), group = rep(1:4, each = 5), event = sample(c("A", "B", "C"), 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
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 = tidyselect::everything(), 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, ... )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 = tidyselect::everything(), 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, ... )
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 |
An optional |
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 |
An |
A ggplot object containing either a sequence index plot or
a state distribution plot, faceted by group when supplied.
# 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" )# 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" )
Plots a transition network of each cluster using cograph.
## S3 method for class 'group_tna' plot(x, title, which, ...)## S3 method for class 'group_tna' plot(x, title, which, ...)
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
|
NULL (invisibly).
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
model <- group_model(engagement_mmm) plot(model, which = 1)model <- group_model(engagement_mmm) plot(model, which = 1)
Plot a Bootstrapped Grouped Transition Network Analysis Model
## S3 method for class 'group_tna_bootstrap' plot(x, title, ...)## S3 method for class 'group_tna_bootstrap' plot(x, title, ...)
x |
A |
title |
A |
... |
Additional arguments passed to |
A list with the plot of each group (see
plot.tna_bootstrap()), invisibly.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- group_model(engagement_mmm) # Small number of iterations for CRAN boot <- bootstrap(model, iter = 10) plot(boot)model <- group_model(engagement_mmm) # Small number of iterations for CRAN boot <- bootstrap(model, iter = 10) plot(boot)
Plot Centrality Measures
## S3 method for class 'group_tna_centralities' plot( x, reorder = TRUE, ncol = 3, scales = c("free_x", "fixed"), colors, palette = "Set2", labels = TRUE, ... )## S3 method for class 'group_tna_centralities' plot( x, reorder = TRUE, ncol = 3, scales = c("free_x", "fixed"), colors, palette = "Set2", labels = TRUE, ... )
x |
A |
reorder |
A |
ncol |
Number of columns to use for the facets. The default is 3. |
scales |
Either |
colors |
The colors for each state. The default is the state colors
of the model that the centralities were computed from, or |
palette |
A color palette to be applied if |
labels |
A |
... |
Ignored. |
A ggplot object displaying a line chart for each centrality
with one line per cluster.
Centrality measure functions
betweenness_network(),
centralities(),
plot.tna_centralities(),
print.group_tna_centralities(),
print.tna_centralities()
model <- group_model(engagement_mmm) cm <- centralities(model) plot(cm)model <- group_model(engagement_mmm) cm <- centralities(model) plot(cm)
Plot Found Cliques
## S3 method for class 'group_tna_cliques' plot(x, title, ...)## S3 method for class 'group_tna_cliques' plot(x, title, ...)
x |
A |
title |
A |
... |
Arguments passed to |
A list (invisibly) with one element per cluster. Each element
contains a cograph_network plot when only one clique is present per
cluster, otherwise the element is NULL.
Clique-related functions
cliques(),
plot.tna_cliques(),
print.group_tna_cliques(),
print.tna_cliques()
model <- group_model(engagement_mmm) cliq <- cliques(model, size = 2) plot(cliq, ask = FALSE)model <- group_model(engagement_mmm) cliq <- cliques(model, size = 2) plot(cliq, ask = FALSE)
Plot Detected Communities
## S3 method for class 'group_tna_communities' plot(x, title, colors, ...)## S3 method for class 'group_tna_communities' plot(x, title, colors, ...)
x |
A |
title |
A |
colors |
A |
... |
Arguments passed to |
A list (invisibly) of cograph_network objects in which the
nodes are colored by community for each cluster.
Community detection functions
communities(),
plot.tna_communities(),
print.group_tna_communities(),
print.tna_communities()
model <- group_model(engagement_mmm) comm <- communities(model) plot(comm)model <- group_model(engagement_mmm) comm <- communities(model) plot(comm)
Plot Permutation Test Results
## S3 method for class 'group_tna_permutation' plot(x, title, ...)## S3 method for class 'group_tna_permutation' plot(x, title, ...)
x |
A |
title |
An optional |
... |
Arguments passed to |
A list (invisibly) of cograph_network objects depicting the
significant difference between each pair.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- group_tna(engagement_mmm) # Small number of iterations for CRAN perm <- permutation_test(model, iter = 20) plot(perm)model <- group_tna(engagement_mmm) # Small number of iterations for CRAN perm <- permutation_test(model, iter = 20) plot(perm)
Plot Centrality Stability Results
## S3 method for class 'group_tna_stability' plot(x, ...)## S3 method for class 'group_tna_stability' plot(x, ...)
x |
A |
... |
Arguments passed to |
A list (invisibly) of ggplot objects displaying the stability
analysis plot.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
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)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)
This function plots a transition network analysis (TNA) model using
the cograph package. The nodes in the graph represent states, and the
filled share of the ring (donut) around each node is its initial state
probability. Edge labels represent the edge weights of the network. See cograph::splot() for details on
how to further configure the plot.
## S3 method for class 'tna' plot( x, node_list, use_list_order = TRUE, scale_nodes, scaling_factor = 0.5, ... )## S3 method for class 'tna' plot( x, node_list, use_list_order = TRUE, scale_nodes, scaling_factor = 0.5, ... )
x |
A |
node_list |
An optional |
use_list_order |
A |
scale_nodes |
A |
scaling_factor |
A |
... |
Additional arguments passed to |
A cograph_network object of the plotted transition network,
invisibly.
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
model <- tna(group_regulation) plot(model)model <- tna(group_regulation) plot(model)
Plot a Bootstrapped Transition Network Analysis Model
## S3 method for class 'tna_bootstrap' plot(x, ...)## S3 method for class 'tna_bootstrap' plot(x, ...)
x |
A |
... |
Additional arguments passed to |
A cograph_network plot of the bootstrapped network (see
plot.tna()), invisibly.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) # Small number of iterations for CRAN boot <- bootstrap(model, iter = 50) plot(boot)model <- tna(group_regulation) # Small number of iterations for CRAN boot <- bootstrap(model, iter = 50) plot(boot)
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.
## S3 method for class 'tna_centralities' plot( x, reorder = TRUE, ncol = 3, scales = c("free_x", "fixed"), colors, labels = TRUE, ... )## S3 method for class 'tna_centralities' plot( x, reorder = TRUE, ncol = 3, scales = c("free_x", "fixed"), colors, labels = TRUE, ... )
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 state. The default is the state colors
of the model that the centralities were computed from, or |
labels |
A |
... |
Ignored. |
A ggplot object displaying the lollipop charts for each centrality
measure.
Centrality measure functions
betweenness_network(),
centralities(),
plot.group_tna_centralities(),
print.group_tna_centralities(),
print.tna_centralities()
tna_model <- tna(group_regulation) cm <- centralities(tna_model) plot(cm, ncol = 3, reorder = TRUE)tna_model <- tna(group_regulation) cm <- centralities(tna_model) plot(cm, ncol = 3, reorder = TRUE)
Plot Cliques of a TNA Network
## S3 method for class 'tna_cliques' plot(x, n = 6, first = 1, show_loops = FALSE, colors, ask = TRUE, ...)## S3 method for class 'tna_cliques' plot(x, n = 6, first = 1, show_loops = FALSE, colors, ask = TRUE, ...)
x |
A |
n |
An |
first |
An |
show_loops |
A |
colors |
Optional |
ask |
A |
... |
Ignored. |
NULL (invisibly).
Clique-related functions
cliques(),
plot.group_tna_cliques(),
print.group_tna_cliques(),
print.tna_cliques()
model <- tna(group_regulation) cliq <- cliques(model, size = 2) plot(cliq, n = 1, ask = FALSE)model <- tna(group_regulation) cliq <- cliques(model, size = 2) plot(cliq, n = 1, ask = FALSE)
This function visualizes the communities detected within a tna object
based on different community detection algorithms and their corresponding
color mappings.
## S3 method for class 'tna_communities' plot(x, colors, method, ...)## S3 method for class 'tna_communities' plot(x, colors, method, ...)
x |
A |
colors |
A |
method |
A |
... |
Additional arguments passed to |
A cograph_network object in which the nodes are colored by
community, invisibly.
Community detection functions
communities(),
plot.group_tna_communities(),
print.group_tna_communities(),
print.tna_communities()
model <- tna(group_regulation) comm <- communities(model) plot(comm, method = "leading_eigen")model <- tna(group_regulation) comm <- communities(model) plot(comm, method = "leading_eigen")
Plot the Comparison of Two TNA Models or Matrices
## S3 method for class 'tna_comparison' plot( x, type = "heatmap", population = "difference", method = "pearson", name_x = "x", name_y = "y", ... )## S3 method for class 'tna_comparison' plot( x, type = "heatmap", population = "difference", method = "pearson", name_x = "x", name_y = "y", ... )
x |
A |
type |
A |
population |
A |
method |
A |
name_x |
An optional |
name_y |
An optional |
... |
Ignored. |
A ggplot object.
Szekely, G.J., Rizzo, M.L., and Bakirov, N.K. (2007), Measuring and Testing Dependence by Correlation of Distances, Annals of Statistics, 35(6), 2769-2794. doi:10.1214/009053607000000505
Model comparison functions
compare(),
compare.group_tna(),
compare_sequences(),
plot.tna_sequence_comparison(),
plot_compare(),
plot_compare.group_tna(),
print.tna_comparison(),
print.tna_sequence_comparison()
model_x <- tna(head(group_regulation, 200)) model_y <- tna(tail(group_regulation, 200)) comp <- compare(model_x, model_y) plot(comp) plot(comp, type = "scatterplot", name_x = "High", name_y = "Low")model_x <- tna(head(group_regulation, 200)) model_y <- tna(tail(group_regulation, 200)) comp <- compare(model_x, model_y) plot(comp) plot(comp, type = "scatterplot", name_x = "High", name_y = "Low")
A two-panel visualization (the plot of Nestimate::markov_order_test()):
## S3 method for class 'tna_markov_order' plot(x, panel = "both", combined = TRUE, title = NULL, ...) ## S3 method for class 'group_tna_markov_order' plot(x, panel = "both", combined = TRUE, title = names(x), ...)## S3 method for class 'tna_markov_order' plot(x, panel = "both", combined = TRUE, title = NULL, ...) ## S3 method for class 'group_tna_markov_order' plot(x, panel = "both", combined = TRUE, title = names(x), ...)
x |
A |
panel |
A |
combined |
A |
title |
An optional |
... |
Must be empty: an unknown argument, such as a misspelled
|
Panel A: the log-likelihood, AIC, and BIC across the tested orders, with the order selected by the permutation tests (dashed line) and the order that minimizes BIC (dotted line) marked.
Panel B: the permutation null density of each order with the observed
as a vertical line, colored by rejection at level and
labelled with its p-value.
Uses the Okabe-Ito colorblind-safe palette.
A ggplot object for panel = "ic" or panel = "permutation".
For panel = "both", a named list of the two ggplot objects (ic,
permutation), invisibly, after drawing them side by side when
combined = TRUE. For a group_tna_markov_order object, the plots of
the groups are drawn one after another, and a list with the result for
each group is returned invisibly.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
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_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) mo <- markov_order(model, max_order = 2, iter = 50) plot(mo) plot(mo, panel = "ic")model <- tna(group_regulation) mo <- markov_order(model, max_order = 2, iter = 50) plot(mo) plot(mo, panel = "ic")
Plot the Significant Differences from a Permutation Test
## S3 method for class 'tna_permutation' plot(x, colors, posCol = "#009900", negCol = "red", edge_labels = TRUE, ...)## S3 method for class 'tna_permutation' plot(x, colors, posCol = "#009900", negCol = "red", edge_labels = TRUE, ...)
x |
A |
colors |
See |
posCol |
Color for plotting edges
the difference in edge weights is positive. See |
negCol |
Color for plotting edges when
the difference in edge weights is negative. See |
edge_labels |
A |
... |
Additional arguments passed to the permutation renderer of
|
A cograph_network object containing the significant edges
(and, when show_nonsig = TRUE, the non-significant edges) according to
the permutation test, invisibly.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model_x <- tna(head(group_regulation, 200)) model_y <- tna(tail(group_regulation, 200)) # Small number of iterations for CRAN perm <- permutation_test(model_x, model_y, iter = 20) plot(perm)model_x <- tna(head(group_regulation, 200)) model_y <- tna(tail(group_regulation, 200)) # Small number of iterations for CRAN perm <- permutation_test(model_x, model_y, iter = 20) plot(perm)
Plot Reliability Analysis Results
## S3 method for class 'tna_reliability' plot(x, type = "histogram", metric = "Median Abs. Diff.", bins = 30, ...)## S3 method for class 'tna_reliability' plot(x, type = "histogram", metric = "Median Abs. Diff.", bins = 30, ...)
x |
A |
type |
A |
metric |
A |
bins |
An |
... |
Ignored |
A ggplot object.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
# Small number of iterations for CRAN model <- tna(engagement) rel <- reliability(model, iter = 20) plot(rel)# Small number of iterations for CRAN model <- tna(engagement) rel <- reliability(model, iter = 20) plot(rel)
Visualize the differences in pattern counts by plotting the standardized residuals by pattern and group.
## S3 method for class 'tna_sequence_comparison' plot( x, n = 10, legend = TRUE, cells = TRUE, text_color = "white", digits = 2L, ... )## S3 method for class 'tna_sequence_comparison' plot( x, n = 10, legend = TRUE, cells = TRUE, text_color = "white", digits = 2L, ... )
x |
A |
n |
An |
legend |
A |
cells |
A |
text_color |
A |
digits |
An |
... |
Not used. |
A ggplot object.
Model comparison functions
compare(),
compare.group_tna(),
compare_sequences(),
plot.tna_comparison(),
plot_compare(),
plot_compare.group_tna(),
print.tna_comparison(),
print.tna_sequence_comparison()
# A small subset without the permutation test idx <- c(1:100, 1001:1100) group <- rep(c("High", "Low"), each = 100) comp <- compare_sequences(group_regulation[idx, ], group, test = FALSE) plot(comp) idx <- c(1:500, 1001:1500) group <- c(rep("High", 500), rep("Low", 500)) comp <- compare_sequences(group_regulation[idx, ], group) plot(comp)# A small subset without the permutation test idx <- c(1:100, 1001:1100) group <- rep(c("High", "Low"), each = 100) comp <- compare_sequences(group_regulation[idx, ], group, test = FALSE) plot(comp) idx <- c(1:500, 1001:1500) group <- c(rep("High", 500), rep("Low", 500)) comp <- compare_sequences(group_regulation[idx, ], group) plot(comp)
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).
## S3 method for class 'tna_stability' plot(x, level = 0.05, ...)## S3 method for class 'tna_stability' plot(x, level = 0.05, ...)
x |
A |
level |
A |
... |
Ignored. |
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.
A ggplot object displaying the stability analysis plot.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
print.group_tna_bootstrap(),
print.group_tna_permutation(),
print.group_tna_stability(),
print.summary.group_tna_bootstrap(),
print.summary.tna_bootstrap(),
print.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) cs <- estimate_cs(model, iter = 10) plot(cs)model <- tna(group_regulation) cs <- estimate_cs(model, iter = 10) plot(cs)
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.
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, timezone = "UTC", session = NULL )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, timezone = "UTC", session = NULL )
data |
A |
actor |
A |
time |
A |
action |
A |
order |
A |
time_threshold |
A positive |
custom_format |
A |
is_unix_time |
A |
unix_time_unit |
A |
unused_fn |
How to handle extra columns when pivoting to wide format.
See |
timezone |
An Olson time zone used to interpret timestamps that do not
contain an explicit UTC offset. Explicit offsets such as |
session |
An optional tidy selection of one or more columns identifying
explicit sessions within actors, such as a course or semester. When |
Session identity is based on observed combinations of the original
actor and session columns. Separator characters and high-cardinality
marginal levels therefore cannot merge distinct sessions. .session_id is
the collision-safe key and .session_label is its readable display label.
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.
time_data: Parsed timestamps in wide format when time is supplied,
or NULL otherwise.
statistics: A list containing summary statistics:
total_sessions, total_actions, max_sequence_length,
unique_users, sessions_per_user and actions_per_session (tibbles
with one row per user and per session), and time_range (when time
is supplied).
The statistics are also reported as messages while the data is
prepared. print.tna_data() prints the sequence data, the metadata, or
the long data.
Other data:
import_data(),
import_onehot(),
list_random_state_pools(),
print.tna_data(),
random_group_tna(),
random_tna(),
random_tna_mmm(),
simulate.group_tna(),
simulate.tna()
results <- prepare_data( group_regulation_long, actor = "Actor", time = "Time", action = "Action" ) print(results) print(results, data = "meta") # Custom order column 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) # No actor scenario leading to a single session 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) # Multiple actors data_multi_actor <- tibble::tibble( user = c("A", "A", "A", "A", "B", "B", "B", "B"), session = c(1, 1, 2, 2, 1, 1, 2, 2), action = c( "view", "click", "add_cart", "view", "checkout", "view", "click", "share" ) ) results_multi_actor <- prepare_data( data_multi_actor, actor = c("user", "session"), action = "action" ) print(results_multi_actor) print(results_multi_actor, data = "meta")results <- prepare_data( group_regulation_long, actor = "Actor", time = "Time", action = "Action" ) print(results) print(results, data = "meta") # Custom order column 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) # No actor scenario leading to a single session 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) # Multiple actors data_multi_actor <- tibble::tibble( user = c("A", "A", "A", "A", "B", "B", "B", "B"), session = c(1, 1, 2, 2, 1, 1, 2, 2), action = c( "view", "click", "add_cart", "view", "checkout", "view", "click", "share" ) ) results_multi_actor <- prepare_data( data_multi_actor, actor = c("user", "session"), action = "action" ) print(results_multi_actor) print(results_multi_actor, data = "meta")
group_tna ObjectPrint a group_tna Object
## S3 method for class 'group_tna' print(x, ...)## S3 method for class 'group_tna' print(x, ...)
x |
A |
... |
Arguments passed to |
x (invisibly).
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
model <- group_model(engagement_mmm) print(model)model <- group_model(engagement_mmm) print(model)
group_tna Bootstrap ResultsPrint group_tna Bootstrap Results
## S3 method for class 'group_tna_bootstrap' print(x, ...)## S3 method for class 'group_tna_bootstrap' print(x, ...)
x |
A |
... |
Arguments passed to |
x (invisibly).
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
plot.tna_stability(),
print.group_tna_permutation(),
print.group_tna_stability(),
print.summary.group_tna_bootstrap(),
print.summary.tna_bootstrap(),
print.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- group_model(engagement_mmm) # Low number of iteration for CRAN boot <- bootstrap(model, iter = 10) print(boot)model <- group_model(engagement_mmm) # Low number of iteration for CRAN boot <- bootstrap(model, iter = 10) print(boot)
Print Centrality Measures
## S3 method for class 'group_tna_centralities' print(x, ...)## S3 method for class 'group_tna_centralities' print(x, ...)
x |
A |
... |
Ignored. |
x (invisibly).
Centrality measure functions
betweenness_network(),
centralities(),
plot.group_tna_centralities(),
plot.tna_centralities(),
print.tna_centralities()
model <- group_model(engagement_mmm) cm <- centralities(model) print(cm)model <- group_model(engagement_mmm) cm <- centralities(model) print(cm)
Print Found Cliques
## S3 method for class 'group_tna_cliques' print(x, ...)## S3 method for class 'group_tna_cliques' print(x, ...)
x |
A |
... |
Arguments passed to |
x (invisibly).
Clique-related functions
cliques(),
plot.group_tna_cliques(),
plot.tna_cliques(),
print.tna_cliques()
model <- group_model(engagement_mmm) cliq <- cliques(model, size = 2) print(cliq)model <- group_model(engagement_mmm) cliq <- cliques(model, size = 2) print(cliq)
Print Detected Communities
## S3 method for class 'group_tna_communities' print(x, ...)## S3 method for class 'group_tna_communities' print(x, ...)
x |
A |
... |
Arguments passed to |
x (invisibly).
Community detection functions
communities(),
plot.group_tna_communities(),
plot.tna_communities(),
print.tna_communities()
model <- group_model(engagement_mmm) comm <- communities(model) print(comm)model <- group_model(engagement_mmm) comm <- communities(model) print(comm)
Print Permutation Test Results
## S3 method for class 'group_tna_permutation' print(x, ...)## S3 method for class 'group_tna_permutation' print(x, ...)
x |
A |
... |
Arguments passed to |
x (invisibly).
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
plot.tna_stability(),
print.group_tna_bootstrap(),
print.group_tna_stability(),
print.summary.group_tna_bootstrap(),
print.summary.tna_bootstrap(),
print.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- group_model(engagement_mmm) # Small number of iterations for CRAN perm <- permutation_test(model, iter = 20) print(perm)model <- group_model(engagement_mmm) # Small number of iterations for CRAN perm <- permutation_test(model, iter = 20) print(perm)
Print Centrality Stability Results
## S3 method for class 'group_tna_stability' print(x, ...)## S3 method for class 'group_tna_stability' print(x, ...)
x |
A |
... |
Arguments passed to |
x (invisibly).
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
plot.tna_stability(),
print.group_tna_bootstrap(),
print.group_tna_permutation(),
print.summary.group_tna_bootstrap(),
print.summary.tna_bootstrap(),
print.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
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)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
## S3 method for class 'summary.group_tna' print(x, ...)## S3 method for class 'summary.group_tna' print(x, ...)
x |
A |
... |
Arguments passed to the |
x (invisibly).
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
model <- group_model(engagement_mmm) print(summary(model))model <- group_model(engagement_mmm) print(summary(model))
Print a Bootstrap Summary for a Grouped Transition Network Model
## S3 method for class 'summary.group_tna_bootstrap' print(x, ...)## S3 method for class 'summary.group_tna_bootstrap' print(x, ...)
x |
A |
... |
Arguments passed to the generic |
x (invisibly).
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
plot.tna_stability(),
print.group_tna_bootstrap(),
print.group_tna_permutation(),
print.group_tna_stability(),
print.summary.tna_bootstrap(),
print.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- group_model(engagement_mmm) # Low number of iteration for CRAN boot <- bootstrap(model, iter = 10) print(summary(boot))model <- group_model(engagement_mmm) # Low number of iteration for CRAN boot <- bootstrap(model, iter = 10) print(summary(boot))
Print a TNA Summary
## S3 method for class 'summary.tna' print(x, ...)## S3 method for class 'summary.tna' print(x, ...)
x |
A |
... |
Ignored. |
A summary.tna object (invisibly) containing the TNA model network
metrics and values.
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
model <- tna(group_regulation) print(summary(model))model <- tna(group_regulation) print(summary(model))
Print a Bootstrap Summary
## S3 method for class 'summary.tna_bootstrap' print(x, ...)## S3 method for class 'summary.tna_bootstrap' print(x, ...)
x |
A |
... |
Arguments passed to the generic |
A summary.tna_bootstrap object (invisibly) containing the weight,
estimated p-value and confidence interval of each edge.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
plot.tna_stability(),
print.group_tna_bootstrap(),
print.group_tna_permutation(),
print.group_tna_stability(),
print.summary.group_tna_bootstrap(),
print.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) # Small number of iterations for CRAN boot <- bootstrap(model, iter = 10) print(summary(boot))model <- tna(group_regulation) # Small number of iterations for CRAN boot <- bootstrap(model, iter = 10) print(summary(boot))
Print a Summary of a Markov Order Test
## S3 method for class 'summary.tna_markov_order' print(x, digits = attr(x, "digits"), ...)## S3 method for class 'summary.tna_markov_order' print(x, digits = attr(x, "digits"), ...)
x |
A |
digits |
An |
... |
Ignored. |
x (invisibly).
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) summary(markov_order(model, max_order = 2, iter = 50))model <- tna(group_regulation) summary(markov_order(model, max_order = 2, iter = 50))
tna ObjectPrint a tna Object
## S3 method for class 'tna' print(x, generic = FALSE, ...)## S3 method for class 'tna' print(x, generic = FALSE, ...)
x |
A |
generic |
A |
... |
Additional arguments passed to the generic |
The tna object passed as argument x (invisibly).
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
model <- tna(group_regulation) print(model)model <- tna(group_regulation) print(model)
Print Bootstrap Results
## S3 method for class 'tna_bootstrap' print(x, digits = getOption("digits"), type = "both", ...)## S3 method for class 'tna_bootstrap' print(x, digits = getOption("digits"), type = "both", ...)
x |
A |
digits |
An |
type |
A |
... |
Ignored. |
x (invisibly).
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) # Small number of iterations for CRAN boot <- bootstrap(model, iter = 10) print(boot)model <- tna(group_regulation) # Small number of iterations for CRAN boot <- bootstrap(model, iter = 10) print(boot)
Print Centrality Measures
## S3 method for class 'tna_centralities' print(x, ...)## S3 method for class 'tna_centralities' print(x, ...)
x |
A |
... |
Ignored. |
x (invisibly).
Centrality measure functions
betweenness_network(),
centralities(),
plot.group_tna_centralities(),
plot.tna_centralities(),
print.group_tna_centralities()
model <- tna(group_regulation) cm <- centralities(model) print(cm)model <- tna(group_regulation) cm <- centralities(model) print(cm)
Print Found Cliques of a TNA Network
## S3 method for class 'tna_cliques' print(x, n = 6, first = 1, digits = getOption("digits"), ...)## S3 method for class 'tna_cliques' print(x, n = 6, first = 1, digits = getOption("digits"), ...)
x |
A |
n |
An |
first |
An |
digits |
An |
... |
Ignored. |
x (invisibly).
Clique-related functions
cliques(),
plot.group_tna_cliques(),
plot.tna_cliques(),
print.group_tna_cliques()
model <- tna(group_regulation) cliq <- cliques(model, size = 2) print(cliq)model <- tna(group_regulation) cliq <- cliques(model, size = 2) print(cliq)
Print the Results of Clustering
## S3 method for class 'tna_clustering' print(x, ...)## S3 method for class 'tna_clustering' print(x, ...)
x |
A |
... |
Additional arguments passed to the generic print method. |
x (invisibly).
Cluster-related functions
cluster_data(),
communities(),
group_model(),
mmm_stats(),
rename_groups()
data <- data.frame( T1 = c("A", "B", "A", "C", "A", "B"), T2 = c("B", "A", "B", "A", "C", "A"), T3 = c("C", "C", "A", "B", "B", "C") ) # PAM clustering with the Hamming distance (the defaults) result <- cluster_sequences(data, k = 2) print(result)data <- data.frame( T1 = c("A", "B", "A", "C", "A", "B"), T2 = c("B", "A", "B", "A", "C", "A"), T3 = c("C", "C", "A", "B", "B", "C") ) # PAM clustering with the Hamming distance (the defaults) result <- cluster_sequences(data, k = 2) print(result)
Print Detected Communities
## S3 method for class 'tna_communities' print(x, ...)## S3 method for class 'tna_communities' print(x, ...)
x |
A |
... |
Additional arguments passed to the generic |
x (invisibly).
Community detection functions
communities(),
plot.group_tna_communities(),
plot.tna_communities(),
print.group_tna_communities()
model <- tna(group_regulation) comm <- communities(model) print(comm)model <- tna(group_regulation) comm <- communities(model) print(comm)
Print Comparison Results
## S3 method for class 'tna_comparison' print(x, ...)## S3 method for class 'tna_comparison' print(x, ...)
x |
A |
... |
Additional arguments passed to the tibble |
x (invisibly).
Model comparison functions
compare(),
compare.group_tna(),
compare_sequences(),
plot.tna_comparison(),
plot.tna_sequence_comparison(),
plot_compare(),
plot_compare.group_tna(),
print.tna_sequence_comparison()
model_x <- tna(head(group_regulation, 200)) model_y <- tna(tail(group_regulation, 200)) comp <- compare(model_x, model_y) print(comp)model_x <- tna(head(group_regulation, 200)) model_y <- tna(tail(group_regulation, 200)) comp <- compare(model_x, model_y) print(comp)
Print a TNA Data Object
## S3 method for class 'tna_data' print(x, data = "sequence", ...)## S3 method for class 'tna_data' print(x, data = "sequence", ...)
x |
A |
data |
A |
... |
Arguments passed to the tibble |
x (invisibly).
Other data:
import_data(),
import_onehot(),
list_random_state_pools(),
prepare_data(),
random_group_tna(),
random_tna(),
random_tna_mmm(),
simulate.group_tna(),
simulate.tna()
res <- prepare_data( group_regulation_long, action = "Action", actor = "Actor", time = "Time" ) print(res, data = "sequence") print(res, data = "meta") print(res, data = "long")res <- prepare_data( group_regulation_long, action = "Action", actor = "Actor", time = "Time" ) print(res, data = "sequence") print(res, data = "meta") print(res, data = "long")
Print the Results of a Markov Order Test
## S3 method for class 'tna_markov_order' print(x, digits = 2L, ...) ## S3 method for class 'group_tna_markov_order' print(x, digits = 2L, ...)## S3 method for class 'tna_markov_order' print(x, digits = 2L, ...) ## S3 method for class 'group_tna_markov_order' print(x, digits = 2L, ...)
x |
A |
digits |
An |
... |
Ignored. |
x (invisibly).
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) markov_order(model, max_order = 2, iter = 50)model <- tna(group_regulation) markov_order(model, max_order = 2, iter = 50)
Print Permutation Test Results
## S3 method for class 'tna_permutation' print(x, ...)## S3 method for class 'tna_permutation' print(x, ...)
x |
A |
... |
Additional arguments passed to the |
x (invisibly).
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model_x <- tna(head(group_regulation, 200)) model_y <- tna(tail(group_regulation, 200)) # Small number of iterations for CRAN perm <- permutation_test(model_x, model_y, iter = 20) print(perm)model_x <- tna(head(group_regulation, 200)) model_y <- tna(tail(group_regulation, 200)) # Small number of iterations for CRAN perm <- permutation_test(model_x, model_y, iter = 20) print(perm)
Print Reliability Analysis Results
## S3 method for class 'tna_reliability' print(x, summary_metrics, ...)## S3 method for class 'tna_reliability' print(x, summary_metrics, ...)
x |
A |
summary_metrics |
A |
... |
Arguments passed to the generic |
x (invisibly).
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
# Small number of iterations for CRAN model <- tna(engagement) rel <- reliability(model, iter = 20) print(rel)# Small number of iterations for CRAN model <- tna(engagement) rel <- reliability(model, iter = 20) print(rel)
Print a Comparison of Sequences
## S3 method for class 'tna_sequence_comparison' print(x, ...)## S3 method for class 'tna_sequence_comparison' print(x, ...)
x |
A |
... |
Arguments passed to the generic |
x (invisibly).
Model comparison functions
compare(),
compare.group_tna(),
compare_sequences(),
plot.tna_comparison(),
plot.tna_sequence_comparison(),
plot_compare(),
plot_compare.group_tna(),
print.tna_comparison()
# A small subset (100 high and 100 low achievers) without the test sequences <- rbind(head(group_regulation, 100), tail(group_regulation, 100)) group <- rep(c("High", "Low"), each = 100) comp <- compare_sequences(sequences, group, test = FALSE) print(comp) # With the permutation test (small number of iterations for CRAN) sequences <- rbind(head(group_regulation, 500), tail(group_regulation, 500)) group <- rep(c("High", "Low"), each = 500) comp <- compare_sequences(sequences, group, sub = 2:3, iter = 20) print(comp)# A small subset (100 high and 100 low achievers) without the test sequences <- rbind(head(group_regulation, 100), tail(group_regulation, 100)) group <- rep(c("High", "Low"), each = 100) comp <- compare_sequences(sequences, group, test = FALSE) print(comp) # With the permutation test (small number of iterations for CRAN) sequences <- rbind(head(group_regulation, 500), tail(group_regulation, 500)) group <- rep(c("High", "Low"), each = 500) comp <- compare_sequences(sequences, group, sub = 2:3, iter = 20) print(comp)
Print Centrality Stability Results
## S3 method for class 'tna_stability' print(x, ...)## S3 method for class 'tna_stability' print(x, ...)
x |
A |
... |
Additional arguments passed to the generic |
x (invisibly).
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
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)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)
Prunes a network represented by a tna object by removing
edges based on a specified threshold, lowest percent of non-zero edge
weights, the disparity filter algorithm (Serrano et al., 2009), or
bootstrap significance.
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, ...)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, ...)
x |
An object of class |
... |
Arguments passed to |
method |
A |
threshold |
A |
lowest |
A |
level |
A |
boot |
A |
The available methods are:
"threshold": Removes the edges whose weight is at most threshold.
"lowest": Removes the edges whose weight is at most the lowest
quantile of the positive edge weights.
"disparity": Keeps the edges that are significant at level level
under the disparity filter of Serrano et al. (2009), either among the
outgoing edges of their source state or among the incoming edges of
their target state. Self-loops are always removed by this method.
"bootstrap": Keeps the edges that are significant in bootstrap()
(the model element of a tna_bootstrap object).
With "threshold" and "lowest", an edge is only removed when the
network stays weakly connected without it, so some edges below the
cut-off can be retained. The "disparity" and "bootstrap" methods do
not check the connectivity.
A pruned tna or group_tna object: the removed edges have
weight zero in weights, and the pruning is recorded in the attribute
pruning. Details on the pruning can be viewed with pruning_details().
The original model can be restored with deprune().
Serrano, M. A., Boguna, M., & Vespignani, A. (2009). Extracting the multiscale backbone of complex weighted networks. Proceedings of the National Academy of Sciences, 106(16), 6483–6488. doi:10.1073/pnas.0808904106
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
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)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
pruning_details(x, ...) ## S3 method for class 'tna' pruning_details(x, ...) ## S3 method for class 'group_tna' pruning_details(x, ...)pruning_details(x, ...) ## S3 method for class 'tna' pruning_details(x, ...) ## S3 method for class 'group_tna' pruning_details(x, ...)
x |
A |
... |
Ignored. |
The pruning method and the numbers of removed and retained edges
are printed. Invisibly, a data.frame of the removed edges with one row per
edge and the columns from, to, and weight if x is a tna object,
or a named list of such data.frame objects (one per cluster) in the
case of a group_tna object.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) pruned_threshold <- prune(model, method = "threshold", threshold = 0.1) pruning_details(pruned_threshold)model <- tna(group_regulation) pruned_threshold <- prune(model, method = "threshold", threshold = 0.1) pruning_details(pruned_threshold)
Construct a fully-functional group_tna object from synthetic parameters.
Each group receives its own randomly drawn transition matrix and initial
probabilities over a shared alphabet, so groups have heterogeneous
dynamics by default. Per-group overrides allow custom group sizes,
sparsity, stickiness, or hand-supplied transition matrices.
random_group_tna( n_groups = NULL, group_names = NULL, n_states = NULL, states = NULL, category = NULL, alpha = NULL, diag_boost = NULL, n_sequences = NULL, seq_length = NULL, type = "relative", per_group = NULL, seed = NULL )random_group_tna( n_groups = NULL, group_names = NULL, n_states = NULL, states = NULL, category = NULL, alpha = NULL, diag_boost = NULL, n_sequences = NULL, seq_length = NULL, type = "relative", per_group = NULL, seed = NULL )
n_groups |
An |
group_names |
An optional |
n_states |
An |
states |
An optional |
category |
An optional |
alpha |
A positive |
diag_boost |
A non-negative |
n_sequences |
An |
seq_length |
An |
type |
A |
per_group |
An optional |
seed |
An |
A group_tna object: a named list with one tna object per
group (see group_model()).
Other data:
import_data(),
import_onehot(),
list_random_state_pools(),
prepare_data(),
print.tna_data(),
random_tna(),
random_tna_mmm(),
simulate.group_tna(),
simulate.tna()
# Fresh random group model on every call model <- random_group_tna() # Explicit two-group engagement demo with per-group differences model <- random_group_tna( n_groups = 2, n_states = 3, category = "engagement", per_group = list( list(n_sequences = 400, diag_boost = 3), list(n_sequences = 100, alpha = 0.3) ), seed = 42 )# Fresh random group model on every call model <- random_group_tna() # Explicit two-group engagement demo with per-group differences model <- random_group_tna( n_groups = 2, n_states = 3, category = "engagement", per_group = list( list(n_sequences = 400, diag_boost = 3), list(n_sequences = 100, alpha = 0.3) ), seed = 42 )
Construct a fully-functional tna object from synthetic parameters
without needing pre-existing sequence data. Random transition probabilities
are drawn from a Dirichlet distribution, sequences are simulated from the
resulting model, and a canonical tna object is fitted on those sequences.
Calling random_tna() with no arguments returns a fresh, sticky network
with a coherent alphabet, drawn fresh on every call.
random_tna( n_states = NULL, states = NULL, category = NULL, alpha = NULL, diag_boost = NULL, trans_matrix = NULL, init_probs = NULL, n_sequences = NULL, seq_length = NULL, type = "relative", return_params = FALSE, seed = NULL )random_tna( n_states = NULL, states = NULL, category = NULL, alpha = NULL, diag_boost = NULL, trans_matrix = NULL, init_probs = NULL, n_sequences = NULL, seq_length = NULL, type = "relative", return_params = FALSE, seed = NULL )
n_states |
An |
states |
An optional |
category |
An optional |
alpha |
A positive |
diag_boost |
A non-negative |
trans_matrix |
An optional square |
init_probs |
An optional |
n_sequences |
An |
seq_length |
An |
type |
A |
return_params |
A |
seed |
An |
A tna object, or, when return_params = TRUE, a list with
the elements model (the tna object), trans_matrix (the true
transition matrix), init_probs (the true initial probabilities),
sequences (the simulated sequences as a wide data.frame), labels
(the state labels), and category (the label pool used).
Other data:
import_data(),
import_onehot(),
list_random_state_pools(),
prepare_data(),
print.tna_data(),
random_group_tna(),
random_tna_mmm(),
simulate.group_tna(),
simulate.tna()
# Fresh random model on every call model <- random_tna() # Explicit small-state demo using the engagement pool model <- random_tna(n_states = 3, category = "engagement") # Reproducible model model <- random_tna(seed = 42) # Recover the ground-truth parameters along with the model out <- random_tna(seed = 7, return_params = TRUE) str(out, max.level = 1)# Fresh random model on every call model <- random_tna() # Explicit small-state demo using the engagement pool model <- random_tna(n_states = 3, category = "engagement") # Reproducible model model <- random_tna(seed = 42) # Recover the ground-truth parameters along with the model out <- random_tna(seed = 7, return_params = TRUE) str(out, max.level = 1)
Construct a synthetic tna_mmm object that mirrors the structure a
fitted seqHMM mixed Markov model exposes to tna without depending on
seqHMM at runtime. The returned object can be passed to
group_model() (dispatching via group_model.tna_mmm) and to
mmm_stats() (dispatching via mmm_stats.tna_mmm).
Real seqHMM mhmm objects continue to dispatch via the original
*.mhmm methods.
random_tna_mmm( n_clusters = NULL, n_states = NULL, states = NULL, category = NULL, alpha = NULL, diag_boost = NULL, n_sequences = NULL, seq_length = NULL, n_covariates = 1L, seed = NULL )random_tna_mmm( n_clusters = NULL, n_states = NULL, states = NULL, category = NULL, alpha = NULL, diag_boost = NULL, n_sequences = NULL, seq_length = NULL, n_covariates = 1L, seed = NULL )
n_clusters |
An |
n_states |
An |
states |
An optional |
category |
An optional |
alpha |
A positive |
diag_boost |
A non-negative |
n_sequences |
An |
seq_length |
An |
n_covariates |
An |
seed |
An |
An object of class tna_mmm containing fields
observations, transition_probs, initial_probs, coefficients,
vcov, most_probable_cluster, cluster_names, state_names,
n_clusters, n_states, n_sequences, n_covariates.
Other data:
import_data(),
import_onehot(),
list_random_state_pools(),
prepare_data(),
print.tna_data(),
random_group_tna(),
random_tna(),
simulate.group_tna(),
simulate.tna()
model <- random_tna_mmm(seed = 1) mmm_stats(model) grp <- group_model(model)model <- random_tna_mmm(seed = 1) mmm_stats(model) grp <- group_model(model)
Performs reliability analysis and outputs a concise summary of key metrics. The results can also be visualized.
reliability(x, ...) ## S3 method for class 'tna' reliability( x, types = NULL, split = 0.5, iter = 1000, scaling = "none", actor = NULL, ... )reliability(x, ...) ## S3 method for class 'tna' reliability( x, types = NULL, split = 0.5, iter = 1000, scaling = "none", actor = NULL, ... )
x |
A |
... |
Ignored. |
types |
A |
split |
A |
iter |
An |
scaling |
A |
actor |
An optional actor identifier for sequences nested in actors:
a |
A tna_reliability object, which is a list with two tibbles:
metrics: One row per split and comparison metric, with the columns
category, metric, and value (and model_type when several
types are given).
summary: One row per metric with the mean, sd, median, min,
max, and quartiles (q25, q75) of the metric over the splits.
summary.tna_reliability() returns all metrics with their category as
a tidy table.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
# Small number of iterations for CRAN model <- tna(engagement) rel <- reliability(model, iter = 20)# Small number of iterations for CRAN model <- tna(engagement) rel <- reliability(model, iter = 20)
Rename Groups
rename_groups(x, new_names)rename_groups(x, new_names)
x |
A |
new_names |
A |
The group_tna object x with its elements (groups) renamed to
new_names.
Cluster-related functions
cluster_data(),
communities(),
group_model(),
mmm_stats(),
print.tna_clustering()
model <- group_model(engagement_mmm) model_renamed <- rename_groups(model, c("A", "B", "C"))model <- group_model(engagement_mmm) model_renamed <- rename_groups(model, c("A", "B", "C"))
Restore Previous Pruning of a Transition Network Analysis Model
reprune(x, ...) ## S3 method for class 'tna' reprune(x, ...) ## S3 method for class 'group_tna' reprune(x, ...)reprune(x, ...) ## S3 method for class 'tna' reprune(x, ...) ## S3 method for class 'group_tna' reprune(x, ...)
x |
A |
... |
Ignored. |
A tna or group_tna object with the previous pruning of a
model restored with deprune() applied again.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
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 pruningmodel <- 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
The stats::simulate() generic is re-exported so that the
simulate.tna() and simulate.group_tna() methods provided by this
package are dispatched correctly when the user only loads tna.
See the method-specific help pages for argument and return details.
simulate(object, nsim = 1, seed = NULL, ...)simulate(object, nsim = 1, seed = NULL, ...)
object |
A statistical model object. The |
nsim |
An |
seed |
An |
... |
Further arguments passed to the dispatched method. |
The value returned by the dispatched method (a data.frame of
simulated sequences for tna and group_tna objects). See the
method-specific help pages for details.
model <- tna(group_regulation) sim <- simulate(model, nsim = 5, max_len = 10)model <- tna(group_regulation) sim <- simulate(model, nsim = 5, max_len = 10)
Simulate Data from a Group Transition Network Analysis Model
## S3 method for class 'group_tna' simulate( object, nsim = 1, seed = NULL, max_len = 100L, na_range = c(0L, 0L), zero_row = "self", format = "wide", ... )## S3 method for class 'group_tna' simulate( object, nsim = 1, seed = NULL, max_len = 100L, na_range = c(0L, 0L), zero_row = "self", format = "wide", ... )
object |
A |
nsim |
An |
seed |
an object specifying if and how the random number
generator should be initialized (‘seeded’). |
max_len |
An |
na_range |
An |
zero_row |
A |
format |
A |
... |
Ignored. |
A data.frame of the simulated sequence data, as for
simulate.tna(), with the group of each sequence in the first column
group.
Other data:
import_data(),
import_onehot(),
list_random_state_pools(),
prepare_data(),
print.tna_data(),
random_group_tna(),
random_tna(),
random_tna_mmm(),
simulate.tna()
model <- group_tna( group_regulation, group = rep(c("High", "Low"), each = 1000) ) sim <- simulate(model, nsim = 10, max_len = 10)model <- group_tna( group_regulation, group = rep(c("High", "Low"), each = 1000) ) sim <- simulate(model, nsim = 10, max_len = 10)
Simulate Data from a Transition Network Analysis Model
## S3 method for class 'tna' simulate( object, nsim = 1, seed = NULL, max_len = 100L, na_range = c(0L, 0L), zero_row = "self", format = "wide", ... )## S3 method for class 'tna' simulate( object, nsim = 1, seed = NULL, max_len = 100L, na_range = c(0L, 0L), zero_row = "self", format = "wide", ... )
object |
A |
nsim |
An |
seed |
an object specifying if and how the random number
generator should be initialized (‘seeded’). |
max_len |
An |
na_range |
An |
zero_row |
A |
format |
A |
... |
Ignored. |
A data.frame of the simulated sequence data. In wide format,
one row per sequence and one column per time point (T1, T2, ...).
In long format, one row per observation with the columns id,
time, and state.
Other data:
import_data(),
import_onehot(),
list_random_state_pools(),
prepare_data(),
print.tna_data(),
random_group_tna(),
random_tna(),
random_tna_mmm(),
simulate.group_tna()
model <- tna(group_regulation) sim <- simulate(model, nsim = 10, max_len = 10, seed = 1) print(sim)model <- tna(group_regulation) sim <- simulate(model, nsim = 10, max_len = 10, seed = 1) print(sim)
Build a Social Network Analysis Model
sna(x, aggregate = sum, ...)sna(x, aggregate = sum, ...)
x |
A |
aggregate |
A |
... |
Additional arguments passed to |
A tna object representing the model. Its weights element is a
square matrix with one row and column per state, holding the
aggregated weight of each pair of states (zero when the pair does not
occur). The inits and data elements are NULL.
set.seed(123) states <- c("A", "B", "C", "D") d <- data.frame( from = sample(states, 100, replace = TRUE), to = sample(states, 100, replace = TRUE), weight = rexp(100) ) model <- sna(d)set.seed(123) states <- c("A", "B", "C", "D") d <- data.frame( from = sample(states, 100, replace = TRUE), to = sample(states, 100, replace = TRUE), weight = rexp(100) ) model <- sna(d)
This function calculates a variety of network metrics for each network
of a group_tna object. It computes key metrics such as node and edge
counts, network density, mean distance, strength measures, degree
centrality, and reciprocity.
## S3 method for class 'group_tna' summary(object, combined = TRUE, ...)## S3 method for class 'group_tna' summary(object, combined = TRUE, ...)
object |
A |
combined |
A |
... |
Ignored. |
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).
A summary.group_tna object. When combined = TRUE, a tibble
with one row per metric (see summary.tna()), the column metric, and
one column of values per cluster. When combined = FALSE, a named
list with the summary.tna() table of each cluster.
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
group <- c(rep("High", 1000), rep("Low", 1000)) model <- group_model(group_regulation, group = group) summary(model)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
## S3 method for class 'group_tna_bootstrap' summary(object, ...)## S3 method for class 'group_tna_bootstrap' summary(object, ...)
object |
A |
... |
Ignored. |
A summary.group_tna_bootstrap object, which is a data.frame
with the columns of summary.tna_bootstrap() preceded by the column
group: one row per cluster and edge with a positive weight.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- group_tna(engagement_mmm) # Small number of iterations for CRAN boot <- bootstrap(model, iter = 10) summary(boot)model <- group_tna(engagement_mmm) # Small number of iterations for CRAN boot <- bootstrap(model, iter = 10) summary(boot)
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.
## S3 method for class 'tna' summary(object, ...)## S3 method for class 'tna' summary(object, ...)
object |
A |
... |
Ignored. |
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.tna object, which is a tibble with one row per metric
(13 rows) and the columns metric (the name of the metric, for example
"Node Count" or "Reciprocity") and value.
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
model <- tna(group_regulation) summary(model)model <- tna(group_regulation) summary(model)
Summarize Bootstrap Results
## S3 method for class 'tna_bootstrap' summary(object, ...)## S3 method for class 'tna_bootstrap' summary(object, ...)
object |
A |
... |
Ignored. |
A summary.tna_bootstrap object, which is a data.frame with one
row per edge with a positive weight and the columns from, to,
weight, p_value, sig (p_value < level), cr_lower, cr_upper
(the consistency range), ci_lower, and ci_upper (the bootstrap
confidence interval).
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) # Small number of iterations for CRAN boot <- bootstrap(model, iter = 50) summary(boot)model <- tna(group_regulation) # Small number of iterations for CRAN boot <- bootstrap(model, iter = 50) summary(boot)
Summarize a Markov Order Test
## S3 method for class 'tna_markov_order' summary(object, digits = 2L, ...) ## S3 method for class 'group_tna_markov_order' summary(object, digits = 2L, ...)## S3 method for class 'tna_markov_order' summary(object, digits = 2L, ...) ## S3 method for class 'group_tna_markov_order' summary(object, digits = 2L, ...)
object |
A |
digits |
An |
... |
Ignored. |
A summary.tna_markov_order object, which is a data.frame with
one row per order (and per group, in the first column group, for a
group_tna_markov_order object) and the columns of the stats element
described in markov_order(). The numeric columns other than the
p-values are rounded to digits decimals. When the order selected by
the tests and the orders selected by AIC and BIC disagree, a note is
printed below the table.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_permutation(),
summary.tna_reliability(),
summary.tna_stability()
model <- tna(group_regulation) summary(markov_order(model, max_order = 2, iter = 50))model <- tna(group_regulation) summary(markov_order(model, max_order = 2, iter = 50))
Returns the results of a permutation test as a tidy table, for the edges or for the centrality measures.
## S3 method for class 'tna_permutation' summary(object, what = "edges", digits = 2L, ...) ## S3 method for class 'group_tna_permutation' summary(object, what = "edges", digits = 2L, ...)## S3 method for class 'tna_permutation' summary(object, what = "edges", digits = 2L, ...) ## S3 method for class 'group_tna_permutation' summary(object, what = "edges", digits = 2L, ...)
object |
A |
what |
A |
digits |
An |
... |
Ignored. |
A data.frame with one row per edge, or per state and centrality
measure, and per pair of groups (in the first column pair) for a
group_tna_permutation object. For the edges, the columns are from,
to, diff_true (the observed difference in the edge weight),
effect_size (the difference divided by the standard deviation of the
permuted differences, NA when they do not vary), and p_value. For
the centralities, state and centrality replace from and to.
An error of class tna_error_permutation is raised when
what = "centralities" and the test was run without measures.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_reliability(),
summary.tna_stability()
model <- group_model(engagement_mmm) # Small number of iterations for CRAN perm <- permutation_test(model, iter = 20, measures = "InStrength") summary(perm) summary(perm, what = "centralities")model <- group_model(engagement_mmm) # Small number of iterations for CRAN perm <- permutation_test(model, iter = 20, measures = "InStrength") summary(perm) summary(perm, what = "centralities")
Returns every metric of a split-half reliability analysis as a tidy
table. print() shows four of them.
## S3 method for class 'tna_reliability' summary(object, ...)## S3 method for class 'tna_reliability' summary(object, ...)
object |
A |
... |
Ignored. |
A data.frame with one row per metric (and per model type, in
the column model_type, when reliability() was run with several
types). The columns are category (the kind of metric: weight
deviations, correlations, dissimilarities, similarities, or pattern
similarities), metric, and the mean, sd, median, min, max,
and quartiles (q25, q75) of the metric over the splits.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_stability()
# Small number of iterations for CRAN rel <- reliability(tna(engagement), iter = 20) summary(rel)# Small number of iterations for CRAN rel <- reliability(tna(engagement), iter = 20) summary(rel)
Summarize Case-Dropping Stability Results
## S3 method for class 'tna_stability' summary(object, ...) ## S3 method for class 'group_tna_stability' summary(object, ...)## S3 method for class 'tna_stability' summary(object, ...) ## S3 method for class 'group_tna_stability' summary(object, ...)
object |
A |
... |
Ignored. |
A data.frame with one row per centrality measure (and Edges,
when the edge weights were assessed), and per group in the first column
group for a group_tna_stability object, with the columns measure
and cs_coefficient.
Validation functions
bootstrap(),
deprune(),
estimate_cs(),
markov_order(),
permutation_test(),
permutation_test.group_tna(),
plot.group_tna_bootstrap(),
plot.group_tna_permutation(),
plot.group_tna_stability(),
plot.tna_bootstrap(),
plot.tna_markov_order(),
plot.tna_permutation(),
plot.tna_reliability(),
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.summary.tna_markov_order(),
print.tna_bootstrap(),
print.tna_markov_order(),
print.tna_permutation(),
print.tna_reliability(),
print.tna_stability(),
prune(),
pruning_details(),
reliability(),
reprune(),
summary.group_tna_bootstrap(),
summary.tna_bootstrap(),
summary.tna_markov_order(),
summary.tna_permutation(),
summary.tna_reliability()
# A small subset and few iterations small <- estimate_cs( tna(head(group_regulation, 200)), drop_prop = c(0.3, 0.6), measures = "InStrength", iter = 5, edges = TRUE ) summary(small) model <- tna(group_regulation) # Small number of iterations and drop proportions for CRAN stability <- estimate_cs( model, drop_prop = seq(0.3, 0.9, by = 0.2), measures = "InStrength", iter = 10, edges = TRUE ) summary(stability)# A small subset and few iterations small <- estimate_cs( tna(head(group_regulation, 200)), drop_prop = c(0.3, 0.6), measures = "InStrength", iter = 5, edges = TRUE ) summary(small) model <- tna(group_regulation) # Small number of iterations and drop proportions for CRAN stability <- estimate_cs( model, drop_prop = seq(0.3, 0.9, by = 0.2), measures = "InStrength", iter = 10, edges = TRUE ) summary(stability)