# See epiNet.est help to understand these steps
nw <- network.initialize(n = 500, directed = FALSE)
nw <- set.vertex.attribute(nw, "race", value = rep(0:1, each = 250))
formation <- ~ edges + nodematch("race") + degree(0) + concurrent
target.stats <- c(225, 187, 180, 90)
dissolution <- ~ offset(edges)
coef.diss <- dissolution.coefs(dissolution, durations = 20)
# Model estimation using the direct STERGM fit, then simulation
est <- epiNet.est(
nw,
formation,
dissolution,
target.stats,
coef.diss,
edapprox = FALSE)
nwsims <- epiNet.simNet(est, nsteps = 250, nsims = 10)
# Default will plot all simulations for target statistics formation plot
plot(nwsims)
# If that is too busy, try adjusting the line width or transparency with alpha
plot(nwsims, lwd=0.5)
plot(nwsims, lwd=0.75, alpha=0.5)
# If still too busy, then split plots
plot(nwsims, plots.joined=FALSE)
# Or plot just a subset of simulations
plot(nwsims, sim=1)
plot(nwsims, sim=4:6, lwd=0.6)
# Or plot just a subset of time
plot(nwsims, dx.start=100, dx.end=150, alpha=0.4)
# Duration plot shows the average age of partnerships along each time step
# Since a nodematch term was used in the dissolution, it will plot
# partnerships matched and unmatched separately
plot(nwsims, type="duration", alpha=0.5)
# Truncate plot to start after time 100, given the age ramp up period
plot(nwsims, type="duration", dx.start=100, lwd=0.5)
Run the code above in your browser using DataLab