| get_degree_dist | R Documentation |
Calculates the cumulative or momentary degree distribution from
the timed edgelist of a dynamic netdx() simulation.
get_degree_dist(
x,
type = c("cumulative", "momentary"),
sims = NULL,
window = NULL,
unique.partners = TRUE
)
x |
An |
type |
Distribution to calculate, either |
sims |
A vector of simulation numbers to include. The default is all
simulations in |
window |
A vector of length 2 giving the first and last time step of
the observation window, on the time scale of the timed edgelist
(which starts at 0). The default is the full simulation,
|
unique.partners |
If |
The momentary degree distribution is the distribution plotted by
plot.netdx() when degree(k) terms are included in the nwstats.formula
of netdx(): it counts the partners a node has at one moment in time. The
cumulative degree distribution counts the partners a node accumulates across
the whole observation window, so a node with one partner at a time and a
node with several simultaneous partners may have the same cumulative degree.
Partnerships are counted if they are active at any point in the window: a
partnership contributes to the cumulative degree of both of its nodes when
its spell overlaps window, and to the momentary degree of both nodes at
each time step of the window in which it is active. Partnerships that are
ongoing when the simulation ends are counted for the steps they are
observed.
Because the cumulative degree grows with the length of the observation
window, window should be set to a substantively meaningful period (for
example, one year of time steps) when comparing across models or against
data.
A data.frame with one row per simulation and degree value, and the
columns:
sim: the simulation number.
degree: the degree value, from 0 to the maximum observed across the
selected simulations.
count: the number of nodes with that degree. For
type = "momentary", this is the mean number of nodes per time step,
and so need not be a whole number.
prop: count divided by the network size.
plot.netdx() with type = "cumldeg" to plot these distributions,
and netdx() to generate the input object.
nw <- network_initialize(n = 100)
est <- netest(nw, formation = ~edges, target.stats = 50,
coef.diss = dissolution_coefs(~offset(edges), duration = 10),
verbose = FALSE)
dx <- netdx(est, nsims = 2, nsteps = 50, keep.tedgelist = TRUE,
verbose = FALSE)
# Cumulative degree over the full simulation
cd <- get_degree_dist(dx, type = "cumulative")
head(cd)
# Mean cumulative degree per simulation
tapply(cd$degree * cd$prop, cd$sim, sum)
# Momentary degree over the last 25 steps
get_degree_dist(dx, type = "momentary", window = c(25, 50))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.