View source: R/fit-distribution.R
| fit_degree_distribution | R Documentation |
Fits one or more statistical distributions to the degree sequence of a network via maximum likelihood estimation and evaluates goodness-of-fit using Kolmogorov-Smirnov tests. Returns a comparison table sorted by AIC.
fit_degree_distribution(
x,
distributions = NULL,
mode = "all",
directed = NULL,
xmin = NULL,
...
)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
distributions |
Character vector of distributions to fit. Options:
|
mode |
For directed networks: |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
xmin |
Minimum degree to include in fitting. For power-law, NULL triggers automatic estimation (Clauset et al. 2009 via igraph). For other distributions, NULL defaults to 1. |
... |
Additional arguments (currently unused). |
Power-law (Pareto Type I): P(k) \sim k^{-\alpha}. When igraph is
available, uses igraph::fit_power_law() implementing the Clauset
et al. (2009) method. Otherwise, computes the simple MLE:
\alpha = 1 + n / \sum \log(k / k_{min}).
Exponential: P(k) \sim e^{-\lambda k}. MLE:
\lambda = 1 / \bar{k}.
Poisson: P(k) \sim \lambda^k e^{-\lambda} / k!. MLE:
\lambda = \bar{k}. Note: the KS test uses a continuous approximation
for a discrete distribution; p-values are approximate.
Geometric: P(k) \sim (1-p)^k p. MLE:
p = 1 / (1 + \bar{k}).
An object of class "cograph_degree_fit" containing:
Named list, one entry per distribution, each with:
distribution, parameters (named list of fitted params),
loglik, aic, bic, ks_stat, ks_p.
Data frame sorted by AIC with columns:
distribution, aic, bic, ks_stat,
ks_p.
Name of the best-fitting distribution (lowest AIC).
The degree vector used for fitting.
Clauset, A., Shalizi, C. R., & Newman, M. E. J. (2009). Power-law distributions in empirical data. SIAM Review, 51(4), 661–703.
degree_distribution, centrality
adj <- matrix(c(0, 1, 1, 0, 0,
1, 0, 1, 1, 0,
1, 1, 0, 1, 1,
0, 1, 1, 0, 1,
0, 0, 1, 1, 0), 5, 5, byrow = TRUE)
rownames(adj) <- colnames(adj) <- LETTERS[1:5]
fit <- cograph::fit_degree_distribution(adj,
distributions = c("exponential", "poisson"))
print(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.