View source: R/cluster-metrics.R
| csum | R Documentation |
Aggregates node-level network weights to cluster-level summaries. The result holds the macro (cluster-to-cluster) network and one network of within-cluster connections per cluster.
csum(
x,
clusters = NULL,
method = c("sum", "mean", "median", "max", "min", "density", "geomean"),
type = c("tna", "cooccurrence", "semi_markov", "raw"),
directed = TRUE,
compute_within = TRUE
)
x |
Network input. Accepts multiple formats:
|
clusters |
Cluster/group assignments for nodes. Accepts multiple formats:
|
method |
Aggregation method for combining edge weights within/between
clusters. Zero and
|
type |
Post-processing applied to aggregated weights. Determines the interpretation of the resulting matrices:
|
directed |
Logical. Default |
compute_within |
Logical. If |
The function is the matrix-based entry point to Multi-Cluster Multi-Level
(MCML) analysis. as_tna converts the result to tna models.
A typical MCML analysis computes the summary, then plots it with
plot_mcml or converts it to tna models with
as_tna:
cs <- csum(net, clusters = clusters, type = "tna") plot_mcml(cs) as_tna(cs)
The macro weight matrix has clusters as both rows and columns. An
off-diagonal cell (i, j) holds the aggregated weight from cluster i to
cluster j. A diagonal cell (i, i) holds the aggregated weight of the edges
inside cluster i. When type = "tna", rows sum to 1 and the diagonal
is the probability of staying inside the same cluster.
| Input data | Recommended | Reason |
| Edge counts | method="sum", type="tna" | Preserves total flow, normalizes to probabilities |
| Transition matrix | method="mean", type="tna" | Avoids cluster size bias |
| Frequencies | method="sum", type="raw" | Keep raw counts for analysis |
| Correlation matrix | method="mean", type="raw" | Average correlations |
A cluster_summary object (S3 class) containing:
A tna object representing the macro (cluster-level) network:
k x k matrix of cluster-to-cluster weights, where k is
the number of clusters. Row i, column j contains the aggregated
weight from cluster i to cluster j. The diagonal contains the
aggregated within-cluster weight, node self-loops included.
Processing depends on type.
Named numeric vector of length k, the column sums of
the aggregated cluster matrix (before type processing)
divided by their total. It is uniform when all weights are zero.
Cluster names.
Sequence data of a tna input, otherwise NULL.
A group_tna list with one tna object per
cluster, each containing:
n_i x n_i matrix for nodes inside that cluster. Shows internal transitions between nodes in the same cluster.
Column sums of the within-cluster weights divided by their total.
NULL if compute_within = FALSE.
Named list mapping cluster names to their member node labels.
Example: list(A = c("n1", "n2"), B = c("n3", "n4", "n5"))
List of metadata:
The type argument used ("tna", "raw", etc.)
The method argument used ("sum", "mean", etc.)
Logical, effective directedness of the stored
weights (FALSE when type = "cooccurrence", which
symmetrizes them)
Total number of nodes in original network
Number of clusters
Named vector of cluster sizes
as_tna to convert results to tna objects,
plot_mcml for two-layer visualization,
plot_mtna for flat cluster visualization
clusters <- list(C1 = c("Explore", "Reflect", "Discuss"),
C2 = c("Plan", "Create", "Share"),
C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate"))
csum(regulation_net, clusters = clusters, type = "tna")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.