# NOT RUN {
# Network initialization and model parameterization
nw <- network_initialize(n = 100)
nw <- set_vertex_attribute(nw, "sex", rbinom(100, 1, 0.5))
formation <- ~edges + nodematch("sex")
target.stats <- c(50, 40)
coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 50)
# Estimate the model
est <- netest(nw, formation, target.stats, coef.diss, verbose = FALSE)
# Static diagnostics
dx1 <- netdx(est, nsims = 1e4, dynamic = FALSE,
nwstats.formula = ~edges + meandeg + concurrent +
nodefactor("sex", levels = NULL) +
nodematch("sex"))
dx1
# Plot diagnostics
plot(dx1)
plot(dx1, stats = c("edges", "concurrent"), mean.col = "black",
sim.lines = TRUE, plots.joined = FALSE)
plot(dx1, stats = "edges", method = "b",
col = "seagreen3", grid = TRUE)
# Dynamic diagnostics
dx2 <- netdx(est, nsims = 10, nsteps = 500,
nwstats.formula = ~edges + meandeg + concurrent +
nodefactor("sex", levels = NULL) +
nodematch("sex"))
dx2
# Formation statistics plots, joined and separate
plot(dx2, grid = TRUE)
plot(dx2, type = "formation", plots.joined = TRUE)
plot(dx2, type = "formation", sims = 1, plots.joined = TRUE,
qnts = FALSE, sim.lines = TRUE, mean.line = FALSE)
plot(dx2, type = "formation", plots.joined = FALSE,
stats = c("edges", "concurrent"), grid = TRUE)
plot(dx2, method = "b", col = "bisque", grid = TRUE)
plot(dx2, method = "b", stats = "meandeg", col = "dodgerblue")
# Duration statistics plot
plot(dx2, type = "duration", mean.col = "black", grid = TRUE)
plot(dx2, type = "duration", sims = 10, mean.line = FALSE, sim.line = TRUE,
sim.col = "steelblue", sim.lwd = 3, targ.lty = 1, targ.lwd = 0.5)
# Dissolution statistics plot
plot(dx2, type = "dissolution", mean.col = "black", grid = TRUE)
plot(dx2, type = "dissolution", method = "b", col = "pink1")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab