Converts a cluster_summary object to proper tna objects that can be
used with all functions from the tna package. Creates both a between-cluster
tna model (cluster-level transitions) and within-cluster tna models (internal
transitions within each cluster).
Arguments
- x
A
cluster_summaryobject created bycluster_summary. The cluster_summary should typically be created withtype = "tna"to ensure row-normalized transition probabilities. If created withtype = "raw", the raw counts will be passed totna::tna()which will normalize them.
Value
A cluster_tna object (S3 class) containing:
- between
A tna object representing cluster-level transitions. Contains
$weights(k x k transition matrix),$inits(initial distribution), and$labels(cluster names). Use this for analyzing how learners/entities move between high-level groups or phases.- within
Named list of tna objects, one per cluster. Each tna object represents internal transitions within that cluster. Contains
$weights(n_i x n_i matrix),$inits(initial distribution), and$labels(node labels). Clusters with single nodes or zero-row nodes are excluded (tna requires positive row sums).
A netobject_group with data preserved from each sub-network.
A tna object constructed from the input.
Details
This is the final step in the MCML workflow, enabling full integration with the tna package for centrality analysis, bootstrap validation, permutation tests, and visualization.
Requirements
The tna package must be installed. If not available, the function throws an error with installation instructions.
Workflow
# Full MCML workflow
net <- build_network(data, method = "relative")
net$nodes$clusters <- group_assignments
cs <- cluster_summary(net, type = "tna")
tna_models <- as_tna(cs)
# Now use tna package functions
plot(tna_models$macro)
tna::centralities(tna_models$macro)
tna::bootstrap(tna_models$macro, iter = 1000)
# Analyze within-cluster patterns
plot(tna_models$clusters$ClusterA)
tna::centralities(tna_models$clusters$ClusterA)See also
cluster_summary to create the input object,
plot() for visualization without conversion,
tna::tna for the underlying tna constructor
Examples
mat <- matrix(runif(36), 6, 6)
rownames(mat) <- colnames(mat) <- LETTERS[1:6]
clusters <- list(G1 = c("A", "B"), G2 = c("C", "D"), G3 = c("E", "F"))
cs <- cluster_summary(mat, clusters, type = "tna")
tna_models <- as_tna(cs)
tna_models
#> Group Networks (4 groups)
#> macro: 3 nodes, 6 edges
#> G1: 2 nodes, 2 edges
#> G2: 2 nodes, 2 edges
#> G3: 2 nodes, 2 edges
tna_models$macro$weights
#> G1 G2 G3
#> G1 0.3605522 0.3496602 0.2897876
#> G2 0.2108219 0.3460607 0.4431174
#> G3 0.4029241 0.2495898 0.3474861