View source: R/magnitude_difference.R
| magnitude_difference | R Documentation |
Quantifies, per edge, how much row-normalization moves a transition
network between its two natural summaries: raw transition counts
(frequency / FTNA, build_network(method = "frequency")) and
row-conditional probabilities (TNA, build_network(method = "relative")).
The two matrices rank edges differently - an edge that is large in counts
can be modest in probability, and a rare-source edge can dominate its row
in probability. The per-edge discrepancy on a common scale is the
magnitude difference.
magnitude_difference(
data,
actor = "Actor",
action = "Action",
time = NULL,
metric = c("abs_diff", "chord_dist", "atanh_diff", "geom_norm_diff", "cv_inflation"),
scale = c("tna_range", "rank_minmax", "minmax", "none"),
format = c("auto", "long", "wide")
)
## S3 method for class 'magnitude_difference'
print(x, ...)
## S3 method for class 'magnitude_difference'
plot(x, type = c("stacked", "circular"), min_show = 0.01, title = NULL, ...)
data |
Long- or wide-format event log ( |
actor, action, time |
Column names in |
metric |
Discrepancy metric. One of |
scale |
How the two weight matrices are placed on a common scale
before differencing. |
format |
Input format passed through to |
x |
A |
... |
Passed to plotting helpers (ignored by |
type |
Plot style, |
min_show |
For |
title |
Plot title. |
An object of class "magnitude_difference": a list with
$edges (per-edge data.frame with columns from, to, ftna,
tna, signed = tna - ftna, and value = the chosen metric),
$metric, $scale, $weights_ftna, $weights_tna, and $states.
print invisibly returns x.
plot returns a ggplot object.
print(magnitude_difference): Print a compact summary of the per-edge
magnitude-difference distribution.
plot(magnitude_difference): Plot the per-edge magnitude difference as
a polar portrait. type = "stacked" (default) draws one sector per
from-state with stacked wedges (grey base = shared value, colored tip =
magnitude difference); type = "circular" draws a chord-style diagram
with signed differences on a diverging blue-orange scale.
build_network(), compare_model()
data(group_regulation_long, package = "Nestimate")
fit <- magnitude_difference(group_regulation_long,
actor = "Actor", action = "Action",
time = "Time")
print(fit)
# Edges most promoted by row-normalization (rare-source transitions):
head(fit$edges[order(-fit$edges$signed), c("from", "to", "ftna", "tna")])
plot(fit) # stacked polar portrait
plot(fit, type = "circular") # chord-style diagram
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.