edgelist_meanage: Mean Age of Partnerships over Time

Description Usage Arguments Details Examples

View source: R/net.utils.R

Description

Outputs a vector of mean ages of edges at a series of timesteps

Usage

1

Arguments

x

An EpiModel object of class netest.

el

If not passing x, a timed edgelist from a networkDynamic object extracted with the as.data.frame.networkDynamic function.

Details

This function calculates the mean partnership age at each time step over a dynamic network simulation from netest. These objects contain the network, edgelist, and dissolution objects needed for the calculation. Alternatively, one may pass in these objects separately if netest was not used, or statistics were not run requested after the estimation.

Currently, the calculations are limited to those dissolution formulas with a single homogenous dissolution (~offset(edges)). This functionality will be expanded in future releases.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Initialize and parameterize the network model
nw <- network_initialize(n = 100)
formation <- ~edges
target.stats <- 50
coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 20)

# Model estimation
est <- netest(nw, formation, target.stats, coef.diss, verbose = FALSE)

# Simulate the network and extract a timed edgelist
dx <- netdx(est, nsims = 1, nsteps = 100, keep.tedgelist = TRUE,
      verbose = FALSE)
el <- as.data.frame(dx)

# Calculate ages directly from edgelist
mean_ages <- edgelist_meanage(el = el)
mean_ages

# Alternatively, netdx calculates these
dx$pages
identical(dx$pages[[1]], mean_ages)

EpiModel documentation built on Feb. 2, 2022, 9:06 a.m.