View source: R/centrality_stability.R
| centrality_stability | R Documentation |
Estimates the stability of centrality indices under case-dropping.
For each drop proportion, sequences are randomly removed and the
network is re-estimated. The correlation between the original and
subset centrality values is computed. The CS-coefficient is the
maximum proportion of cases that can be dropped while maintaining
a correlation above threshold in at least certainty
of bootstrap samples.
For transition methods, uses pre-computed per-sequence count matrices for fast resampling. Strength centralities (InStrength, OutStrength) are computed directly from the matrix without igraph.
centrality_stability(
x,
measures = c("InStrength", "OutStrength", "Betweenness"),
iter = 1000L,
drop_prop = seq(0.1, 0.9, by = 0.1),
threshold = 0.7,
certainty = 0.95,
method = "pearson",
centrality_fn = NULL,
loops = FALSE,
seed = NULL
)
x |
A |
measures |
Character vector. Centrality measures to assess.
Built-in: |
iter |
Integer. Number of bootstrap iterations per drop proportion (default: 1000). |
drop_prop |
Numeric vector. Proportions of cases to drop
(default: |
threshold |
Numeric. Minimum correlation to consider stable (default: 0.7). |
certainty |
Numeric. Required proportion of iterations above threshold (default: 0.95). |
method |
Character. Correlation method: |
centrality_fn |
Optional function. A custom centrality function
that takes a weight matrix and returns a named list of centrality
vectors. When |
loops |
Logical. If |
seed |
Integer or NULL. RNG seed for reproducibility. |
An object of class "net_stability" containing:
Named numeric vector of CS-coefficients per measure.
Named list of matrices (iter x n_prop) of correlation values per measure.
Character vector of measures assessed.
Drop proportions used.
Stability threshold.
Required certainty level.
Number of iterations.
Correlation method.
build_network, network_reliability
net <- build_network(data.frame(V1 = c("A","B","C","A"),
V2 = c("B","C","A","B")), method = "relative")
cs <- centrality_stability(net, iter = 10, drop_prop = 0.3)
seqs <- data.frame(
V1 = sample(LETTERS[1:4], 30, TRUE), V2 = sample(LETTERS[1:4], 30, TRUE),
V3 = sample(LETTERS[1:4], 30, TRUE), V4 = sample(LETTERS[1:4], 30, TRUE)
)
net <- build_network(seqs, method = "relative")
cs <- centrality_stability(net, iter = 100, seed = 42,
measures = c("InStrength", "OutStrength"))
print(cs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.