Learn R Programming

EpiModel (version 2.0.1)

edgelist_meanage: Mean Age of Partnerships over Time

Description

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

Usage

edgelist_meanage(x, el)

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

Run this code
# NOT RUN {
# 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)

# }

Run the code above in your browser using DataLab