nw <- network.initialize(n = 100, directed = FALSE)
nw <- set.vertex.attribute(nw, "race", value = rep(0:1, each = 50))
formation <- ~ edges + nodematch("race")
target.stats <- c(45, 25)
dissolution <- ~ offset(edges)
coef.diss <- dissolution.coefs(dissolution, duration = 20)
# Model estimation
est <- epiNet.est(
nw,
formation,
dissolution,
target.stats,
coef.diss,
save.stats = FALSE,
verbose = FALSE)
# Get the formation coefficients, then simulate a dynamic network
# from a simulated static network
coef.form <- est$coef.form
sim <- simulate(
simulate(est$fit),
formation = formation,
dissolution = dissolution,
coef.form = coef.form,
coef.diss = coef.diss[[3]],
time.slices = 200)
# Gather the three objects needed for the age calculation
nw <- est$fit$network
el <- as.data.frame(sim)
dissolution <- est$dissolution
edgelist.meanage(nw=nw, el=el, dissolution=dissolution)
# Alternatively, epiNet.est automatically calculates these with stats = TRUE
est <- epiNet.est(
nw,
formation,
dissolution,
target.stats,
coef.diss,
edapprox = TRUE,
save.stats = TRUE,
stats.end = 200)
est$pages
Run the code above in your browser using DataLab