View source: R/damping_sensitivity.R
| damping_sensitivity | R Documentation |
Runs [pagerank()] at each damping factor \alpha in
'alphas' and returns a tidy data frame of per-URL scores alongside the
convergence metadata for each solve. This makes the sensitivity of the
ranking to \alpha directly inspectable on *your* graph, rather than
relying on the field default of '0.85' (see the "Damping factor" section of
[pagerank()] for why that default is only an empirical convention).
damping_sensitivity(edge_list_df, alphas = c(0.75, 0.8, 0.85, 0.9, 0.95), ...)
edge_list_df |
A data frame representing the edge list, passed to every [pagerank()] call. (Named for consistency with the rest of the package; it is an edge list, not a constructed graph object.) |
alphas |
Numeric vector of damping factors to sweep, each strictly between 0 and 1. Default 'c(0.75, 0.80, 0.85, 0.90, 0.95)'. Duplicate values are dropped. |
... |
Additional arguments forwarded to [pagerank()] (e.g. 'redirects_df', 'weight_col', 'algo', 'eps', 'niter', 'prior_df'). Passing 'damping' here is an error, since 'alphas' is what drives the damping factor. |
The helper is the empirical companion to the closed-form
\alpha-derivative analysis of Boldi, Santini & Vigna (PageRank as
a Function of the Damping Factor, WWW 2005): instead of differentiating the
PageRank vector with respect to \alpha analytically, it samples the
vector at a grid of \alpha values so you can see how much each page's
score (and the overall ranking) actually moves. Pair it with
[compare_pagerank()] to quantify the rank churn between any two \alpha
values.
Each row also carries the convergence metadata for that \alpha's solve.
The empirical 'iters' count is only reported by the ARPACK solver; under the
default PRPACK direct solver it is 'NA' (PRPACK exposes no iteration count).
To populate it, forward 'algo = "arpack"' (or an 'eps' / 'niter' control)
through '...'. The solver-independent 'iters_estimate' column is always
populated: it is the power-iteration rule of thumb
\lceil \log_{10}(\tau) / \log_{10}(\alpha) \rceil (Langville & Meyer,
2004) at the convergence tolerance \tau, and shows how the required
iteration count climbs as \alpha approaches 1 regardless of solver.
A tidy data frame with one row per (URL, \alpha) pair, sorted
by 'alpha' ascending then 'score' descending, with columns:
Node / page identifier.
The damping factor used for this solve.
The page's PageRank score at this 'alpha'.
Iterations the solver used (ARPACK only; 'NA' under PRPACK).
Power-iteration iteration-count estimate at the convergence tolerance (solver-independent).
Post-hoc L1 residual \|G x - x\|_1 of the solve.
Whether the residual met the tolerance.
A '"convergence"' attribute is attached: a compact one-row-per-'alpha' data frame ('alpha', 'algo', 'iters', 'iters_estimate', 'residual', 'tol', 'converged', 'n_nodes') summarizing each solve.
[pagerank()] (the "Damping factor" section), [pagerank_convergence], [compare_pagerank()], [pagerank_grid()]
edges <- data.frame(
from = c("A", "B", "C", "A", "D"),
to = c("B", "C", "A", "C", "A")
)
sens <- damping_sensitivity(edges, clean_edge_urls = FALSE)
print(sens)
attr(sens, "convergence")
# Populate the empirical iteration count by using the ARPACK solver.
sens_ar <- suppressMessages(
damping_sensitivity(edges, algo = "arpack", clean_edge_urls = FALSE)
)
attr(sens_ar, "convergence")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.