Running 'test-all.R' [44s]
Running the tests in 'tests/test-all.R' failed.
Complete output:
  > library(testthat)
  > test_check("EpiModel")
  Loading required package: EpiModel
  Loading required package: deSolve
  Loading required package: networkDynamic
  Loading required package: network
  network: Classes for Relational Data
  Version 1.15 created on 2019-04-01.
  copyright (c) 2005, Carter T. Butts, University of California-Irvine
                      Mark S. Handcock, University of California -- Los Angeles
                      David R. Hunter, Penn State University
                      Martina Morris, University of Washington
                      Skye Bender-deMoll, University of Washington
   For citation information, type citation("network").
   Type help("network-package") to get started.
  
  
  networkDynamic: version 0.10.0, created on 2019-04-04
  Copyright (c) 2019, Carter T. Butts, University of California -- Irvine
                      Ayn Leslie-Cook, University of Washington
                      Pavel N. Krivitsky, University of Wollongong
                      Skye Bender-deMoll, University of Washington
                      with contributions from
                      Zack Almquist, University of California -- Irvine
                      David R. Hunter, Penn State University
                      Li Wang
                      Kirk Li, University of Washington
                      Steven M. Goodreau, University of Washington
                      Jeffrey Horner
                      Martina Morris, University of Washington
  Based on "statnet" project software (statnet.org).
  For license and citation information see statnet.org/attribution
  or type citation("networkDynamic").
  
  Loading required package: tergm
  Loading required package: ergm
  
  ergm: version 3.10.1, created on 2019-05-14
  Copyright (c) 2019, Mark S. Handcock, University of California -- Los Angeles
                      David R. Hunter, Penn State University
                      Carter T. Butts, University of California -- Irvine
                      Steven M. Goodreau, University of Washington
                      Pavel N. Krivitsky, University of Wollongong
                      Martina Morris, University of Washington
                      with contributions from
                      Li Wang
                      Kirk Li, University of Washington
                      Skye Bender-deMoll, University of Washington
                      Chad Klumb
  Based on "statnet" project software (statnet.org).
  For license and citation information see statnet.org/attribution
  or type citation("ergm").
  
  NOTE: Versions before 3.6.1 had a bug in the implementation of the bd()
  constriant which distorted the sampled distribution somewhat. In
  addition, Sampson's Monks datasets had mislabeled vertices. See the
  NEWS and the documentation for more details.
  
  NOTE: Some common term arguments pertaining to vertex attribute and
  level selection have changed in 3.10.0. See terms help for more
  details. Use 'options(ergm.term=list(version="3.9.4"))' to use old
  behavior.
  
  
  tergm: version 3.5.2, created on 2018-08-18
  Copyright (c) 2018, Pavel N. Krivitsky, University of Wollongong
                      Mark S. Handcock, University of California -- Los Angeles
                      with contributions from
                      David R. Hunter, Penn State University
                      Steven M. Goodreau, University of Washington
                      Martina Morris, University of Washington
                      Nicole Bohme Carnegie, New York University
                      Carter T. Butts, University of California -- Irvine
                      Ayn Leslie-Cook, University of Washington
                      Skye Bender-deMoll
                      Li Wang
                      Kirk Li, University of Washington
  Based on "statnet" project software (statnet.org).
  For license and citation information see statnet.org/attribution
  or type citation("tergm").
  
  -- 1. Error: (unknown) (@test-get.R#17)  ---------------------------------------
  'Calloc' could not allocate memory (129604177 of 16 bytes)
  1: netsim(est, param, init, control) at testthat/test-get.R:17
  2: do.call(control[["initialize.FUN"]], list(x, param, init, control, s))
  3: (function (x, param, init, control, s) 
     {
         if (control$start == 1) {
             dat <- list()
             dat$param <- param
             dat$init <- init
             dat$control <- control
             dat$attr <- list()
             dat$stats <- list()
             dat$temp <- list()
             nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
             modes <- ifelse(nw %n% "bipartite", 2, 1)
             if (control$depend == TRUE) {
                 if (class(x$fit) == "stergm") {
                     nw <- network.collapse(nw, at = 1)
                 }
                 nw <- sim_nets(x, nw, nsteps = 1, control)
             }
             if (control$depend == FALSE) {
                 nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
             }
             nw <- activate.vertices(nw, onset = 1, terminus = Inf)
             dat$nw <- nw
             dat$nwparam <- list(x[-which(names(x) == "fit")])
             dat$param$modes <- modes
             if (control$use.pids == TRUE) {
                 dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
             }
             form <- get_nwparam(dat)$formation
             fterms <- get_formula_term_attr(form, nw)
             dat <- copy_toall_attr(dat, at = 1, fterms)
             dat$temp$fterms <- fterms
             dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
             dat <- init_status.net(dat)
             dat <- get_prev.net(dat, at = 1)
         }
         else {
             dat <- list()
             dat$nw <- x$network[[s]]
             dat$param <- x$param
             dat$control <- control
             dat$nwparam <- x$nwparam
             dat$epi <- sapply(x$epi, function(var) var[s])
             names(dat$epi) <- names(x$epi)
             dat$attr <- x$attr[[s]]
             dat$stats <- sapply(x$stats, function(var) var[[s]])
             dat$temp <- list()
         }
         return(dat)
     })(structure(list(fit = structure(list(coef = c(edges = -3.8918202981106), iterations = 7L, 
         MCMCtheta = c(edges = -3.8918202981106), gradient = NA, hessian = structure(-49.0000108501759, .Dim = c(1L, 
         1L)), covar = structure(0.0204081587462834, .Dim = c(1L, 1L)), failure = FALSE, 
         est.cov = structure(0, .Dim = c(1L, 1L)), glm = structure(list(coefficients = c(edges = -3.8918202981106), 
             residuals = c(`1` = -1.02040816326531, `2` = 49.9999999999988), fitted.values = c(`1` = 0.0200000000000005, 
             `2` = 0.0200000000000005), effects = c(edges = 27.2427451029837, 49.9999944641969
             ), R = structure(-7.00000077501252, .Dim = c(1L, 1L), .Dimnames = list("edges", 
                 "edges")), rank = 1L, qr = structure(list(qr = structure(c(-7.00000077501252, 
             0.14142135623731), .Dim = 2:1, .Dimnames = list(c("1", "2"), "edges")), rank = 1L, 
                 qraux = 1.98994949366117, pivot = 1L, tol = 1e-11), class = "qr"), family = structure(list(
                 family = "binomial", link = "logit", linkfun = function (mu) 
                 .Call(C_logit_link, mu), linkinv = function (eta) 
                 .Call(C_logit_linkinv, eta), variance = function (mu) 
                 mu * (1 - mu), dev.resids = function (y, mu, wt) 
                 .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, 
                     dev) 
                 {
                     m <- if (any(n > 1)) 
                       n
                     else wt
                     -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), 
                       mu, log = TRUE))
                 }, mu.eta = function (eta) 
                 .Call(C_logit_mu_eta, eta), initialize = {
                     if (NCOL(y) == 1) {
                       if (is.factor(y)) 
                         y <- y != levels(y)[1L]
                       n <- rep.int(1, nobs)
                       y[weights == 0] <- 0
                       if (any(y < 0 | y > 1)) 
                         stop("y values must be 0 <= y <= 1")
                       mustart <- (weights * y + 0.5)/(weights + 1)
                       m <- weights * y
                       if (any(abs(m - round(m)) > 0.001)) 
                         warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                           domain = NA)
                     }
                     else if (NCOL(y) == 2) {
                       if (any(abs(y - round(y)) > 0.001)) 
                         warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                           domain = NA)
                       n <- (y1 <- y[, 1L]) + y[, 2L]
                       y <- y1/n
                       if (any(n0 <- n == 0)) 
                         y[n0] <- 0
                       weights <- weights * n
                       mustart <- (n * y + 0.5)/(n + 1)
                     }
                     else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                       "binomial"), domain = NA)
                 }, validmu = function (mu) 
                 all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
                 TRUE, simulate = function (object, nsim) 
                 {
                     ftd <- fitted(object)
                     n <- length(ftd)
                     ntot <- n * nsim
                     wts <- object$prior.weights
                     if (any(wts%%1 != 0)) 
                       stop("cannot simulate from non-integer prior.weights")
                     if (!is.null(m <- object$model)) {
                       y <- model.response(m)
                       if (is.factor(y)) {
                         yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                         split(yy, rep(seq_len(nsim), each = n))
                       }
                       else if (is.matrix(y) && ncol(y) == 2) {
                         yy <- vector("list", nsim)
                         for (i in seq_len(nsim)) {
                           Y <- rbinom(n, size = wts, prob = ftd)
                           YY <- cbind(Y, wts - Y)
                           colnames(YY) <- colnames(y)
                           yy[[i]] <- YY
                         }
                         yy
                       }
                       else rbinom(ntot, size = wts, prob = ftd)/wts
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }), class = "family"), linear.predictors = c(`1` = -3.8918202981106, 
             `2` = -3.8918202981106), deviance = 490.19556639866, aic = 492.19556639866, 
             null.deviance = 3465.73590279973, iter = 7L, weights = c(`1` = 48.0200106331724, 
             `2` = 0.980000217003518), prior.weights = c(`1` = 2450, `2` = 50), df.residual = 1L, 
             df.null = 2L, y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, 
             model = structure(list(`pl$zy` = 0:1, edges = c(1, 1), `offset(pl$foffset)` = c(0, 
             0), `(weights)` = c(2450, 50)), terms = pl$zy ~ edges - 1 + offset(pl$foffset), row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ . - 1 + offset(pl$foffset), family = family, 
                 data = data.frame(pl$xmat), weights = pl$wend), formula = pl$zy ~ . - 
                 1 + offset(pl$foffset), terms = pl$zy ~ edges - 1 + offset(pl$foffset), 
             data = structure(list(edges = c(1, 1)), class = "data.frame", row.names = c(NA, 
             -2L)), offset = c(0, 0), control = list(epsilon = 1e-08, maxit = 25, trace = FALSE), 
             method = "glm.fit", contrasts = NULL, xlevels = structure(list(), .Names = character(0))), class = c("glm", 
         "lm")), glm.null = structure(list(coefficients = c(`(Intercept)` = -3.8918202981106), 
             residuals = c(`1` = -1.02040816326531, `2` = 49.9999999999988), fitted.values = c(`1` = 0.0200000000000005, 
             `2` = 0.0200000000000005), effects = c(`(Intercept)` = 27.2427451029837, 
             49.9999944641969), R = structure(-7.00000077501252, .Dim = c(1L, 1L), .Dimnames = list(
                 "(Intercept)", "(Intercept)")), rank = 1L, qr = structure(list(qr = structure(c(-7.00000077501252, 
             0.14142135623731), .Dim = 2:1, .Dimnames = list(c("1", "2"), "(Intercept)")), 
                 rank = 1L, qraux = 1.98994949366117, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -3.8918202981106, `2` = -3.8918202981106
             ), deviance = 490.19556639866, aic = 492.19556639866, null.deviance = 490.19556639866, 
             iter = 7L, weights = c(`1` = 48.0200106331724, `2` = 0.980000217003518), 
             prior.weights = c(`1` = 2450, `2` = 50), df.residual = 1L, df.null = 1L, 
             y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = 0:1, `(weights)` = c(2450, 50)), terms = pl$zy ~ 1, row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ 1, family = family, weights = pl$wend), formula = pl$zy ~ 
                 1, terms = pl$zy ~ 1, data = <environment>, offset = NULL, control = list(
                 epsilon = 1e-08, maxit = 25, trace = FALSE), method = "glm.fit", contrasts = NULL, 
             xlevels = NULL), class = c("glm", "lm")), theta1 = list(coef = c(edges = -3.8918202981106), 
             theta = c(edges = -3.8918202981106), independent = c(edges = TRUE)), MPLE_is_MLE = TRUE, 
         ergm_version = structure(list(c(3L, 10L, 1L)), class = c("package_version", "numeric_version"
         )), offset = FALSE, drop = 0, estimable = TRUE, network = structure(list(mel = list(
             list(inl = 56L, outl = 1L, atl = list(na = FALSE)), list(inl = 57L, outl = 1L, 
                 atl = list(na = FALSE)), list(inl = 78L, outl = 1L, atl = list(na = FALSE)), 
             list(inl = 92L, outl = 1L, atl = list(na = FALSE)), list(inl = 55L, outl = 2L, 
                 atl = list(na = FALSE)), list(inl = 79L, outl = 2L, atl = list(na = FALSE)), 
             list(inl = 70L, outl = 3L, atl = list(na = FALSE)), list(inl = 65L, outl = 6L, 
                 atl = list(na = FALSE)), list(inl = 54L, outl = 7L, atl = list(na = FALSE)), 
             list(inl = 71L, outl = 7L, atl = list(na = FALSE)), list(inl = 98L, outl = 7L, 
                 atl = list(na = FALSE)), list(inl = 67L, outl = 9L, atl = list(na = FALSE)), 
             list(inl = 69L, outl = 10L, atl = list(na = FALSE)), list(inl = 75L, outl = 10L, 
                 atl = list(na = FALSE)), list(inl = 82L, outl = 11L, atl = list(na = FALSE)), 
             list(inl = 93L, outl = 11L, atl = list(na = FALSE)), list(inl = 94L, outl = 11L, 
                 atl = list(na = FALSE)), list(inl = 89L, outl = 12L, atl = list(na = FALSE)), 
             list(inl = 94L, outl = 15L, atl = list(na = FALSE)), list(inl = 55L, outl = 16L, 
                 atl = list(na = FALSE)), list(inl = 76L, outl = 16L, atl = list(na = FALSE)), 
             list(inl = 99L, outl = 16L, atl = list(na = FALSE)), list(inl = 64L, outl = 17L, 
                 atl = list(na = FALSE)), list(inl = 56L, outl = 18L, atl = list(na = FALSE)), 
             list(inl = 61L, outl = 18L, atl = list(na = FALSE)), list(inl = 87L, outl = 18L, 
                 atl = list(na = FALSE)), list(inl = 68L, outl = 19L, atl = list(na = FALSE)), 
             list(inl = 71L, outl = 19L, atl = list(na = FALSE)), list(inl = 55L, outl = 20L, 
                 atl = list(na = FALSE)), list(inl = 85L, outl = 23L, atl = list(na = FALSE)), 
             list(inl = 60L, outl = 25L, atl = list(na = FALSE)), list(inl = 92L, outl = 26L, 
                 atl = list(na = FALSE)), list(inl = 62L, outl = 28L, atl = list(na = FALSE)), 
             list(inl = 71L, outl = 28L, atl = list(na = FALSE)), list(inl = 69L, outl = 30L, 
                 atl = list(na = FALSE)), list(inl = 99L, outl = 30L, atl = list(na = FALSE)), 
             list(inl = 97L, outl = 31L, atl = list(na = FALSE)), list(inl = 54L, outl = 32L, 
                 atl = list(na = FALSE)), list(inl = 71L, outl = 33L, atl = list(na = FALSE)), 
             list(inl = 93L, outl = 35L, atl = list(na = FALSE)), list(inl = 55L, outl = 37L, 
                 atl = list(na = FALSE)), list(inl = 51L, outl = 39L, atl = list(na = FALSE)), 
             list(inl = 55L, outl = 41L, atl = list(na = FALSE)), list(inl = 64L, outl = 42L, 
                 atl = list(na = FALSE)), list(inl = 62L, outl = 44L, atl = list(na = FALSE)), 
             list(inl = 96L, outl = 45L, atl = list(na = FALSE)), list(inl = 60L, outl = 46L, 
                 atl = list(na = FALSE)), list(inl = 76L, outl = 47L, atl = list(na = FALSE)), 
             list(inl = 84L, outl = 49L, atl = list(na = FALSE)), list(inl = 69L, outl = 50L, 
                 atl = list(na = FALSE))), gal = list(n = 100, mnext = 51L, directed = FALSE, 
             hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = 50), val = list(
             list(na = FALSE, vertex.names = 1L), list(na = FALSE, vertex.names = 2L), 
             list(na = FALSE, vertex.names = 3L), list(na = FALSE, vertex.names = 4L), 
             list(na = FALSE, vertex.names = 5L), list(na = FALSE, vertex.names = 6L), 
             list(na = FALSE, vertex.names = 7L), list(na = FALSE, vertex.names = 8L), 
             list(na = FALSE, vertex.names = 9L), list(na = FALSE, vertex.names = 10L), 
             list(na = FALSE, vertex.names = 11L), list(na = FALSE, vertex.names = 12L), 
             list(na = FALSE, vertex.names = 13L), list(na = FALSE, vertex.names = 14L), 
             list(na = FALSE, vertex.names = 15L), list(na = FALSE, vertex.names = 16L), 
             list(na = FALSE, vertex.names = 17L), list(na = FALSE, vertex.names = 18L), 
             list(na = FALSE, vertex.names = 19L), list(na = FALSE, vertex.names = 20L), 
             list(na = FALSE, vertex.names = 21L), list(na = FALSE, vertex.names = 22L), 
             list(na = FALSE, vertex.names = 23L), list(na = FALSE, vertex.names = 24L), 
             list(na = FALSE, vertex.names = 25L), list(na = FALSE, vertex.names = 26L), 
             list(na = FALSE, vertex.names = 27L), list(na = FALSE, vertex.names = 28L), 
             list(na = FALSE, vertex.names = 29L), list(na = FALSE, vertex.names = 30L), 
             list(na = FALSE, vertex.names = 31L), list(na = FALSE, vertex.names = 32L), 
             list(na = FALSE, vertex.names = 33L), list(na = FALSE, vertex.names = 34L), 
             list(na = FALSE, vertex.names = 35L), list(na = FALSE, vertex.names = 36L), 
             list(na = FALSE, vertex.names = 37L), list(na = FALSE, vertex.names = 38L), 
             list(na = FALSE, vertex.names = 39L), list(na = FALSE, vertex.names = 40L), 
             list(na = FALSE, vertex.names = 41L), list(na = FALSE, vertex.names = 42L), 
             list(na = FALSE, vertex.names = 43L), list(na = FALSE, vertex.names = 44L), 
             list(na = FALSE, vertex.names = 45L), list(na = FALSE, vertex.names = 46L), 
             list(na = FALSE, vertex.names = 47L), list(na = FALSE, vertex.names = 48L), 
             list(na = FALSE, vertex.names = 49L), list(na = FALSE, vertex.names = 50L), 
             list(na = FALSE, vertex.names = 51L), list(na = FALSE, vertex.names = 52L), 
             list(na = FALSE, vertex.names = 53L), list(na = FALSE, vertex.names = 54L), 
             list(na = FALSE, vertex.names = 55L), list(na = FALSE, vertex.names = 56L), 
             list(na = FALSE, vertex.names = 57L), list(na = FALSE, vertex.names = 58L), 
             list(na = FALSE, vertex.names = 59L), list(na = FALSE, vertex.names = 60L), 
             list(na = FALSE, vertex.names = 61L), list(na = FALSE, vertex.names = 62L), 
             list(na = FALSE, vertex.names = 63L), list(na = FALSE, vertex.names = 64L), 
             list(na = FALSE, vertex.names = 65L), list(na = FALSE, vertex.names = 66L), 
             list(na = FALSE, vertex.names = 67L), list(na = FALSE, vertex.names = 68L), 
             list(na = FALSE, vertex.names = 69L), list(na = FALSE, vertex.names = 70L), 
             list(na = FALSE, vertex.names = 71L), list(na = FALSE, vertex.names = 72L), 
             list(na = FALSE, vertex.names = 73L), list(na = FALSE, vertex.names = 74L), 
             list(na = FALSE, vertex.names = 75L), list(na = FALSE, vertex.names = 76L), 
             list(na = FALSE, vertex.names = 77L), list(na = FALSE, vertex.names = 78L), 
             list(na = FALSE, vertex.names = 79L), list(na = FALSE, vertex.names = 80L), 
             list(na = FALSE, vertex.names = 81L), list(na = FALSE, vertex.names = 82L), 
             list(na = FALSE, vertex.names = 83L), list(na = FALSE, vertex.names = 84L), 
             list(na = FALSE, vertex.names = 85L), list(na = FALSE, vertex.names = 86L), 
             list(na = FALSE, vertex.names = 87L), list(na = FALSE, vertex.names = 88L), 
             list(na = FALSE, vertex.names = 89L), list(na = FALSE, vertex.names = 90L), 
             list(na = FALSE, vertex.names = 91L), list(na = FALSE, vertex.names = 92L), 
             list(na = FALSE, vertex.names = 93L), list(na = FALSE, vertex.names = 94L), 
             list(na = FALSE, vertex.names = 95L), list(na = FALSE, vertex.names = 96L), 
             list(na = FALSE, vertex.names = 97L), list(na = FALSE, vertex.names = 98L), 
             list(na = FALSE, vertex.names = 99L), list(na = FALSE, vertex.names = 100L)), 
             iel = list(integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 42L, integer(0), integer(0), c(9L, 38L), c(5L, 
                 20L, 29L, 41L, 43L), c(1L, 24L), 2L, integer(0), integer(0), c(31L, 47L
                 ), 25L, c(33L, 45L), integer(0), c(23L, 44L), 8L, integer(0), 12L, 27L, 
                 c(13L, 35L, 50L), 7L, c(10L, 28L, 34L, 39L), integer(0), integer(0), 
                 integer(0), 14L, c(21L, 48L), integer(0), 3L, 6L, integer(0), integer(0), 
                 15L, integer(0), 49L, 30L, integer(0), 26L, integer(0), 18L, integer(0), 
                 integer(0), c(4L, 32L), c(16L, 40L), c(17L, 19L), integer(0), 46L, 37L, 
                 11L, c(22L, 36L), integer(0)), oel = list(4:1, 6:5, 7L, integer(0), integer(0), 
                 8L, 11:9, integer(0), 12L, 14:13, 17:15, 18L, integer(0), integer(0), 
                 19L, 22:20, 23L, 26:24, 28:27, 29L, integer(0), integer(0), 30L, integer(0), 
                 31L, 32L, integer(0), 34:33, integer(0), 36:35, 37L, 38L, 39L, integer(0), 
                 40L, integer(0), 41L, integer(0), 42L, integer(0), 43L, 44L, integer(0), 
                 45L, 46L, 47L, 48L, integer(0), 49L, 50L, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0))), class = "network"), 
         reference = ~Bernoulli, newnetwork = structure(list(mel = list(list(inl = 56L, 
             outl = 1L, atl = list(na = FALSE)), list(inl = 57L, outl = 1L, atl = list(
             na = FALSE)), list(inl = 78L, outl = 1L, atl = list(na = FALSE)), list(inl = 92L, 
             outl = 1L, atl = list(na = FALSE)), list(inl = 55L, outl = 2L, atl = list(
             na = FALSE)), list(inl = 79L, outl = 2L, atl = list(na = FALSE)), list(inl = 70L, 
             outl = 3L, atl = list(na = FALSE)), list(inl = 65L, outl = 6L, atl = list(
             na = FALSE)), list(inl = 54L, outl = 7L, atl = list(na = FALSE)), list(inl = 71L, 
             outl = 7L, atl = list(na = FALSE)), list(inl = 98L, outl = 7L, atl = list(
             na = FALSE)), list(inl = 67L, outl = 9L, atl = list(na = FALSE)), list(inl = 69L, 
             outl = 10L, atl = list(na = FALSE)), list(inl = 75L, outl = 10L, atl = list(
             na = FALSE)), list(inl = 82L, outl = 11L, atl = list(na = FALSE)), list(inl = 93L, 
             outl = 11L, atl = list(na = FALSE)), list(inl = 94L, outl = 11L, atl = list(
             na = FALSE)), list(inl = 89L, outl = 12L, atl = list(na = FALSE)), list(inl = 94L, 
             outl = 15L, atl = list(na = FALSE)), list(inl = 55L, outl = 16L, atl = list(
             na = FALSE)), list(inl = 76L, outl = 16L, atl = list(na = FALSE)), list(inl = 99L, 
             outl = 16L, atl = list(na = FALSE)), list(inl = 64L, outl = 17L, atl = list(
             na = FALSE)), list(inl = 56L, outl = 18L, atl = list(na = FALSE)), list(inl = 61L, 
             outl = 18L, atl = list(na = FALSE)), list(inl = 87L, outl = 18L, atl = list(
             na = FALSE)), list(inl = 68L, outl = 19L, atl = list(na = FALSE)), list(inl = 71L, 
             outl = 19L, atl = list(na = FALSE)), list(inl = 55L, outl = 20L, atl = list(
             na = FALSE)), list(inl = 85L, outl = 23L, atl = list(na = FALSE)), list(inl = 60L, 
             outl = 25L, atl = list(na = FALSE)), list(inl = 92L, outl = 26L, atl = list(
             na = FALSE)), list(inl = 62L, outl = 28L, atl = list(na = FALSE)), list(inl = 71L, 
             outl = 28L, atl = list(na = FALSE)), list(inl = 69L, outl = 30L, atl = list(
             na = FALSE)), list(inl = 99L, outl = 30L, atl = list(na = FALSE)), list(inl = 97L, 
             outl = 31L, atl = list(na = FALSE)), list(inl = 54L, outl = 32L, atl = list(
             na = FALSE)), list(inl = 71L, outl = 33L, atl = list(na = FALSE)), list(inl = 93L, 
             outl = 35L, atl = list(na = FALSE)), list(inl = 55L, outl = 37L, atl = list(
             na = FALSE)), list(inl = 51L, outl = 39L, atl = list(na = FALSE)), list(inl = 55L, 
             outl = 41L, atl = list(na = FALSE)), list(inl = 64L, outl = 42L, atl = list(
             na = FALSE)), list(inl = 62L, outl = 44L, atl = list(na = FALSE)), list(inl = 96L, 
             outl = 45L, atl = list(na = FALSE)), list(inl = 60L, outl = 46L, atl = list(
             na = FALSE)), list(inl = 76L, outl = 47L, atl = list(na = FALSE)), list(inl = 84L, 
             outl = 49L, atl = list(na = FALSE)), list(inl = 69L, outl = 50L, atl = list(
             na = FALSE))), gal = list(n = 100, mnext = 51L, directed = FALSE, hyper = FALSE, 
             loops = FALSE, multiple = FALSE, bipartite = 50), val = list(list(na = FALSE, 
             vertex.names = 1L), list(na = FALSE, vertex.names = 2L), list(na = FALSE, 
             vertex.names = 3L), list(na = FALSE, vertex.names = 4L), list(na = FALSE, 
             vertex.names = 5L), list(na = FALSE, vertex.names = 6L), list(na = FALSE, 
             vertex.names = 7L), list(na = FALSE, vertex.names = 8L), list(na = FALSE, 
             vertex.names = 9L), list(na = FALSE, vertex.names = 10L), list(na = FALSE, 
             vertex.names = 11L), list(na = FALSE, vertex.names = 12L), list(na = FALSE, 
             vertex.names = 13L), list(na = FALSE, vertex.names = 14L), list(na = FALSE, 
             vertex.names = 15L), list(na = FALSE, vertex.names = 16L), list(na = FALSE, 
             vertex.names = 17L), list(na = FALSE, vertex.names = 18L), list(na = FALSE, 
             vertex.names = 19L), list(na = FALSE, vertex.names = 20L), list(na = FALSE, 
             vertex.names = 21L), list(na = FALSE, vertex.names = 22L), list(na = FALSE, 
             vertex.names = 23L), list(na = FALSE, vertex.names = 24L), list(na = FALSE, 
             vertex.names = 25L), list(na = FALSE, vertex.names = 26L), list(na = FALSE, 
             vertex.names = 27L), list(na = FALSE, vertex.names = 28L), list(na = FALSE, 
             vertex.names = 29L), list(na = FALSE, vertex.names = 30L), list(na = FALSE, 
             vertex.names = 31L), list(na = FALSE, vertex.names = 32L), list(na = FALSE, 
             vertex.names = 33L), list(na = FALSE, vertex.names = 34L), list(na = FALSE, 
             vertex.names = 35L), list(na = FALSE, vertex.names = 36L), list(na = FALSE, 
             vertex.names = 37L), list(na = FALSE, vertex.names = 38L), list(na = FALSE, 
             vertex.names = 39L), list(na = FALSE, vertex.names = 40L), list(na = FALSE, 
             vertex.names = 41L), list(na = FALSE, vertex.names = 42L), list(na = FALSE, 
             vertex.names = 43L), list(na = FALSE, vertex.names = 44L), list(na = FALSE, 
             vertex.names = 45L), list(na = FALSE, vertex.names = 46L), list(na = FALSE, 
             vertex.names = 47L), list(na = FALSE, vertex.names = 48L), list(na = FALSE, 
             vertex.names = 49L), list(na = FALSE, vertex.names = 50L), list(na = FALSE, 
             vertex.names = 51L), list(na = FALSE, vertex.names = 52L), list(na = FALSE, 
             vertex.names = 53L), list(na = FALSE, vertex.names = 54L), list(na = FALSE, 
             vertex.names = 55L), list(na = FALSE, vertex.names = 56L), list(na = FALSE, 
             vertex.names = 57L), list(na = FALSE, vertex.names = 58L), list(na = FALSE, 
             vertex.names = 59L), list(na = FALSE, vertex.names = 60L), list(na = FALSE, 
             vertex.names = 61L), list(na = FALSE, vertex.names = 62L), list(na = FALSE, 
             vertex.names = 63L), list(na = FALSE, vertex.names = 64L), list(na = FALSE, 
             vertex.names = 65L), list(na = FALSE, vertex.names = 66L), list(na = FALSE, 
             vertex.names = 67L), list(na = FALSE, vertex.names = 68L), list(na = FALSE, 
             vertex.names = 69L), list(na = FALSE, vertex.names = 70L), list(na = FALSE, 
             vertex.names = 71L), list(na = FALSE, vertex.names = 72L), list(na = FALSE, 
             vertex.names = 73L), list(na = FALSE, vertex.names = 74L), list(na = FALSE, 
             vertex.names = 75L), list(na = FALSE, vertex.names = 76L), list(na = FALSE, 
             vertex.names = 77L), list(na = FALSE, vertex.names = 78L), list(na = FALSE, 
             vertex.names = 79L), list(na = FALSE, vertex.names = 80L), list(na = FALSE, 
             vertex.names = 81L), list(na = FALSE, vertex.names = 82L), list(na = FALSE, 
             vertex.names = 83L), list(na = FALSE, vertex.names = 84L), list(na = FALSE, 
             vertex.names = 85L), list(na = FALSE, vertex.names = 86L), list(na = FALSE, 
             vertex.names = 87L), list(na = FALSE, vertex.names = 88L), list(na = FALSE, 
             vertex.names = 89L), list(na = FALSE, vertex.names = 90L), list(na = FALSE, 
             vertex.names = 91L), list(na = FALSE, vertex.names = 92L), list(na = FALSE, 
             vertex.names = 93L), list(na = FALSE, vertex.names = 94L), list(na = FALSE, 
             vertex.names = 95L), list(na = FALSE, vertex.names = 96L), list(na = FALSE, 
             vertex.names = 97L), list(na = FALSE, vertex.names = 98L), list(na = FALSE, 
             vertex.names = 99L), list(na = FALSE, vertex.names = 100L)), iel = list(integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             42L, integer(0), integer(0), c(9L, 38L), c(5L, 20L, 29L, 41L, 43L), c(1L, 
             24L), 2L, integer(0), integer(0), c(31L, 47L), 25L, c(33L, 45L), integer(0), 
             c(23L, 44L), 8L, integer(0), 12L, 27L, c(13L, 35L, 50L), 7L, c(10L, 28L, 
             34L, 39L), integer(0), integer(0), integer(0), 14L, c(21L, 48L), integer(0), 
             3L, 6L, integer(0), integer(0), 15L, integer(0), 49L, 30L, integer(0), 26L, 
             integer(0), 18L, integer(0), integer(0), c(4L, 32L), c(16L, 40L), c(17L, 
             19L), integer(0), 46L, 37L, 11L, c(22L, 36L), integer(0)), oel = list(4:1, 
             6:5, 7L, integer(0), integer(0), 8L, 11:9, integer(0), 12L, 14:13, 17:15, 
             18L, integer(0), integer(0), 19L, 22:20, 23L, 26:24, 28:27, 29L, integer(0), 
             integer(0), 30L, integer(0), 31L, 32L, integer(0), 34:33, integer(0), 36:35, 
             37L, 38L, 39L, integer(0), 40L, integer(0), 41L, integer(0), 42L, integer(0), 
             43L, 44L, integer(0), 45L, 46L, 47L, 48L, integer(0), 49L, 50L, integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0))), class = "network"), 
         formula = TARGET_STATS ~ edges, constraints = ~., target.stats = c(edges = 50), 
         etamap = list(canonical = 1L, offsetmap = FALSE, offset = FALSE, offsettheta = FALSE, 
             curved = list(), etalength = 1), target.esteq = structure(-50, .Dim = c(1L, 
         1L), .Dimnames = list(NULL, "edges")), estimate = "MLE", control = structure(list(
             drop = TRUE, init = NA_real_, init.method = "MPLE", main.method = "MCMLE", 
             force.main = FALSE, main.hessian = TRUE, checkpoint = NULL, resume = NULL, 
             MPLE.max.dyad.types = 1e+06, MPLE.samplesize = 50000, MPLE.type = "glm", 
             MCMC.prop.weights = "default", MCMC.prop.args = list(), MCMC.interval = 1024, 
             MCMC.burnin = 16384, MCMC.samplesize = 1024, MCMC.effectiveSize = NULL, MCMC.effectiveSize.damp = 10, 
             MCMC.effectiveSize.maxruns = 1000, MCMC.effectiveSize.base = 0.5, MCMC.effectiveSize.points = 5, 
             MCMC.effectiveSize.order = 1, MCMC.return.stats = TRUE, MCMC.runtime.traceplot = FALSE, 
             MCMC.init.maxedges = 20000, MCMC.max.maxedges = Inf, MCMC.addto.se = TRUE, 
             MCMC.compress = FALSE, MCMC.packagenames = NULL, SAN.maxit = 4, SAN.nsteps.times = 8, 
             SAN.control = structure(list(SAN.maxit = 4, SAN.tau = 1, SAN.invcov = NULL, 
                 SAN.invcov.diag = FALSE, SAN.nsteps.alloc = function (nsim) 
                 2^seq_len(nsim), SAN.nsteps = 131072, SAN.samplesize = 1024, SAN.init.maxedges = 20000, 
                 SAN.max.maxedges = Inf, SAN.prop.weights = "default", SAN.prop.args = list(), 
                 SAN.packagenames = NULL, term.options = NULL, seed = NULL, parallel = 0, 
                 parallel.type = NULL, parallel.version.check = TRUE), class = c("control.san", 
             "control.list", "list")), MCMLE.termination = "Hummel", MCMLE.maxit = 20, 
             MCMLE.conv.min.pval = 0.5, MCMLE.NR.maxit = 100, MCMLE.NR.reltol = 1.49011611938477e-08, 
             obs.MCMC.samplesize = 1024, obs.MCMC.interval = 1024, obs.MCMC.burnin = 16384, 
             obs.MCMC.burnin.min = 1638.4, obs.MCMC.prop.weights = "default", obs.MCMC.prop.args = list(), 
             obs.MCMC.impute.min_informative = function (nw) 
             network.size(nw)/4, obs.MCMC.impute.default_density = function (nw) 
             2/network.size(nw), MCMLE.check.degeneracy = FALSE, MCMLE.MCMC.precision = 0.005, 
             MCMLE.MCMC.max.ESS.frac = 0.1, MCMLE.metric = "lognormal", MCMLE.method = "BFGS", 
             MCMLE.trustregion = 20, MCMLE.dampening = FALSE, MCMLE.dampening.min.ess = 20, 
             MCMLE.dampening.level = 0.1, MCMLE.steplength.margin = 0.05, MCMLE.steplength = 1, 
             MCMLE.adaptive.trustregion = 3, MCMLE.sequential = TRUE, MCMLE.density.guard.min = 10000, 
             MCMLE.density.guard = 20.0855369231877, MCMLE.effectiveSize = NULL, MCMLE.last.boost = 4, 
             MCMLE.Hummel.esteq = TRUE, MCMLE.Hummel.miss.sample = 100, MCMLE.Hummel.maxit = 25, 
             MCMLE.steplength.min = 1e-04, MCMLE.effectiveSize.interval_drop = 2, MCMLE.save_intermediates = NULL, 
             SA.phase1_n = NULL, SA.initial_gain = NULL, SA.nsubphases = 4, SA.niterations = NULL, 
             SA.phase3_n = NULL, SA.trustregion = 0.5, RM.phase1n_base = 7, RM.phase2n_base = 100, 
             RM.phase2sub = 7, RM.init_gain = 0.5, RM.phase3n = 500, Step.MCMC.samplesize = 100, 
             Step.maxit = 50, Step.gridsize = 100, CD.nsteps = 8, CD.multiplicity = 1, 
             CD.nsteps.obs = 128, CD.multiplicity.obs = 1, CD.maxit = 60, CD.conv.min.pval = 0.5, 
             CD.NR.maxit = 100, CD.NR.reltol = 1.49011611938477e-08, CD.metric = "naive", 
             CD.method = "BFGS", CD.trustregion = 20, CD.dampening = FALSE, CD.dampening.min.ess = 20, 
             CD.dampening.level = 0.1, CD.steplength.margin = 0.5, CD.steplength = 1, 
             CD.adaptive.trustregion = 3, CD.adaptive.epsilon = 0.01, CD.Hummel.esteq = TRUE, 
             CD.Hummel.miss.sample = 100, CD.Hummel.maxit = 25, CD.steplength.min = 1e-04, 
             loglik.control = structure(list(nsteps = 20, MCMC.burnin = NULL, MCMC.interval = NULL, 
                 MCMC.samplesize = NULL, obs.MCMC.samplesize = NULL, obs.MCMC.interval = NULL, 
                 obs.MCMC.burnin = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 warn.dyads = NULL, MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, 
                 term.options = NULL, seed = NULL, parallel = NULL, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.logLik.ergm", "control.list", 
             "list")), term.options = NULL, seed = NULL, parallel = 0, parallel.type = NULL, 
             parallel.version.check = TRUE), class = c("control.ergm", "control.list", 
         "list"))), class = "ergm"), formation = ~edges, target.stats = 50, target.stats.names = "edges", 
         coef.form = c(edges = -6.83625927727704), coef.form.crude = c(edges = -3.8918202981106), 
         coef.diss = structure(list(dissolution = ~offset(edges), duration = 20, coef.crude = 2.94443897916644, 
             coef.adj = 2.94443897916644, d.rate = 0, model.type = "homog"), class = "disscoef"), 
         constraints = ~., edapprox = TRUE), class = "netest"), structure(list(inf.prob = 0.3, 
         inf.prob.m2 = 0.15, act.rate = 1, vital = FALSE), class = c("param.net", "list"
     )), structure(list(i.num = 10, i.num.m2 = 10), class = c("init.net", "list")), structure(list(
         type = "SI", nsteps = 10, start = 1, nsims = 3, ncores = 1, rec.rand = TRUE, 
         a.rand = TRUE, d.rand = TRUE, tea.status = TRUE, use.pids = TRUE, initialize.FUN = function (x, 
             param, init, control, s) 
         {
             if (control$start == 1) {
                 dat <- list()
                 dat$param <- param
                 dat$init <- init
                 dat$control <- control
                 dat$attr <- list()
                 dat$stats <- list()
                 dat$temp <- list()
                 nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
                 modes <- ifelse(nw %n% "bipartite", 2, 1)
                 if (control$depend == TRUE) {
                     if (class(x$fit) == "stergm") {
                       nw <- network.collapse(nw, at = 1)
                     }
                     nw <- sim_nets(x, nw, nsteps = 1, control)
                 }
                 if (control$depend == FALSE) {
                     nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
                 }
                 nw <- activate.vertices(nw, onset = 1, terminus = Inf)
                 dat$nw <- nw
                 dat$nwparam <- list(x[-which(names(x) == "fit")])
                 dat$param$modes <- modes
                 if (control$use.pids == TRUE) {
                     dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
                 }
                 form <- get_nwparam(dat)$formation
                 fterms <- get_formula_term_attr(form, nw)
                 dat <- copy_toall_attr(dat, at = 1, fterms)
                 dat$temp$fterms <- fterms
                 dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
                 dat <- init_status.net(dat)
                 dat <- get_prev.net(dat, at = 1)
             }
             else {
                 dat <- list()
                 dat$nw <- x$network[[s]]
                 dat$param <- x$param
                 dat$control <- control
                 dat$nwparam <- x$nwparam
                 dat$epi <- sapply(x$epi, function(var) var[s])
                 names(dat$epi) <- names(x$epi)
                 dat$attr <- x$attr[[s]]
                 dat$stats <- sapply(x$stats, function(var) var[[s]])
                 dat$temp <- list()
             }
             return(dat)
         }, departures.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             d.rand <- dat$control$d.rand
             nDepartures.sus <- nDeparturesM2.sus <- 0
             idsElig.sus <- which(dat$attr$active == 1 & dat$attr$status == "s")
             nElig.sus <- length(idsElig.sus)
             if (nElig.sus > 0) {
                 mElig.sus <- mode[idsElig.sus]
                 rates.sus <- c(dat$param$ds.rate, dat$param$ds.rate.m2)
                 ratesElig.sus <- rates.sus[mElig.sus]
                 if (d.rand == TRUE) {
                     vecDepartures.sus <- which(rbinom(nElig.sus, 1, ratesElig.sus) == 
                       1)
                     if (length(vecDepartures.sus) > 0) {
                       idsDpt.sus <- idsElig.sus[vecDepartures.sus]
                       nDepartures.sus <- sum(mode[idsDpt.sus] == 1)
                       nDeparturesM2.sus <- sum(mode[idsDpt.sus] == 2)
                       dat$attr$active[idsDpt.sus] <- 0
                       dat$attr$exitTime[idsDpt.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.sus, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.sus <- idsDptM2.sus <- NULL
                     nDepartures.sus <- min(round(sum(ratesElig.sus[mElig.sus == 1])), 
                       sum(mElig.sus == 1))
                     idsDpt.sus <- ssample(idsElig.sus[mElig.sus == 1], nDepartures.sus)
                     if (modes == 2) {
                       nDeparturesM2.sus <- min(round(sum(ratesElig.sus[mElig.sus == 2])), 
                         sum(mElig.sus == 2))
                       idsDptM2.sus <- ssample(idsElig.sus[mElig.sus == 2], nDeparturesM2.sus)
                     }
                     totDpt.sus <- nDepartures.sus + nDeparturesM2.sus
                     if (totDpt.sus > 0) {
                       idsDptAll.sus <- c(idsDpt.sus, idsDptM2.sus)
                       dat$attr$active[idsDptAll.sus] <- 0
                       dat$attr$exitTime[idsDptAll.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.sus, deactivate.edges = TRUE)
                     }
                 }
             }
             nDepartures.inf <- nDeparturesM2.inf <- 0
             idsElig.inf <- which(dat$attr$active == 1 & dat$attr$status == "i")
             nElig.inf <- length(idsElig.inf)
             if (nElig.inf > 0) {
                 mElig.inf <- mode[idsElig.inf]
                 rates.inf <- c(dat$param$di.rate, dat$param$di.rate.m2)
                 ratesElig.inf <- rates.inf[mElig.inf]
                 if (d.rand == TRUE) {
                     vecDepartures.inf <- which(rbinom(nElig.inf, 1, ratesElig.inf) == 
                       1)
                     if (length(vecDepartures.inf) > 0) {
                       idsDpt.inf <- idsElig.inf[vecDepartures.inf]
                       nDepartures.inf <- sum(mode[idsDpt.inf] == 1)
                       nDeparturesM2.inf <- sum(mode[idsDpt.inf] == 2)
                       dat$attr$active[idsDpt.inf] <- 0
                       dat$attr$exitTime[idsDpt.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.inf, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.inf <- idsDptM2.inf <- NULL
                     nDepartures.inf <- min(round(sum(ratesElig.inf[mElig.inf == 1])), 
                       sum(mElig.inf == 1))
                     idsDpt.inf <- ssample(idsElig.inf[mElig.inf == 1], nDepartures.inf)
                     if (modes == 2) {
                       nDeparturesM2.inf <- min(round(sum(ratesElig.inf[mElig.inf == 2])), 
                         sum(mElig.inf == 2))
                       idsDptM2.inf <- ssample(idsElig.inf[mElig.inf == 2], nDeparturesM2.inf)
                     }
                     totDpt.inf <- nDepartures.inf + nDeparturesM2.inf
                     if (totDpt.inf > 0) {
                       idsDptAll.inf <- c(idsDpt.inf, idsDptM2.inf)
                       dat$attr$active[idsDptAll.inf] <- 0
                       dat$attr$exitTime[idsDptAll.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.inf, deactivate.edges = TRUE)
                     }
                 }
             }
             if (type == "SIR") {
                 nDepartures.rec <- nDeparturesM2.rec <- 0
                 idsElig.rec <- which(dat$attr$active == 1 & dat$attr$status == "r")
                 nElig.rec <- length(idsElig.rec)
                 if (nElig.rec > 0) {
                     mElig.rec <- mode[idsElig.rec]
                     rates.rec <- c(dat$param$dr.rate, dat$param$dr.rate.m2)
                     ratesElig.rec <- rates.rec[mElig.rec]
                     if (d.rand == TRUE) {
                       vecDepartures.rec <- which(rbinom(nElig.rec, 1, ratesElig.rec) == 
                         1)
                       if (length(vecDepartures.rec) > 0) {
                         idsDpt.rec <- idsElig.rec[vecDepartures.rec]
                         nDepartures.rec <- sum(mode[idsDpt.rec] == 1)
                         nDeparturesM2.rec <- sum(mode[idsDpt.rec] == 2)
                         dat$attr$active[idsDpt.rec] <- 0
                         dat$attr$exitTime[idsDpt.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.rec, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.rec <- idsDptM2.rec <- NULL
                       nDepartures.rec <- min(round(sum(ratesElig.rec[mElig.rec == 1])), 
                         sum(mElig.rec == 1))
                       idsDpt.rec <- ssample(idsElig.rec[mElig.rec == 1], nDepartures.rec)
                       if (modes == 2) {
                         nDeparturesM2.rec <- min(round(sum(ratesElig.rec[mElig.rec == 
                           2])), sum(mElig.rec == 2))
                         idsDptM2.rec <- ssample(idsElig.rec[mElig.rec == 2], nDeparturesM2.rec)
                       }
                       totDpt.rec <- nDepartures.rec + nDeparturesM2.rec
                       if (totDpt.rec > 0) {
                         idsDptAll.rec <- c(idsDpt.rec, idsDptM2.rec)
                         dat$attr$active[idsDptAll.rec] <- 0
                         dat$attr$exitTime[idsDptAll.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.rec, deactivate.edges = TRUE)
                       }
                     }
                 }
             }
             if (at == 2) {
                 dat$epi$ds.flow <- c(0, nDepartures.sus)
                 dat$epi$di.flow <- c(0, nDepartures.inf)
                 if (type == "SIR") {
                     dat$epi$dr.flow <- c(0, nDepartures.rec)
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2 <- c(0, nDeparturesM2.sus)
                     dat$epi$di.flow.m2 <- c(0, nDeparturesM2.inf)
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2 <- c(0, nDeparturesM2.rec)
                     }
                 }
             }
             else {
                 dat$epi$ds.flow[at] <- nDepartures.sus
                 dat$epi$di.flow[at] <- nDepartures.inf
                 if (type == "SIR") {
                     dat$epi$dr.flow[at] <- nDepartures.rec
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2[at] <- nDeparturesM2.sus
                     dat$epi$di.flow.m2[at] <- nDeparturesM2.inf
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2[at] <- nDeparturesM2.rec
                     }
                 }
             }
             return(dat)
         }, arrivals.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             a.rate <- dat$param$a.rate
             a.rate.m2 <- dat$param$a.rate.m2
             modes <- dat$param$modes
             tea.status <- dat$control$tea.status
             nOld <- dat$epi$num[at - 1]
             nCurr <- network.size(dat$nw)
             a.rand <- dat$control$a.rand
             delete.nodes <- dat$control$delete.nodes
             nArrivals <- nArrivalsM2 <- 0
             newNodes <- newNodesM2 <- NULL
             if (modes == 1 && nOld > 0) {
                 if (a.rand == TRUE) {
                     nArrivals <- sum(rbinom(nOld, 1, a.rate))
                 }
                 if (a.rand == FALSE) {
                     nArrivals <- round(nOld * a.rate)
                 }
                 if (nArrivals > 0) {
                     dat$nw <- add.vertices(dat$nw, nv = nArrivals)
                     newNodes <- (nCurr + 1):(nCurr + nArrivals)
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (modes == 2 && nOld > 0) {
                 nOldM2 <- dat$epi$num.m2[at - 1]
                 if (a.rand == TRUE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOld, 1, a.rate))
                     }
                     else {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOldM2, 1, a.rate.m2))
                     }
                 }
                 if (a.rand == FALSE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOld * a.rate)
                     }
                     else {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOldM2 * a.rate.m2)
                     }
                 }
                 nCurrM1 <- length(modeids(dat$nw, 1))
                 nCurrM2 <- length(modeids(dat$nw, 2))
                 prefixes <- unique(substr(dat$nw %v% "vertex.names", 1, 1))
                 if (nArrivals > 0) {
                     newNodeIDs <- (nCurrM1 + 1):(nCurrM1 + nArrivals)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[1], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE)
                     }
                     newNodes <- newNodeIDs
                 }
                 if (nArrivalsM2 > 0) {
                     newNodeIDs <- (nCurrM2 + 1):(nCurrM2 + nArrivalsM2)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[2], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE)
                     }
                     newSize <- network.size(dat$nw)
                     newNodesM2 <- (newSize - nArrivalsM2 + 1):newSize
                 }
                 newNodes <- c(newNodes, newNodesM2)
                 if (!is.null(newNodes)) {
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (length(newNodes) > 0) {
                 fterms <- dat$temp$fterms
                 curr.tab <- get_attr_prop(dat$nw, fterms)
                 if (length(curr.tab) > 0) {
                     dat$nw <- update_nwattr(dat$nw, newNodes, dat$control$attr.rules, 
                       curr.tab, dat$temp$t1.tab)
                 }
                 dat <- copy_toall_attr(dat, at, fterms)
                 if (tea.status == TRUE) {
                     if ("status" %in% fterms) {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = dat$attr$status[newNodes], onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                     else {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = "s", onset = at, terminus = Inf, v = newNodes)
                     }
                 }
                 if (modes == 1) {
                     if (!("status" %in% fterms)) {
                       dat$attr$status <- c(dat$attr$status, rep("s", length(newNodes)))
                     }
                     dat$attr$active <- c(dat$attr$active, rep(1, length(newNodes)))
                     dat$attr$infTime <- c(dat$attr$infTime, rep(NA, length(newNodes)))
                     dat$attr$entrTime <- c(dat$attr$entrTime, rep(at, length(newNodes)))
                     dat$attr$exitTime <- c(dat$attr$exitTime, rep(NA, length(newNodes)))
                 }
                 if (modes == 2) {
                     if (!("status" %in% fterms)) {
                       dat <- split_bip(dat, "status", "s", nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                     }
                     dat <- split_bip(dat, "active", 1, nCurrM1, nCurrM2, nArrivals, nArrivalsM2)
                     dat <- split_bip(dat, "infTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "entrTime", at, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "exitTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                 }
                 newNodesInf <- intersect(newNodes, which(dat$attr$status == "i"))
                 dat$attr$infTime[newNodesInf] <- at
                 if (length(unique(sapply(dat$attr, length))) != 1) {
                     stop("Attribute list of unequal length. Check arrivals.net module.")
                 }
             }
             if (at == 2) {
                 dat$epi$a.flow <- c(0, nArrivals)
                 if (modes == 2) {
                     dat$epi$a.flow.m2 <- c(0, nArrivalsM2)
                 }
             }
             else {
                 dat$epi$a.flow[at] <- nArrivals
                 if (modes == 2) {
                     dat$epi$a.flow.m2[at] <- nArrivalsM2
                 }
             }
             return(dat)
         }, recovery.FUN = function (dat, at) 
         {
             if (!(dat$control$type %in% c("SIR", "SIS"))) {
                 return(dat)
             }
             active <- dat$attr$active
             status <- dat$attr$status
             infTime <- dat$attr$infTime
             tea.status <- dat$control$tea.status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             recovState <- ifelse(type == "SIR", "r", "s")
             rec.rand <- dat$control$rec.rand
             rec.rate <- dat$param$rec.rate
             rec.rate.m2 <- dat$param$rec.rate.m2
             nRecov <- nRecovM2 <- 0
             idsElig <- which(active == 1 & status == "i")
             nElig <- length(idsElig)
             infDur <- at - infTime[active == 1 & status == "i"]
             infDur[infDur == 0] <- 1
             lrec.rate <- length(rec.rate)
             if (lrec.rate == 1) {
                 mElig <- mode[idsElig]
                 rates <- c(rec.rate, rec.rate.m2)
                 ratesElig <- rates[mElig]
             }
             else {
                 mElig <- mode[idsElig]
                 if (is.null(rec.rate.m2)) {
                     rates <- ifelse(infDur <= lrec.rate, rec.rate[infDur], rec.rate[lrec.rate])
                 }
                 else {
                     rates <- rep(NA, length(infDur))
                     rates[mElig == 1] <- ifelse(infDur[mElig == 1] <= lrec.rate, rec.rate[infDur[mElig == 
                       1]], rec.rate[lrec.rate])
                     rates[mElig == 2] <- ifelse(infDur[mElig == 2] <= length(rec.rate.m2), 
                       rec.rate.m2[infDur[mElig == 2]], rec.rate.m2[length(rec.rate.m2)])
                 }
                 ratesElig <- rates
             }
             if (nElig > 0) {
                 if (rec.rand == TRUE) {
                     vecRecov <- which(rbinom(nElig, 1, ratesElig) == 1)
                     if (length(vecRecov) > 0) {
                       idsRecov <- idsElig[vecRecov]
                       nRecov <- sum(mode[idsRecov] == 1)
                       nRecovM2 <- sum(mode[idsRecov] == 2)
                       status[idsRecov] <- recovState
                       if (tea.status == TRUE) {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = recovState, onset = at, terminus = Inf, v = idsRecov)
                       }
                     }
                 }
                 else {
                     idsRecov <- idsRecovM2 <- NULL
                     nRecov <- min(round(sum(ratesElig[mElig == 1])), sum(mElig == 1))
                     if (nRecov > 0) {
                       idsRecov <- ssample(idsElig[mElig == 1], nRecov)
                       status[idsRecov] <- recovState
                     }
                     if (modes == 2) {
                       nRecovM2 <- min(round(sum(ratesElig[mElig == 2])), sum(mElig == 
                         2))
                       if (nRecovM2 > 0) {
                         idsRecovM2 <- ssample(idsElig[mElig == 2], nRecovM2)
                         status[idsRecovM2] <- recovState
                       }
                     }
                     totRecov <- nRecov + nRecovM2
                     if (tea.status == TRUE & totRecov > 0) {
                       allids <- c(idsRecov, idsRecovM2)
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = recovState, onset = at, terminus = Inf, v = allids)
                     }
                 }
             }
             dat$attr$status <- status
             if ("status" %in% dat$temp$fterms) {
                 dat$nw <- set.vertex.attribute(dat$nw, "status", dat$attr$status)
             }
             outName <- ifelse(type == "SIR", "ir.flow", "is.flow")
             outName[2] <- paste0(outName, ".m2")
             if (at == 2) {
                 dat$epi[[outName[1]]] <- c(0, nRecov)
             }
             else {
                 dat$epi[[outName[1]]][at] <- nRecov
             }
             if (modes == 2) {
                 if (at == 2) {
                     dat$epi[[outName[2]]] <- c(0, nRecovM2)
                 }
                 else {
                     dat$epi[[outName[2]]][at] <- nRecovM2
                 }
             }
             return(dat)
         }, edges_correct.FUN = function (dat, at) 
         {
             if (dat$control$depend == TRUE) {
                 if (dat$param$modes == 1) {
                     old.num <- dat$epi$num[at - 1]
                     new.num <- sum(dat$attr$active == 1)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(old.num) - log(new.num)
                 }
                 if (dat$param$modes == 2) {
                     mode <- idmode(dat$nw)
                     old.num.m1 <- dat$epi$num[at - 1]
                     old.num.m2 <- dat$epi$num.m2[at - 1]
                     new.num.m1 <- sum(dat$attr$active == 1 & mode == 1)
                     new.num.m2 <- sum(dat$attr$active == 1 & mode == 2)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(2 * old.num.m1 * old.num.m2/(old.num.m1 + old.num.m2)) - log(2 * 
                       new.num.m1 * new.num.m2/(new.num.m1 + new.num.m2))
                 }
             }
             return(dat)
         }, resim_nets.FUN = function (dat, at) 
         {
             idsActive <- which(dat$attr$active == 1)
             anyActive <- ifelse(length(idsActive) > 0, TRUE, FALSE)
             if (dat$param$modes == 2) {
                 nActiveM1 <- length(intersect(modeids(dat$nw, mode = 1), idsActive))
                 nActiveM2 <- length(intersect(modeids(dat$nw, mode = 2), idsActive))
                 anyActive <- ifelse(nActiveM1 > 0 & nActiveM2 > 0, TRUE, FALSE)
             }
             nwparam <- get_nwparam(dat)
             statOnNw <- ("status" %in% dat$temp$fterms)
             status <- dat$attr$status
             if (statOnNw == TRUE && length(unique(status)) == 1) {
                 stop("Stopping simulation because status in formation formula and ", 
                     "no longer any discordant nodes", call. = TRUE)
             }
             if (dat$control$save.nwstats == TRUE) {
                 if (at == 2) {
                     nwstats <- attributes(dat$nw)$stats
                     dat$stats$nwstats <- as.data.frame(nwstats)
                 }
             }
             if (anyActive > 0 & dat$control$depend == TRUE) {
                 suppressWarnings(dat$nw <- simulate(dat$nw, formation = nwparam$formation, 
                     dissolution = nwparam$coef.diss$dissolution, coef.form = nwparam$coef.form, 
                     coef.diss = nwparam$coef.diss$coef.adj, constraints = nwparam$constraints, 
                     time.start = at, time.slices = 1, time.offset = 0, monitor = dat$control$nwstats.formula, 
                     control = dat$control$set.control.stergm))
                 if (dat$control$save.nwstats == TRUE) {
                     dat$stats$nwstats <- rbind(dat$stats$nwstats, tail(attributes(dat$nw)$stats, 
                       1))
                 }
                 if (dat$control$delete.nodes == TRUE) {
                     dat$nw <- network.extract(dat$nw, at = at)
                     inactive <- which(dat$attr$active == 0)
                     dat$attr <- deleteAttr(dat$attr, inactive)
                 }
             }
             return(dat)
         }, infection.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             status <- dat$attr$status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             inf.prob <- dat$param$inf.prob
             inf.prob.m2 <- dat$param$inf.prob.m2
             act.rate <- dat$param$act.rate
             nw <- dat$nw
             tea.status <- dat$control$tea.status
             idsInf <- which(active == 1 & status == "i")
             nActive <- sum(active == 1)
             nElig <- length(idsInf)
             nInf <- nInfM2 <- totInf <- 0
             if (nElig > 0 && nElig < nActive) {
                 del <- discord_edgelist(dat, at)
                 if (!(is.null(del))) {
                     del$infDur <- at - dat$attr$infTime[del$inf]
                     del$infDur[del$infDur == 0] <- 1
                     linf.prob <- length(inf.prob)
                     if (is.null(inf.prob.m2)) {
                       del$transProb <- ifelse(del$infDur <= linf.prob, inf.prob[del$infDur], 
                         inf.prob[linf.prob])
                     }
                     else {
                       del$transProb <- ifelse(del$sus <= nw %n% "bipartite", ifelse(del$infDur <= 
                         linf.prob, inf.prob[del$infDur], inf.prob[linf.prob]), ifelse(del$infDur <= 
                         linf.prob, inf.prob.m2[del$infDur], inf.prob.m2[linf.prob]))
                     }
                     if (!is.null(dat$param$inter.eff) && at >= dat$param$inter.start) {
                       del$transProb <- del$transProb * (1 - dat$param$inter.eff)
                     }
                     lact.rate <- length(act.rate)
                     del$actRate <- ifelse(del$infDur <= lact.rate, act.rate[del$infDur], 
                       act.rate[lact.rate])
                     del$finalProb <- 1 - (1 - del$transProb)^del$actRate
                     transmit <- rbinom(nrow(del), 1, del$finalProb)
                     del <- del[which(transmit == 1), ]
                     idsNewInf <- unique(del$sus)
                     nInf <- sum(mode[idsNewInf] == 1)
                     nInfM2 <- sum(mode[idsNewInf] == 2)
                     totInf <- nInf + nInfM2
                     if (totInf > 0) {
                       if (tea.status == TRUE) {
                         nw <- activate.vertex.attribute(nw, prefix = "testatus", value = "i", 
                           onset = at, terminus = Inf, v = idsNewInf)
                       }
                       dat$attr$status[idsNewInf] <- "i"
                       dat$attr$infTime[idsNewInf] <- at
                       if ("status" %in% dat$temp$fterms) {
                         nw <- set.vertex.attribute(nw, "status", dat$attr$status)
                       }
                     }
                     if (any(names(nw$gal) %in% "vertex.pid")) {
                       del$sus <- get.vertex.pid(nw, del$sus)
                       del$inf <- get.vertex.pid(nw, del$inf)
                     }
                 }
             }
             if (totInf > 0) {
                 del <- del[!duplicated(del$sus), ]
                 if (at == 2) {
                     dat$stats$transmat <- del
                 }
                 else {
                     dat$stats$transmat <- rbind(dat$stats$transmat, del)
                 }
             }
             if (at == 2) {
                 dat$epi$si.flow <- c(0, nInf)
                 if (modes == 2) {
                     dat$epi$si.flow.m2 <- c(0, nInfM2)
                 }
             }
             else {
                 dat$epi$si.flow[at] <- nInf
                 if (modes == 2) {
                     dat$epi$si.flow.m2[at] <- nInfM2
                 }
             }
             dat$nw <- nw
             return(dat)
         }, get_prev.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             modes <- dat$param$modes
             l <- lapply(1:length(dat$attr), function(x) dat$attr[[x]][active == 1])
             names(l) <- names(dat$attr)
             l$active <- l$infTime <- NULL
             status <- l$status
             if (modes == 2) {
                 mode <- idmode(dat$nw)[active == 1]
             }
             eb <- !is.null(dat$control$epi.by)
             if (eb == TRUE) {
                 ebn <- dat$control$epi.by
                 ebv <- dat$temp$epi.by.vals
                 ebun <- paste0(".", ebn, ebv)
                 assign(ebn, l[[ebn]])
             }
             if (modes == 1) {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]][at] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
             }
             else {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2 <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2 <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2 <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]] <- sum(status == "r" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2 <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2[at] <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2[at] <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2[at] <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]][at] <- sum(status == 
                             "r" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2[at] <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]][at] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
             }
             return(dat)
         }, verbose.FUN = function (x, type, s = 1, at = 2) 
         {
             if (type == "startup" && x$ncores == 1) {
                 if (x$verbose == TRUE) {
                     cat("\nStarting Network Simulation...")
                 }
             }
             if (type == "progress" && x$control$ncores == 1) {
                 if (x$control$verbose == TRUE) {
                     if (x$control$verbose.int == 0 && at == x$control$nsteps) {
                       cat("\nSim = ", s, "/", x$control$nsims, sep = "")
                     }
                     if (x$control$verbose.int > 0 && (at%%x$control$verbose.int == 0)) {
                       cat("\f")
                       cat("\nEpidemic Simulation")
                       cat("\n----------------------------")
                       cat("\nSimulation: ", s, "/", x$control$nsims, sep = "")
                       cat("\nTimestep: ", at, "/", x$control$nsteps, sep = "")
                       status <- x$attr$status
                       if (class(status) == "character") {
                         status <- ifelse(status == "i", 1, 0)
                       }
                       cat("\nPrevalence:", sum(status, na.rm = TRUE))
                       cat("\nPopulation Size:", sum(x$attr$active == 1))
                       cat("\n----------------------------")
                     }
                 }
             }
         }, module.order = NULL, save.nwstats = TRUE, nwstats.formula = "formation", delete.nodes = FALSE, 
         save.transmat = TRUE, save.network = TRUE, verbose = FALSE, verbose.int = 1, 
         skip.check = FALSE, bi.mods = c("initialize.FUN", "departures.FUN", "arrivals.FUN", 
         "recovery.FUN", "edges_correct.FUN", "resim_nets.FUN", "infection.FUN", "get_prev.FUN", 
         "verbose.FUN"), user.mods = character(0), attr.rules = list(), set.control.stergm = structure(list(
             MCMC.burnin.min = 1000, MCMC.burnin.max = 1e+05, MCMC.burnin.pval = 0.5, 
             MCMC.burnin.add = 1, MCMC.burnin = NULL, MCMC.burnin.mul = NULL, MCMC.prop.weights.form = "default", 
             MCMC.prop.args.form = NULL, MCMC.prop.weights.diss = "default", MCMC.prop.args.diss = NULL, 
             MCMC.init.maxedges = 20000, MCMC.packagenames = NULL, MCMC.init.maxchanges = 1e+06), class = c("control.simulate.network", 
         "control.list", "list")), set.control.ergm = structure(list(MCMC.burnin = 2e+05, 
             MCMC.interval = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, MCMC.init.maxedges = NULL, 
             MCMC.packagenames = NULL, MCMC.runtime.traceplot = FALSE, network.output = "network", 
             term.options = NULL, parallel = 0, parallel.type = NULL, parallel.version.check = TRUE), class = c("control.simulate.ergm", 
         "control.list", "list")), depend = FALSE, pid.prefix = c("F", "M")), class = c("control.net", 
     "list")), 1L)
  4: sim_nets(x, nw, nsteps = control$nsteps, control)
  5: suppressWarnings(sim <- simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm))
  6: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  7: simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, coef.form = x$coef.form, 
         coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, time.start = 1, time.offset = 0, 
         constraints = x$constraints, monitor = control$nwstats.formula, nsim = 1, control = control$set.control.stergm)
  8: simulate.network(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm)
  9: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  10: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  11: lapply(X = X, FUN = FUN, ...)
  12: FUN(X[[i]], ...)
  13: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  14: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 2. Error: merge for netsim (@test-merge.R#71)  ------------------------------
  'Calloc' could not allocate memory (183186291 of 16 bytes)
  1: netsim(est, param, init, control) at testthat/test-merge.R:71
  2: do.call(control[["initialize.FUN"]], list(x, param, init, control, s))
  3: (function (x, param, init, control, s) 
     {
         if (control$start == 1) {
             dat <- list()
             dat$param <- param
             dat$init <- init
             dat$control <- control
             dat$attr <- list()
             dat$stats <- list()
             dat$temp <- list()
             nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
             modes <- ifelse(nw %n% "bipartite", 2, 1)
             if (control$depend == TRUE) {
                 if (class(x$fit) == "stergm") {
                     nw <- network.collapse(nw, at = 1)
                 }
                 nw <- sim_nets(x, nw, nsteps = 1, control)
             }
             if (control$depend == FALSE) {
                 nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
             }
             nw <- activate.vertices(nw, onset = 1, terminus = Inf)
             dat$nw <- nw
             dat$nwparam <- list(x[-which(names(x) == "fit")])
             dat$param$modes <- modes
             if (control$use.pids == TRUE) {
                 dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
             }
             form <- get_nwparam(dat)$formation
             fterms <- get_formula_term_attr(form, nw)
             dat <- copy_toall_attr(dat, at = 1, fterms)
             dat$temp$fterms <- fterms
             dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
             dat <- init_status.net(dat)
             dat <- get_prev.net(dat, at = 1)
         }
         else {
             dat <- list()
             dat$nw <- x$network[[s]]
             dat$param <- x$param
             dat$control <- control
             dat$nwparam <- x$nwparam
             dat$epi <- sapply(x$epi, function(var) var[s])
             names(dat$epi) <- names(x$epi)
             dat$attr <- x$attr[[s]]
             dat$stats <- sapply(x$stats, function(var) var[[s]])
             dat$temp <- list()
         }
         return(dat)
     })(structure(list(fit = structure(list(coef = c(edges = -5.28320371887165), iterations = 7L, 
         MCMCtheta = c(edges = -5.28320371887165), gradient = NA, hessian = structure(-24.8772140948116, .Dim = c(1L, 
         1L)), covar = structure(0.0401974270989033, .Dim = c(1L, 1L)), failure = FALSE, 
         est.cov = structure(0, .Dim = c(1L, 1L)), glm = structure(list(coefficients = c(edges = -5.28320371887165), 
             residuals = c(`1` = -1.00507614218206, `2` = 197.999998056331), fitted.values = c(`1` = 0.00505050510008338, 
             `2` = 0.00505050510008338), effects = c(edges = 26.3510684514833, 70.3513198991495
             ), R = structure(-4.98770629596528, .Dim = c(1L, 1L), .Dimnames = list("edges", 
                 "edges")), rank = 1L, qr = structure(list(qr = structure(c(-4.98770629596528, 
             0.0710669054518701), .Dim = 2:1, .Dimnames = list(c("1", "2"), "edges")), 
                 rank = 1L, qraux = 1.99747155094744, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -5.28320371887165, `2` = -5.28320371887165
             ), deviance = 314.286875806712, aic = 316.286875806712, null.deviance = 6862.15708754346, 
             iter = 7L, weights = c(`1` = 24.7515715993833, `2` = 0.125642495428342), 
             prior.weights = c(`1` = 4925, `2` = 25), df.residual = 1L, df.null = 2L, 
             y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = 0:1, edges = c(1, 1), `offset(pl$foffset)` = c(0, 0), `(weights)` = c(4925, 
                 25)), terms = pl$zy ~ edges - 1 + offset(pl$foffset), row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ . - 1 + offset(pl$foffset), family = family, 
                 data = data.frame(pl$xmat), weights = pl$wend), formula = pl$zy ~ . - 
                 1 + offset(pl$foffset), terms = pl$zy ~ edges - 1 + offset(pl$foffset), 
             data = structure(list(edges = c(1, 1)), class = "data.frame", row.names = c(NA, 
             -2L)), offset = c(0, 0), control = list(epsilon = 1e-08, maxit = 25, trace = FALSE), 
             method = "glm.fit", contrasts = NULL, xlevels = structure(list(), .Names = character(0))), class = c("glm", 
         "lm")), glm.null = structure(list(coefficients = c(`(Intercept)` = -5.28320371887165), 
             residuals = c(`1` = -1.00507614218206, `2` = 197.999998056331), fitted.values = c(`1` = 0.00505050510008338, 
             `2` = 0.00505050510008338), effects = c(`(Intercept)` = 26.3510684514833, 
             70.3513198991495), R = structure(-4.98770629596528, .Dim = c(1L, 1L), .Dimnames = list(
                 "(Intercept)", "(Intercept)")), rank = 1L, qr = structure(list(qr = structure(c(-4.98770629596528, 
             0.0710669054518701), .Dim = 2:1, .Dimnames = list(c("1", "2"), "(Intercept)")), 
                 rank = 1L, qraux = 1.99747155094744, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -5.28320371887165, `2` = -5.28320371887165
             ), deviance = 314.286875806712, aic = 316.286875806712, null.deviance = 314.286875806711, 
             iter = 7L, weights = c(`1` = 24.7515715993833, `2` = 0.125642495428342), 
             prior.weights = c(`1` = 4925, `2` = 25), df.residual = 1L, df.null = 1L, 
             y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = 0:1, `(weights)` = c(4925, 25)), terms = pl$zy ~ 1, row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ 1, family = family, weights = pl$wend), formula = pl$zy ~ 
                 1, terms = pl$zy ~ 1, data = <environment>, offset = NULL, control = list(
                 epsilon = 1e-08, maxit = 25, trace = FALSE), method = "glm.fit", contrasts = NULL, 
             xlevels = NULL), class = c("glm", "lm")), theta1 = list(coef = c(edges = -5.28320371887165), 
             theta = c(edges = -5.28320371887165), independent = c(edges = TRUE)), MPLE_is_MLE = TRUE, 
         ergm_version = structure(list(c(3L, 10L, 1L)), class = c("package_version", "numeric_version"
         )), offset = FALSE, drop = 0, estimable = TRUE, network = structure(list(mel = list(
             list(inl = 62L, outl = 7L, atl = list(na = FALSE)), list(inl = 69L, outl = 10L, 
                 atl = list(na = FALSE)), list(inl = 72L, outl = 10L, atl = list(na = FALSE)), 
             list(inl = 73L, outl = 14L, atl = list(na = FALSE)), list(inl = 27L, outl = 16L, 
                 atl = list(na = FALSE)), list(inl = 82L, outl = 16L, atl = list(na = FALSE)), 
             list(inl = 89L, outl = 20L, atl = list(na = FALSE)), list(inl = 29L, outl = 21L, 
                 atl = list(na = FALSE)), list(inl = 35L, outl = 23L, atl = list(na = FALSE)), 
             list(inl = 44L, outl = 23L, atl = list(na = FALSE)), list(inl = 59L, outl = 25L, 
                 atl = list(na = FALSE)), list(inl = 72L, outl = 25L, atl = list(na = FALSE)), 
             list(inl = 97L, outl = 26L, atl = list(na = FALSE)), list(inl = 72L, outl = 30L, 
                 atl = list(na = FALSE)), list(inl = 81L, outl = 33L, atl = list(na = FALSE)), 
             list(inl = 59L, outl = 38L, atl = list(na = FALSE)), list(inl = 96L, outl = 40L, 
                 atl = list(na = FALSE)), list(inl = 45L, outl = 43L, atl = list(na = FALSE)), 
             list(inl = 94L, outl = 47L, atl = list(na = FALSE)), list(inl = 51L, outl = 48L, 
                 atl = list(na = FALSE)), list(inl = 60L, outl = 59L, atl = list(na = FALSE)), 
             list(inl = 68L, outl = 67L, atl = list(na = FALSE)), list(inl = 84L, outl = 74L, 
                 atl = list(na = FALSE)), list(inl = 92L, outl = 83L, atl = list(na = FALSE)), 
             list(inl = 92L, outl = 87L, atl = list(na = FALSE))), gal = list(n = 100, 
             mnext = 26L, directed = FALSE, hyper = FALSE, loops = FALSE, multiple = FALSE, 
             bipartite = FALSE), val = list(list(na = FALSE, vertex.names = 1L), list(
             na = FALSE, vertex.names = 2L), list(na = FALSE, vertex.names = 3L), list(
             na = FALSE, vertex.names = 4L), list(na = FALSE, vertex.names = 5L), list(
             na = FALSE, vertex.names = 6L), list(na = FALSE, vertex.names = 7L), list(
             na = FALSE, vertex.names = 8L), list(na = FALSE, vertex.names = 9L), list(
             na = FALSE, vertex.names = 10L), list(na = FALSE, vertex.names = 11L), list(
             na = FALSE, vertex.names = 12L), list(na = FALSE, vertex.names = 13L), list(
             na = FALSE, vertex.names = 14L), list(na = FALSE, vertex.names = 15L), list(
             na = FALSE, vertex.names = 16L), list(na = FALSE, vertex.names = 17L), list(
             na = FALSE, vertex.names = 18L), list(na = FALSE, vertex.names = 19L), list(
             na = FALSE, vertex.names = 20L), list(na = FALSE, vertex.names = 21L), list(
             na = FALSE, vertex.names = 22L), list(na = FALSE, vertex.names = 23L), list(
             na = FALSE, vertex.names = 24L), list(na = FALSE, vertex.names = 25L), list(
             na = FALSE, vertex.names = 26L), list(na = FALSE, vertex.names = 27L), list(
             na = FALSE, vertex.names = 28L), list(na = FALSE, vertex.names = 29L), list(
             na = FALSE, vertex.names = 30L), list(na = FALSE, vertex.names = 31L), list(
             na = FALSE, vertex.names = 32L), list(na = FALSE, vertex.names = 33L), list(
             na = FALSE, vertex.names = 34L), list(na = FALSE, vertex.names = 35L), list(
             na = FALSE, vertex.names = 36L), list(na = FALSE, vertex.names = 37L), list(
             na = FALSE, vertex.names = 38L), list(na = FALSE, vertex.names = 39L), list(
             na = FALSE, vertex.names = 40L), list(na = FALSE, vertex.names = 41L), list(
             na = FALSE, vertex.names = 42L), list(na = FALSE, vertex.names = 43L), list(
             na = FALSE, vertex.names = 44L), list(na = FALSE, vertex.names = 45L), list(
             na = FALSE, vertex.names = 46L), list(na = FALSE, vertex.names = 47L), list(
             na = FALSE, vertex.names = 48L), list(na = FALSE, vertex.names = 49L), list(
             na = FALSE, vertex.names = 50L), list(na = FALSE, vertex.names = 51L), list(
             na = FALSE, vertex.names = 52L), list(na = FALSE, vertex.names = 53L), list(
             na = FALSE, vertex.names = 54L), list(na = FALSE, vertex.names = 55L), list(
             na = FALSE, vertex.names = 56L), list(na = FALSE, vertex.names = 57L), list(
             na = FALSE, vertex.names = 58L), list(na = FALSE, vertex.names = 59L), list(
             na = FALSE, vertex.names = 60L), list(na = FALSE, vertex.names = 61L), list(
             na = FALSE, vertex.names = 62L), list(na = FALSE, vertex.names = 63L), list(
             na = FALSE, vertex.names = 64L), list(na = FALSE, vertex.names = 65L), list(
             na = FALSE, vertex.names = 66L), list(na = FALSE, vertex.names = 67L), list(
             na = FALSE, vertex.names = 68L), list(na = FALSE, vertex.names = 69L), list(
             na = FALSE, vertex.names = 70L), list(na = FALSE, vertex.names = 71L), list(
             na = FALSE, vertex.names = 72L), list(na = FALSE, vertex.names = 73L), list(
             na = FALSE, vertex.names = 74L), list(na = FALSE, vertex.names = 75L), list(
             na = FALSE, vertex.names = 76L), list(na = FALSE, vertex.names = 77L), list(
             na = FALSE, vertex.names = 78L), list(na = FALSE, vertex.names = 79L), list(
             na = FALSE, vertex.names = 80L), list(na = FALSE, vertex.names = 81L), list(
             na = FALSE, vertex.names = 82L), list(na = FALSE, vertex.names = 83L), list(
             na = FALSE, vertex.names = 84L), list(na = FALSE, vertex.names = 85L), list(
             na = FALSE, vertex.names = 86L), list(na = FALSE, vertex.names = 87L), list(
             na = FALSE, vertex.names = 88L), list(na = FALSE, vertex.names = 89L), list(
             na = FALSE, vertex.names = 90L), list(na = FALSE, vertex.names = 91L), list(
             na = FALSE, vertex.names = 92L), list(na = FALSE, vertex.names = 93L), list(
             na = FALSE, vertex.names = 94L), list(na = FALSE, vertex.names = 95L), list(
             na = FALSE, vertex.names = 96L), list(na = FALSE, vertex.names = 97L), list(
             na = FALSE, vertex.names = 98L), list(na = FALSE, vertex.names = 99L), list(
             na = FALSE, vertex.names = 100L)), iel = list(integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), 5L, integer(0), 8L, integer(0), integer(0), integer(0), 
             integer(0), integer(0), 9L, integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), 10L, 18L, integer(0), integer(0), 
             integer(0), integer(0), integer(0), 20L, integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), c(11L, 16L), 21L, integer(0), 
             1L, integer(0), integer(0), integer(0), integer(0), integer(0), 22L, 2L, 
             integer(0), integer(0), c(3L, 12L, 14L), 4L, integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), 15L, 6L, integer(0), 23L, 
             integer(0), integer(0), integer(0), integer(0), 7L, integer(0), integer(0), 
             24:25, integer(0), 19L, integer(0), 17L, 13L, integer(0), integer(0), integer(0)), 
             oel = list(integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 1L, integer(0), integer(0), 3:2, integer(0), integer(0), integer(0), 
                 4L, integer(0), 6:5, integer(0), integer(0), integer(0), 7L, 8L, integer(0), 
                 10:9, integer(0), 12:11, 13L, integer(0), integer(0), integer(0), 14L, 
                 integer(0), integer(0), 15L, integer(0), integer(0), integer(0), integer(0), 
                 16L, integer(0), 17L, integer(0), integer(0), 18L, integer(0), integer(0), 
                 integer(0), 19L, 20L, integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 21L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), 22L, integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), 23L, integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 24L, integer(0), integer(0), integer(0), 
                 25L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0))), class = "network"), reference = ~Bernoulli, newnetwork = structure(list(
             mel = list(list(inl = 62L, outl = 7L, atl = list(na = FALSE)), list(inl = 69L, 
                 outl = 10L, atl = list(na = FALSE)), list(inl = 72L, outl = 10L, atl = list(
                 na = FALSE)), list(inl = 73L, outl = 14L, atl = list(na = FALSE)), list(
                 inl = 27L, outl = 16L, atl = list(na = FALSE)), list(inl = 82L, outl = 16L, 
                 atl = list(na = FALSE)), list(inl = 89L, outl = 20L, atl = list(na = FALSE)), 
                 list(inl = 29L, outl = 21L, atl = list(na = FALSE)), list(inl = 35L, 
                     outl = 23L, atl = list(na = FALSE)), list(inl = 44L, outl = 23L, 
                     atl = list(na = FALSE)), list(inl = 59L, outl = 25L, atl = list(na = FALSE)), 
                 list(inl = 72L, outl = 25L, atl = list(na = FALSE)), list(inl = 97L, 
                     outl = 26L, atl = list(na = FALSE)), list(inl = 72L, outl = 30L, 
                     atl = list(na = FALSE)), list(inl = 81L, outl = 33L, atl = list(na = FALSE)), 
                 list(inl = 59L, outl = 38L, atl = list(na = FALSE)), list(inl = 96L, 
                     outl = 40L, atl = list(na = FALSE)), list(inl = 45L, outl = 43L, 
                     atl = list(na = FALSE)), list(inl = 94L, outl = 47L, atl = list(na = FALSE)), 
                 list(inl = 51L, outl = 48L, atl = list(na = FALSE)), list(inl = 60L, 
                     outl = 59L, atl = list(na = FALSE)), list(inl = 68L, outl = 67L, 
                     atl = list(na = FALSE)), list(inl = 84L, outl = 74L, atl = list(na = FALSE)), 
                 list(inl = 92L, outl = 83L, atl = list(na = FALSE)), list(inl = 92L, 
                     outl = 87L, atl = list(na = FALSE))), gal = list(n = 100, mnext = 26L, 
                 directed = FALSE, hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = FALSE), 
             val = list(list(na = FALSE, vertex.names = 1L), list(na = FALSE, vertex.names = 2L), 
                 list(na = FALSE, vertex.names = 3L), list(na = FALSE, vertex.names = 4L), 
                 list(na = FALSE, vertex.names = 5L), list(na = FALSE, vertex.names = 6L), 
                 list(na = FALSE, vertex.names = 7L), list(na = FALSE, vertex.names = 8L), 
                 list(na = FALSE, vertex.names = 9L), list(na = FALSE, vertex.names = 10L), 
                 list(na = FALSE, vertex.names = 11L), list(na = FALSE, vertex.names = 12L), 
                 list(na = FALSE, vertex.names = 13L), list(na = FALSE, vertex.names = 14L), 
                 list(na = FALSE, vertex.names = 15L), list(na = FALSE, vertex.names = 16L), 
                 list(na = FALSE, vertex.names = 17L), list(na = FALSE, vertex.names = 18L), 
                 list(na = FALSE, vertex.names = 19L), list(na = FALSE, vertex.names = 20L), 
                 list(na = FALSE, vertex.names = 21L), list(na = FALSE, vertex.names = 22L), 
                 list(na = FALSE, vertex.names = 23L), list(na = FALSE, vertex.names = 24L), 
                 list(na = FALSE, vertex.names = 25L), list(na = FALSE, vertex.names = 26L), 
                 list(na = FALSE, vertex.names = 27L), list(na = FALSE, vertex.names = 28L), 
                 list(na = FALSE, vertex.names = 29L), list(na = FALSE, vertex.names = 30L), 
                 list(na = FALSE, vertex.names = 31L), list(na = FALSE, vertex.names = 32L), 
                 list(na = FALSE, vertex.names = 33L), list(na = FALSE, vertex.names = 34L), 
                 list(na = FALSE, vertex.names = 35L), list(na = FALSE, vertex.names = 36L), 
                 list(na = FALSE, vertex.names = 37L), list(na = FALSE, vertex.names = 38L), 
                 list(na = FALSE, vertex.names = 39L), list(na = FALSE, vertex.names = 40L), 
                 list(na = FALSE, vertex.names = 41L), list(na = FALSE, vertex.names = 42L), 
                 list(na = FALSE, vertex.names = 43L), list(na = FALSE, vertex.names = 44L), 
                 list(na = FALSE, vertex.names = 45L), list(na = FALSE, vertex.names = 46L), 
                 list(na = FALSE, vertex.names = 47L), list(na = FALSE, vertex.names = 48L), 
                 list(na = FALSE, vertex.names = 49L), list(na = FALSE, vertex.names = 50L), 
                 list(na = FALSE, vertex.names = 51L), list(na = FALSE, vertex.names = 52L), 
                 list(na = FALSE, vertex.names = 53L), list(na = FALSE, vertex.names = 54L), 
                 list(na = FALSE, vertex.names = 55L), list(na = FALSE, vertex.names = 56L), 
                 list(na = FALSE, vertex.names = 57L), list(na = FALSE, vertex.names = 58L), 
                 list(na = FALSE, vertex.names = 59L), list(na = FALSE, vertex.names = 60L), 
                 list(na = FALSE, vertex.names = 61L), list(na = FALSE, vertex.names = 62L), 
                 list(na = FALSE, vertex.names = 63L), list(na = FALSE, vertex.names = 64L), 
                 list(na = FALSE, vertex.names = 65L), list(na = FALSE, vertex.names = 66L), 
                 list(na = FALSE, vertex.names = 67L), list(na = FALSE, vertex.names = 68L), 
                 list(na = FALSE, vertex.names = 69L), list(na = FALSE, vertex.names = 70L), 
                 list(na = FALSE, vertex.names = 71L), list(na = FALSE, vertex.names = 72L), 
                 list(na = FALSE, vertex.names = 73L), list(na = FALSE, vertex.names = 74L), 
                 list(na = FALSE, vertex.names = 75L), list(na = FALSE, vertex.names = 76L), 
                 list(na = FALSE, vertex.names = 77L), list(na = FALSE, vertex.names = 78L), 
                 list(na = FALSE, vertex.names = 79L), list(na = FALSE, vertex.names = 80L), 
                 list(na = FALSE, vertex.names = 81L), list(na = FALSE, vertex.names = 82L), 
                 list(na = FALSE, vertex.names = 83L), list(na = FALSE, vertex.names = 84L), 
                 list(na = FALSE, vertex.names = 85L), list(na = FALSE, vertex.names = 86L), 
                 list(na = FALSE, vertex.names = 87L), list(na = FALSE, vertex.names = 88L), 
                 list(na = FALSE, vertex.names = 89L), list(na = FALSE, vertex.names = 90L), 
                 list(na = FALSE, vertex.names = 91L), list(na = FALSE, vertex.names = 92L), 
                 list(na = FALSE, vertex.names = 93L), list(na = FALSE, vertex.names = 94L), 
                 list(na = FALSE, vertex.names = 95L), list(na = FALSE, vertex.names = 96L), 
                 list(na = FALSE, vertex.names = 97L), list(na = FALSE, vertex.names = 98L), 
                 list(na = FALSE, vertex.names = 99L), list(na = FALSE, vertex.names = 100L)), 
             iel = list(integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 5L, integer(0), 8L, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 9L, integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), 10L, 18L, integer(0), 
                 integer(0), integer(0), integer(0), integer(0), 20L, integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), c(11L, 16L
                 ), 21L, integer(0), 1L, integer(0), integer(0), integer(0), integer(0), 
                 integer(0), 22L, 2L, integer(0), integer(0), c(3L, 12L, 14L), 4L, integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 15L, 6L, integer(0), 23L, integer(0), integer(0), integer(0), integer(0), 
                 7L, integer(0), integer(0), 24:25, integer(0), 19L, integer(0), 17L, 
                 13L, integer(0), integer(0), integer(0)), oel = list(integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), 1L, integer(0), integer(0), 
                 3:2, integer(0), integer(0), integer(0), 4L, integer(0), 6:5, integer(0), 
                 integer(0), integer(0), 7L, 8L, integer(0), 10:9, integer(0), 12:11, 
                 13L, integer(0), integer(0), integer(0), 14L, integer(0), integer(0), 
                 15L, integer(0), integer(0), integer(0), integer(0), 16L, integer(0), 
                 17L, integer(0), integer(0), 18L, integer(0), integer(0), integer(0), 
                 19L, 20L, integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), 21L, integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 22L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 23L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 24L, integer(0), integer(0), integer(0), 25L, 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0))), class = "network"), formula = TARGET_STATS ~ edges, constraints = ~., 
         target.stats = c(edges = 25), etamap = list(canonical = 1L, offsetmap = FALSE, 
             offset = FALSE, offsettheta = FALSE, curved = list(), etalength = 1), target.esteq = structure(-25, .Dim = c(1L, 
         1L), .Dimnames = list(NULL, "edges")), estimate = "MLE", control = structure(list(
             drop = TRUE, init = NA_real_, init.method = "MPLE", main.method = "MCMLE", 
             force.main = FALSE, main.hessian = TRUE, checkpoint = NULL, resume = NULL, 
             MPLE.max.dyad.types = 1e+06, MPLE.samplesize = 50000, MPLE.type = "glm", 
             MCMC.prop.weights = "default", MCMC.prop.args = list(), MCMC.interval = 1024, 
             MCMC.burnin = 16384, MCMC.samplesize = 1024, MCMC.effectiveSize = NULL, MCMC.effectiveSize.damp = 10, 
             MCMC.effectiveSize.maxruns = 1000, MCMC.effectiveSize.base = 0.5, MCMC.effectiveSize.points = 5, 
             MCMC.effectiveSize.order = 1, MCMC.return.stats = TRUE, MCMC.runtime.traceplot = FALSE, 
             MCMC.init.maxedges = 20000, MCMC.max.maxedges = Inf, MCMC.addto.se = TRUE, 
             MCMC.compress = FALSE, MCMC.packagenames = NULL, SAN.maxit = 4, SAN.nsteps.times = 8, 
             SAN.control = structure(list(SAN.maxit = 4, SAN.tau = 1, SAN.invcov = NULL, 
                 SAN.invcov.diag = FALSE, SAN.nsteps.alloc = function (nsim) 
                 2^seq_len(nsim), SAN.nsteps = 131072, SAN.samplesize = 1024, SAN.init.maxedges = 20000, 
                 SAN.max.maxedges = Inf, SAN.prop.weights = "default", SAN.prop.args = list(), 
                 SAN.packagenames = NULL, term.options = NULL, seed = NULL, parallel = 0, 
                 parallel.type = NULL, parallel.version.check = TRUE), class = c("control.san", 
             "control.list", "list")), MCMLE.termination = "Hummel", MCMLE.maxit = 20, 
             MCMLE.conv.min.pval = 0.5, MCMLE.NR.maxit = 100, MCMLE.NR.reltol = 1.49011611938477e-08, 
             obs.MCMC.samplesize = 1024, obs.MCMC.interval = 1024, obs.MCMC.burnin = 16384, 
             obs.MCMC.burnin.min = 1638.4, obs.MCMC.prop.weights = "default", obs.MCMC.prop.args = list(), 
             obs.MCMC.impute.min_informative = function (nw) 
             network.size(nw)/4, obs.MCMC.impute.default_density = function (nw) 
             2/network.size(nw), MCMLE.check.degeneracy = FALSE, MCMLE.MCMC.precision = 0.005, 
             MCMLE.MCMC.max.ESS.frac = 0.1, MCMLE.metric = "lognormal", MCMLE.method = "BFGS", 
             MCMLE.trustregion = 20, MCMLE.dampening = FALSE, MCMLE.dampening.min.ess = 20, 
             MCMLE.dampening.level = 0.1, MCMLE.steplength.margin = 0.05, MCMLE.steplength = 1, 
             MCMLE.adaptive.trustregion = 3, MCMLE.sequential = TRUE, MCMLE.density.guard.min = 10000, 
             MCMLE.density.guard = 20.0855369231877, MCMLE.effectiveSize = NULL, MCMLE.last.boost = 4, 
             MCMLE.Hummel.esteq = TRUE, MCMLE.Hummel.miss.sample = 100, MCMLE.Hummel.maxit = 25, 
             MCMLE.steplength.min = 1e-04, MCMLE.effectiveSize.interval_drop = 2, MCMLE.save_intermediates = NULL, 
             SA.phase1_n = NULL, SA.initial_gain = NULL, SA.nsubphases = 4, SA.niterations = NULL, 
             SA.phase3_n = NULL, SA.trustregion = 0.5, RM.phase1n_base = 7, RM.phase2n_base = 100, 
             RM.phase2sub = 7, RM.init_gain = 0.5, RM.phase3n = 500, Step.MCMC.samplesize = 100, 
             Step.maxit = 50, Step.gridsize = 100, CD.nsteps = 8, CD.multiplicity = 1, 
             CD.nsteps.obs = 128, CD.multiplicity.obs = 1, CD.maxit = 60, CD.conv.min.pval = 0.5, 
             CD.NR.maxit = 100, CD.NR.reltol = 1.49011611938477e-08, CD.metric = "naive", 
             CD.method = "BFGS", CD.trustregion = 20, CD.dampening = FALSE, CD.dampening.min.ess = 20, 
             CD.dampening.level = 0.1, CD.steplength.margin = 0.5, CD.steplength = 1, 
             CD.adaptive.trustregion = 3, CD.adaptive.epsilon = 0.01, CD.Hummel.esteq = TRUE, 
             CD.Hummel.miss.sample = 100, CD.Hummel.maxit = 25, CD.steplength.min = 1e-04, 
             loglik.control = structure(list(nsteps = 20, MCMC.burnin = NULL, MCMC.interval = NULL, 
                 MCMC.samplesize = NULL, obs.MCMC.samplesize = NULL, obs.MCMC.interval = NULL, 
                 obs.MCMC.burnin = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 warn.dyads = NULL, MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, 
                 term.options = NULL, seed = NULL, parallel = NULL, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.logLik.ergm", "control.list", 
             "list")), term.options = NULL, seed = NULL, parallel = 0, parallel.type = NULL, 
             parallel.version.check = TRUE), class = c("control.ergm", "control.list", 
         "list"))), class = "ergm"), formation = ~edges, target.stats = 25, target.stats.names = "edges", 
         coef.form = c(edges = -7.48042829620787), coef.form.crude = c(edges = -5.28320371887165), 
         coef.diss = structure(list(dissolution = ~offset(edges), duration = 10, coef.crude = 2.19722457733622, 
             coef.adj = 2.19722457733622, d.rate = 0, model.type = "homog"), class = "disscoef"), 
         constraints = ~., edapprox = TRUE), class = "netest"), structure(list(inf.prob = 1, 
         act.rate = 1, vital = FALSE), class = c("param.net", "list")), structure(list(
         i.num = 1), class = c("init.net", "list")), structure(list(type = "SI", nsteps = 20, 
         start = 1, nsims = 2, ncores = 1, rec.rand = TRUE, a.rand = TRUE, d.rand = TRUE, 
         tea.status = TRUE, use.pids = TRUE, initialize.FUN = function (x, param, init, 
             control, s) 
         {
             if (control$start == 1) {
                 dat <- list()
                 dat$param <- param
                 dat$init <- init
                 dat$control <- control
                 dat$attr <- list()
                 dat$stats <- list()
                 dat$temp <- list()
                 nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
                 modes <- ifelse(nw %n% "bipartite", 2, 1)
                 if (control$depend == TRUE) {
                     if (class(x$fit) == "stergm") {
                       nw <- network.collapse(nw, at = 1)
                     }
                     nw <- sim_nets(x, nw, nsteps = 1, control)
                 }
                 if (control$depend == FALSE) {
                     nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
                 }
                 nw <- activate.vertices(nw, onset = 1, terminus = Inf)
                 dat$nw <- nw
                 dat$nwparam <- list(x[-which(names(x) == "fit")])
                 dat$param$modes <- modes
                 if (control$use.pids == TRUE) {
                     dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
                 }
                 form <- get_nwparam(dat)$formation
                 fterms <- get_formula_term_attr(form, nw)
                 dat <- copy_toall_attr(dat, at = 1, fterms)
                 dat$temp$fterms <- fterms
                 dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
                 dat <- init_status.net(dat)
                 dat <- get_prev.net(dat, at = 1)
             }
             else {
                 dat <- list()
                 dat$nw <- x$network[[s]]
                 dat$param <- x$param
                 dat$control <- control
                 dat$nwparam <- x$nwparam
                 dat$epi <- sapply(x$epi, function(var) var[s])
                 names(dat$epi) <- names(x$epi)
                 dat$attr <- x$attr[[s]]
                 dat$stats <- sapply(x$stats, function(var) var[[s]])
                 dat$temp <- list()
             }
             return(dat)
         }, departures.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             d.rand <- dat$control$d.rand
             nDepartures.sus <- nDeparturesM2.sus <- 0
             idsElig.sus <- which(dat$attr$active == 1 & dat$attr$status == "s")
             nElig.sus <- length(idsElig.sus)
             if (nElig.sus > 0) {
                 mElig.sus <- mode[idsElig.sus]
                 rates.sus <- c(dat$param$ds.rate, dat$param$ds.rate.m2)
                 ratesElig.sus <- rates.sus[mElig.sus]
                 if (d.rand == TRUE) {
                     vecDepartures.sus <- which(rbinom(nElig.sus, 1, ratesElig.sus) == 
                       1)
                     if (length(vecDepartures.sus) > 0) {
                       idsDpt.sus <- idsElig.sus[vecDepartures.sus]
                       nDepartures.sus <- sum(mode[idsDpt.sus] == 1)
                       nDeparturesM2.sus <- sum(mode[idsDpt.sus] == 2)
                       dat$attr$active[idsDpt.sus] <- 0
                       dat$attr$exitTime[idsDpt.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.sus, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.sus <- idsDptM2.sus <- NULL
                     nDepartures.sus <- min(round(sum(ratesElig.sus[mElig.sus == 1])), 
                       sum(mElig.sus == 1))
                     idsDpt.sus <- ssample(idsElig.sus[mElig.sus == 1], nDepartures.sus)
                     if (modes == 2) {
                       nDeparturesM2.sus <- min(round(sum(ratesElig.sus[mElig.sus == 2])), 
                         sum(mElig.sus == 2))
                       idsDptM2.sus <- ssample(idsElig.sus[mElig.sus == 2], nDeparturesM2.sus)
                     }
                     totDpt.sus <- nDepartures.sus + nDeparturesM2.sus
                     if (totDpt.sus > 0) {
                       idsDptAll.sus <- c(idsDpt.sus, idsDptM2.sus)
                       dat$attr$active[idsDptAll.sus] <- 0
                       dat$attr$exitTime[idsDptAll.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.sus, deactivate.edges = TRUE)
                     }
                 }
             }
             nDepartures.inf <- nDeparturesM2.inf <- 0
             idsElig.inf <- which(dat$attr$active == 1 & dat$attr$status == "i")
             nElig.inf <- length(idsElig.inf)
             if (nElig.inf > 0) {
                 mElig.inf <- mode[idsElig.inf]
                 rates.inf <- c(dat$param$di.rate, dat$param$di.rate.m2)
                 ratesElig.inf <- rates.inf[mElig.inf]
                 if (d.rand == TRUE) {
                     vecDepartures.inf <- which(rbinom(nElig.inf, 1, ratesElig.inf) == 
                       1)
                     if (length(vecDepartures.inf) > 0) {
                       idsDpt.inf <- idsElig.inf[vecDepartures.inf]
                       nDepartures.inf <- sum(mode[idsDpt.inf] == 1)
                       nDeparturesM2.inf <- sum(mode[idsDpt.inf] == 2)
                       dat$attr$active[idsDpt.inf] <- 0
                       dat$attr$exitTime[idsDpt.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.inf, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.inf <- idsDptM2.inf <- NULL
                     nDepartures.inf <- min(round(sum(ratesElig.inf[mElig.inf == 1])), 
                       sum(mElig.inf == 1))
                     idsDpt.inf <- ssample(idsElig.inf[mElig.inf == 1], nDepartures.inf)
                     if (modes == 2) {
                       nDeparturesM2.inf <- min(round(sum(ratesElig.inf[mElig.inf == 2])), 
                         sum(mElig.inf == 2))
                       idsDptM2.inf <- ssample(idsElig.inf[mElig.inf == 2], nDeparturesM2.inf)
                     }
                     totDpt.inf <- nDepartures.inf + nDeparturesM2.inf
                     if (totDpt.inf > 0) {
                       idsDptAll.inf <- c(idsDpt.inf, idsDptM2.inf)
                       dat$attr$active[idsDptAll.inf] <- 0
                       dat$attr$exitTime[idsDptAll.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.inf, deactivate.edges = TRUE)
                     }
                 }
             }
             if (type == "SIR") {
                 nDepartures.rec <- nDeparturesM2.rec <- 0
                 idsElig.rec <- which(dat$attr$active == 1 & dat$attr$status == "r")
                 nElig.rec <- length(idsElig.rec)
                 if (nElig.rec > 0) {
                     mElig.rec <- mode[idsElig.rec]
                     rates.rec <- c(dat$param$dr.rate, dat$param$dr.rate.m2)
                     ratesElig.rec <- rates.rec[mElig.rec]
                     if (d.rand == TRUE) {
                       vecDepartures.rec <- which(rbinom(nElig.rec, 1, ratesElig.rec) == 
                         1)
                       if (length(vecDepartures.rec) > 0) {
                         idsDpt.rec <- idsElig.rec[vecDepartures.rec]
                         nDepartures.rec <- sum(mode[idsDpt.rec] == 1)
                         nDeparturesM2.rec <- sum(mode[idsDpt.rec] == 2)
                         dat$attr$active[idsDpt.rec] <- 0
                         dat$attr$exitTime[idsDpt.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.rec, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.rec <- idsDptM2.rec <- NULL
                       nDepartures.rec <- min(round(sum(ratesElig.rec[mElig.rec == 1])), 
                         sum(mElig.rec == 1))
                       idsDpt.rec <- ssample(idsElig.rec[mElig.rec == 1], nDepartures.rec)
                       if (modes == 2) {
                         nDeparturesM2.rec <- min(round(sum(ratesElig.rec[mElig.rec == 
                           2])), sum(mElig.rec == 2))
                         idsDptM2.rec <- ssample(idsElig.rec[mElig.rec == 2], nDeparturesM2.rec)
                       }
                       totDpt.rec <- nDepartures.rec + nDeparturesM2.rec
                       if (totDpt.rec > 0) {
                         idsDptAll.rec <- c(idsDpt.rec, idsDptM2.rec)
                         dat$attr$active[idsDptAll.rec] <- 0
                         dat$attr$exitTime[idsDptAll.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.rec, deactivate.edges = TRUE)
                       }
                     }
                 }
             }
             if (at == 2) {
                 dat$epi$ds.flow <- c(0, nDepartures.sus)
                 dat$epi$di.flow <- c(0, nDepartures.inf)
                 if (type == "SIR") {
                     dat$epi$dr.flow <- c(0, nDepartures.rec)
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2 <- c(0, nDeparturesM2.sus)
                     dat$epi$di.flow.m2 <- c(0, nDeparturesM2.inf)
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2 <- c(0, nDeparturesM2.rec)
                     }
                 }
             }
             else {
                 dat$epi$ds.flow[at] <- nDepartures.sus
                 dat$epi$di.flow[at] <- nDepartures.inf
                 if (type == "SIR") {
                     dat$epi$dr.flow[at] <- nDepartures.rec
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2[at] <- nDeparturesM2.sus
                     dat$epi$di.flow.m2[at] <- nDeparturesM2.inf
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2[at] <- nDeparturesM2.rec
                     }
                 }
             }
             return(dat)
         }, arrivals.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             a.rate <- dat$param$a.rate
             a.rate.m2 <- dat$param$a.rate.m2
             modes <- dat$param$modes
             tea.status <- dat$control$tea.status
             nOld <- dat$epi$num[at - 1]
             nCurr <- network.size(dat$nw)
             a.rand <- dat$control$a.rand
             delete.nodes <- dat$control$delete.nodes
             nArrivals <- nArrivalsM2 <- 0
             newNodes <- newNodesM2 <- NULL
             if (modes == 1 && nOld > 0) {
                 if (a.rand == TRUE) {
                     nArrivals <- sum(rbinom(nOld, 1, a.rate))
                 }
                 if (a.rand == FALSE) {
                     nArrivals <- round(nOld * a.rate)
                 }
                 if (nArrivals > 0) {
                     dat$nw <- add.vertices(dat$nw, nv = nArrivals)
                     newNodes <- (nCurr + 1):(nCurr + nArrivals)
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (modes == 2 && nOld > 0) {
                 nOldM2 <- dat$epi$num.m2[at - 1]
                 if (a.rand == TRUE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOld, 1, a.rate))
                     }
                     else {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOldM2, 1, a.rate.m2))
                     }
                 }
                 if (a.rand == FALSE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOld * a.rate)
                     }
                     else {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOldM2 * a.rate.m2)
                     }
                 }
                 nCurrM1 <- length(modeids(dat$nw, 1))
                 nCurrM2 <- length(modeids(dat$nw, 2))
                 prefixes <- unique(substr(dat$nw %v% "vertex.names", 1, 1))
                 if (nArrivals > 0) {
                     newNodeIDs <- (nCurrM1 + 1):(nCurrM1 + nArrivals)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[1], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE)
                     }
                     newNodes <- newNodeIDs
                 }
                 if (nArrivalsM2 > 0) {
                     newNodeIDs <- (nCurrM2 + 1):(nCurrM2 + nArrivalsM2)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[2], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE)
                     }
                     newSize <- network.size(dat$nw)
                     newNodesM2 <- (newSize - nArrivalsM2 + 1):newSize
                 }
                 newNodes <- c(newNodes, newNodesM2)
                 if (!is.null(newNodes)) {
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (length(newNodes) > 0) {
                 fterms <- dat$temp$fterms
                 curr.tab <- get_attr_prop(dat$nw, fterms)
                 if (length(curr.tab) > 0) {
                     dat$nw <- update_nwattr(dat$nw, newNodes, dat$control$attr.rules, 
                       curr.tab, dat$temp$t1.tab)
                 }
                 dat <- copy_toall_attr(dat, at, fterms)
                 if (tea.status == TRUE) {
                     if ("status" %in% fterms) {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = dat$attr$status[newNodes], onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                     else {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = "s", onset = at, terminus = Inf, v = newNodes)
                     }
                 }
                 if (modes == 1) {
                     if (!("status" %in% fterms)) {
                       dat$attr$status <- c(dat$attr$status, rep("s", length(newNodes)))
                     }
                     dat$attr$active <- c(dat$attr$active, rep(1, length(newNodes)))
                     dat$attr$infTime <- c(dat$attr$infTime, rep(NA, length(newNodes)))
                     dat$attr$entrTime <- c(dat$attr$entrTime, rep(at, length(newNodes)))
                     dat$attr$exitTime <- c(dat$attr$exitTime, rep(NA, length(newNodes)))
                 }
                 if (modes == 2) {
                     if (!("status" %in% fterms)) {
                       dat <- split_bip(dat, "status", "s", nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                     }
                     dat <- split_bip(dat, "active", 1, nCurrM1, nCurrM2, nArrivals, nArrivalsM2)
                     dat <- split_bip(dat, "infTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "entrTime", at, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "exitTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                 }
                 newNodesInf <- intersect(newNodes, which(dat$attr$status == "i"))
                 dat$attr$infTime[newNodesInf] <- at
                 if (length(unique(sapply(dat$attr, length))) != 1) {
                     stop("Attribute list of unequal length. Check arrivals.net module.")
                 }
             }
             if (at == 2) {
                 dat$epi$a.flow <- c(0, nArrivals)
                 if (modes == 2) {
                     dat$epi$a.flow.m2 <- c(0, nArrivalsM2)
                 }
             }
             else {
                 dat$epi$a.flow[at] <- nArrivals
                 if (modes == 2) {
                     dat$epi$a.flow.m2[at] <- nArrivalsM2
                 }
             }
             return(dat)
         }, recovery.FUN = function (dat, at) 
         {
             if (!(dat$control$type %in% c("SIR", "SIS"))) {
                 return(dat)
             }
             active <- dat$attr$active
             status <- dat$attr$status
             infTime <- dat$attr$infTime
             tea.status <- dat$control$tea.status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             recovState <- ifelse(type == "SIR", "r", "s")
             rec.rand <- dat$control$rec.rand
             rec.rate <- dat$param$rec.rate
             rec.rate.m2 <- dat$param$rec.rate.m2
             nRecov <- nRecovM2 <- 0
             idsElig <- which(active == 1 & status == "i")
             nElig <- length(idsElig)
             infDur <- at - infTime[active == 1 & status == "i"]
             infDur[infDur == 0] <- 1
             lrec.rate <- length(rec.rate)
             if (lrec.rate == 1) {
                 mElig <- mode[idsElig]
                 rates <- c(rec.rate, rec.rate.m2)
                 ratesElig <- rates[mElig]
             }
             else {
                 mElig <- mode[idsElig]
                 if (is.null(rec.rate.m2)) {
                     rates <- ifelse(infDur <= lrec.rate, rec.rate[infDur], rec.rate[lrec.rate])
                 }
                 else {
                     rates <- rep(NA, length(infDur))
                     rates[mElig == 1] <- ifelse(infDur[mElig == 1] <= lrec.rate, rec.rate[infDur[mElig == 
                       1]], rec.rate[lrec.rate])
                     rates[mElig == 2] <- ifelse(infDur[mElig == 2] <= length(rec.rate.m2), 
                       rec.rate.m2[infDur[mElig == 2]], rec.rate.m2[length(rec.rate.m2)])
                 }
                 ratesElig <- rates
             }
             if (nElig > 0) {
                 if (rec.rand == TRUE) {
                     vecRecov <- which(rbinom(nElig, 1, ratesElig) == 1)
                     if (length(vecRecov) > 0) {
                       idsRecov <- idsElig[vecRecov]
                       nRecov <- sum(mode[idsRecov] == 1)
                       nRecovM2 <- sum(mode[idsRecov] == 2)
                       status[idsRecov] <- recovState
                       if (tea.status == TRUE) {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = recovState, onset = at, terminus = Inf, v = idsRecov)
                       }
                     }
                 }
                 else {
                     idsRecov <- idsRecovM2 <- NULL
                     nRecov <- min(round(sum(ratesElig[mElig == 1])), sum(mElig == 1))
                     if (nRecov > 0) {
                       idsRecov <- ssample(idsElig[mElig == 1], nRecov)
                       status[idsRecov] <- recovState
                     }
                     if (modes == 2) {
                       nRecovM2 <- min(round(sum(ratesElig[mElig == 2])), sum(mElig == 
                         2))
                       if (nRecovM2 > 0) {
                         idsRecovM2 <- ssample(idsElig[mElig == 2], nRecovM2)
                         status[idsRecovM2] <- recovState
                       }
                     }
                     totRecov <- nRecov + nRecovM2
                     if (tea.status == TRUE & totRecov > 0) {
                       allids <- c(idsRecov, idsRecovM2)
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = recovState, onset = at, terminus = Inf, v = allids)
                     }
                 }
             }
             dat$attr$status <- status
             if ("status" %in% dat$temp$fterms) {
                 dat$nw <- set.vertex.attribute(dat$nw, "status", dat$attr$status)
             }
             outName <- ifelse(type == "SIR", "ir.flow", "is.flow")
             outName[2] <- paste0(outName, ".m2")
             if (at == 2) {
                 dat$epi[[outName[1]]] <- c(0, nRecov)
             }
             else {
                 dat$epi[[outName[1]]][at] <- nRecov
             }
             if (modes == 2) {
                 if (at == 2) {
                     dat$epi[[outName[2]]] <- c(0, nRecovM2)
                 }
                 else {
                     dat$epi[[outName[2]]][at] <- nRecovM2
                 }
             }
             return(dat)
         }, edges_correct.FUN = function (dat, at) 
         {
             if (dat$control$depend == TRUE) {
                 if (dat$param$modes == 1) {
                     old.num <- dat$epi$num[at - 1]
                     new.num <- sum(dat$attr$active == 1)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(old.num) - log(new.num)
                 }
                 if (dat$param$modes == 2) {
                     mode <- idmode(dat$nw)
                     old.num.m1 <- dat$epi$num[at - 1]
                     old.num.m2 <- dat$epi$num.m2[at - 1]
                     new.num.m1 <- sum(dat$attr$active == 1 & mode == 1)
                     new.num.m2 <- sum(dat$attr$active == 1 & mode == 2)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(2 * old.num.m1 * old.num.m2/(old.num.m1 + old.num.m2)) - log(2 * 
                       new.num.m1 * new.num.m2/(new.num.m1 + new.num.m2))
                 }
             }
             return(dat)
         }, resim_nets.FUN = function (dat, at) 
         {
             idsActive <- which(dat$attr$active == 1)
             anyActive <- ifelse(length(idsActive) > 0, TRUE, FALSE)
             if (dat$param$modes == 2) {
                 nActiveM1 <- length(intersect(modeids(dat$nw, mode = 1), idsActive))
                 nActiveM2 <- length(intersect(modeids(dat$nw, mode = 2), idsActive))
                 anyActive <- ifelse(nActiveM1 > 0 & nActiveM2 > 0, TRUE, FALSE)
             }
             nwparam <- get_nwparam(dat)
             statOnNw <- ("status" %in% dat$temp$fterms)
             status <- dat$attr$status
             if (statOnNw == TRUE && length(unique(status)) == 1) {
                 stop("Stopping simulation because status in formation formula and ", 
                     "no longer any discordant nodes", call. = TRUE)
             }
             if (dat$control$save.nwstats == TRUE) {
                 if (at == 2) {
                     nwstats <- attributes(dat$nw)$stats
                     dat$stats$nwstats <- as.data.frame(nwstats)
                 }
             }
             if (anyActive > 0 & dat$control$depend == TRUE) {
                 suppressWarnings(dat$nw <- simulate(dat$nw, formation = nwparam$formation, 
                     dissolution = nwparam$coef.diss$dissolution, coef.form = nwparam$coef.form, 
                     coef.diss = nwparam$coef.diss$coef.adj, constraints = nwparam$constraints, 
                     time.start = at, time.slices = 1, time.offset = 0, monitor = dat$control$nwstats.formula, 
                     control = dat$control$set.control.stergm))
                 if (dat$control$save.nwstats == TRUE) {
                     dat$stats$nwstats <- rbind(dat$stats$nwstats, tail(attributes(dat$nw)$stats, 
                       1))
                 }
                 if (dat$control$delete.nodes == TRUE) {
                     dat$nw <- network.extract(dat$nw, at = at)
                     inactive <- which(dat$attr$active == 0)
                     dat$attr <- deleteAttr(dat$attr, inactive)
                 }
             }
             return(dat)
         }, infection.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             status <- dat$attr$status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             inf.prob <- dat$param$inf.prob
             inf.prob.m2 <- dat$param$inf.prob.m2
             act.rate <- dat$param$act.rate
             nw <- dat$nw
             tea.status <- dat$control$tea.status
             idsInf <- which(active == 1 & status == "i")
             nActive <- sum(active == 1)
             nElig <- length(idsInf)
             nInf <- nInfM2 <- totInf <- 0
             if (nElig > 0 && nElig < nActive) {
                 del <- discord_edgelist(dat, at)
                 if (!(is.null(del))) {
                     del$infDur <- at - dat$attr$infTime[del$inf]
                     del$infDur[del$infDur == 0] <- 1
                     linf.prob <- length(inf.prob)
                     if (is.null(inf.prob.m2)) {
                       del$transProb <- ifelse(del$infDur <= linf.prob, inf.prob[del$infDur], 
                         inf.prob[linf.prob])
                     }
                     else {
                       del$transProb <- ifelse(del$sus <= nw %n% "bipartite", ifelse(del$infDur <= 
                         linf.prob, inf.prob[del$infDur], inf.prob[linf.prob]), ifelse(del$infDur <= 
                         linf.prob, inf.prob.m2[del$infDur], inf.prob.m2[linf.prob]))
                     }
                     if (!is.null(dat$param$inter.eff) && at >= dat$param$inter.start) {
                       del$transProb <- del$transProb * (1 - dat$param$inter.eff)
                     }
                     lact.rate <- length(act.rate)
                     del$actRate <- ifelse(del$infDur <= lact.rate, act.rate[del$infDur], 
                       act.rate[lact.rate])
                     del$finalProb <- 1 - (1 - del$transProb)^del$actRate
                     transmit <- rbinom(nrow(del), 1, del$finalProb)
                     del <- del[which(transmit == 1), ]
                     idsNewInf <- unique(del$sus)
                     nInf <- sum(mode[idsNewInf] == 1)
                     nInfM2 <- sum(mode[idsNewInf] == 2)
                     totInf <- nInf + nInfM2
                     if (totInf > 0) {
                       if (tea.status == TRUE) {
                         nw <- activate.vertex.attribute(nw, prefix = "testatus", value = "i", 
                           onset = at, terminus = Inf, v = idsNewInf)
                       }
                       dat$attr$status[idsNewInf] <- "i"
                       dat$attr$infTime[idsNewInf] <- at
                       if ("status" %in% dat$temp$fterms) {
                         nw <- set.vertex.attribute(nw, "status", dat$attr$status)
                       }
                     }
                     if (any(names(nw$gal) %in% "vertex.pid")) {
                       del$sus <- get.vertex.pid(nw, del$sus)
                       del$inf <- get.vertex.pid(nw, del$inf)
                     }
                 }
             }
             if (totInf > 0) {
                 del <- del[!duplicated(del$sus), ]
                 if (at == 2) {
                     dat$stats$transmat <- del
                 }
                 else {
                     dat$stats$transmat <- rbind(dat$stats$transmat, del)
                 }
             }
             if (at == 2) {
                 dat$epi$si.flow <- c(0, nInf)
                 if (modes == 2) {
                     dat$epi$si.flow.m2 <- c(0, nInfM2)
                 }
             }
             else {
                 dat$epi$si.flow[at] <- nInf
                 if (modes == 2) {
                     dat$epi$si.flow.m2[at] <- nInfM2
                 }
             }
             dat$nw <- nw
             return(dat)
         }, get_prev.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             modes <- dat$param$modes
             l <- lapply(1:length(dat$attr), function(x) dat$attr[[x]][active == 1])
             names(l) <- names(dat$attr)
             l$active <- l$infTime <- NULL
             status <- l$status
             if (modes == 2) {
                 mode <- idmode(dat$nw)[active == 1]
             }
             eb <- !is.null(dat$control$epi.by)
             if (eb == TRUE) {
                 ebn <- dat$control$epi.by
                 ebv <- dat$temp$epi.by.vals
                 ebun <- paste0(".", ebn, ebv)
                 assign(ebn, l[[ebn]])
             }
             if (modes == 1) {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]][at] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
             }
             else {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2 <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2 <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2 <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]] <- sum(status == "r" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2 <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2[at] <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2[at] <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2[at] <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]][at] <- sum(status == 
                             "r" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2[at] <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]][at] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
             }
             return(dat)
         }, verbose.FUN = function (x, type, s = 1, at = 2) 
         {
             if (type == "startup" && x$ncores == 1) {
                 if (x$verbose == TRUE) {
                     cat("\nStarting Network Simulation...")
                 }
             }
             if (type == "progress" && x$control$ncores == 1) {
                 if (x$control$verbose == TRUE) {
                     if (x$control$verbose.int == 0 && at == x$control$nsteps) {
                       cat("\nSim = ", s, "/", x$control$nsims, sep = "")
                     }
                     if (x$control$verbose.int > 0 && (at%%x$control$verbose.int == 0)) {
                       cat("\f")
                       cat("\nEpidemic Simulation")
                       cat("\n----------------------------")
                       cat("\nSimulation: ", s, "/", x$control$nsims, sep = "")
                       cat("\nTimestep: ", at, "/", x$control$nsteps, sep = "")
                       status <- x$attr$status
                       if (class(status) == "character") {
                         status <- ifelse(status == "i", 1, 0)
                       }
                       cat("\nPrevalence:", sum(status, na.rm = TRUE))
                       cat("\nPopulation Size:", sum(x$attr$active == 1))
                       cat("\n----------------------------")
                     }
                 }
             }
         }, module.order = NULL, save.nwstats = TRUE, nwstats.formula = ~edges + degree(0), 
         delete.nodes = FALSE, save.transmat = TRUE, save.network = TRUE, verbose = FALSE, 
         verbose.int = 1, skip.check = FALSE, bi.mods = c("initialize.FUN", "departures.FUN", 
         "arrivals.FUN", "recovery.FUN", "edges_correct.FUN", "resim_nets.FUN", "infection.FUN", 
         "get_prev.FUN", "verbose.FUN"), user.mods = character(0), attr.rules = list(), 
         set.control.stergm = structure(list(MCMC.burnin.min = 1000, MCMC.burnin.max = 1e+05, 
             MCMC.burnin.pval = 0.5, MCMC.burnin.add = 1, MCMC.burnin = NULL, MCMC.burnin.mul = NULL, 
             MCMC.prop.weights.form = "default", MCMC.prop.args.form = NULL, MCMC.prop.weights.diss = "default", 
             MCMC.prop.args.diss = NULL, MCMC.init.maxedges = 20000, MCMC.packagenames = NULL, 
             MCMC.init.maxchanges = 1e+06), class = c("control.simulate.network", "control.list", 
         "list")), set.control.ergm = structure(list(MCMC.burnin = 2e+05, MCMC.interval = NULL, 
             MCMC.prop.weights = NULL, MCMC.prop.args = NULL, MCMC.init.maxedges = NULL, 
             MCMC.packagenames = NULL, MCMC.runtime.traceplot = FALSE, network.output = "network", 
             term.options = NULL, parallel = 0, parallel.type = NULL, parallel.version.check = TRUE), class = c("control.simulate.ergm", 
         "control.list", "list")), depend = FALSE), class = c("control.net", "list")), 
         1L)
  4: sim_nets(x, nw, nsteps = control$nsteps, control)
  5: suppressWarnings(sim <- simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm))
  6: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  7: simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, coef.form = x$coef.form, 
         coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, time.start = 1, time.offset = 0, 
         constraints = x$constraints, monitor = control$nwstats.formula, nsim = 1, control = control$set.control.stergm)
  8: simulate.network(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm)
  9: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  10: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  11: lapply(X = X, FUN = FUN, ...)
  12: FUN(X[[i]], ...)
  13: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  14: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 3. Error: merge for netsim (@test-merge.R#90)  ------------------------------
  'Calloc' could not allocate memory (135547608 of 16 bytes)
  1: netsim(est, param, init, control) at testthat/test-merge.R:90
  2: do.call(control[["initialize.FUN"]], list(x, param, init, control, s))
  3: (function (x, param, init, control, s) 
     {
         if (control$start == 1) {
             dat <- list()
             dat$param <- param
             dat$init <- init
             dat$control <- control
             dat$attr <- list()
             dat$stats <- list()
             dat$temp <- list()
             nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
             modes <- ifelse(nw %n% "bipartite", 2, 1)
             if (control$depend == TRUE) {
                 if (class(x$fit) == "stergm") {
                     nw <- network.collapse(nw, at = 1)
                 }
                 nw <- sim_nets(x, nw, nsteps = 1, control)
             }
             if (control$depend == FALSE) {
                 nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
             }
             nw <- activate.vertices(nw, onset = 1, terminus = Inf)
             dat$nw <- nw
             dat$nwparam <- list(x[-which(names(x) == "fit")])
             dat$param$modes <- modes
             if (control$use.pids == TRUE) {
                 dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
             }
             form <- get_nwparam(dat)$formation
             fterms <- get_formula_term_attr(form, nw)
             dat <- copy_toall_attr(dat, at = 1, fterms)
             dat$temp$fterms <- fterms
             dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
             dat <- init_status.net(dat)
             dat <- get_prev.net(dat, at = 1)
         }
         else {
             dat <- list()
             dat$nw <- x$network[[s]]
             dat$param <- x$param
             dat$control <- control
             dat$nwparam <- x$nwparam
             dat$epi <- sapply(x$epi, function(var) var[s])
             names(dat$epi) <- names(x$epi)
             dat$attr <- x$attr[[s]]
             dat$stats <- sapply(x$stats, function(var) var[[s]])
             dat$temp <- list()
         }
         return(dat)
     })(structure(list(fit = structure(list(coef = c(edges = -5.28320371887165), iterations = 7L, 
         MCMCtheta = c(edges = -5.28320371887165), gradient = NA, hessian = structure(-24.8772140948116, .Dim = c(1L, 
         1L)), covar = structure(0.0401974270989033, .Dim = c(1L, 1L)), failure = FALSE, 
         est.cov = structure(0, .Dim = c(1L, 1L)), glm = structure(list(coefficients = c(edges = -5.28320371887165), 
             residuals = c(`1` = -1.00507614218206, `2` = 197.999998056331), fitted.values = c(`1` = 0.00505050510008338, 
             `2` = 0.00505050510008338), effects = c(edges = 26.3510684514833, 70.3513198991495
             ), R = structure(-4.98770629596528, .Dim = c(1L, 1L), .Dimnames = list("edges", 
                 "edges")), rank = 1L, qr = structure(list(qr = structure(c(-4.98770629596528, 
             0.0710669054518701), .Dim = 2:1, .Dimnames = list(c("1", "2"), "edges")), 
                 rank = 1L, qraux = 1.99747155094744, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -5.28320371887165, `2` = -5.28320371887165
             ), deviance = 314.286875806712, aic = 316.286875806712, null.deviance = 6862.15708754346, 
             iter = 7L, weights = c(`1` = 24.7515715993833, `2` = 0.125642495428342), 
             prior.weights = c(`1` = 4925, `2` = 25), df.residual = 1L, df.null = 2L, 
             y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = 0:1, edges = c(1, 1), `offset(pl$foffset)` = c(0, 0), `(weights)` = c(4925, 
                 25)), terms = pl$zy ~ edges - 1 + offset(pl$foffset), row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ . - 1 + offset(pl$foffset), family = family, 
                 data = data.frame(pl$xmat), weights = pl$wend), formula = pl$zy ~ . - 
                 1 + offset(pl$foffset), terms = pl$zy ~ edges - 1 + offset(pl$foffset), 
             data = structure(list(edges = c(1, 1)), class = "data.frame", row.names = c(NA, 
             -2L)), offset = c(0, 0), control = list(epsilon = 1e-08, maxit = 25, trace = FALSE), 
             method = "glm.fit", contrasts = NULL, xlevels = structure(list(), .Names = character(0))), class = c("glm", 
         "lm")), glm.null = structure(list(coefficients = c(`(Intercept)` = -5.28320371887165), 
             residuals = c(`1` = -1.00507614218206, `2` = 197.999998056331), fitted.values = c(`1` = 0.00505050510008338, 
             `2` = 0.00505050510008338), effects = c(`(Intercept)` = 26.3510684514833, 
             70.3513198991495), R = structure(-4.98770629596528, .Dim = c(1L, 1L), .Dimnames = list(
                 "(Intercept)", "(Intercept)")), rank = 1L, qr = structure(list(qr = structure(c(-4.98770629596528, 
             0.0710669054518701), .Dim = 2:1, .Dimnames = list(c("1", "2"), "(Intercept)")), 
                 rank = 1L, qraux = 1.99747155094744, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -5.28320371887165, `2` = -5.28320371887165
             ), deviance = 314.286875806712, aic = 316.286875806712, null.deviance = 314.286875806711, 
             iter = 7L, weights = c(`1` = 24.7515715993833, `2` = 0.125642495428342), 
             prior.weights = c(`1` = 4925, `2` = 25), df.residual = 1L, df.null = 1L, 
             y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = 0:1, `(weights)` = c(4925, 25)), terms = pl$zy ~ 1, row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ 1, family = family, weights = pl$wend), formula = pl$zy ~ 
                 1, terms = pl$zy ~ 1, data = <environment>, offset = NULL, control = list(
                 epsilon = 1e-08, maxit = 25, trace = FALSE), method = "glm.fit", contrasts = NULL, 
             xlevels = NULL), class = c("glm", "lm")), theta1 = list(coef = c(edges = -5.28320371887165), 
             theta = c(edges = -5.28320371887165), independent = c(edges = TRUE)), MPLE_is_MLE = TRUE, 
         ergm_version = structure(list(c(3L, 10L, 1L)), class = c("package_version", "numeric_version"
         )), offset = FALSE, drop = 0, estimable = TRUE, network = structure(list(mel = list(
             list(inl = 34L, outl = 1L, atl = list(na = FALSE)), list(inl = 78L, outl = 2L, 
                 atl = list(na = FALSE)), list(inl = 24L, outl = 4L, atl = list(na = FALSE)), 
             list(inl = 9L, outl = 5L, atl = list(na = FALSE)), list(inl = 97L, outl = 6L, 
                 atl = list(na = FALSE)), list(inl = 21L, outl = 7L, atl = list(na = FALSE)), 
             list(inl = 13L, outl = 11L, atl = list(na = FALSE)), list(inl = 84L, outl = 11L, 
                 atl = list(na = FALSE)), list(inl = 26L, outl = 13L, atl = list(na = FALSE)), 
             list(inl = 58L, outl = 13L, atl = list(na = FALSE)), list(inl = 98L, outl = 14L, 
                 atl = list(na = FALSE)), list(inl = 64L, outl = 15L, atl = list(na = FALSE)), 
             list(inl = 17L, outl = 16L, atl = list(na = FALSE)), list(inl = 37L, outl = 17L, 
                 atl = list(na = FALSE)), list(inl = 56L, outl = 25L, atl = list(na = FALSE)), 
             list(inl = 95L, outl = 28L, atl = list(na = FALSE)), list(inl = 54L, outl = 42L, 
                 atl = list(na = FALSE)), list(inl = 86L, outl = 42L, atl = list(na = FALSE)), 
             list(inl = 90L, outl = 46L, atl = list(na = FALSE)), list(inl = 61L, outl = 48L, 
                 atl = list(na = FALSE)), list(inl = 76L, outl = 50L, atl = list(na = FALSE)), 
             list(inl = 70L, outl = 57L, atl = list(na = FALSE)), list(inl = 94L, outl = 60L, 
                 atl = list(na = FALSE)), list(inl = 85L, outl = 81L, atl = list(na = FALSE)), 
             list(inl = 100L, outl = 81L, atl = list(na = FALSE))), gal = list(n = 100, 
             mnext = 26L, directed = FALSE, hyper = FALSE, loops = FALSE, multiple = FALSE, 
             bipartite = FALSE), val = list(list(na = FALSE, vertex.names = 1L), list(
             na = FALSE, vertex.names = 2L), list(na = FALSE, vertex.names = 3L), list(
             na = FALSE, vertex.names = 4L), list(na = FALSE, vertex.names = 5L), list(
             na = FALSE, vertex.names = 6L), list(na = FALSE, vertex.names = 7L), list(
             na = FALSE, vertex.names = 8L), list(na = FALSE, vertex.names = 9L), list(
             na = FALSE, vertex.names = 10L), list(na = FALSE, vertex.names = 11L), list(
             na = FALSE, vertex.names = 12L), list(na = FALSE, vertex.names = 13L), list(
             na = FALSE, vertex.names = 14L), list(na = FALSE, vertex.names = 15L), list(
             na = FALSE, vertex.names = 16L), list(na = FALSE, vertex.names = 17L), list(
             na = FALSE, vertex.names = 18L), list(na = FALSE, vertex.names = 19L), list(
             na = FALSE, vertex.names = 20L), list(na = FALSE, vertex.names = 21L), list(
             na = FALSE, vertex.names = 22L), list(na = FALSE, vertex.names = 23L), list(
             na = FALSE, vertex.names = 24L), list(na = FALSE, vertex.names = 25L), list(
             na = FALSE, vertex.names = 26L), list(na = FALSE, vertex.names = 27L), list(
             na = FALSE, vertex.names = 28L), list(na = FALSE, vertex.names = 29L), list(
             na = FALSE, vertex.names = 30L), list(na = FALSE, vertex.names = 31L), list(
             na = FALSE, vertex.names = 32L), list(na = FALSE, vertex.names = 33L), list(
             na = FALSE, vertex.names = 34L), list(na = FALSE, vertex.names = 35L), list(
             na = FALSE, vertex.names = 36L), list(na = FALSE, vertex.names = 37L), list(
             na = FALSE, vertex.names = 38L), list(na = FALSE, vertex.names = 39L), list(
             na = FALSE, vertex.names = 40L), list(na = FALSE, vertex.names = 41L), list(
             na = FALSE, vertex.names = 42L), list(na = FALSE, vertex.names = 43L), list(
             na = FALSE, vertex.names = 44L), list(na = FALSE, vertex.names = 45L), list(
             na = FALSE, vertex.names = 46L), list(na = FALSE, vertex.names = 47L), list(
             na = FALSE, vertex.names = 48L), list(na = FALSE, vertex.names = 49L), list(
             na = FALSE, vertex.names = 50L), list(na = FALSE, vertex.names = 51L), list(
             na = FALSE, vertex.names = 52L), list(na = FALSE, vertex.names = 53L), list(
             na = FALSE, vertex.names = 54L), list(na = FALSE, vertex.names = 55L), list(
             na = FALSE, vertex.names = 56L), list(na = FALSE, vertex.names = 57L), list(
             na = FALSE, vertex.names = 58L), list(na = FALSE, vertex.names = 59L), list(
             na = FALSE, vertex.names = 60L), list(na = FALSE, vertex.names = 61L), list(
             na = FALSE, vertex.names = 62L), list(na = FALSE, vertex.names = 63L), list(
             na = FALSE, vertex.names = 64L), list(na = FALSE, vertex.names = 65L), list(
             na = FALSE, vertex.names = 66L), list(na = FALSE, vertex.names = 67L), list(
             na = FALSE, vertex.names = 68L), list(na = FALSE, vertex.names = 69L), list(
             na = FALSE, vertex.names = 70L), list(na = FALSE, vertex.names = 71L), list(
             na = FALSE, vertex.names = 72L), list(na = FALSE, vertex.names = 73L), list(
             na = FALSE, vertex.names = 74L), list(na = FALSE, vertex.names = 75L), list(
             na = FALSE, vertex.names = 76L), list(na = FALSE, vertex.names = 77L), list(
             na = FALSE, vertex.names = 78L), list(na = FALSE, vertex.names = 79L), list(
             na = FALSE, vertex.names = 80L), list(na = FALSE, vertex.names = 81L), list(
             na = FALSE, vertex.names = 82L), list(na = FALSE, vertex.names = 83L), list(
             na = FALSE, vertex.names = 84L), list(na = FALSE, vertex.names = 85L), list(
             na = FALSE, vertex.names = 86L), list(na = FALSE, vertex.names = 87L), list(
             na = FALSE, vertex.names = 88L), list(na = FALSE, vertex.names = 89L), list(
             na = FALSE, vertex.names = 90L), list(na = FALSE, vertex.names = 91L), list(
             na = FALSE, vertex.names = 92L), list(na = FALSE, vertex.names = 93L), list(
             na = FALSE, vertex.names = 94L), list(na = FALSE, vertex.names = 95L), list(
             na = FALSE, vertex.names = 96L), list(na = FALSE, vertex.names = 97L), list(
             na = FALSE, vertex.names = 98L), list(na = FALSE, vertex.names = 99L), list(
             na = FALSE, vertex.names = 100L)), iel = list(integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), 4L, integer(0), 
             integer(0), integer(0), 7L, integer(0), integer(0), integer(0), 13L, integer(0), 
             integer(0), integer(0), 6L, integer(0), integer(0), 3L, integer(0), 9L, integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 1L, 
             integer(0), integer(0), 14L, integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), 17L, integer(0), 
             15L, integer(0), 10L, integer(0), integer(0), 20L, integer(0), integer(0), 
             12L, integer(0), integer(0), integer(0), integer(0), integer(0), 22L, integer(0), 
             integer(0), integer(0), integer(0), integer(0), 21L, integer(0), 2L, integer(0), 
             integer(0), integer(0), integer(0), integer(0), 8L, 24L, 18L, integer(0), 
             integer(0), integer(0), 19L, integer(0), integer(0), integer(0), 23L, 16L, 
             integer(0), 5L, 11L, integer(0), 25L), oel = list(1L, 2L, integer(0), 3L, 
             4L, 5L, 6L, integer(0), integer(0), integer(0), 8:7, integer(0), 10:9, 11L, 
             12L, 13L, 14L, integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), 15L, integer(0), integer(0), 16L, integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), 18:17, integer(0), integer(0), 
             integer(0), 19L, integer(0), 20L, integer(0), 21L, integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), 22L, integer(0), integer(0), 
             23L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             25:24, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0))), class = "network"), 
         reference = ~Bernoulli, newnetwork = structure(list(mel = list(list(inl = 34L, 
             outl = 1L, atl = list(na = FALSE)), list(inl = 78L, outl = 2L, atl = list(
             na = FALSE)), list(inl = 24L, outl = 4L, atl = list(na = FALSE)), list(inl = 9L, 
             outl = 5L, atl = list(na = FALSE)), list(inl = 97L, outl = 6L, atl = list(
             na = FALSE)), list(inl = 21L, outl = 7L, atl = list(na = FALSE)), list(inl = 13L, 
             outl = 11L, atl = list(na = FALSE)), list(inl = 84L, outl = 11L, atl = list(
             na = FALSE)), list(inl = 26L, outl = 13L, atl = list(na = FALSE)), list(inl = 58L, 
             outl = 13L, atl = list(na = FALSE)), list(inl = 98L, outl = 14L, atl = list(
             na = FALSE)), list(inl = 64L, outl = 15L, atl = list(na = FALSE)), list(inl = 17L, 
             outl = 16L, atl = list(na = FALSE)), list(inl = 37L, outl = 17L, atl = list(
             na = FALSE)), list(inl = 56L, outl = 25L, atl = list(na = FALSE)), list(inl = 95L, 
             outl = 28L, atl = list(na = FALSE)), list(inl = 54L, outl = 42L, atl = list(
             na = FALSE)), list(inl = 86L, outl = 42L, atl = list(na = FALSE)), list(inl = 90L, 
             outl = 46L, atl = list(na = FALSE)), list(inl = 61L, outl = 48L, atl = list(
             na = FALSE)), list(inl = 76L, outl = 50L, atl = list(na = FALSE)), list(inl = 70L, 
             outl = 57L, atl = list(na = FALSE)), list(inl = 94L, outl = 60L, atl = list(
             na = FALSE)), list(inl = 85L, outl = 81L, atl = list(na = FALSE)), list(inl = 100L, 
             outl = 81L, atl = list(na = FALSE))), gal = list(n = 100, mnext = 26L, directed = FALSE, 
             hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = FALSE), val = list(
             list(na = FALSE, vertex.names = 1L), list(na = FALSE, vertex.names = 2L), 
             list(na = FALSE, vertex.names = 3L), list(na = FALSE, vertex.names = 4L), 
             list(na = FALSE, vertex.names = 5L), list(na = FALSE, vertex.names = 6L), 
             list(na = FALSE, vertex.names = 7L), list(na = FALSE, vertex.names = 8L), 
             list(na = FALSE, vertex.names = 9L), list(na = FALSE, vertex.names = 10L), 
             list(na = FALSE, vertex.names = 11L), list(na = FALSE, vertex.names = 12L), 
             list(na = FALSE, vertex.names = 13L), list(na = FALSE, vertex.names = 14L), 
             list(na = FALSE, vertex.names = 15L), list(na = FALSE, vertex.names = 16L), 
             list(na = FALSE, vertex.names = 17L), list(na = FALSE, vertex.names = 18L), 
             list(na = FALSE, vertex.names = 19L), list(na = FALSE, vertex.names = 20L), 
             list(na = FALSE, vertex.names = 21L), list(na = FALSE, vertex.names = 22L), 
             list(na = FALSE, vertex.names = 23L), list(na = FALSE, vertex.names = 24L), 
             list(na = FALSE, vertex.names = 25L), list(na = FALSE, vertex.names = 26L), 
             list(na = FALSE, vertex.names = 27L), list(na = FALSE, vertex.names = 28L), 
             list(na = FALSE, vertex.names = 29L), list(na = FALSE, vertex.names = 30L), 
             list(na = FALSE, vertex.names = 31L), list(na = FALSE, vertex.names = 32L), 
             list(na = FALSE, vertex.names = 33L), list(na = FALSE, vertex.names = 34L), 
             list(na = FALSE, vertex.names = 35L), list(na = FALSE, vertex.names = 36L), 
             list(na = FALSE, vertex.names = 37L), list(na = FALSE, vertex.names = 38L), 
             list(na = FALSE, vertex.names = 39L), list(na = FALSE, vertex.names = 40L), 
             list(na = FALSE, vertex.names = 41L), list(na = FALSE, vertex.names = 42L), 
             list(na = FALSE, vertex.names = 43L), list(na = FALSE, vertex.names = 44L), 
             list(na = FALSE, vertex.names = 45L), list(na = FALSE, vertex.names = 46L), 
             list(na = FALSE, vertex.names = 47L), list(na = FALSE, vertex.names = 48L), 
             list(na = FALSE, vertex.names = 49L), list(na = FALSE, vertex.names = 50L), 
             list(na = FALSE, vertex.names = 51L), list(na = FALSE, vertex.names = 52L), 
             list(na = FALSE, vertex.names = 53L), list(na = FALSE, vertex.names = 54L), 
             list(na = FALSE, vertex.names = 55L), list(na = FALSE, vertex.names = 56L), 
             list(na = FALSE, vertex.names = 57L), list(na = FALSE, vertex.names = 58L), 
             list(na = FALSE, vertex.names = 59L), list(na = FALSE, vertex.names = 60L), 
             list(na = FALSE, vertex.names = 61L), list(na = FALSE, vertex.names = 62L), 
             list(na = FALSE, vertex.names = 63L), list(na = FALSE, vertex.names = 64L), 
             list(na = FALSE, vertex.names = 65L), list(na = FALSE, vertex.names = 66L), 
             list(na = FALSE, vertex.names = 67L), list(na = FALSE, vertex.names = 68L), 
             list(na = FALSE, vertex.names = 69L), list(na = FALSE, vertex.names = 70L), 
             list(na = FALSE, vertex.names = 71L), list(na = FALSE, vertex.names = 72L), 
             list(na = FALSE, vertex.names = 73L), list(na = FALSE, vertex.names = 74L), 
             list(na = FALSE, vertex.names = 75L), list(na = FALSE, vertex.names = 76L), 
             list(na = FALSE, vertex.names = 77L), list(na = FALSE, vertex.names = 78L), 
             list(na = FALSE, vertex.names = 79L), list(na = FALSE, vertex.names = 80L), 
             list(na = FALSE, vertex.names = 81L), list(na = FALSE, vertex.names = 82L), 
             list(na = FALSE, vertex.names = 83L), list(na = FALSE, vertex.names = 84L), 
             list(na = FALSE, vertex.names = 85L), list(na = FALSE, vertex.names = 86L), 
             list(na = FALSE, vertex.names = 87L), list(na = FALSE, vertex.names = 88L), 
             list(na = FALSE, vertex.names = 89L), list(na = FALSE, vertex.names = 90L), 
             list(na = FALSE, vertex.names = 91L), list(na = FALSE, vertex.names = 92L), 
             list(na = FALSE, vertex.names = 93L), list(na = FALSE, vertex.names = 94L), 
             list(na = FALSE, vertex.names = 95L), list(na = FALSE, vertex.names = 96L), 
             list(na = FALSE, vertex.names = 97L), list(na = FALSE, vertex.names = 98L), 
             list(na = FALSE, vertex.names = 99L), list(na = FALSE, vertex.names = 100L)), 
             iel = list(integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 4L, integer(0), integer(0), integer(0), 7L, integer(0), 
                 integer(0), integer(0), 13L, integer(0), integer(0), integer(0), 6L, 
                 integer(0), integer(0), 3L, integer(0), 9L, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), 1L, integer(0), integer(0), 
                 14L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), 17L, integer(0), 15L, 
                 integer(0), 10L, integer(0), integer(0), 20L, integer(0), integer(0), 
                 12L, integer(0), integer(0), integer(0), integer(0), integer(0), 22L, 
                 integer(0), integer(0), integer(0), integer(0), integer(0), 21L, integer(0), 
                 2L, integer(0), integer(0), integer(0), integer(0), integer(0), 8L, 24L, 
                 18L, integer(0), integer(0), integer(0), 19L, integer(0), integer(0), 
                 integer(0), 23L, 16L, integer(0), 5L, 11L, integer(0), 25L), oel = list(
                 1L, 2L, integer(0), 3L, 4L, 5L, 6L, integer(0), integer(0), integer(0), 
                 8:7, integer(0), 10:9, 11L, 12L, 13L, 14L, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), 15L, integer(0), integer(0), 
                 16L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), 18:17, integer(0), integer(0), integer(0), 19L, integer(0), 
                 20L, integer(0), 21L, integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 22L, integer(0), integer(0), 23L, integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), 25:24, integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0))), class = "network"), formula = TARGET_STATS ~ 
             edges, constraints = ~., target.stats = c(edges = 25), etamap = list(canonical = 1L, 
             offsetmap = FALSE, offset = FALSE, offsettheta = FALSE, curved = list(), 
             etalength = 1), target.esteq = structure(-25, .Dim = c(1L, 1L), .Dimnames = list(
             NULL, "edges")), estimate = "MLE", control = structure(list(drop = TRUE, 
             init = NA_real_, init.method = "MPLE", main.method = "MCMLE", force.main = FALSE, 
             main.hessian = TRUE, checkpoint = NULL, resume = NULL, MPLE.max.dyad.types = 1e+06, 
             MPLE.samplesize = 50000, MPLE.type = "glm", MCMC.prop.weights = "default", 
             MCMC.prop.args = list(), MCMC.interval = 1024, MCMC.burnin = 16384, MCMC.samplesize = 1024, 
             MCMC.effectiveSize = NULL, MCMC.effectiveSize.damp = 10, MCMC.effectiveSize.maxruns = 1000, 
             MCMC.effectiveSize.base = 0.5, MCMC.effectiveSize.points = 5, MCMC.effectiveSize.order = 1, 
             MCMC.return.stats = TRUE, MCMC.runtime.traceplot = FALSE, MCMC.init.maxedges = 20000, 
             MCMC.max.maxedges = Inf, MCMC.addto.se = TRUE, MCMC.compress = FALSE, MCMC.packagenames = NULL, 
             SAN.maxit = 4, SAN.nsteps.times = 8, SAN.control = structure(list(SAN.maxit = 4, 
                 SAN.tau = 1, SAN.invcov = NULL, SAN.invcov.diag = FALSE, SAN.nsteps.alloc = function (nsim) 
                 2^seq_len(nsim), SAN.nsteps = 131072, SAN.samplesize = 1024, SAN.init.maxedges = 20000, 
                 SAN.max.maxedges = Inf, SAN.prop.weights = "default", SAN.prop.args = list(), 
                 SAN.packagenames = NULL, term.options = NULL, seed = NULL, parallel = 0, 
                 parallel.type = NULL, parallel.version.check = TRUE), class = c("control.san", 
             "control.list", "list")), MCMLE.termination = "Hummel", MCMLE.maxit = 20, 
             MCMLE.conv.min.pval = 0.5, MCMLE.NR.maxit = 100, MCMLE.NR.reltol = 1.49011611938477e-08, 
             obs.MCMC.samplesize = 1024, obs.MCMC.interval = 1024, obs.MCMC.burnin = 16384, 
             obs.MCMC.burnin.min = 1638.4, obs.MCMC.prop.weights = "default", obs.MCMC.prop.args = list(), 
             obs.MCMC.impute.min_informative = function (nw) 
             network.size(nw)/4, obs.MCMC.impute.default_density = function (nw) 
             2/network.size(nw), MCMLE.check.degeneracy = FALSE, MCMLE.MCMC.precision = 0.005, 
             MCMLE.MCMC.max.ESS.frac = 0.1, MCMLE.metric = "lognormal", MCMLE.method = "BFGS", 
             MCMLE.trustregion = 20, MCMLE.dampening = FALSE, MCMLE.dampening.min.ess = 20, 
             MCMLE.dampening.level = 0.1, MCMLE.steplength.margin = 0.05, MCMLE.steplength = 1, 
             MCMLE.adaptive.trustregion = 3, MCMLE.sequential = TRUE, MCMLE.density.guard.min = 10000, 
             MCMLE.density.guard = 20.0855369231877, MCMLE.effectiveSize = NULL, MCMLE.last.boost = 4, 
             MCMLE.Hummel.esteq = TRUE, MCMLE.Hummel.miss.sample = 100, MCMLE.Hummel.maxit = 25, 
             MCMLE.steplength.min = 1e-04, MCMLE.effectiveSize.interval_drop = 2, MCMLE.save_intermediates = NULL, 
             SA.phase1_n = NULL, SA.initial_gain = NULL, SA.nsubphases = 4, SA.niterations = NULL, 
             SA.phase3_n = NULL, SA.trustregion = 0.5, RM.phase1n_base = 7, RM.phase2n_base = 100, 
             RM.phase2sub = 7, RM.init_gain = 0.5, RM.phase3n = 500, Step.MCMC.samplesize = 100, 
             Step.maxit = 50, Step.gridsize = 100, CD.nsteps = 8, CD.multiplicity = 1, 
             CD.nsteps.obs = 128, CD.multiplicity.obs = 1, CD.maxit = 60, CD.conv.min.pval = 0.5, 
             CD.NR.maxit = 100, CD.NR.reltol = 1.49011611938477e-08, CD.metric = "naive", 
             CD.method = "BFGS", CD.trustregion = 20, CD.dampening = FALSE, CD.dampening.min.ess = 20, 
             CD.dampening.level = 0.1, CD.steplength.margin = 0.5, CD.steplength = 1, 
             CD.adaptive.trustregion = 3, CD.adaptive.epsilon = 0.01, CD.Hummel.esteq = TRUE, 
             CD.Hummel.miss.sample = 100, CD.Hummel.maxit = 25, CD.steplength.min = 1e-04, 
             loglik.control = structure(list(nsteps = 20, MCMC.burnin = NULL, MCMC.interval = NULL, 
                 MCMC.samplesize = NULL, obs.MCMC.samplesize = NULL, obs.MCMC.interval = NULL, 
                 obs.MCMC.burnin = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 warn.dyads = NULL, MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, 
                 term.options = NULL, seed = NULL, parallel = NULL, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.logLik.ergm", "control.list", 
             "list")), term.options = NULL, seed = NULL, parallel = 0, parallel.type = NULL, 
             parallel.version.check = TRUE), class = c("control.ergm", "control.list", 
         "list"))), class = "ergm"), formation = ~edges, target.stats = 25, target.stats.names = "edges", 
         coef.form = c(edges = -7.48042829620787), coef.form.crude = c(edges = -5.28320371887165), 
         coef.diss = structure(list(dissolution = ~offset(edges), duration = 10, coef.crude = 2.19722457733622, 
             coef.adj = 2.19722457733622, d.rate = 0, model.type = "homog"), class = "disscoef"), 
         constraints = ~., edapprox = TRUE), class = "netest"), structure(list(inf.prob = 1, 
         act.rate = 1, vital = FALSE), class = c("param.net", "list")), structure(list(
         i.num = 1), class = c("init.net", "list")), structure(list(type = "SI", nsteps = 20, 
         start = 1, nsims = 2, ncores = 1, rec.rand = TRUE, a.rand = TRUE, d.rand = TRUE, 
         tea.status = TRUE, use.pids = TRUE, initialize.FUN = function (x, param, init, 
             control, s) 
         {
             if (control$start == 1) {
                 dat <- list()
                 dat$param <- param
                 dat$init <- init
                 dat$control <- control
                 dat$attr <- list()
                 dat$stats <- list()
                 dat$temp <- list()
                 nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
                 modes <- ifelse(nw %n% "bipartite", 2, 1)
                 if (control$depend == TRUE) {
                     if (class(x$fit) == "stergm") {
                       nw <- network.collapse(nw, at = 1)
                     }
                     nw <- sim_nets(x, nw, nsteps = 1, control)
                 }
                 if (control$depend == FALSE) {
                     nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
                 }
                 nw <- activate.vertices(nw, onset = 1, terminus = Inf)
                 dat$nw <- nw
                 dat$nwparam <- list(x[-which(names(x) == "fit")])
                 dat$param$modes <- modes
                 if (control$use.pids == TRUE) {
                     dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
                 }
                 form <- get_nwparam(dat)$formation
                 fterms <- get_formula_term_attr(form, nw)
                 dat <- copy_toall_attr(dat, at = 1, fterms)
                 dat$temp$fterms <- fterms
                 dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
                 dat <- init_status.net(dat)
                 dat <- get_prev.net(dat, at = 1)
             }
             else {
                 dat <- list()
                 dat$nw <- x$network[[s]]
                 dat$param <- x$param
                 dat$control <- control
                 dat$nwparam <- x$nwparam
                 dat$epi <- sapply(x$epi, function(var) var[s])
                 names(dat$epi) <- names(x$epi)
                 dat$attr <- x$attr[[s]]
                 dat$stats <- sapply(x$stats, function(var) var[[s]])
                 dat$temp <- list()
             }
             return(dat)
         }, departures.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             d.rand <- dat$control$d.rand
             nDepartures.sus <- nDeparturesM2.sus <- 0
             idsElig.sus <- which(dat$attr$active == 1 & dat$attr$status == "s")
             nElig.sus <- length(idsElig.sus)
             if (nElig.sus > 0) {
                 mElig.sus <- mode[idsElig.sus]
                 rates.sus <- c(dat$param$ds.rate, dat$param$ds.rate.m2)
                 ratesElig.sus <- rates.sus[mElig.sus]
                 if (d.rand == TRUE) {
                     vecDepartures.sus <- which(rbinom(nElig.sus, 1, ratesElig.sus) == 
                       1)
                     if (length(vecDepartures.sus) > 0) {
                       idsDpt.sus <- idsElig.sus[vecDepartures.sus]
                       nDepartures.sus <- sum(mode[idsDpt.sus] == 1)
                       nDeparturesM2.sus <- sum(mode[idsDpt.sus] == 2)
                       dat$attr$active[idsDpt.sus] <- 0
                       dat$attr$exitTime[idsDpt.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.sus, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.sus <- idsDptM2.sus <- NULL
                     nDepartures.sus <- min(round(sum(ratesElig.sus[mElig.sus == 1])), 
                       sum(mElig.sus == 1))
                     idsDpt.sus <- ssample(idsElig.sus[mElig.sus == 1], nDepartures.sus)
                     if (modes == 2) {
                       nDeparturesM2.sus <- min(round(sum(ratesElig.sus[mElig.sus == 2])), 
                         sum(mElig.sus == 2))
                       idsDptM2.sus <- ssample(idsElig.sus[mElig.sus == 2], nDeparturesM2.sus)
                     }
                     totDpt.sus <- nDepartures.sus + nDeparturesM2.sus
                     if (totDpt.sus > 0) {
                       idsDptAll.sus <- c(idsDpt.sus, idsDptM2.sus)
                       dat$attr$active[idsDptAll.sus] <- 0
                       dat$attr$exitTime[idsDptAll.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.sus, deactivate.edges = TRUE)
                     }
                 }
             }
             nDepartures.inf <- nDeparturesM2.inf <- 0
             idsElig.inf <- which(dat$attr$active == 1 & dat$attr$status == "i")
             nElig.inf <- length(idsElig.inf)
             if (nElig.inf > 0) {
                 mElig.inf <- mode[idsElig.inf]
                 rates.inf <- c(dat$param$di.rate, dat$param$di.rate.m2)
                 ratesElig.inf <- rates.inf[mElig.inf]
                 if (d.rand == TRUE) {
                     vecDepartures.inf <- which(rbinom(nElig.inf, 1, ratesElig.inf) == 
                       1)
                     if (length(vecDepartures.inf) > 0) {
                       idsDpt.inf <- idsElig.inf[vecDepartures.inf]
                       nDepartures.inf <- sum(mode[idsDpt.inf] == 1)
                       nDeparturesM2.inf <- sum(mode[idsDpt.inf] == 2)
                       dat$attr$active[idsDpt.inf] <- 0
                       dat$attr$exitTime[idsDpt.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.inf, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.inf <- idsDptM2.inf <- NULL
                     nDepartures.inf <- min(round(sum(ratesElig.inf[mElig.inf == 1])), 
                       sum(mElig.inf == 1))
                     idsDpt.inf <- ssample(idsElig.inf[mElig.inf == 1], nDepartures.inf)
                     if (modes == 2) {
                       nDeparturesM2.inf <- min(round(sum(ratesElig.inf[mElig.inf == 2])), 
                         sum(mElig.inf == 2))
                       idsDptM2.inf <- ssample(idsElig.inf[mElig.inf == 2], nDeparturesM2.inf)
                     }
                     totDpt.inf <- nDepartures.inf + nDeparturesM2.inf
                     if (totDpt.inf > 0) {
                       idsDptAll.inf <- c(idsDpt.inf, idsDptM2.inf)
                       dat$attr$active[idsDptAll.inf] <- 0
                       dat$attr$exitTime[idsDptAll.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.inf, deactivate.edges = TRUE)
                     }
                 }
             }
             if (type == "SIR") {
                 nDepartures.rec <- nDeparturesM2.rec <- 0
                 idsElig.rec <- which(dat$attr$active == 1 & dat$attr$status == "r")
                 nElig.rec <- length(idsElig.rec)
                 if (nElig.rec > 0) {
                     mElig.rec <- mode[idsElig.rec]
                     rates.rec <- c(dat$param$dr.rate, dat$param$dr.rate.m2)
                     ratesElig.rec <- rates.rec[mElig.rec]
                     if (d.rand == TRUE) {
                       vecDepartures.rec <- which(rbinom(nElig.rec, 1, ratesElig.rec) == 
                         1)
                       if (length(vecDepartures.rec) > 0) {
                         idsDpt.rec <- idsElig.rec[vecDepartures.rec]
                         nDepartures.rec <- sum(mode[idsDpt.rec] == 1)
                         nDeparturesM2.rec <- sum(mode[idsDpt.rec] == 2)
                         dat$attr$active[idsDpt.rec] <- 0
                         dat$attr$exitTime[idsDpt.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.rec, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.rec <- idsDptM2.rec <- NULL
                       nDepartures.rec <- min(round(sum(ratesElig.rec[mElig.rec == 1])), 
                         sum(mElig.rec == 1))
                       idsDpt.rec <- ssample(idsElig.rec[mElig.rec == 1], nDepartures.rec)
                       if (modes == 2) {
                         nDeparturesM2.rec <- min(round(sum(ratesElig.rec[mElig.rec == 
                           2])), sum(mElig.rec == 2))
                         idsDptM2.rec <- ssample(idsElig.rec[mElig.rec == 2], nDeparturesM2.rec)
                       }
                       totDpt.rec <- nDepartures.rec + nDeparturesM2.rec
                       if (totDpt.rec > 0) {
                         idsDptAll.rec <- c(idsDpt.rec, idsDptM2.rec)
                         dat$attr$active[idsDptAll.rec] <- 0
                         dat$attr$exitTime[idsDptAll.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.rec, deactivate.edges = TRUE)
                       }
                     }
                 }
             }
             if (at == 2) {
                 dat$epi$ds.flow <- c(0, nDepartures.sus)
                 dat$epi$di.flow <- c(0, nDepartures.inf)
                 if (type == "SIR") {
                     dat$epi$dr.flow <- c(0, nDepartures.rec)
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2 <- c(0, nDeparturesM2.sus)
                     dat$epi$di.flow.m2 <- c(0, nDeparturesM2.inf)
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2 <- c(0, nDeparturesM2.rec)
                     }
                 }
             }
             else {
                 dat$epi$ds.flow[at] <- nDepartures.sus
                 dat$epi$di.flow[at] <- nDepartures.inf
                 if (type == "SIR") {
                     dat$epi$dr.flow[at] <- nDepartures.rec
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2[at] <- nDeparturesM2.sus
                     dat$epi$di.flow.m2[at] <- nDeparturesM2.inf
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2[at] <- nDeparturesM2.rec
                     }
                 }
             }
             return(dat)
         }, arrivals.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             a.rate <- dat$param$a.rate
             a.rate.m2 <- dat$param$a.rate.m2
             modes <- dat$param$modes
             tea.status <- dat$control$tea.status
             nOld <- dat$epi$num[at - 1]
             nCurr <- network.size(dat$nw)
             a.rand <- dat$control$a.rand
             delete.nodes <- dat$control$delete.nodes
             nArrivals <- nArrivalsM2 <- 0
             newNodes <- newNodesM2 <- NULL
             if (modes == 1 && nOld > 0) {
                 if (a.rand == TRUE) {
                     nArrivals <- sum(rbinom(nOld, 1, a.rate))
                 }
                 if (a.rand == FALSE) {
                     nArrivals <- round(nOld * a.rate)
                 }
                 if (nArrivals > 0) {
                     dat$nw <- add.vertices(dat$nw, nv = nArrivals)
                     newNodes <- (nCurr + 1):(nCurr + nArrivals)
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (modes == 2 && nOld > 0) {
                 nOldM2 <- dat$epi$num.m2[at - 1]
                 if (a.rand == TRUE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOld, 1, a.rate))
                     }
                     else {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOldM2, 1, a.rate.m2))
                     }
                 }
                 if (a.rand == FALSE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOld * a.rate)
                     }
                     else {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOldM2 * a.rate.m2)
                     }
                 }
                 nCurrM1 <- length(modeids(dat$nw, 1))
                 nCurrM2 <- length(modeids(dat$nw, 2))
                 prefixes <- unique(substr(dat$nw %v% "vertex.names", 1, 1))
                 if (nArrivals > 0) {
                     newNodeIDs <- (nCurrM1 + 1):(nCurrM1 + nArrivals)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[1], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE)
                     }
                     newNodes <- newNodeIDs
                 }
                 if (nArrivalsM2 > 0) {
                     newNodeIDs <- (nCurrM2 + 1):(nCurrM2 + nArrivalsM2)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[2], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE)
                     }
                     newSize <- network.size(dat$nw)
                     newNodesM2 <- (newSize - nArrivalsM2 + 1):newSize
                 }
                 newNodes <- c(newNodes, newNodesM2)
                 if (!is.null(newNodes)) {
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (length(newNodes) > 0) {
                 fterms <- dat$temp$fterms
                 curr.tab <- get_attr_prop(dat$nw, fterms)
                 if (length(curr.tab) > 0) {
                     dat$nw <- update_nwattr(dat$nw, newNodes, dat$control$attr.rules, 
                       curr.tab, dat$temp$t1.tab)
                 }
                 dat <- copy_toall_attr(dat, at, fterms)
                 if (tea.status == TRUE) {
                     if ("status" %in% fterms) {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = dat$attr$status[newNodes], onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                     else {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = "s", onset = at, terminus = Inf, v = newNodes)
                     }
                 }
                 if (modes == 1) {
                     if (!("status" %in% fterms)) {
                       dat$attr$status <- c(dat$attr$status, rep("s", length(newNodes)))
                     }
                     dat$attr$active <- c(dat$attr$active, rep(1, length(newNodes)))
                     dat$attr$infTime <- c(dat$attr$infTime, rep(NA, length(newNodes)))
                     dat$attr$entrTime <- c(dat$attr$entrTime, rep(at, length(newNodes)))
                     dat$attr$exitTime <- c(dat$attr$exitTime, rep(NA, length(newNodes)))
                 }
                 if (modes == 2) {
                     if (!("status" %in% fterms)) {
                       dat <- split_bip(dat, "status", "s", nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                     }
                     dat <- split_bip(dat, "active", 1, nCurrM1, nCurrM2, nArrivals, nArrivalsM2)
                     dat <- split_bip(dat, "infTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "entrTime", at, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "exitTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                 }
                 newNodesInf <- intersect(newNodes, which(dat$attr$status == "i"))
                 dat$attr$infTime[newNodesInf] <- at
                 if (length(unique(sapply(dat$attr, length))) != 1) {
                     stop("Attribute list of unequal length. Check arrivals.net module.")
                 }
             }
             if (at == 2) {
                 dat$epi$a.flow <- c(0, nArrivals)
                 if (modes == 2) {
                     dat$epi$a.flow.m2 <- c(0, nArrivalsM2)
                 }
             }
             else {
                 dat$epi$a.flow[at] <- nArrivals
                 if (modes == 2) {
                     dat$epi$a.flow.m2[at] <- nArrivalsM2
                 }
             }
             return(dat)
         }, recovery.FUN = function (dat, at) 
         {
             if (!(dat$control$type %in% c("SIR", "SIS"))) {
                 return(dat)
             }
             active <- dat$attr$active
             status <- dat$attr$status
             infTime <- dat$attr$infTime
             tea.status <- dat$control$tea.status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             recovState <- ifelse(type == "SIR", "r", "s")
             rec.rand <- dat$control$rec.rand
             rec.rate <- dat$param$rec.rate
             rec.rate.m2 <- dat$param$rec.rate.m2
             nRecov <- nRecovM2 <- 0
             idsElig <- which(active == 1 & status == "i")
             nElig <- length(idsElig)
             infDur <- at - infTime[active == 1 & status == "i"]
             infDur[infDur == 0] <- 1
             lrec.rate <- length(rec.rate)
             if (lrec.rate == 1) {
                 mElig <- mode[idsElig]
                 rates <- c(rec.rate, rec.rate.m2)
                 ratesElig <- rates[mElig]
             }
             else {
                 mElig <- mode[idsElig]
                 if (is.null(rec.rate.m2)) {
                     rates <- ifelse(infDur <= lrec.rate, rec.rate[infDur], rec.rate[lrec.rate])
                 }
                 else {
                     rates <- rep(NA, length(infDur))
                     rates[mElig == 1] <- ifelse(infDur[mElig == 1] <= lrec.rate, rec.rate[infDur[mElig == 
                       1]], rec.rate[lrec.rate])
                     rates[mElig == 2] <- ifelse(infDur[mElig == 2] <= length(rec.rate.m2), 
                       rec.rate.m2[infDur[mElig == 2]], rec.rate.m2[length(rec.rate.m2)])
                 }
                 ratesElig <- rates
             }
             if (nElig > 0) {
                 if (rec.rand == TRUE) {
                     vecRecov <- which(rbinom(nElig, 1, ratesElig) == 1)
                     if (length(vecRecov) > 0) {
                       idsRecov <- idsElig[vecRecov]
                       nRecov <- sum(mode[idsRecov] == 1)
                       nRecovM2 <- sum(mode[idsRecov] == 2)
                       status[idsRecov] <- recovState
                       if (tea.status == TRUE) {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = recovState, onset = at, terminus = Inf, v = idsRecov)
                       }
                     }
                 }
                 else {
                     idsRecov <- idsRecovM2 <- NULL
                     nRecov <- min(round(sum(ratesElig[mElig == 1])), sum(mElig == 1))
                     if (nRecov > 0) {
                       idsRecov <- ssample(idsElig[mElig == 1], nRecov)
                       status[idsRecov] <- recovState
                     }
                     if (modes == 2) {
                       nRecovM2 <- min(round(sum(ratesElig[mElig == 2])), sum(mElig == 
                         2))
                       if (nRecovM2 > 0) {
                         idsRecovM2 <- ssample(idsElig[mElig == 2], nRecovM2)
                         status[idsRecovM2] <- recovState
                       }
                     }
                     totRecov <- nRecov + nRecovM2
                     if (tea.status == TRUE & totRecov > 0) {
                       allids <- c(idsRecov, idsRecovM2)
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = recovState, onset = at, terminus = Inf, v = allids)
                     }
                 }
             }
             dat$attr$status <- status
             if ("status" %in% dat$temp$fterms) {
                 dat$nw <- set.vertex.attribute(dat$nw, "status", dat$attr$status)
             }
             outName <- ifelse(type == "SIR", "ir.flow", "is.flow")
             outName[2] <- paste0(outName, ".m2")
             if (at == 2) {
                 dat$epi[[outName[1]]] <- c(0, nRecov)
             }
             else {
                 dat$epi[[outName[1]]][at] <- nRecov
             }
             if (modes == 2) {
                 if (at == 2) {
                     dat$epi[[outName[2]]] <- c(0, nRecovM2)
                 }
                 else {
                     dat$epi[[outName[2]]][at] <- nRecovM2
                 }
             }
             return(dat)
         }, edges_correct.FUN = function (dat, at) 
         {
             if (dat$control$depend == TRUE) {
                 if (dat$param$modes == 1) {
                     old.num <- dat$epi$num[at - 1]
                     new.num <- sum(dat$attr$active == 1)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(old.num) - log(new.num)
                 }
                 if (dat$param$modes == 2) {
                     mode <- idmode(dat$nw)
                     old.num.m1 <- dat$epi$num[at - 1]
                     old.num.m2 <- dat$epi$num.m2[at - 1]
                     new.num.m1 <- sum(dat$attr$active == 1 & mode == 1)
                     new.num.m2 <- sum(dat$attr$active == 1 & mode == 2)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(2 * old.num.m1 * old.num.m2/(old.num.m1 + old.num.m2)) - log(2 * 
                       new.num.m1 * new.num.m2/(new.num.m1 + new.num.m2))
                 }
             }
             return(dat)
         }, resim_nets.FUN = function (dat, at) 
         {
             idsActive <- which(dat$attr$active == 1)
             anyActive <- ifelse(length(idsActive) > 0, TRUE, FALSE)
             if (dat$param$modes == 2) {
                 nActiveM1 <- length(intersect(modeids(dat$nw, mode = 1), idsActive))
                 nActiveM2 <- length(intersect(modeids(dat$nw, mode = 2), idsActive))
                 anyActive <- ifelse(nActiveM1 > 0 & nActiveM2 > 0, TRUE, FALSE)
             }
             nwparam <- get_nwparam(dat)
             statOnNw <- ("status" %in% dat$temp$fterms)
             status <- dat$attr$status
             if (statOnNw == TRUE && length(unique(status)) == 1) {
                 stop("Stopping simulation because status in formation formula and ", 
                     "no longer any discordant nodes", call. = TRUE)
             }
             if (dat$control$save.nwstats == TRUE) {
                 if (at == 2) {
                     nwstats <- attributes(dat$nw)$stats
                     dat$stats$nwstats <- as.data.frame(nwstats)
                 }
             }
             if (anyActive > 0 & dat$control$depend == TRUE) {
                 suppressWarnings(dat$nw <- simulate(dat$nw, formation = nwparam$formation, 
                     dissolution = nwparam$coef.diss$dissolution, coef.form = nwparam$coef.form, 
                     coef.diss = nwparam$coef.diss$coef.adj, constraints = nwparam$constraints, 
                     time.start = at, time.slices = 1, time.offset = 0, monitor = dat$control$nwstats.formula, 
                     control = dat$control$set.control.stergm))
                 if (dat$control$save.nwstats == TRUE) {
                     dat$stats$nwstats <- rbind(dat$stats$nwstats, tail(attributes(dat$nw)$stats, 
                       1))
                 }
                 if (dat$control$delete.nodes == TRUE) {
                     dat$nw <- network.extract(dat$nw, at = at)
                     inactive <- which(dat$attr$active == 0)
                     dat$attr <- deleteAttr(dat$attr, inactive)
                 }
             }
             return(dat)
         }, infection.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             status <- dat$attr$status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             inf.prob <- dat$param$inf.prob
             inf.prob.m2 <- dat$param$inf.prob.m2
             act.rate <- dat$param$act.rate
             nw <- dat$nw
             tea.status <- dat$control$tea.status
             idsInf <- which(active == 1 & status == "i")
             nActive <- sum(active == 1)
             nElig <- length(idsInf)
             nInf <- nInfM2 <- totInf <- 0
             if (nElig > 0 && nElig < nActive) {
                 del <- discord_edgelist(dat, at)
                 if (!(is.null(del))) {
                     del$infDur <- at - dat$attr$infTime[del$inf]
                     del$infDur[del$infDur == 0] <- 1
                     linf.prob <- length(inf.prob)
                     if (is.null(inf.prob.m2)) {
                       del$transProb <- ifelse(del$infDur <= linf.prob, inf.prob[del$infDur], 
                         inf.prob[linf.prob])
                     }
                     else {
                       del$transProb <- ifelse(del$sus <= nw %n% "bipartite", ifelse(del$infDur <= 
                         linf.prob, inf.prob[del$infDur], inf.prob[linf.prob]), ifelse(del$infDur <= 
                         linf.prob, inf.prob.m2[del$infDur], inf.prob.m2[linf.prob]))
                     }
                     if (!is.null(dat$param$inter.eff) && at >= dat$param$inter.start) {
                       del$transProb <- del$transProb * (1 - dat$param$inter.eff)
                     }
                     lact.rate <- length(act.rate)
                     del$actRate <- ifelse(del$infDur <= lact.rate, act.rate[del$infDur], 
                       act.rate[lact.rate])
                     del$finalProb <- 1 - (1 - del$transProb)^del$actRate
                     transmit <- rbinom(nrow(del), 1, del$finalProb)
                     del <- del[which(transmit == 1), ]
                     idsNewInf <- unique(del$sus)
                     nInf <- sum(mode[idsNewInf] == 1)
                     nInfM2 <- sum(mode[idsNewInf] == 2)
                     totInf <- nInf + nInfM2
                     if (totInf > 0) {
                       if (tea.status == TRUE) {
                         nw <- activate.vertex.attribute(nw, prefix = "testatus", value = "i", 
                           onset = at, terminus = Inf, v = idsNewInf)
                       }
                       dat$attr$status[idsNewInf] <- "i"
                       dat$attr$infTime[idsNewInf] <- at
                       if ("status" %in% dat$temp$fterms) {
                         nw <- set.vertex.attribute(nw, "status", dat$attr$status)
                       }
                     }
                     if (any(names(nw$gal) %in% "vertex.pid")) {
                       del$sus <- get.vertex.pid(nw, del$sus)
                       del$inf <- get.vertex.pid(nw, del$inf)
                     }
                 }
             }
             if (totInf > 0) {
                 del <- del[!duplicated(del$sus), ]
                 if (at == 2) {
                     dat$stats$transmat <- del
                 }
                 else {
                     dat$stats$transmat <- rbind(dat$stats$transmat, del)
                 }
             }
             if (at == 2) {
                 dat$epi$si.flow <- c(0, nInf)
                 if (modes == 2) {
                     dat$epi$si.flow.m2 <- c(0, nInfM2)
                 }
             }
             else {
                 dat$epi$si.flow[at] <- nInf
                 if (modes == 2) {
                     dat$epi$si.flow.m2[at] <- nInfM2
                 }
             }
             dat$nw <- nw
             return(dat)
         }, get_prev.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             modes <- dat$param$modes
             l <- lapply(1:length(dat$attr), function(x) dat$attr[[x]][active == 1])
             names(l) <- names(dat$attr)
             l$active <- l$infTime <- NULL
             status <- l$status
             if (modes == 2) {
                 mode <- idmode(dat$nw)[active == 1]
             }
             eb <- !is.null(dat$control$epi.by)
             if (eb == TRUE) {
                 ebn <- dat$control$epi.by
                 ebv <- dat$temp$epi.by.vals
                 ebun <- paste0(".", ebn, ebv)
                 assign(ebn, l[[ebn]])
             }
             if (modes == 1) {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]][at] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
             }
             else {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2 <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2 <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2 <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]] <- sum(status == "r" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2 <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2[at] <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2[at] <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2[at] <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]][at] <- sum(status == 
                             "r" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2[at] <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]][at] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
             }
             return(dat)
         }, verbose.FUN = function (x, type, s = 1, at = 2) 
         {
             if (type == "startup" && x$ncores == 1) {
                 if (x$verbose == TRUE) {
                     cat("\nStarting Network Simulation...")
                 }
             }
             if (type == "progress" && x$control$ncores == 1) {
                 if (x$control$verbose == TRUE) {
                     if (x$control$verbose.int == 0 && at == x$control$nsteps) {
                       cat("\nSim = ", s, "/", x$control$nsims, sep = "")
                     }
                     if (x$control$verbose.int > 0 && (at%%x$control$verbose.int == 0)) {
                       cat("\f")
                       cat("\nEpidemic Simulation")
                       cat("\n----------------------------")
                       cat("\nSimulation: ", s, "/", x$control$nsims, sep = "")
                       cat("\nTimestep: ", at, "/", x$control$nsteps, sep = "")
                       status <- x$attr$status
                       if (class(status) == "character") {
                         status <- ifelse(status == "i", 1, 0)
                       }
                       cat("\nPrevalence:", sum(status, na.rm = TRUE))
                       cat("\nPopulation Size:", sum(x$attr$active == 1))
                       cat("\n----------------------------")
                     }
                 }
             }
         }, module.order = NULL, save.nwstats = TRUE, nwstats.formula = ~edges + degree(0), 
         delete.nodes = FALSE, save.transmat = TRUE, save.network = TRUE, save.other = "attr", 
         verbose = FALSE, verbose.int = 1, skip.check = FALSE, bi.mods = c("initialize.FUN", 
         "departures.FUN", "arrivals.FUN", "recovery.FUN", "edges_correct.FUN", "resim_nets.FUN", 
         "infection.FUN", "get_prev.FUN", "verbose.FUN"), user.mods = character(0), attr.rules = list(), 
         set.control.stergm = structure(list(MCMC.burnin.min = 1000, MCMC.burnin.max = 1e+05, 
             MCMC.burnin.pval = 0.5, MCMC.burnin.add = 1, MCMC.burnin = NULL, MCMC.burnin.mul = NULL, 
             MCMC.prop.weights.form = "default", MCMC.prop.args.form = NULL, MCMC.prop.weights.diss = "default", 
             MCMC.prop.args.diss = NULL, MCMC.init.maxedges = 20000, MCMC.packagenames = NULL, 
             MCMC.init.maxchanges = 1e+06), class = c("control.simulate.network", "control.list", 
         "list")), set.control.ergm = structure(list(MCMC.burnin = 2e+05, MCMC.interval = NULL, 
             MCMC.prop.weights = NULL, MCMC.prop.args = NULL, MCMC.init.maxedges = NULL, 
             MCMC.packagenames = NULL, MCMC.runtime.traceplot = FALSE, network.output = "network", 
             term.options = NULL, parallel = 0, parallel.type = NULL, parallel.version.check = TRUE), class = c("control.simulate.ergm", 
         "control.list", "list")), depend = FALSE), class = c("control.net", "list")), 
         1L)
  4: sim_nets(x, nw, nsteps = control$nsteps, control)
  5: suppressWarnings(sim <- simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm))
  6: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  7: simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, coef.form = x$coef.form, 
         coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, time.start = 1, time.offset = 0, 
         constraints = x$constraints, monitor = control$nwstats.formula, nsim = 1, control = control$set.control.stergm)
  8: simulate.network(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm)
  9: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  10: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  11: lapply(X = X, FUN = FUN, ...)
  12: FUN(X[[i]], ...)
  13: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  14: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 4. Error: mutate_epi.netsim (@test-mutate.R#15)  ----------------------------
  'Calloc' could not allocate memory (270655681 of 16 bytes)
  1: netsim(est1, param, init, control) at testthat/test-mutate.R:15
  2: do.call(control[["initialize.FUN"]], list(x, param, init, control, s))
  3: (function (x, param, init, control, s) 
     {
         if (control$start == 1) {
             dat <- list()
             dat$param <- param
             dat$init <- init
             dat$control <- control
             dat$attr <- list()
             dat$stats <- list()
             dat$temp <- list()
             nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
             modes <- ifelse(nw %n% "bipartite", 2, 1)
             if (control$depend == TRUE) {
                 if (class(x$fit) == "stergm") {
                     nw <- network.collapse(nw, at = 1)
                 }
                 nw <- sim_nets(x, nw, nsteps = 1, control)
             }
             if (control$depend == FALSE) {
                 nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
             }
             nw <- activate.vertices(nw, onset = 1, terminus = Inf)
             dat$nw <- nw
             dat$nwparam <- list(x[-which(names(x) == "fit")])
             dat$param$modes <- modes
             if (control$use.pids == TRUE) {
                 dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
             }
             form <- get_nwparam(dat)$formation
             fterms <- get_formula_term_attr(form, nw)
             dat <- copy_toall_attr(dat, at = 1, fterms)
             dat$temp$fterms <- fterms
             dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
             dat <- init_status.net(dat)
             dat <- get_prev.net(dat, at = 1)
         }
         else {
             dat <- list()
             dat$nw <- x$network[[s]]
             dat$param <- x$param
             dat$control <- control
             dat$nwparam <- x$nwparam
             dat$epi <- sapply(x$epi, function(var) var[s])
             names(dat$epi) <- names(x$epi)
             dat$attr <- x$attr[[s]]
             dat$stats <- sapply(x$stats, function(var) var[[s]])
             dat$temp <- list()
         }
         return(dat)
     })(structure(list(fit = structure(list(coef = c(edges = -3.8918202981106), iterations = 7L, 
         MCMCtheta = c(edges = -3.8918202981106), gradient = NA, hessian = structure(-49.0000108501759, .Dim = c(1L, 
         1L)), covar = structure(0.0204081587462834, .Dim = c(1L, 1L)), failure = FALSE, 
         est.cov = structure(0, .Dim = c(1L, 1L)), glm = structure(list(coefficients = c(edges = -3.8918202981106), 
             residuals = c(`1` = -1.02040816326531, `2` = 49.9999999999988), fitted.values = c(`1` = 0.0200000000000005, 
             `2` = 0.0200000000000005), effects = c(edges = 27.2427451029837, 49.9999944641969
             ), R = structure(-7.00000077501252, .Dim = c(1L, 1L), .Dimnames = list("edges", 
                 "edges")), rank = 1L, qr = structure(list(qr = structure(c(-7.00000077501252, 
             0.14142135623731), .Dim = 2:1, .Dimnames = list(c("1", "2"), "edges")), rank = 1L, 
                 qraux = 1.98994949366117, pivot = 1L, tol = 1e-11), class = "qr"), family = structure(list(
                 family = "binomial", link = "logit", linkfun = function (mu) 
                 .Call(C_logit_link, mu), linkinv = function (eta) 
                 .Call(C_logit_linkinv, eta), variance = function (mu) 
                 mu * (1 - mu), dev.resids = function (y, mu, wt) 
                 .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, 
                     dev) 
                 {
                     m <- if (any(n > 1)) 
                       n
                     else wt
                     -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), 
                       mu, log = TRUE))
                 }, mu.eta = function (eta) 
                 .Call(C_logit_mu_eta, eta), initialize = {
                     if (NCOL(y) == 1) {
                       if (is.factor(y)) 
                         y <- y != levels(y)[1L]
                       n <- rep.int(1, nobs)
                       y[weights == 0] <- 0
                       if (any(y < 0 | y > 1)) 
                         stop("y values must be 0 <= y <= 1")
                       mustart <- (weights * y + 0.5)/(weights + 1)
                       m <- weights * y
                       if (any(abs(m - round(m)) > 0.001)) 
                         warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                           domain = NA)
                     }
                     else if (NCOL(y) == 2) {
                       if (any(abs(y - round(y)) > 0.001)) 
                         warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                           domain = NA)
                       n <- (y1 <- y[, 1L]) + y[, 2L]
                       y <- y1/n
                       if (any(n0 <- n == 0)) 
                         y[n0] <- 0
                       weights <- weights * n
                       mustart <- (n * y + 0.5)/(n + 1)
                     }
                     else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                       "binomial"), domain = NA)
                 }, validmu = function (mu) 
                 all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
                 TRUE, simulate = function (object, nsim) 
                 {
                     ftd <- fitted(object)
                     n <- length(ftd)
                     ntot <- n * nsim
                     wts <- object$prior.weights
                     if (any(wts%%1 != 0)) 
                       stop("cannot simulate from non-integer prior.weights")
                     if (!is.null(m <- object$model)) {
                       y <- model.response(m)
                       if (is.factor(y)) {
                         yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                         split(yy, rep(seq_len(nsim), each = n))
                       }
                       else if (is.matrix(y) && ncol(y) == 2) {
                         yy <- vector("list", nsim)
                         for (i in seq_len(nsim)) {
                           Y <- rbinom(n, size = wts, prob = ftd)
                           YY <- cbind(Y, wts - Y)
                           colnames(YY) <- colnames(y)
                           yy[[i]] <- YY
                         }
                         yy
                       }
                       else rbinom(ntot, size = wts, prob = ftd)/wts
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }), class = "family"), linear.predictors = c(`1` = -3.8918202981106, 
             `2` = -3.8918202981106), deviance = 490.19556639866, aic = 492.19556639866, 
             null.deviance = 3465.73590279973, iter = 7L, weights = c(`1` = 48.0200106331724, 
             `2` = 0.980000217003518), prior.weights = c(`1` = 2450, `2` = 50), df.residual = 1L, 
             df.null = 2L, y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, 
             model = structure(list(`pl$zy` = 0:1, edges = c(1, 1), `offset(pl$foffset)` = c(0, 
             0), `(weights)` = c(2450, 50)), terms = pl$zy ~ edges - 1 + offset(pl$foffset), row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ . - 1 + offset(pl$foffset), family = family, 
                 data = data.frame(pl$xmat), weights = pl$wend), formula = pl$zy ~ . - 
                 1 + offset(pl$foffset), terms = pl$zy ~ edges - 1 + offset(pl$foffset), 
             data = structure(list(edges = c(1, 1)), class = "data.frame", row.names = c(NA, 
             -2L)), offset = c(0, 0), control = list(epsilon = 1e-08, maxit = 25, trace = FALSE), 
             method = "glm.fit", contrasts = NULL, xlevels = structure(list(), .Names = character(0))), class = c("glm", 
         "lm")), glm.null = structure(list(coefficients = c(`(Intercept)` = -3.8918202981106), 
             residuals = c(`1` = -1.02040816326531, `2` = 49.9999999999988), fitted.values = c(`1` = 0.0200000000000005, 
             `2` = 0.0200000000000005), effects = c(`(Intercept)` = 27.2427451029837, 
             49.9999944641969), R = structure(-7.00000077501252, .Dim = c(1L, 1L), .Dimnames = list(
                 "(Intercept)", "(Intercept)")), rank = 1L, qr = structure(list(qr = structure(c(-7.00000077501252, 
             0.14142135623731), .Dim = 2:1, .Dimnames = list(c("1", "2"), "(Intercept)")), 
                 rank = 1L, qraux = 1.98994949366117, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -3.8918202981106, `2` = -3.8918202981106
             ), deviance = 490.19556639866, aic = 492.19556639866, null.deviance = 490.19556639866, 
             iter = 7L, weights = c(`1` = 48.0200106331724, `2` = 0.980000217003518), 
             prior.weights = c(`1` = 2450, `2` = 50), df.residual = 1L, df.null = 1L, 
             y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = 0:1, `(weights)` = c(2450, 50)), terms = pl$zy ~ 1, row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ 1, family = family, weights = pl$wend), formula = pl$zy ~ 
                 1, terms = pl$zy ~ 1, data = <environment>, offset = NULL, control = list(
                 epsilon = 1e-08, maxit = 25, trace = FALSE), method = "glm.fit", contrasts = NULL, 
             xlevels = NULL), class = c("glm", "lm")), theta1 = list(coef = c(edges = -3.8918202981106), 
             theta = c(edges = -3.8918202981106), independent = c(edges = TRUE)), MPLE_is_MLE = TRUE, 
         ergm_version = structure(list(c(3L, 10L, 1L)), class = c("package_version", "numeric_version"
         )), offset = FALSE, drop = 0, estimable = TRUE, network = structure(list(mel = list(
             list(inl = 51L, outl = 1L, atl = list(na = FALSE)), list(inl = 80L, outl = 3L, 
                 atl = list(na = FALSE)), list(inl = 87L, outl = 4L, atl = list(na = FALSE)), 
             list(inl = 85L, outl = 6L, atl = list(na = FALSE)), list(inl = 52L, outl = 7L, 
                 atl = list(na = FALSE)), list(inl = 92L, outl = 8L, atl = list(na = FALSE)), 
             list(inl = 75L, outl = 9L, atl = list(na = FALSE)), list(inl = 93L, outl = 10L, 
                 atl = list(na = FALSE)), list(inl = 62L, outl = 14L, atl = list(na = FALSE)), 
             list(inl = 97L, outl = 16L, atl = list(na = FALSE)), list(inl = 94L, outl = 17L, 
                 atl = list(na = FALSE)), list(inl = 65L, outl = 18L, atl = list(na = FALSE)), 
             list(inl = 88L, outl = 19L, atl = list(na = FALSE)), list(inl = 67L, outl = 20L, 
                 atl = list(na = FALSE)), list(inl = 68L, outl = 20L, atl = list(na = FALSE)), 
             list(inl = 61L, outl = 22L, atl = list(na = FALSE)), list(inl = 82L, outl = 22L, 
                 atl = list(na = FALSE)), list(inl = 89L, outl = 22L, atl = list(na = FALSE)), 
             list(inl = 87L, outl = 23L, atl = list(na = FALSE)), list(inl = 74L, outl = 25L, 
                 atl = list(na = FALSE)), list(inl = 94L, outl = 25L, atl = list(na = FALSE)), 
             list(inl = 62L, outl = 26L, atl = list(na = FALSE)), list(inl = 55L, outl = 27L, 
                 atl = list(na = FALSE)), list(inl = 77L, outl = 28L, atl = list(na = FALSE)), 
             list(inl = 80L, outl = 29L, atl = list(na = FALSE)), list(inl = 93L, outl = 29L, 
                 atl = list(na = FALSE)), list(inl = 95L, outl = 30L, atl = list(na = FALSE)), 
             list(inl = 89L, outl = 31L, atl = list(na = FALSE)), list(inl = 71L, outl = 33L, 
                 atl = list(na = FALSE)), list(inl = 84L, outl = 33L, atl = list(na = FALSE)), 
             list(inl = 100L, outl = 33L, atl = list(na = FALSE)), list(inl = 75L, outl = 34L, 
                 atl = list(na = FALSE)), list(inl = 79L, outl = 35L, atl = list(na = FALSE)), 
             list(inl = 72L, outl = 36L, atl = list(na = FALSE)), list(inl = 63L, outl = 39L, 
                 atl = list(na = FALSE)), list(inl = 90L, outl = 39L, atl = list(na = FALSE)), 
             list(inl = 56L, outl = 40L, atl = list(na = FALSE)), list(inl = 57L, outl = 40L, 
                 atl = list(na = FALSE)), list(inl = 98L, outl = 42L, atl = list(na = FALSE)), 
             list(inl = 55L, outl = 43L, atl = list(na = FALSE)), list(inl = 57L, outl = 44L, 
                 atl = list(na = FALSE)), list(inl = 52L, outl = 45L, atl = list(na = FALSE)), 
             list(inl = 74L, outl = 45L, atl = list(na = FALSE)), list(inl = 95L, outl = 45L, 
                 atl = list(na = FALSE)), list(inl = 72L, outl = 46L, atl = list(na = FALSE)), 
             list(inl = 58L, outl = 47L, atl = list(na = FALSE)), list(inl = 98L, outl = 47L, 
                 atl = list(na = FALSE)), list(inl = 79L, outl = 49L, atl = list(na = FALSE)), 
             list(inl = 89L, outl = 49L, atl = list(na = FALSE)), list(inl = 59L, outl = 50L, 
                 atl = list(na = FALSE))), gal = list(n = 100, mnext = 51L, directed = FALSE, 
             hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = 50), val = list(
             list(na = FALSE, vertex.names = 1L), list(na = FALSE, vertex.names = 2L), 
             list(na = FALSE, vertex.names = 3L), list(na = FALSE, vertex.names = 4L), 
             list(na = FALSE, vertex.names = 5L), list(na = FALSE, vertex.names = 6L), 
             list(na = FALSE, vertex.names = 7L), list(na = FALSE, vertex.names = 8L), 
             list(na = FALSE, vertex.names = 9L), list(na = FALSE, vertex.names = 10L), 
             list(na = FALSE, vertex.names = 11L), list(na = FALSE, vertex.names = 12L), 
             list(na = FALSE, vertex.names = 13L), list(na = FALSE, vertex.names = 14L), 
             list(na = FALSE, vertex.names = 15L), list(na = FALSE, vertex.names = 16L), 
             list(na = FALSE, vertex.names = 17L), list(na = FALSE, vertex.names = 18L), 
             list(na = FALSE, vertex.names = 19L), list(na = FALSE, vertex.names = 20L), 
             list(na = FALSE, vertex.names = 21L), list(na = FALSE, vertex.names = 22L), 
             list(na = FALSE, vertex.names = 23L), list(na = FALSE, vertex.names = 24L), 
             list(na = FALSE, vertex.names = 25L), list(na = FALSE, vertex.names = 26L), 
             list(na = FALSE, vertex.names = 27L), list(na = FALSE, vertex.names = 28L), 
             list(na = FALSE, vertex.names = 29L), list(na = FALSE, vertex.names = 30L), 
             list(na = FALSE, vertex.names = 31L), list(na = FALSE, vertex.names = 32L), 
             list(na = FALSE, vertex.names = 33L), list(na = FALSE, vertex.names = 34L), 
             list(na = FALSE, vertex.names = 35L), list(na = FALSE, vertex.names = 36L), 
             list(na = FALSE, vertex.names = 37L), list(na = FALSE, vertex.names = 38L), 
             list(na = FALSE, vertex.names = 39L), list(na = FALSE, vertex.names = 40L), 
             list(na = FALSE, vertex.names = 41L), list(na = FALSE, vertex.names = 42L), 
             list(na = FALSE, vertex.names = 43L), list(na = FALSE, vertex.names = 44L), 
             list(na = FALSE, vertex.names = 45L), list(na = FALSE, vertex.names = 46L), 
             list(na = FALSE, vertex.names = 47L), list(na = FALSE, vertex.names = 48L), 
             list(na = FALSE, vertex.names = 49L), list(na = FALSE, vertex.names = 50L), 
             list(na = FALSE, vertex.names = 51L), list(na = FALSE, vertex.names = 52L), 
             list(na = FALSE, vertex.names = 53L), list(na = FALSE, vertex.names = 54L), 
             list(na = FALSE, vertex.names = 55L), list(na = FALSE, vertex.names = 56L), 
             list(na = FALSE, vertex.names = 57L), list(na = FALSE, vertex.names = 58L), 
             list(na = FALSE, vertex.names = 59L), list(na = FALSE, vertex.names = 60L), 
             list(na = FALSE, vertex.names = 61L), list(na = FALSE, vertex.names = 62L), 
             list(na = FALSE, vertex.names = 63L), list(na = FALSE, vertex.names = 64L), 
             list(na = FALSE, vertex.names = 65L), list(na = FALSE, vertex.names = 66L), 
             list(na = FALSE, vertex.names = 67L), list(na = FALSE, vertex.names = 68L), 
             list(na = FALSE, vertex.names = 69L), list(na = FALSE, vertex.names = 70L), 
             list(na = FALSE, vertex.names = 71L), list(na = FALSE, vertex.names = 72L), 
             list(na = FALSE, vertex.names = 73L), list(na = FALSE, vertex.names = 74L), 
             list(na = FALSE, vertex.names = 75L), list(na = FALSE, vertex.names = 76L), 
             list(na = FALSE, vertex.names = 77L), list(na = FALSE, vertex.names = 78L), 
             list(na = FALSE, vertex.names = 79L), list(na = FALSE, vertex.names = 80L), 
             list(na = FALSE, vertex.names = 81L), list(na = FALSE, vertex.names = 82L), 
             list(na = FALSE, vertex.names = 83L), list(na = FALSE, vertex.names = 84L), 
             list(na = FALSE, vertex.names = 85L), list(na = FALSE, vertex.names = 86L), 
             list(na = FALSE, vertex.names = 87L), list(na = FALSE, vertex.names = 88L), 
             list(na = FALSE, vertex.names = 89L), list(na = FALSE, vertex.names = 90L), 
             list(na = FALSE, vertex.names = 91L), list(na = FALSE, vertex.names = 92L), 
             list(na = FALSE, vertex.names = 93L), list(na = FALSE, vertex.names = 94L), 
             list(na = FALSE, vertex.names = 95L), list(na = FALSE, vertex.names = 96L), 
             list(na = FALSE, vertex.names = 97L), list(na = FALSE, vertex.names = 98L), 
             list(na = FALSE, vertex.names = 99L), list(na = FALSE, vertex.names = 100L)), 
             iel = list(integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 1L, c(5L, 42L), integer(0), integer(0), c(23L, 
                 40L), 37L, c(38L, 41L), 46L, 50L, integer(0), 16L, c(9L, 22L), 35L, integer(0), 
                 12L, integer(0), 14L, 15L, integer(0), integer(0), 29L, c(34L, 45L), 
                 integer(0), c(20L, 43L), c(7L, 32L), integer(0), 24L, integer(0), c(33L, 
                 48L), c(2L, 25L), integer(0), 17L, integer(0), 30L, 4L, integer(0), c(3L, 
                 19L), 13L, c(18L, 28L, 49L), 36L, integer(0), 6L, c(8L, 26L), c(11L, 
                 21L), c(27L, 44L), integer(0), 10L, c(39L, 47L), integer(0), 31L), oel = list(
                 1L, integer(0), 2L, 3L, integer(0), 4L, 5L, 6L, 7L, 8L, integer(0), integer(0), 
                 integer(0), 9L, integer(0), 10L, 11L, 12L, 13L, 15:14, integer(0), 18:16, 
                 19L, integer(0), 21:20, 22L, 23L, 24L, 26:25, 27L, 28L, integer(0), 31:29, 
                 32L, 33L, 34L, integer(0), integer(0), 36:35, 38:37, integer(0), 39L, 
                 40L, 41L, 44:42, 45L, 47:46, integer(0), 49:48, 50L, integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0))), class = "network"), 
         reference = ~Bernoulli, newnetwork = structure(list(mel = list(list(inl = 51L, 
             outl = 1L, atl = list(na = FALSE)), list(inl = 80L, outl = 3L, atl = list(
             na = FALSE)), list(inl = 87L, outl = 4L, atl = list(na = FALSE)), list(inl = 85L, 
             outl = 6L, atl = list(na = FALSE)), list(inl = 52L, outl = 7L, atl = list(
             na = FALSE)), list(inl = 92L, outl = 8L, atl = list(na = FALSE)), list(inl = 75L, 
             outl = 9L, atl = list(na = FALSE)), list(inl = 93L, outl = 10L, atl = list(
             na = FALSE)), list(inl = 62L, outl = 14L, atl = list(na = FALSE)), list(inl = 97L, 
             outl = 16L, atl = list(na = FALSE)), list(inl = 94L, outl = 17L, atl = list(
             na = FALSE)), list(inl = 65L, outl = 18L, atl = list(na = FALSE)), list(inl = 88L, 
             outl = 19L, atl = list(na = FALSE)), list(inl = 67L, outl = 20L, atl = list(
             na = FALSE)), list(inl = 68L, outl = 20L, atl = list(na = FALSE)), list(inl = 61L, 
             outl = 22L, atl = list(na = FALSE)), list(inl = 82L, outl = 22L, atl = list(
             na = FALSE)), list(inl = 89L, outl = 22L, atl = list(na = FALSE)), list(inl = 87L, 
             outl = 23L, atl = list(na = FALSE)), list(inl = 74L, outl = 25L, atl = list(
             na = FALSE)), list(inl = 94L, outl = 25L, atl = list(na = FALSE)), list(inl = 62L, 
             outl = 26L, atl = list(na = FALSE)), list(inl = 55L, outl = 27L, atl = list(
             na = FALSE)), list(inl = 77L, outl = 28L, atl = list(na = FALSE)), list(inl = 80L, 
             outl = 29L, atl = list(na = FALSE)), list(inl = 93L, outl = 29L, atl = list(
             na = FALSE)), list(inl = 95L, outl = 30L, atl = list(na = FALSE)), list(inl = 89L, 
             outl = 31L, atl = list(na = FALSE)), list(inl = 71L, outl = 33L, atl = list(
             na = FALSE)), list(inl = 84L, outl = 33L, atl = list(na = FALSE)), list(inl = 100L, 
             outl = 33L, atl = list(na = FALSE)), list(inl = 75L, outl = 34L, atl = list(
             na = FALSE)), list(inl = 79L, outl = 35L, atl = list(na = FALSE)), list(inl = 72L, 
             outl = 36L, atl = list(na = FALSE)), list(inl = 63L, outl = 39L, atl = list(
             na = FALSE)), list(inl = 90L, outl = 39L, atl = list(na = FALSE)), list(inl = 56L, 
             outl = 40L, atl = list(na = FALSE)), list(inl = 57L, outl = 40L, atl = list(
             na = FALSE)), list(inl = 98L, outl = 42L, atl = list(na = FALSE)), list(inl = 55L, 
             outl = 43L, atl = list(na = FALSE)), list(inl = 57L, outl = 44L, atl = list(
             na = FALSE)), list(inl = 52L, outl = 45L, atl = list(na = FALSE)), list(inl = 74L, 
             outl = 45L, atl = list(na = FALSE)), list(inl = 95L, outl = 45L, atl = list(
             na = FALSE)), list(inl = 72L, outl = 46L, atl = list(na = FALSE)), list(inl = 58L, 
             outl = 47L, atl = list(na = FALSE)), list(inl = 98L, outl = 47L, atl = list(
             na = FALSE)), list(inl = 79L, outl = 49L, atl = list(na = FALSE)), list(inl = 89L, 
             outl = 49L, atl = list(na = FALSE)), list(inl = 59L, outl = 50L, atl = list(
             na = FALSE))), gal = list(n = 100, mnext = 51L, directed = FALSE, hyper = FALSE, 
             loops = FALSE, multiple = FALSE, bipartite = 50), val = list(list(na = FALSE, 
             vertex.names = 1L), list(na = FALSE, vertex.names = 2L), list(na = FALSE, 
             vertex.names = 3L), list(na = FALSE, vertex.names = 4L), list(na = FALSE, 
             vertex.names = 5L), list(na = FALSE, vertex.names = 6L), list(na = FALSE, 
             vertex.names = 7L), list(na = FALSE, vertex.names = 8L), list(na = FALSE, 
             vertex.names = 9L), list(na = FALSE, vertex.names = 10L), list(na = FALSE, 
             vertex.names = 11L), list(na = FALSE, vertex.names = 12L), list(na = FALSE, 
             vertex.names = 13L), list(na = FALSE, vertex.names = 14L), list(na = FALSE, 
             vertex.names = 15L), list(na = FALSE, vertex.names = 16L), list(na = FALSE, 
             vertex.names = 17L), list(na = FALSE, vertex.names = 18L), list(na = FALSE, 
             vertex.names = 19L), list(na = FALSE, vertex.names = 20L), list(na = FALSE, 
             vertex.names = 21L), list(na = FALSE, vertex.names = 22L), list(na = FALSE, 
             vertex.names = 23L), list(na = FALSE, vertex.names = 24L), list(na = FALSE, 
             vertex.names = 25L), list(na = FALSE, vertex.names = 26L), list(na = FALSE, 
             vertex.names = 27L), list(na = FALSE, vertex.names = 28L), list(na = FALSE, 
             vertex.names = 29L), list(na = FALSE, vertex.names = 30L), list(na = FALSE, 
             vertex.names = 31L), list(na = FALSE, vertex.names = 32L), list(na = FALSE, 
             vertex.names = 33L), list(na = FALSE, vertex.names = 34L), list(na = FALSE, 
             vertex.names = 35L), list(na = FALSE, vertex.names = 36L), list(na = FALSE, 
             vertex.names = 37L), list(na = FALSE, vertex.names = 38L), list(na = FALSE, 
             vertex.names = 39L), list(na = FALSE, vertex.names = 40L), list(na = FALSE, 
             vertex.names = 41L), list(na = FALSE, vertex.names = 42L), list(na = FALSE, 
             vertex.names = 43L), list(na = FALSE, vertex.names = 44L), list(na = FALSE, 
             vertex.names = 45L), list(na = FALSE, vertex.names = 46L), list(na = FALSE, 
             vertex.names = 47L), list(na = FALSE, vertex.names = 48L), list(na = FALSE, 
             vertex.names = 49L), list(na = FALSE, vertex.names = 50L), list(na = FALSE, 
             vertex.names = 51L), list(na = FALSE, vertex.names = 52L), list(na = FALSE, 
             vertex.names = 53L), list(na = FALSE, vertex.names = 54L), list(na = FALSE, 
             vertex.names = 55L), list(na = FALSE, vertex.names = 56L), list(na = FALSE, 
             vertex.names = 57L), list(na = FALSE, vertex.names = 58L), list(na = FALSE, 
             vertex.names = 59L), list(na = FALSE, vertex.names = 60L), list(na = FALSE, 
             vertex.names = 61L), list(na = FALSE, vertex.names = 62L), list(na = FALSE, 
             vertex.names = 63L), list(na = FALSE, vertex.names = 64L), list(na = FALSE, 
             vertex.names = 65L), list(na = FALSE, vertex.names = 66L), list(na = FALSE, 
             vertex.names = 67L), list(na = FALSE, vertex.names = 68L), list(na = FALSE, 
             vertex.names = 69L), list(na = FALSE, vertex.names = 70L), list(na = FALSE, 
             vertex.names = 71L), list(na = FALSE, vertex.names = 72L), list(na = FALSE, 
             vertex.names = 73L), list(na = FALSE, vertex.names = 74L), list(na = FALSE, 
             vertex.names = 75L), list(na = FALSE, vertex.names = 76L), list(na = FALSE, 
             vertex.names = 77L), list(na = FALSE, vertex.names = 78L), list(na = FALSE, 
             vertex.names = 79L), list(na = FALSE, vertex.names = 80L), list(na = FALSE, 
             vertex.names = 81L), list(na = FALSE, vertex.names = 82L), list(na = FALSE, 
             vertex.names = 83L), list(na = FALSE, vertex.names = 84L), list(na = FALSE, 
             vertex.names = 85L), list(na = FALSE, vertex.names = 86L), list(na = FALSE, 
             vertex.names = 87L), list(na = FALSE, vertex.names = 88L), list(na = FALSE, 
             vertex.names = 89L), list(na = FALSE, vertex.names = 90L), list(na = FALSE, 
             vertex.names = 91L), list(na = FALSE, vertex.names = 92L), list(na = FALSE, 
             vertex.names = 93L), list(na = FALSE, vertex.names = 94L), list(na = FALSE, 
             vertex.names = 95L), list(na = FALSE, vertex.names = 96L), list(na = FALSE, 
             vertex.names = 97L), list(na = FALSE, vertex.names = 98L), list(na = FALSE, 
             vertex.names = 99L), list(na = FALSE, vertex.names = 100L)), iel = list(integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             1L, c(5L, 42L), integer(0), integer(0), c(23L, 40L), 37L, c(38L, 41L), 46L, 
             50L, integer(0), 16L, c(9L, 22L), 35L, integer(0), 12L, integer(0), 14L, 
             15L, integer(0), integer(0), 29L, c(34L, 45L), integer(0), c(20L, 43L), c(7L, 
             32L), integer(0), 24L, integer(0), c(33L, 48L), c(2L, 25L), integer(0), 17L, 
             integer(0), 30L, 4L, integer(0), c(3L, 19L), 13L, c(18L, 28L, 49L), 36L, 
             integer(0), 6L, c(8L, 26L), c(11L, 21L), c(27L, 44L), integer(0), 10L, c(39L, 
             47L), integer(0), 31L), oel = list(1L, integer(0), 2L, 3L, integer(0), 4L, 
             5L, 6L, 7L, 8L, integer(0), integer(0), integer(0), 9L, integer(0), 10L, 
             11L, 12L, 13L, 15:14, integer(0), 18:16, 19L, integer(0), 21:20, 22L, 23L, 
             24L, 26:25, 27L, 28L, integer(0), 31:29, 32L, 33L, 34L, integer(0), integer(0), 
             36:35, 38:37, integer(0), 39L, 40L, 41L, 44:42, 45L, 47:46, integer(0), 49:48, 
             50L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0))), class = "network"), formula = TARGET_STATS ~ edges, 
         constraints = ~., target.stats = c(edges = 50), etamap = list(canonical = 1L, 
             offsetmap = FALSE, offset = FALSE, offsettheta = FALSE, curved = list(), 
             etalength = 1), target.esteq = structure(-50, .Dim = c(1L, 1L), .Dimnames = list(
             NULL, "edges")), estimate = "MLE", control = structure(list(drop = TRUE, 
             init = NA_real_, init.method = "MPLE", main.method = "MCMLE", force.main = FALSE, 
             main.hessian = TRUE, checkpoint = NULL, resume = NULL, MPLE.max.dyad.types = 1e+06, 
             MPLE.samplesize = 50000, MPLE.type = "glm", MCMC.prop.weights = "default", 
             MCMC.prop.args = list(), MCMC.interval = 1024, MCMC.burnin = 16384, MCMC.samplesize = 1024, 
             MCMC.effectiveSize = NULL, MCMC.effectiveSize.damp = 10, MCMC.effectiveSize.maxruns = 1000, 
             MCMC.effectiveSize.base = 0.5, MCMC.effectiveSize.points = 5, MCMC.effectiveSize.order = 1, 
             MCMC.return.stats = TRUE, MCMC.runtime.traceplot = FALSE, MCMC.init.maxedges = 20000, 
             MCMC.max.maxedges = Inf, MCMC.addto.se = TRUE, MCMC.compress = FALSE, MCMC.packagenames = NULL, 
             SAN.maxit = 4, SAN.nsteps.times = 8, SAN.control = structure(list(SAN.maxit = 4, 
                 SAN.tau = 1, SAN.invcov = NULL, SAN.invcov.diag = FALSE, SAN.nsteps.alloc = function (nsim) 
                 2^seq_len(nsim), SAN.nsteps = 131072, SAN.samplesize = 1024, SAN.init.maxedges = 20000, 
                 SAN.max.maxedges = Inf, SAN.prop.weights = "default", SAN.prop.args = list(), 
                 SAN.packagenames = NULL, term.options = NULL, seed = NULL, parallel = 0, 
                 parallel.type = NULL, parallel.version.check = TRUE), class = c("control.san", 
             "control.list", "list")), MCMLE.termination = "Hummel", MCMLE.maxit = 20, 
             MCMLE.conv.min.pval = 0.5, MCMLE.NR.maxit = 100, MCMLE.NR.reltol = 1.49011611938477e-08, 
             obs.MCMC.samplesize = 1024, obs.MCMC.interval = 1024, obs.MCMC.burnin = 16384, 
             obs.MCMC.burnin.min = 1638.4, obs.MCMC.prop.weights = "default", obs.MCMC.prop.args = list(), 
             obs.MCMC.impute.min_informative = function (nw) 
             network.size(nw)/4, obs.MCMC.impute.default_density = function (nw) 
             2/network.size(nw), MCMLE.check.degeneracy = FALSE, MCMLE.MCMC.precision = 0.005, 
             MCMLE.MCMC.max.ESS.frac = 0.1, MCMLE.metric = "lognormal", MCMLE.method = "BFGS", 
             MCMLE.trustregion = 20, MCMLE.dampening = FALSE, MCMLE.dampening.min.ess = 20, 
             MCMLE.dampening.level = 0.1, MCMLE.steplength.margin = 0.05, MCMLE.steplength = 1, 
             MCMLE.adaptive.trustregion = 3, MCMLE.sequential = TRUE, MCMLE.density.guard.min = 10000, 
             MCMLE.density.guard = 20.0855369231877, MCMLE.effectiveSize = NULL, MCMLE.last.boost = 4, 
             MCMLE.Hummel.esteq = TRUE, MCMLE.Hummel.miss.sample = 100, MCMLE.Hummel.maxit = 25, 
             MCMLE.steplength.min = 1e-04, MCMLE.effectiveSize.interval_drop = 2, MCMLE.save_intermediates = NULL, 
             SA.phase1_n = NULL, SA.initial_gain = NULL, SA.nsubphases = 4, SA.niterations = NULL, 
             SA.phase3_n = NULL, SA.trustregion = 0.5, RM.phase1n_base = 7, RM.phase2n_base = 100, 
             RM.phase2sub = 7, RM.init_gain = 0.5, RM.phase3n = 500, Step.MCMC.samplesize = 100, 
             Step.maxit = 50, Step.gridsize = 100, CD.nsteps = 8, CD.multiplicity = 1, 
             CD.nsteps.obs = 128, CD.multiplicity.obs = 1, CD.maxit = 60, CD.conv.min.pval = 0.5, 
             CD.NR.maxit = 100, CD.NR.reltol = 1.49011611938477e-08, CD.metric = "naive", 
             CD.method = "BFGS", CD.trustregion = 20, CD.dampening = FALSE, CD.dampening.min.ess = 20, 
             CD.dampening.level = 0.1, CD.steplength.margin = 0.5, CD.steplength = 1, 
             CD.adaptive.trustregion = 3, CD.adaptive.epsilon = 0.01, CD.Hummel.esteq = TRUE, 
             CD.Hummel.miss.sample = 100, CD.Hummel.maxit = 25, CD.steplength.min = 1e-04, 
             loglik.control = structure(list(nsteps = 20, MCMC.burnin = NULL, MCMC.interval = NULL, 
                 MCMC.samplesize = NULL, obs.MCMC.samplesize = NULL, obs.MCMC.interval = NULL, 
                 obs.MCMC.burnin = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 warn.dyads = NULL, MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, 
                 term.options = NULL, seed = NULL, parallel = NULL, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.logLik.ergm", "control.list", 
             "list")), term.options = NULL, seed = NULL, parallel = 0, parallel.type = NULL, 
             parallel.version.check = TRUE), class = c("control.ergm", "control.list", 
         "list"))), class = "ergm"), formation = ~edges, target.stats = 50, target.stats.names = "edges", 
         coef.form = c(edges = -6.83625927727704), coef.form.crude = c(edges = -3.8918202981106), 
         coef.diss = structure(list(dissolution = ~offset(edges), duration = 20, coef.crude = 2.94443897916644, 
             coef.adj = 2.94443897916644, d.rate = 0, model.type = "homog"), class = "disscoef"), 
         constraints = ~., edapprox = TRUE), class = "netest"), structure(list(inf.prob = 0.3, 
         inf.prob.m2 = 0.15, act.rate = 1, vital = FALSE), class = c("param.net", "list"
     )), structure(list(i.num = 1, i.num.m2 = 0), class = c("init.net", "list")), structure(list(
         type = "SI", nsteps = 10, start = 1, nsims = 2, ncores = 1, rec.rand = TRUE, 
         a.rand = TRUE, d.rand = TRUE, tea.status = TRUE, use.pids = TRUE, initialize.FUN = function (x, 
             param, init, control, s) 
         {
             if (control$start == 1) {
                 dat <- list()
                 dat$param <- param
                 dat$init <- init
                 dat$control <- control
                 dat$attr <- list()
                 dat$stats <- list()
                 dat$temp <- list()
                 nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
                 modes <- ifelse(nw %n% "bipartite", 2, 1)
                 if (control$depend == TRUE) {
                     if (class(x$fit) == "stergm") {
                       nw <- network.collapse(nw, at = 1)
                     }
                     nw <- sim_nets(x, nw, nsteps = 1, control)
                 }
                 if (control$depend == FALSE) {
                     nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
                 }
                 nw <- activate.vertices(nw, onset = 1, terminus = Inf)
                 dat$nw <- nw
                 dat$nwparam <- list(x[-which(names(x) == "fit")])
                 dat$param$modes <- modes
                 if (control$use.pids == TRUE) {
                     dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
                 }
                 form <- get_nwparam(dat)$formation
                 fterms <- get_formula_term_attr(form, nw)
                 dat <- copy_toall_attr(dat, at = 1, fterms)
                 dat$temp$fterms <- fterms
                 dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
                 dat <- init_status.net(dat)
                 dat <- get_prev.net(dat, at = 1)
             }
             else {
                 dat <- list()
                 dat$nw <- x$network[[s]]
                 dat$param <- x$param
                 dat$control <- control
                 dat$nwparam <- x$nwparam
                 dat$epi <- sapply(x$epi, function(var) var[s])
                 names(dat$epi) <- names(x$epi)
                 dat$attr <- x$attr[[s]]
                 dat$stats <- sapply(x$stats, function(var) var[[s]])
                 dat$temp <- list()
             }
             return(dat)
         }, departures.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             d.rand <- dat$control$d.rand
             nDepartures.sus <- nDeparturesM2.sus <- 0
             idsElig.sus <- which(dat$attr$active == 1 & dat$attr$status == "s")
             nElig.sus <- length(idsElig.sus)
             if (nElig.sus > 0) {
                 mElig.sus <- mode[idsElig.sus]
                 rates.sus <- c(dat$param$ds.rate, dat$param$ds.rate.m2)
                 ratesElig.sus <- rates.sus[mElig.sus]
                 if (d.rand == TRUE) {
                     vecDepartures.sus <- which(rbinom(nElig.sus, 1, ratesElig.sus) == 
                       1)
                     if (length(vecDepartures.sus) > 0) {
                       idsDpt.sus <- idsElig.sus[vecDepartures.sus]
                       nDepartures.sus <- sum(mode[idsDpt.sus] == 1)
                       nDeparturesM2.sus <- sum(mode[idsDpt.sus] == 2)
                       dat$attr$active[idsDpt.sus] <- 0
                       dat$attr$exitTime[idsDpt.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.sus, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.sus <- idsDptM2.sus <- NULL
                     nDepartures.sus <- min(round(sum(ratesElig.sus[mElig.sus == 1])), 
                       sum(mElig.sus == 1))
                     idsDpt.sus <- ssample(idsElig.sus[mElig.sus == 1], nDepartures.sus)
                     if (modes == 2) {
                       nDeparturesM2.sus <- min(round(sum(ratesElig.sus[mElig.sus == 2])), 
                         sum(mElig.sus == 2))
                       idsDptM2.sus <- ssample(idsElig.sus[mElig.sus == 2], nDeparturesM2.sus)
                     }
                     totDpt.sus <- nDepartures.sus + nDeparturesM2.sus
                     if (totDpt.sus > 0) {
                       idsDptAll.sus <- c(idsDpt.sus, idsDptM2.sus)
                       dat$attr$active[idsDptAll.sus] <- 0
                       dat$attr$exitTime[idsDptAll.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.sus, deactivate.edges = TRUE)
                     }
                 }
             }
             nDepartures.inf <- nDeparturesM2.inf <- 0
             idsElig.inf <- which(dat$attr$active == 1 & dat$attr$status == "i")
             nElig.inf <- length(idsElig.inf)
             if (nElig.inf > 0) {
                 mElig.inf <- mode[idsElig.inf]
                 rates.inf <- c(dat$param$di.rate, dat$param$di.rate.m2)
                 ratesElig.inf <- rates.inf[mElig.inf]
                 if (d.rand == TRUE) {
                     vecDepartures.inf <- which(rbinom(nElig.inf, 1, ratesElig.inf) == 
                       1)
                     if (length(vecDepartures.inf) > 0) {
                       idsDpt.inf <- idsElig.inf[vecDepartures.inf]
                       nDepartures.inf <- sum(mode[idsDpt.inf] == 1)
                       nDeparturesM2.inf <- sum(mode[idsDpt.inf] == 2)
                       dat$attr$active[idsDpt.inf] <- 0
                       dat$attr$exitTime[idsDpt.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.inf, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.inf <- idsDptM2.inf <- NULL
                     nDepartures.inf <- min(round(sum(ratesElig.inf[mElig.inf == 1])), 
                       sum(mElig.inf == 1))
                     idsDpt.inf <- ssample(idsElig.inf[mElig.inf == 1], nDepartures.inf)
                     if (modes == 2) {
                       nDeparturesM2.inf <- min(round(sum(ratesElig.inf[mElig.inf == 2])), 
                         sum(mElig.inf == 2))
                       idsDptM2.inf <- ssample(idsElig.inf[mElig.inf == 2], nDeparturesM2.inf)
                     }
                     totDpt.inf <- nDepartures.inf + nDeparturesM2.inf
                     if (totDpt.inf > 0) {
                       idsDptAll.inf <- c(idsDpt.inf, idsDptM2.inf)
                       dat$attr$active[idsDptAll.inf] <- 0
                       dat$attr$exitTime[idsDptAll.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.inf, deactivate.edges = TRUE)
                     }
                 }
             }
             if (type == "SIR") {
                 nDepartures.rec <- nDeparturesM2.rec <- 0
                 idsElig.rec <- which(dat$attr$active == 1 & dat$attr$status == "r")
                 nElig.rec <- length(idsElig.rec)
                 if (nElig.rec > 0) {
                     mElig.rec <- mode[idsElig.rec]
                     rates.rec <- c(dat$param$dr.rate, dat$param$dr.rate.m2)
                     ratesElig.rec <- rates.rec[mElig.rec]
                     if (d.rand == TRUE) {
                       vecDepartures.rec <- which(rbinom(nElig.rec, 1, ratesElig.rec) == 
                         1)
                       if (length(vecDepartures.rec) > 0) {
                         idsDpt.rec <- idsElig.rec[vecDepartures.rec]
                         nDepartures.rec <- sum(mode[idsDpt.rec] == 1)
                         nDeparturesM2.rec <- sum(mode[idsDpt.rec] == 2)
                         dat$attr$active[idsDpt.rec] <- 0
                         dat$attr$exitTime[idsDpt.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.rec, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.rec <- idsDptM2.rec <- NULL
                       nDepartures.rec <- min(round(sum(ratesElig.rec[mElig.rec == 1])), 
                         sum(mElig.rec == 1))
                       idsDpt.rec <- ssample(idsElig.rec[mElig.rec == 1], nDepartures.rec)
                       if (modes == 2) {
                         nDeparturesM2.rec <- min(round(sum(ratesElig.rec[mElig.rec == 
                           2])), sum(mElig.rec == 2))
                         idsDptM2.rec <- ssample(idsElig.rec[mElig.rec == 2], nDeparturesM2.rec)
                       }
                       totDpt.rec <- nDepartures.rec + nDeparturesM2.rec
                       if (totDpt.rec > 0) {
                         idsDptAll.rec <- c(idsDpt.rec, idsDptM2.rec)
                         dat$attr$active[idsDptAll.rec] <- 0
                         dat$attr$exitTime[idsDptAll.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.rec, deactivate.edges = TRUE)
                       }
                     }
                 }
             }
             if (at == 2) {
                 dat$epi$ds.flow <- c(0, nDepartures.sus)
                 dat$epi$di.flow <- c(0, nDepartures.inf)
                 if (type == "SIR") {
                     dat$epi$dr.flow <- c(0, nDepartures.rec)
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2 <- c(0, nDeparturesM2.sus)
                     dat$epi$di.flow.m2 <- c(0, nDeparturesM2.inf)
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2 <- c(0, nDeparturesM2.rec)
                     }
                 }
             }
             else {
                 dat$epi$ds.flow[at] <- nDepartures.sus
                 dat$epi$di.flow[at] <- nDepartures.inf
                 if (type == "SIR") {
                     dat$epi$dr.flow[at] <- nDepartures.rec
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2[at] <- nDeparturesM2.sus
                     dat$epi$di.flow.m2[at] <- nDeparturesM2.inf
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2[at] <- nDeparturesM2.rec
                     }
                 }
             }
             return(dat)
         }, arrivals.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             a.rate <- dat$param$a.rate
             a.rate.m2 <- dat$param$a.rate.m2
             modes <- dat$param$modes
             tea.status <- dat$control$tea.status
             nOld <- dat$epi$num[at - 1]
             nCurr <- network.size(dat$nw)
             a.rand <- dat$control$a.rand
             delete.nodes <- dat$control$delete.nodes
             nArrivals <- nArrivalsM2 <- 0
             newNodes <- newNodesM2 <- NULL
             if (modes == 1 && nOld > 0) {
                 if (a.rand == TRUE) {
                     nArrivals <- sum(rbinom(nOld, 1, a.rate))
                 }
                 if (a.rand == FALSE) {
                     nArrivals <- round(nOld * a.rate)
                 }
                 if (nArrivals > 0) {
                     dat$nw <- add.vertices(dat$nw, nv = nArrivals)
                     newNodes <- (nCurr + 1):(nCurr + nArrivals)
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (modes == 2 && nOld > 0) {
                 nOldM2 <- dat$epi$num.m2[at - 1]
                 if (a.rand == TRUE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOld, 1, a.rate))
                     }
                     else {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOldM2, 1, a.rate.m2))
                     }
                 }
                 if (a.rand == FALSE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOld * a.rate)
                     }
                     else {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOldM2 * a.rate.m2)
                     }
                 }
                 nCurrM1 <- length(modeids(dat$nw, 1))
                 nCurrM2 <- length(modeids(dat$nw, 2))
                 prefixes <- unique(substr(dat$nw %v% "vertex.names", 1, 1))
                 if (nArrivals > 0) {
                     newNodeIDs <- (nCurrM1 + 1):(nCurrM1 + nArrivals)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[1], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE)
                     }
                     newNodes <- newNodeIDs
                 }
                 if (nArrivalsM2 > 0) {
                     newNodeIDs <- (nCurrM2 + 1):(nCurrM2 + nArrivalsM2)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[2], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE)
                     }
                     newSize <- network.size(dat$nw)
                     newNodesM2 <- (newSize - nArrivalsM2 + 1):newSize
                 }
                 newNodes <- c(newNodes, newNodesM2)
                 if (!is.null(newNodes)) {
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (length(newNodes) > 0) {
                 fterms <- dat$temp$fterms
                 curr.tab <- get_attr_prop(dat$nw, fterms)
                 if (length(curr.tab) > 0) {
                     dat$nw <- update_nwattr(dat$nw, newNodes, dat$control$attr.rules, 
                       curr.tab, dat$temp$t1.tab)
                 }
                 dat <- copy_toall_attr(dat, at, fterms)
                 if (tea.status == TRUE) {
                     if ("status" %in% fterms) {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = dat$attr$status[newNodes], onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                     else {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = "s", onset = at, terminus = Inf, v = newNodes)
                     }
                 }
                 if (modes == 1) {
                     if (!("status" %in% fterms)) {
                       dat$attr$status <- c(dat$attr$status, rep("s", length(newNodes)))
                     }
                     dat$attr$active <- c(dat$attr$active, rep(1, length(newNodes)))
                     dat$attr$infTime <- c(dat$attr$infTime, rep(NA, length(newNodes)))
                     dat$attr$entrTime <- c(dat$attr$entrTime, rep(at, length(newNodes)))
                     dat$attr$exitTime <- c(dat$attr$exitTime, rep(NA, length(newNodes)))
                 }
                 if (modes == 2) {
                     if (!("status" %in% fterms)) {
                       dat <- split_bip(dat, "status", "s", nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                     }
                     dat <- split_bip(dat, "active", 1, nCurrM1, nCurrM2, nArrivals, nArrivalsM2)
                     dat <- split_bip(dat, "infTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "entrTime", at, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "exitTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                 }
                 newNodesInf <- intersect(newNodes, which(dat$attr$status == "i"))
                 dat$attr$infTime[newNodesInf] <- at
                 if (length(unique(sapply(dat$attr, length))) != 1) {
                     stop("Attribute list of unequal length. Check arrivals.net module.")
                 }
             }
             if (at == 2) {
                 dat$epi$a.flow <- c(0, nArrivals)
                 if (modes == 2) {
                     dat$epi$a.flow.m2 <- c(0, nArrivalsM2)
                 }
             }
             else {
                 dat$epi$a.flow[at] <- nArrivals
                 if (modes == 2) {
                     dat$epi$a.flow.m2[at] <- nArrivalsM2
                 }
             }
             return(dat)
         }, recovery.FUN = function (dat, at) 
         {
             if (!(dat$control$type %in% c("SIR", "SIS"))) {
                 return(dat)
             }
             active <- dat$attr$active
             status <- dat$attr$status
             infTime <- dat$attr$infTime
             tea.status <- dat$control$tea.status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             recovState <- ifelse(type == "SIR", "r", "s")
             rec.rand <- dat$control$rec.rand
             rec.rate <- dat$param$rec.rate
             rec.rate.m2 <- dat$param$rec.rate.m2
             nRecov <- nRecovM2 <- 0
             idsElig <- which(active == 1 & status == "i")
             nElig <- length(idsElig)
             infDur <- at - infTime[active == 1 & status == "i"]
             infDur[infDur == 0] <- 1
             lrec.rate <- length(rec.rate)
             if (lrec.rate == 1) {
                 mElig <- mode[idsElig]
                 rates <- c(rec.rate, rec.rate.m2)
                 ratesElig <- rates[mElig]
             }
             else {
                 mElig <- mode[idsElig]
                 if (is.null(rec.rate.m2)) {
                     rates <- ifelse(infDur <= lrec.rate, rec.rate[infDur], rec.rate[lrec.rate])
                 }
                 else {
                     rates <- rep(NA, length(infDur))
                     rates[mElig == 1] <- ifelse(infDur[mElig == 1] <= lrec.rate, rec.rate[infDur[mElig == 
                       1]], rec.rate[lrec.rate])
                     rates[mElig == 2] <- ifelse(infDur[mElig == 2] <= length(rec.rate.m2), 
                       rec.rate.m2[infDur[mElig == 2]], rec.rate.m2[length(rec.rate.m2)])
                 }
                 ratesElig <- rates
             }
             if (nElig > 0) {
                 if (rec.rand == TRUE) {
                     vecRecov <- which(rbinom(nElig, 1, ratesElig) == 1)
                     if (length(vecRecov) > 0) {
                       idsRecov <- idsElig[vecRecov]
                       nRecov <- sum(mode[idsRecov] == 1)
                       nRecovM2 <- sum(mode[idsRecov] == 2)
                       status[idsRecov] <- recovState
                       if (tea.status == TRUE) {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = recovState, onset = at, terminus = Inf, v = idsRecov)
                       }
                     }
                 }
                 else {
                     idsRecov <- idsRecovM2 <- NULL
                     nRecov <- min(round(sum(ratesElig[mElig == 1])), sum(mElig == 1))
                     if (nRecov > 0) {
                       idsRecov <- ssample(idsElig[mElig == 1], nRecov)
                       status[idsRecov] <- recovState
                     }
                     if (modes == 2) {
                       nRecovM2 <- min(round(sum(ratesElig[mElig == 2])), sum(mElig == 
                         2))
                       if (nRecovM2 > 0) {
                         idsRecovM2 <- ssample(idsElig[mElig == 2], nRecovM2)
                         status[idsRecovM2] <- recovState
                       }
                     }
                     totRecov <- nRecov + nRecovM2
                     if (tea.status == TRUE & totRecov > 0) {
                       allids <- c(idsRecov, idsRecovM2)
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = recovState, onset = at, terminus = Inf, v = allids)
                     }
                 }
             }
             dat$attr$status <- status
             if ("status" %in% dat$temp$fterms) {
                 dat$nw <- set.vertex.attribute(dat$nw, "status", dat$attr$status)
             }
             outName <- ifelse(type == "SIR", "ir.flow", "is.flow")
             outName[2] <- paste0(outName, ".m2")
             if (at == 2) {
                 dat$epi[[outName[1]]] <- c(0, nRecov)
             }
             else {
                 dat$epi[[outName[1]]][at] <- nRecov
             }
             if (modes == 2) {
                 if (at == 2) {
                     dat$epi[[outName[2]]] <- c(0, nRecovM2)
                 }
                 else {
                     dat$epi[[outName[2]]][at] <- nRecovM2
                 }
             }
             return(dat)
         }, edges_correct.FUN = function (dat, at) 
         {
             if (dat$control$depend == TRUE) {
                 if (dat$param$modes == 1) {
                     old.num <- dat$epi$num[at - 1]
                     new.num <- sum(dat$attr$active == 1)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(old.num) - log(new.num)
                 }
                 if (dat$param$modes == 2) {
                     mode <- idmode(dat$nw)
                     old.num.m1 <- dat$epi$num[at - 1]
                     old.num.m2 <- dat$epi$num.m2[at - 1]
                     new.num.m1 <- sum(dat$attr$active == 1 & mode == 1)
                     new.num.m2 <- sum(dat$attr$active == 1 & mode == 2)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(2 * old.num.m1 * old.num.m2/(old.num.m1 + old.num.m2)) - log(2 * 
                       new.num.m1 * new.num.m2/(new.num.m1 + new.num.m2))
                 }
             }
             return(dat)
         }, resim_nets.FUN = function (dat, at) 
         {
             idsActive <- which(dat$attr$active == 1)
             anyActive <- ifelse(length(idsActive) > 0, TRUE, FALSE)
             if (dat$param$modes == 2) {
                 nActiveM1 <- length(intersect(modeids(dat$nw, mode = 1), idsActive))
                 nActiveM2 <- length(intersect(modeids(dat$nw, mode = 2), idsActive))
                 anyActive <- ifelse(nActiveM1 > 0 & nActiveM2 > 0, TRUE, FALSE)
             }
             nwparam <- get_nwparam(dat)
             statOnNw <- ("status" %in% dat$temp$fterms)
             status <- dat$attr$status
             if (statOnNw == TRUE && length(unique(status)) == 1) {
                 stop("Stopping simulation because status in formation formula and ", 
                     "no longer any discordant nodes", call. = TRUE)
             }
             if (dat$control$save.nwstats == TRUE) {
                 if (at == 2) {
                     nwstats <- attributes(dat$nw)$stats
                     dat$stats$nwstats <- as.data.frame(nwstats)
                 }
             }
             if (anyActive > 0 & dat$control$depend == TRUE) {
                 suppressWarnings(dat$nw <- simulate(dat$nw, formation = nwparam$formation, 
                     dissolution = nwparam$coef.diss$dissolution, coef.form = nwparam$coef.form, 
                     coef.diss = nwparam$coef.diss$coef.adj, constraints = nwparam$constraints, 
                     time.start = at, time.slices = 1, time.offset = 0, monitor = dat$control$nwstats.formula, 
                     control = dat$control$set.control.stergm))
                 if (dat$control$save.nwstats == TRUE) {
                     dat$stats$nwstats <- rbind(dat$stats$nwstats, tail(attributes(dat$nw)$stats, 
                       1))
                 }
                 if (dat$control$delete.nodes == TRUE) {
                     dat$nw <- network.extract(dat$nw, at = at)
                     inactive <- which(dat$attr$active == 0)
                     dat$attr <- deleteAttr(dat$attr, inactive)
                 }
             }
             return(dat)
         }, infection.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             status <- dat$attr$status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             inf.prob <- dat$param$inf.prob
             inf.prob.m2 <- dat$param$inf.prob.m2
             act.rate <- dat$param$act.rate
             nw <- dat$nw
             tea.status <- dat$control$tea.status
             idsInf <- which(active == 1 & status == "i")
             nActive <- sum(active == 1)
             nElig <- length(idsInf)
             nInf <- nInfM2 <- totInf <- 0
             if (nElig > 0 && nElig < nActive) {
                 del <- discord_edgelist(dat, at)
                 if (!(is.null(del))) {
                     del$infDur <- at - dat$attr$infTime[del$inf]
                     del$infDur[del$infDur == 0] <- 1
                     linf.prob <- length(inf.prob)
                     if (is.null(inf.prob.m2)) {
                       del$transProb <- ifelse(del$infDur <= linf.prob, inf.prob[del$infDur], 
                         inf.prob[linf.prob])
                     }
                     else {
                       del$transProb <- ifelse(del$sus <= nw %n% "bipartite", ifelse(del$infDur <= 
                         linf.prob, inf.prob[del$infDur], inf.prob[linf.prob]), ifelse(del$infDur <= 
                         linf.prob, inf.prob.m2[del$infDur], inf.prob.m2[linf.prob]))
                     }
                     if (!is.null(dat$param$inter.eff) && at >= dat$param$inter.start) {
                       del$transProb <- del$transProb * (1 - dat$param$inter.eff)
                     }
                     lact.rate <- length(act.rate)
                     del$actRate <- ifelse(del$infDur <= lact.rate, act.rate[del$infDur], 
                       act.rate[lact.rate])
                     del$finalProb <- 1 - (1 - del$transProb)^del$actRate
                     transmit <- rbinom(nrow(del), 1, del$finalProb)
                     del <- del[which(transmit == 1), ]
                     idsNewInf <- unique(del$sus)
                     nInf <- sum(mode[idsNewInf] == 1)
                     nInfM2 <- sum(mode[idsNewInf] == 2)
                     totInf <- nInf + nInfM2
                     if (totInf > 0) {
                       if (tea.status == TRUE) {
                         nw <- activate.vertex.attribute(nw, prefix = "testatus", value = "i", 
                           onset = at, terminus = Inf, v = idsNewInf)
                       }
                       dat$attr$status[idsNewInf] <- "i"
                       dat$attr$infTime[idsNewInf] <- at
                       if ("status" %in% dat$temp$fterms) {
                         nw <- set.vertex.attribute(nw, "status", dat$attr$status)
                       }
                     }
                     if (any(names(nw$gal) %in% "vertex.pid")) {
                       del$sus <- get.vertex.pid(nw, del$sus)
                       del$inf <- get.vertex.pid(nw, del$inf)
                     }
                 }
             }
             if (totInf > 0) {
                 del <- del[!duplicated(del$sus), ]
                 if (at == 2) {
                     dat$stats$transmat <- del
                 }
                 else {
                     dat$stats$transmat <- rbind(dat$stats$transmat, del)
                 }
             }
             if (at == 2) {
                 dat$epi$si.flow <- c(0, nInf)
                 if (modes == 2) {
                     dat$epi$si.flow.m2 <- c(0, nInfM2)
                 }
             }
             else {
                 dat$epi$si.flow[at] <- nInf
                 if (modes == 2) {
                     dat$epi$si.flow.m2[at] <- nInfM2
                 }
             }
             dat$nw <- nw
             return(dat)
         }, get_prev.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             modes <- dat$param$modes
             l <- lapply(1:length(dat$attr), function(x) dat$attr[[x]][active == 1])
             names(l) <- names(dat$attr)
             l$active <- l$infTime <- NULL
             status <- l$status
             if (modes == 2) {
                 mode <- idmode(dat$nw)[active == 1]
             }
             eb <- !is.null(dat$control$epi.by)
             if (eb == TRUE) {
                 ebn <- dat$control$epi.by
                 ebv <- dat$temp$epi.by.vals
                 ebun <- paste0(".", ebn, ebv)
                 assign(ebn, l[[ebn]])
             }
             if (modes == 1) {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]][at] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
             }
             else {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2 <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2 <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2 <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]] <- sum(status == "r" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2 <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2[at] <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2[at] <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2[at] <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]][at] <- sum(status == 
                             "r" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2[at] <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]][at] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
             }
             return(dat)
         }, verbose.FUN = function (x, type, s = 1, at = 2) 
         {
             if (type == "startup" && x$ncores == 1) {
                 if (x$verbose == TRUE) {
                     cat("\nStarting Network Simulation...")
                 }
             }
             if (type == "progress" && x$control$ncores == 1) {
                 if (x$control$verbose == TRUE) {
                     if (x$control$verbose.int == 0 && at == x$control$nsteps) {
                       cat("\nSim = ", s, "/", x$control$nsims, sep = "")
                     }
                     if (x$control$verbose.int > 0 && (at%%x$control$verbose.int == 0)) {
                       cat("\f")
                       cat("\nEpidemic Simulation")
                       cat("\n----------------------------")
                       cat("\nSimulation: ", s, "/", x$control$nsims, sep = "")
                       cat("\nTimestep: ", at, "/", x$control$nsteps, sep = "")
                       status <- x$attr$status
                       if (class(status) == "character") {
                         status <- ifelse(status == "i", 1, 0)
                       }
                       cat("\nPrevalence:", sum(status, na.rm = TRUE))
                       cat("\nPopulation Size:", sum(x$attr$active == 1))
                       cat("\n----------------------------")
                     }
                 }
             }
         }, module.order = NULL, save.nwstats = TRUE, nwstats.formula = "formation", delete.nodes = FALSE, 
         save.transmat = TRUE, save.network = TRUE, verbose = FALSE, verbose.int = 1, 
         skip.check = FALSE, bi.mods = c("initialize.FUN", "departures.FUN", "arrivals.FUN", 
         "recovery.FUN", "edges_correct.FUN", "resim_nets.FUN", "infection.FUN", "get_prev.FUN", 
         "verbose.FUN"), user.mods = character(0), attr.rules = list(), set.control.stergm = structure(list(
             MCMC.burnin.min = 1000, MCMC.burnin.max = 1e+05, MCMC.burnin.pval = 0.5, 
             MCMC.burnin.add = 1, MCMC.burnin = NULL, MCMC.burnin.mul = NULL, MCMC.prop.weights.form = "default", 
             MCMC.prop.args.form = NULL, MCMC.prop.weights.diss = "default", MCMC.prop.args.diss = NULL, 
             MCMC.init.maxedges = 20000, MCMC.packagenames = NULL, MCMC.init.maxchanges = 1e+06), class = c("control.simulate.network", 
         "control.list", "list")), set.control.ergm = structure(list(MCMC.burnin = 2e+05, 
             MCMC.interval = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, MCMC.init.maxedges = NULL, 
             MCMC.packagenames = NULL, MCMC.runtime.traceplot = FALSE, network.output = "network", 
             term.options = NULL, parallel = 0, parallel.type = NULL, parallel.version.check = TRUE), class = c("control.simulate.ergm", 
         "control.list", "list")), depend = FALSE, pid.prefix = c("F", "M")), class = c("control.net", 
     "list")), 1L)
  4: sim_nets(x, nw, nsteps = control$nsteps, control)
  5: suppressWarnings(sim <- simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm))
  6: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  7: simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, coef.form = x$coef.form, 
         coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, time.start = 1, time.offset = 0, 
         constraints = x$constraints, monitor = control$nwstats.formula, nsim = 1, control = control$set.control.stergm)
  8: simulate.network(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm)
  9: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  10: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  11: lapply(X = X, FUN = FUN, ...)
  12: FUN(X[[i]], ...)
  13: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  14: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 5. Error: High departure rate models (@test-net-long.R#305)  ----------------
  'Calloc' could not allocate memory (271919726 of 16 bytes)
  1: netsim(est, param, init, control) at testthat/test-net-long.R:305
  2: do.call(control[["initialize.FUN"]], list(x, param, init, control, s))
  3: (function (x, param, init, control, s) 
     {
         if (control$start == 1) {
             dat <- list()
             dat$param <- param
             dat$init <- init
             dat$control <- control
             dat$attr <- list()
             dat$stats <- list()
             dat$temp <- list()
             nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
             modes <- ifelse(nw %n% "bipartite", 2, 1)
             if (control$depend == TRUE) {
                 if (class(x$fit) == "stergm") {
                     nw <- network.collapse(nw, at = 1)
                 }
                 nw <- sim_nets(x, nw, nsteps = 1, control)
             }
             if (control$depend == FALSE) {
                 nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
             }
             nw <- activate.vertices(nw, onset = 1, terminus = Inf)
             dat$nw <- nw
             dat$nwparam <- list(x[-which(names(x) == "fit")])
             dat$param$modes <- modes
             if (control$use.pids == TRUE) {
                 dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
             }
             form <- get_nwparam(dat)$formation
             fterms <- get_formula_term_attr(form, nw)
             dat <- copy_toall_attr(dat, at = 1, fterms)
             dat$temp$fterms <- fterms
             dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
             dat <- init_status.net(dat)
             dat <- get_prev.net(dat, at = 1)
         }
         else {
             dat <- list()
             dat$nw <- x$network[[s]]
             dat$param <- x$param
             dat$control <- control
             dat$nwparam <- x$nwparam
             dat$epi <- sapply(x$epi, function(var) var[s])
             names(dat$epi) <- names(x$epi)
             dat$attr <- x$attr[[s]]
             dat$stats <- sapply(x$stats, function(var) var[[s]])
             dat$temp <- list()
         }
         return(dat)
     })(structure(list(fit = structure(list(coef = c(edges = -3.17805383032511), iterations = 6L, 
         MCMCtheta = c(edges = -3.17805383032511), gradient = NA, hessian = structure(-11.5200746786697, .Dim = c(1L, 
         1L)), covar = structure(0.0868049928401571, .Dim = c(1L, 1L)), failure = FALSE, 
         est.cov = structure(0, .Dim = c(1L, 1L)), glm = structure(list(coefficients = c(edges = -3.17805383032511), 
             residuals = c(`1` = -1.04166666666762, `2` = 24.9999999994519), fitted.values = c(`1` = 0.040000000000877, 
             `2` = 0.040000000000877), effects = c(edges = 10.7867073514856, 17.3204519356622
             ), R = structure(-3.39412355088463, .Dim = c(1L, 1L), .Dimnames = list("edges", 
                 "edges")), rank = 1L, qr = structure(list(qr = structure(c(-3.39412355088463, 
             0.2), .Dim = 2:1, .Dimnames = list(c("1", "2"), "edges")), rank = 1L, qraux = 1.97979589711327, 
                 pivot = 1L, tol = 1e-11), class = "qr"), family = structure(list(family = "binomial", 
                 link = "logit", linkfun = function (mu) 
                 .Call(C_logit_link, mu), linkinv = function (eta) 
                 .Call(C_logit_linkinv, eta), variance = function (mu) 
                 mu * (1 - mu), dev.resids = function (y, mu, wt) 
                 .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, 
                     dev) 
                 {
                     m <- if (any(n > 1)) 
                       n
                     else wt
                     -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), 
                       mu, log = TRUE))
                 }, mu.eta = function (eta) 
                 .Call(C_logit_mu_eta, eta), initialize = {
                     if (NCOL(y) == 1) {
                       if (is.factor(y)) 
                         y <- y != levels(y)[1L]
                       n <- rep.int(1, nobs)
                       y[weights == 0] <- 0
                       if (any(y < 0 | y > 1)) 
                         stop("y values must be 0 <= y <= 1")
                       mustart <- (weights * y + 0.5)/(weights + 1)
                       m <- weights * y
                       if (any(abs(m - round(m)) > 0.001)) 
                         warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                           domain = NA)
                     }
                     else if (NCOL(y) == 2) {
                       if (any(abs(y - round(y)) > 0.001)) 
                         warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                           domain = NA)
                       n <- (y1 <- y[, 1L]) + y[, 2L]
                       y <- y1/n
                       if (any(n0 <- n == 0)) 
                         y[n0] <- 0
                       weights <- weights * n
                       mustart <- (n * y + 0.5)/(n + 1)
                     }
                     else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                       "binomial"), domain = NA)
                 }, validmu = function (mu) 
                 all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
                 TRUE, simulate = function (object, nsim) 
                 {
                     ftd <- fitted(object)
                     n <- length(ftd)
                     ntot <- n * nsim
                     wts <- object$prior.weights
                     if (any(wts%%1 != 0)) 
                       stop("cannot simulate from non-integer prior.weights")
                     if (!is.null(m <- object$model)) {
                       y <- model.response(m)
                       if (is.factor(y)) {
                         yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                         split(yy, rep(seq_len(nsim), each = n))
                       }
                       else if (is.matrix(y) && ncol(y) == 2) {
                         yy <- vector("list", nsim)
                         for (i in seq_len(nsim)) {
                           Y <- rbinom(n, size = wts, prob = ftd)
                           YY <- cbind(Y, wts - Y)
                           colnames(YY) <- colnames(y)
                           yy[[i]] <- YY
                         }
                         yy
                       }
                       else rbinom(ntot, size = wts, prob = ftd)/wts
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }), class = "family"), linear.predictors = c(`1` = -3.17805383032511, 
             `2` = -3.17805383032511), deviance = 100.766488640504, aic = 102.766488640504, 
             null.deviance = 415.888308335967, iter = 6L, weights = c(`1` = 11.0592716915229, 
             `2` = 0.460802987146789), prior.weights = c(`1` = 288, `2` = 12), df.residual = 1L, 
             df.null = 2L, y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, 
             model = structure(list(`pl$zy` = 0:1, edges = c(1, 1), `offset(pl$foffset)` = c(0, 
             0), `(weights)` = c(288, 12)), terms = pl$zy ~ edges - 1 + offset(pl$foffset), row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ . - 1 + offset(pl$foffset), family = family, 
                 data = data.frame(pl$xmat), weights = pl$wend), formula = pl$zy ~ . - 
                 1 + offset(pl$foffset), terms = pl$zy ~ edges - 1 + offset(pl$foffset), 
             data = structure(list(edges = c(1, 1)), class = "data.frame", row.names = c(NA, 
             -2L)), offset = c(0, 0), control = list(epsilon = 1e-08, maxit = 25, trace = FALSE), 
             method = "glm.fit", contrasts = NULL, xlevels = structure(list(), .Names = character(0))), class = c("glm", 
         "lm")), glm.null = structure(list(coefficients = c(`(Intercept)` = -3.17805383032511), 
             residuals = c(`1` = -1.04166666666762, `2` = 24.9999999994519), fitted.values = c(`1` = 0.040000000000877, 
             `2` = 0.040000000000877), effects = c(`(Intercept)` = 10.7867073514856, 17.3204519356622
             ), R = structure(-3.39412355088463, .Dim = c(1L, 1L), .Dimnames = list("(Intercept)", 
                 "(Intercept)")), rank = 1L, qr = structure(list(qr = structure(c(-3.39412355088463, 
             0.2), .Dim = 2:1, .Dimnames = list(c("1", "2"), "(Intercept)")), rank = 1L, 
                 qraux = 1.97979589711327, pivot = 1L, tol = 1e-11), class = "qr"), family = structure(list(
                 family = "binomial", link = "logit", linkfun = function (mu) 
                 .Call(C_logit_link, mu), linkinv = function (eta) 
                 .Call(C_logit_linkinv, eta), variance = function (mu) 
                 mu * (1 - mu), dev.resids = function (y, mu, wt) 
                 .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, 
                     dev) 
                 {
                     m <- if (any(n > 1)) 
                       n
                     else wt
                     -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), 
                       mu, log = TRUE))
                 }, mu.eta = function (eta) 
                 .Call(C_logit_mu_eta, eta), initialize = {
                     if (NCOL(y) == 1) {
                       if (is.factor(y)) 
                         y <- y != levels(y)[1L]
                       n <- rep.int(1, nobs)
                       y[weights == 0] <- 0
                       if (any(y < 0 | y > 1)) 
                         stop("y values must be 0 <= y <= 1")
                       mustart <- (weights * y + 0.5)/(weights + 1)
                       m <- weights * y
                       if (any(abs(m - round(m)) > 0.001)) 
                         warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                           domain = NA)
                     }
                     else if (NCOL(y) == 2) {
                       if (any(abs(y - round(y)) > 0.001)) 
                         warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                           domain = NA)
                       n <- (y1 <- y[, 1L]) + y[, 2L]
                       y <- y1/n
                       if (any(n0 <- n == 0)) 
                         y[n0] <- 0
                       weights <- weights * n
                       mustart <- (n * y + 0.5)/(n + 1)
                     }
                     else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                       "binomial"), domain = NA)
                 }, validmu = function (mu) 
                 all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
                 TRUE, simulate = function (object, nsim) 
                 {
                     ftd <- fitted(object)
                     n <- length(ftd)
                     ntot <- n * nsim
                     wts <- object$prior.weights
                     if (any(wts%%1 != 0)) 
                       stop("cannot simulate from non-integer prior.weights")
                     if (!is.null(m <- object$model)) {
                       y <- model.response(m)
                       if (is.factor(y)) {
                         yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                         split(yy, rep(seq_len(nsim), each = n))
                       }
                       else if (is.matrix(y) && ncol(y) == 2) {
                         yy <- vector("list", nsim)
                         for (i in seq_len(nsim)) {
                           Y <- rbinom(n, size = wts, prob = ftd)
                           YY <- cbind(Y, wts - Y)
                           colnames(YY) <- colnames(y)
                           yy[[i]] <- YY
                         }
                         yy
                       }
                       else rbinom(ntot, size = wts, prob = ftd)/wts
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }), class = "family"), linear.predictors = c(`1` = -3.17805383032511, 
             `2` = -3.17805383032511), deviance = 100.766488640504, aic = 102.766488640504, 
             null.deviance = 100.766488640504, iter = 6L, weights = c(`1` = 11.0592716915229, 
             `2` = 0.460802987146789), prior.weights = c(`1` = 288, `2` = 12), df.residual = 1L, 
             df.null = 1L, y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, 
             model = structure(list(`pl$zy` = 0:1, `(weights)` = c(288, 12)), terms = pl$zy ~ 
                 1, row.names = 1:2, class = "data.frame"), call = glm(formula = pl$zy ~ 
                 1, family = family, weights = pl$wend), formula = pl$zy ~ 1, terms = pl$zy ~ 
                 1, data = <environment>, offset = NULL, control = list(epsilon = 1e-08, 
                 maxit = 25, trace = FALSE), method = "glm.fit", contrasts = NULL, xlevels = NULL), class = c("glm", 
         "lm")), theta1 = list(coef = c(edges = -3.17805383032511), theta = c(edges = -3.17805383032511), 
             independent = c(edges = TRUE)), MPLE_is_MLE = TRUE, ergm_version = structure(list(
             c(3L, 10L, 1L)), class = c("package_version", "numeric_version")), offset = FALSE, 
         drop = 0, estimable = TRUE, network = structure(list(mel = list(list(inl = 10L, 
             outl = 1L, atl = list(na = FALSE)), list(inl = 23L, outl = 1L, atl = list(
             na = FALSE)), list(inl = 8L, outl = 2L, atl = list(na = FALSE)), list(inl = 16L, 
             outl = 6L, atl = list(na = FALSE)), list(inl = 18L, outl = 8L, atl = list(
             na = FALSE)), list(inl = 20L, outl = 8L, atl = list(na = FALSE)), list(inl = 24L, 
             outl = 8L, atl = list(na = FALSE)), list(inl = 21L, outl = 9L, atl = list(
             na = FALSE)), list(inl = 18L, outl = 10L, atl = list(na = FALSE)), list(inl = 22L, 
             outl = 13L, atl = list(na = FALSE)), list(inl = 21L, outl = 17L, atl = list(
             na = FALSE)), list(inl = 25L, outl = 22L, atl = list(na = FALSE))), gal = list(
             n = 25, mnext = 13L, directed = FALSE, hyper = FALSE, loops = FALSE, multiple = FALSE, 
             bipartite = FALSE), val = list(list(na = FALSE, vertex.names = 1L), list(
             na = FALSE, vertex.names = 2L), list(na = FALSE, vertex.names = 3L), list(
             na = FALSE, vertex.names = 4L), list(na = FALSE, vertex.names = 5L), list(
             na = FALSE, vertex.names = 6L), list(na = FALSE, vertex.names = 7L), list(
             na = FALSE, vertex.names = 8L), list(na = FALSE, vertex.names = 9L), list(
             na = FALSE, vertex.names = 10L), list(na = FALSE, vertex.names = 11L), list(
             na = FALSE, vertex.names = 12L), list(na = FALSE, vertex.names = 13L), list(
             na = FALSE, vertex.names = 14L), list(na = FALSE, vertex.names = 15L), list(
             na = FALSE, vertex.names = 16L), list(na = FALSE, vertex.names = 17L), list(
             na = FALSE, vertex.names = 18L), list(na = FALSE, vertex.names = 19L), list(
             na = FALSE, vertex.names = 20L), list(na = FALSE, vertex.names = 21L), list(
             na = FALSE, vertex.names = 22L), list(na = FALSE, vertex.names = 23L), list(
             na = FALSE, vertex.names = 24L), list(na = FALSE, vertex.names = 25L)), iel = list(
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             3L, integer(0), 1L, integer(0), integer(0), integer(0), integer(0), integer(0), 
             4L, integer(0), c(5L, 9L), integer(0), 6L, c(8L, 11L), 10L, 2L, 7L, 12L), 
             oel = list(2:1, 3L, integer(0), integer(0), integer(0), 4L, integer(0), 7:5, 
                 8L, 9L, integer(0), integer(0), 10L, integer(0), integer(0), integer(0), 
                 11L, integer(0), integer(0), integer(0), integer(0), 12L, integer(0), 
                 integer(0), integer(0))), class = "network"), reference = ~Bernoulli, 
         newnetwork = structure(list(mel = list(list(inl = 10L, outl = 1L, atl = list(
             na = FALSE)), list(inl = 23L, outl = 1L, atl = list(na = FALSE)), list(inl = 8L, 
             outl = 2L, atl = list(na = FALSE)), list(inl = 16L, outl = 6L, atl = list(
             na = FALSE)), list(inl = 18L, outl = 8L, atl = list(na = FALSE)), list(inl = 20L, 
             outl = 8L, atl = list(na = FALSE)), list(inl = 24L, outl = 8L, atl = list(
             na = FALSE)), list(inl = 21L, outl = 9L, atl = list(na = FALSE)), list(inl = 18L, 
             outl = 10L, atl = list(na = FALSE)), list(inl = 22L, outl = 13L, atl = list(
             na = FALSE)), list(inl = 21L, outl = 17L, atl = list(na = FALSE)), list(inl = 25L, 
             outl = 22L, atl = list(na = FALSE))), gal = list(n = 25, mnext = 13L, directed = FALSE, 
             hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = FALSE), val = list(
             list(na = FALSE, vertex.names = 1L), list(na = FALSE, vertex.names = 2L), 
             list(na = FALSE, vertex.names = 3L), list(na = FALSE, vertex.names = 4L), 
             list(na = FALSE, vertex.names = 5L), list(na = FALSE, vertex.names = 6L), 
             list(na = FALSE, vertex.names = 7L), list(na = FALSE, vertex.names = 8L), 
             list(na = FALSE, vertex.names = 9L), list(na = FALSE, vertex.names = 10L), 
             list(na = FALSE, vertex.names = 11L), list(na = FALSE, vertex.names = 12L), 
             list(na = FALSE, vertex.names = 13L), list(na = FALSE, vertex.names = 14L), 
             list(na = FALSE, vertex.names = 15L), list(na = FALSE, vertex.names = 16L), 
             list(na = FALSE, vertex.names = 17L), list(na = FALSE, vertex.names = 18L), 
             list(na = FALSE, vertex.names = 19L), list(na = FALSE, vertex.names = 20L), 
             list(na = FALSE, vertex.names = 21L), list(na = FALSE, vertex.names = 22L), 
             list(na = FALSE, vertex.names = 23L), list(na = FALSE, vertex.names = 24L), 
             list(na = FALSE, vertex.names = 25L)), iel = list(integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), 3L, integer(0), 
             1L, integer(0), integer(0), integer(0), integer(0), integer(0), 4L, integer(0), 
             c(5L, 9L), integer(0), 6L, c(8L, 11L), 10L, 2L, 7L, 12L), oel = list(2:1, 
             3L, integer(0), integer(0), integer(0), 4L, integer(0), 7:5, 8L, 9L, integer(0), 
             integer(0), 10L, integer(0), integer(0), integer(0), 11L, integer(0), integer(0), 
             integer(0), integer(0), 12L, integer(0), integer(0), integer(0))), class = "network"), 
         formula = TARGET_STATS ~ edges, constraints = ~., target.stats = c(edges = 12), 
         etamap = list(canonical = 1L, offsetmap = FALSE, offset = FALSE, offsettheta = FALSE, 
             curved = list(), etalength = 1), target.esteq = structure(-12, .Dim = c(1L, 
         1L), .Dimnames = list(NULL, "edges")), estimate = "MLE", control = structure(list(
             drop = TRUE, init = NA_real_, init.method = "MPLE", main.method = "MCMLE", 
             force.main = FALSE, main.hessian = TRUE, checkpoint = NULL, resume = NULL, 
             MPLE.max.dyad.types = 1e+06, MPLE.samplesize = 50000, MPLE.type = "glm", 
             MCMC.prop.weights = "default", MCMC.prop.args = list(), MCMC.interval = 1024, 
             MCMC.burnin = 16384, MCMC.samplesize = 1024, MCMC.effectiveSize = NULL, MCMC.effectiveSize.damp = 10, 
             MCMC.effectiveSize.maxruns = 1000, MCMC.effectiveSize.base = 0.5, MCMC.effectiveSize.points = 5, 
             MCMC.effectiveSize.order = 1, MCMC.return.stats = TRUE, MCMC.runtime.traceplot = FALSE, 
             MCMC.init.maxedges = 20000, MCMC.max.maxedges = Inf, MCMC.addto.se = TRUE, 
             MCMC.compress = FALSE, MCMC.packagenames = NULL, SAN.maxit = 4, SAN.nsteps.times = 8, 
             SAN.control = structure(list(SAN.maxit = 4, SAN.tau = 1, SAN.invcov = NULL, 
                 SAN.invcov.diag = FALSE, SAN.nsteps.alloc = function (nsim) 
                 2^seq_len(nsim), SAN.nsteps = 131072, SAN.samplesize = 1024, SAN.init.maxedges = 20000, 
                 SAN.max.maxedges = Inf, SAN.prop.weights = "default", SAN.prop.args = list(), 
                 SAN.packagenames = NULL, term.options = NULL, seed = NULL, parallel = 0, 
                 parallel.type = NULL, parallel.version.check = TRUE), class = c("control.san", 
             "control.list", "list")), MCMLE.termination = "Hummel", MCMLE.maxit = 20, 
             MCMLE.conv.min.pval = 0.5, MCMLE.NR.maxit = 100, MCMLE.NR.reltol = 1.49011611938477e-08, 
             obs.MCMC.samplesize = 1024, obs.MCMC.interval = 1024, obs.MCMC.burnin = 16384, 
             obs.MCMC.burnin.min = 1638.4, obs.MCMC.prop.weights = "default", obs.MCMC.prop.args = list(), 
             obs.MCMC.impute.min_informative = function (nw) 
             network.size(nw)/4, obs.MCMC.impute.default_density = function (nw) 
             2/network.size(nw), MCMLE.check.degeneracy = FALSE, MCMLE.MCMC.precision = 0.005, 
             MCMLE.MCMC.max.ESS.frac = 0.1, MCMLE.metric = "lognormal", MCMLE.method = "BFGS", 
             MCMLE.trustregion = 20, MCMLE.dampening = FALSE, MCMLE.dampening.min.ess = 20, 
             MCMLE.dampening.level = 0.1, MCMLE.steplength.margin = 0.05, MCMLE.steplength = 1, 
             MCMLE.adaptive.trustregion = 3, MCMLE.sequential = TRUE, MCMLE.density.guard.min = 10000, 
             MCMLE.density.guard = 20.0855369231877, MCMLE.effectiveSize = NULL, MCMLE.last.boost = 4, 
             MCMLE.Hummel.esteq = TRUE, MCMLE.Hummel.miss.sample = 100, MCMLE.Hummel.maxit = 25, 
             MCMLE.steplength.min = 1e-04, MCMLE.effectiveSize.interval_drop = 2, MCMLE.save_intermediates = NULL, 
             SA.phase1_n = NULL, SA.initial_gain = NULL, SA.nsubphases = 4, SA.niterations = NULL, 
             SA.phase3_n = NULL, SA.trustregion = 0.5, RM.phase1n_base = 7, RM.phase2n_base = 100, 
             RM.phase2sub = 7, RM.init_gain = 0.5, RM.phase3n = 500, Step.MCMC.samplesize = 100, 
             Step.maxit = 50, Step.gridsize = 100, CD.nsteps = 8, CD.multiplicity = 1, 
             CD.nsteps.obs = 128, CD.multiplicity.obs = 1, CD.maxit = 60, CD.conv.min.pval = 0.5, 
             CD.NR.maxit = 100, CD.NR.reltol = 1.49011611938477e-08, CD.metric = "naive", 
             CD.method = "BFGS", CD.trustregion = 20, CD.dampening = FALSE, CD.dampening.min.ess = 20, 
             CD.dampening.level = 0.1, CD.steplength.margin = 0.5, CD.steplength = 1, 
             CD.adaptive.trustregion = 3, CD.adaptive.epsilon = 0.01, CD.Hummel.esteq = TRUE, 
             CD.Hummel.miss.sample = 100, CD.Hummel.maxit = 25, CD.steplength.min = 1e-04, 
             loglik.control = structure(list(nsteps = 20, MCMC.burnin = NULL, MCMC.interval = NULL, 
                 MCMC.samplesize = NULL, obs.MCMC.samplesize = NULL, obs.MCMC.interval = NULL, 
                 obs.MCMC.burnin = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 warn.dyads = NULL, MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, 
                 term.options = NULL, seed = NULL, parallel = NULL, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.logLik.ergm", "control.list", 
             "list")), term.options = NULL, seed = NULL, parallel = 0, parallel.type = NULL, 
             parallel.version.check = TRUE), class = c("control.ergm", "control.list", 
         "list"))), class = "ergm"), formation = ~edges, target.stats = 12, target.stats.names = "edges", 
         coef.form = c(edges = -5.37527840766133), coef.form.crude = c(edges = -3.17805383032511), 
         coef.diss = structure(list(dissolution = ~offset(edges), duration = 10, coef.crude = 2.19722457733622, 
             coef.adj = 2.41911890925, d.rate = 0.01, model.type = "homog"), class = "disscoef"), 
         constraints = ~., edapprox = TRUE), class = "netest"), structure(list(inf.prob = 0.5, 
         act.rate = 2, a.rate = 0.01, ds.rate = 0.5, di.rate = 0.25, vital = TRUE), class = c("param.net", 
     "list")), structure(list(i.num = 10), class = c("init.net", "list")), structure(list(
         type = "SI", nsteps = 25, start = 1, nsims = 1, ncores = 1, rec.rand = TRUE, 
         a.rand = TRUE, d.rand = TRUE, tea.status = FALSE, use.pids = TRUE, initialize.FUN = function (x, 
             param, init, control, s) 
         {
             if (control$start == 1) {
                 dat <- list()
                 dat$param <- param
                 dat$init <- init
                 dat$control <- control
                 dat$attr <- list()
                 dat$stats <- list()
                 dat$temp <- list()
                 nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
                 modes <- ifelse(nw %n% "bipartite", 2, 1)
                 if (control$depend == TRUE) {
                     if (class(x$fit) == "stergm") {
                       nw <- network.collapse(nw, at = 1)
                     }
                     nw <- sim_nets(x, nw, nsteps = 1, control)
                 }
                 if (control$depend == FALSE) {
                     nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
                 }
                 nw <- activate.vertices(nw, onset = 1, terminus = Inf)
                 dat$nw <- nw
                 dat$nwparam <- list(x[-which(names(x) == "fit")])
                 dat$param$modes <- modes
                 if (control$use.pids == TRUE) {
                     dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
                 }
                 form <- get_nwparam(dat)$formation
                 fterms <- get_formula_term_attr(form, nw)
                 dat <- copy_toall_attr(dat, at = 1, fterms)
                 dat$temp$fterms <- fterms
                 dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
                 dat <- init_status.net(dat)
                 dat <- get_prev.net(dat, at = 1)
             }
             else {
                 dat <- list()
                 dat$nw <- x$network[[s]]
                 dat$param <- x$param
                 dat$control <- control
                 dat$nwparam <- x$nwparam
                 dat$epi <- sapply(x$epi, function(var) var[s])
                 names(dat$epi) <- names(x$epi)
                 dat$attr <- x$attr[[s]]
                 dat$stats <- sapply(x$stats, function(var) var[[s]])
                 dat$temp <- list()
             }
             return(dat)
         }, departures.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             d.rand <- dat$control$d.rand
             nDepartures.sus <- nDeparturesM2.sus <- 0
             idsElig.sus <- which(dat$attr$active == 1 & dat$attr$status == "s")
             nElig.sus <- length(idsElig.sus)
             if (nElig.sus > 0) {
                 mElig.sus <- mode[idsElig.sus]
                 rates.sus <- c(dat$param$ds.rate, dat$param$ds.rate.m2)
                 ratesElig.sus <- rates.sus[mElig.sus]
                 if (d.rand == TRUE) {
                     vecDepartures.sus <- which(rbinom(nElig.sus, 1, ratesElig.sus) == 
                       1)
                     if (length(vecDepartures.sus) > 0) {
                       idsDpt.sus <- idsElig.sus[vecDepartures.sus]
                       nDepartures.sus <- sum(mode[idsDpt.sus] == 1)
                       nDeparturesM2.sus <- sum(mode[idsDpt.sus] == 2)
                       dat$attr$active[idsDpt.sus] <- 0
                       dat$attr$exitTime[idsDpt.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.sus, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.sus <- idsDptM2.sus <- NULL
                     nDepartures.sus <- min(round(sum(ratesElig.sus[mElig.sus == 1])), 
                       sum(mElig.sus == 1))
                     idsDpt.sus <- ssample(idsElig.sus[mElig.sus == 1], nDepartures.sus)
                     if (modes == 2) {
                       nDeparturesM2.sus <- min(round(sum(ratesElig.sus[mElig.sus == 2])), 
                         sum(mElig.sus == 2))
                       idsDptM2.sus <- ssample(idsElig.sus[mElig.sus == 2], nDeparturesM2.sus)
                     }
                     totDpt.sus <- nDepartures.sus + nDeparturesM2.sus
                     if (totDpt.sus > 0) {
                       idsDptAll.sus <- c(idsDpt.sus, idsDptM2.sus)
                       dat$attr$active[idsDptAll.sus] <- 0
                       dat$attr$exitTime[idsDptAll.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.sus, deactivate.edges = TRUE)
                     }
                 }
             }
             nDepartures.inf <- nDeparturesM2.inf <- 0
             idsElig.inf <- which(dat$attr$active == 1 & dat$attr$status == "i")
             nElig.inf <- length(idsElig.inf)
             if (nElig.inf > 0) {
                 mElig.inf <- mode[idsElig.inf]
                 rates.inf <- c(dat$param$di.rate, dat$param$di.rate.m2)
                 ratesElig.inf <- rates.inf[mElig.inf]
                 if (d.rand == TRUE) {
                     vecDepartures.inf <- which(rbinom(nElig.inf, 1, ratesElig.inf) == 
                       1)
                     if (length(vecDepartures.inf) > 0) {
                       idsDpt.inf <- idsElig.inf[vecDepartures.inf]
                       nDepartures.inf <- sum(mode[idsDpt.inf] == 1)
                       nDeparturesM2.inf <- sum(mode[idsDpt.inf] == 2)
                       dat$attr$active[idsDpt.inf] <- 0
                       dat$attr$exitTime[idsDpt.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.inf, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.inf <- idsDptM2.inf <- NULL
                     nDepartures.inf <- min(round(sum(ratesElig.inf[mElig.inf == 1])), 
                       sum(mElig.inf == 1))
                     idsDpt.inf <- ssample(idsElig.inf[mElig.inf == 1], nDepartures.inf)
                     if (modes == 2) {
                       nDeparturesM2.inf <- min(round(sum(ratesElig.inf[mElig.inf == 2])), 
                         sum(mElig.inf == 2))
                       idsDptM2.inf <- ssample(idsElig.inf[mElig.inf == 2], nDeparturesM2.inf)
                     }
                     totDpt.inf <- nDepartures.inf + nDeparturesM2.inf
                     if (totDpt.inf > 0) {
                       idsDptAll.inf <- c(idsDpt.inf, idsDptM2.inf)
                       dat$attr$active[idsDptAll.inf] <- 0
                       dat$attr$exitTime[idsDptAll.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.inf, deactivate.edges = TRUE)
                     }
                 }
             }
             if (type == "SIR") {
                 nDepartures.rec <- nDeparturesM2.rec <- 0
                 idsElig.rec <- which(dat$attr$active == 1 & dat$attr$status == "r")
                 nElig.rec <- length(idsElig.rec)
                 if (nElig.rec > 0) {
                     mElig.rec <- mode[idsElig.rec]
                     rates.rec <- c(dat$param$dr.rate, dat$param$dr.rate.m2)
                     ratesElig.rec <- rates.rec[mElig.rec]
                     if (d.rand == TRUE) {
                       vecDepartures.rec <- which(rbinom(nElig.rec, 1, ratesElig.rec) == 
                         1)
                       if (length(vecDepartures.rec) > 0) {
                         idsDpt.rec <- idsElig.rec[vecDepartures.rec]
                         nDepartures.rec <- sum(mode[idsDpt.rec] == 1)
                         nDeparturesM2.rec <- sum(mode[idsDpt.rec] == 2)
                         dat$attr$active[idsDpt.rec] <- 0
                         dat$attr$exitTime[idsDpt.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.rec, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.rec <- idsDptM2.rec <- NULL
                       nDepartures.rec <- min(round(sum(ratesElig.rec[mElig.rec == 1])), 
                         sum(mElig.rec == 1))
                       idsDpt.rec <- ssample(idsElig.rec[mElig.rec == 1], nDepartures.rec)
                       if (modes == 2) {
                         nDeparturesM2.rec <- min(round(sum(ratesElig.rec[mElig.rec == 
                           2])), sum(mElig.rec == 2))
                         idsDptM2.rec <- ssample(idsElig.rec[mElig.rec == 2], nDeparturesM2.rec)
                       }
                       totDpt.rec <- nDepartures.rec + nDeparturesM2.rec
                       if (totDpt.rec > 0) {
                         idsDptAll.rec <- c(idsDpt.rec, idsDptM2.rec)
                         dat$attr$active[idsDptAll.rec] <- 0
                         dat$attr$exitTime[idsDptAll.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.rec, deactivate.edges = TRUE)
                       }
                     }
                 }
             }
             if (at == 2) {
                 dat$epi$ds.flow <- c(0, nDepartures.sus)
                 dat$epi$di.flow <- c(0, nDepartures.inf)
                 if (type == "SIR") {
                     dat$epi$dr.flow <- c(0, nDepartures.rec)
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2 <- c(0, nDeparturesM2.sus)
                     dat$epi$di.flow.m2 <- c(0, nDeparturesM2.inf)
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2 <- c(0, nDeparturesM2.rec)
                     }
                 }
             }
             else {
                 dat$epi$ds.flow[at] <- nDepartures.sus
                 dat$epi$di.flow[at] <- nDepartures.inf
                 if (type == "SIR") {
                     dat$epi$dr.flow[at] <- nDepartures.rec
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2[at] <- nDeparturesM2.sus
                     dat$epi$di.flow.m2[at] <- nDeparturesM2.inf
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2[at] <- nDeparturesM2.rec
                     }
                 }
             }
             return(dat)
         }, arrivals.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             a.rate <- dat$param$a.rate
             a.rate.m2 <- dat$param$a.rate.m2
             modes <- dat$param$modes
             tea.status <- dat$control$tea.status
             nOld <- dat$epi$num[at - 1]
             nCurr <- network.size(dat$nw)
             a.rand <- dat$control$a.rand
             delete.nodes <- dat$control$delete.nodes
             nArrivals <- nArrivalsM2 <- 0
             newNodes <- newNodesM2 <- NULL
             if (modes == 1 && nOld > 0) {
                 if (a.rand == TRUE) {
                     nArrivals <- sum(rbinom(nOld, 1, a.rate))
                 }
                 if (a.rand == FALSE) {
                     nArrivals <- round(nOld * a.rate)
                 }
                 if (nArrivals > 0) {
                     dat$nw <- add.vertices(dat$nw, nv = nArrivals)
                     newNodes <- (nCurr + 1):(nCurr + nArrivals)
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (modes == 2 && nOld > 0) {
                 nOldM2 <- dat$epi$num.m2[at - 1]
                 if (a.rand == TRUE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOld, 1, a.rate))
                     }
                     else {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOldM2, 1, a.rate.m2))
                     }
                 }
                 if (a.rand == FALSE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOld * a.rate)
                     }
                     else {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOldM2 * a.rate.m2)
                     }
                 }
                 nCurrM1 <- length(modeids(dat$nw, 1))
                 nCurrM2 <- length(modeids(dat$nw, 2))
                 prefixes <- unique(substr(dat$nw %v% "vertex.names", 1, 1))
                 if (nArrivals > 0) {
                     newNodeIDs <- (nCurrM1 + 1):(nCurrM1 + nArrivals)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[1], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE)
                     }
                     newNodes <- newNodeIDs
                 }
                 if (nArrivalsM2 > 0) {
                     newNodeIDs <- (nCurrM2 + 1):(nCurrM2 + nArrivalsM2)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[2], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE)
                     }
                     newSize <- network.size(dat$nw)
                     newNodesM2 <- (newSize - nArrivalsM2 + 1):newSize
                 }
                 newNodes <- c(newNodes, newNodesM2)
                 if (!is.null(newNodes)) {
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (length(newNodes) > 0) {
                 fterms <- dat$temp$fterms
                 curr.tab <- get_attr_prop(dat$nw, fterms)
                 if (length(curr.tab) > 0) {
                     dat$nw <- update_nwattr(dat$nw, newNodes, dat$control$attr.rules, 
                       curr.tab, dat$temp$t1.tab)
                 }
                 dat <- copy_toall_attr(dat, at, fterms)
                 if (tea.status == TRUE) {
                     if ("status" %in% fterms) {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = dat$attr$status[newNodes], onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                     else {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = "s", onset = at, terminus = Inf, v = newNodes)
                     }
                 }
                 if (modes == 1) {
                     if (!("status" %in% fterms)) {
                       dat$attr$status <- c(dat$attr$status, rep("s", length(newNodes)))
                     }
                     dat$attr$active <- c(dat$attr$active, rep(1, length(newNodes)))
                     dat$attr$infTime <- c(dat$attr$infTime, rep(NA, length(newNodes)))
                     dat$attr$entrTime <- c(dat$attr$entrTime, rep(at, length(newNodes)))
                     dat$attr$exitTime <- c(dat$attr$exitTime, rep(NA, length(newNodes)))
                 }
                 if (modes == 2) {
                     if (!("status" %in% fterms)) {
                       dat <- split_bip(dat, "status", "s", nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                     }
                     dat <- split_bip(dat, "active", 1, nCurrM1, nCurrM2, nArrivals, nArrivalsM2)
                     dat <- split_bip(dat, "infTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "entrTime", at, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "exitTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                 }
                 newNodesInf <- intersect(newNodes, which(dat$attr$status == "i"))
                 dat$attr$infTime[newNodesInf] <- at
                 if (length(unique(sapply(dat$attr, length))) != 1) {
                     stop("Attribute list of unequal length. Check arrivals.net module.")
                 }
             }
             if (at == 2) {
                 dat$epi$a.flow <- c(0, nArrivals)
                 if (modes == 2) {
                     dat$epi$a.flow.m2 <- c(0, nArrivalsM2)
                 }
             }
             else {
                 dat$epi$a.flow[at] <- nArrivals
                 if (modes == 2) {
                     dat$epi$a.flow.m2[at] <- nArrivalsM2
                 }
             }
             return(dat)
         }, recovery.FUN = function (dat, at) 
         {
             if (!(dat$control$type %in% c("SIR", "SIS"))) {
                 return(dat)
             }
             active <- dat$attr$active
             status <- dat$attr$status
             infTime <- dat$attr$infTime
             tea.status <- dat$control$tea.status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             recovState <- ifelse(type == "SIR", "r", "s")
             rec.rand <- dat$control$rec.rand
             rec.rate <- dat$param$rec.rate
             rec.rate.m2 <- dat$param$rec.rate.m2
             nRecov <- nRecovM2 <- 0
             idsElig <- which(active == 1 & status == "i")
             nElig <- length(idsElig)
             infDur <- at - infTime[active == 1 & status == "i"]
             infDur[infDur == 0] <- 1
             lrec.rate <- length(rec.rate)
             if (lrec.rate == 1) {
                 mElig <- mode[idsElig]
                 rates <- c(rec.rate, rec.rate.m2)
                 ratesElig <- rates[mElig]
             }
             else {
                 mElig <- mode[idsElig]
                 if (is.null(rec.rate.m2)) {
                     rates <- ifelse(infDur <= lrec.rate, rec.rate[infDur], rec.rate[lrec.rate])
                 }
                 else {
                     rates <- rep(NA, length(infDur))
                     rates[mElig == 1] <- ifelse(infDur[mElig == 1] <= lrec.rate, rec.rate[infDur[mElig == 
                       1]], rec.rate[lrec.rate])
                     rates[mElig == 2] <- ifelse(infDur[mElig == 2] <= length(rec.rate.m2), 
                       rec.rate.m2[infDur[mElig == 2]], rec.rate.m2[length(rec.rate.m2)])
                 }
                 ratesElig <- rates
             }
             if (nElig > 0) {
                 if (rec.rand == TRUE) {
                     vecRecov <- which(rbinom(nElig, 1, ratesElig) == 1)
                     if (length(vecRecov) > 0) {
                       idsRecov <- idsElig[vecRecov]
                       nRecov <- sum(mode[idsRecov] == 1)
                       nRecovM2 <- sum(mode[idsRecov] == 2)
                       status[idsRecov] <- recovState
                       if (tea.status == TRUE) {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = recovState, onset = at, terminus = Inf, v = idsRecov)
                       }
                     }
                 }
                 else {
                     idsRecov <- idsRecovM2 <- NULL
                     nRecov <- min(round(sum(ratesElig[mElig == 1])), sum(mElig == 1))
                     if (nRecov > 0) {
                       idsRecov <- ssample(idsElig[mElig == 1], nRecov)
                       status[idsRecov] <- recovState
                     }
                     if (modes == 2) {
                       nRecovM2 <- min(round(sum(ratesElig[mElig == 2])), sum(mElig == 
                         2))
                       if (nRecovM2 > 0) {
                         idsRecovM2 <- ssample(idsElig[mElig == 2], nRecovM2)
                         status[idsRecovM2] <- recovState
                       }
                     }
                     totRecov <- nRecov + nRecovM2
                     if (tea.status == TRUE & totRecov > 0) {
                       allids <- c(idsRecov, idsRecovM2)
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = recovState, onset = at, terminus = Inf, v = allids)
                     }
                 }
             }
             dat$attr$status <- status
             if ("status" %in% dat$temp$fterms) {
                 dat$nw <- set.vertex.attribute(dat$nw, "status", dat$attr$status)
             }
             outName <- ifelse(type == "SIR", "ir.flow", "is.flow")
             outName[2] <- paste0(outName, ".m2")
             if (at == 2) {
                 dat$epi[[outName[1]]] <- c(0, nRecov)
             }
             else {
                 dat$epi[[outName[1]]][at] <- nRecov
             }
             if (modes == 2) {
                 if (at == 2) {
                     dat$epi[[outName[2]]] <- c(0, nRecovM2)
                 }
                 else {
                     dat$epi[[outName[2]]][at] <- nRecovM2
                 }
             }
             return(dat)
         }, edges_correct.FUN = function (dat, at) 
         {
             if (dat$control$depend == TRUE) {
                 if (dat$param$modes == 1) {
                     old.num <- dat$epi$num[at - 1]
                     new.num <- sum(dat$attr$active == 1)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(old.num) - log(new.num)
                 }
                 if (dat$param$modes == 2) {
                     mode <- idmode(dat$nw)
                     old.num.m1 <- dat$epi$num[at - 1]
                     old.num.m2 <- dat$epi$num.m2[at - 1]
                     new.num.m1 <- sum(dat$attr$active == 1 & mode == 1)
                     new.num.m2 <- sum(dat$attr$active == 1 & mode == 2)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(2 * old.num.m1 * old.num.m2/(old.num.m1 + old.num.m2)) - log(2 * 
                       new.num.m1 * new.num.m2/(new.num.m1 + new.num.m2))
                 }
             }
             return(dat)
         }, resim_nets.FUN = function (dat, at) 
         {
             idsActive <- which(dat$attr$active == 1)
             anyActive <- ifelse(length(idsActive) > 0, TRUE, FALSE)
             if (dat$param$modes == 2) {
                 nActiveM1 <- length(intersect(modeids(dat$nw, mode = 1), idsActive))
                 nActiveM2 <- length(intersect(modeids(dat$nw, mode = 2), idsActive))
                 anyActive <- ifelse(nActiveM1 > 0 & nActiveM2 > 0, TRUE, FALSE)
             }
             nwparam <- get_nwparam(dat)
             statOnNw <- ("status" %in% dat$temp$fterms)
             status <- dat$attr$status
             if (statOnNw == TRUE && length(unique(status)) == 1) {
                 stop("Stopping simulation because status in formation formula and ", 
                     "no longer any discordant nodes", call. = TRUE)
             }
             if (dat$control$save.nwstats == TRUE) {
                 if (at == 2) {
                     nwstats <- attributes(dat$nw)$stats
                     dat$stats$nwstats <- as.data.frame(nwstats)
                 }
             }
             if (anyActive > 0 & dat$control$depend == TRUE) {
                 suppressWarnings(dat$nw <- simulate(dat$nw, formation = nwparam$formation, 
                     dissolution = nwparam$coef.diss$dissolution, coef.form = nwparam$coef.form, 
                     coef.diss = nwparam$coef.diss$coef.adj, constraints = nwparam$constraints, 
                     time.start = at, time.slices = 1, time.offset = 0, monitor = dat$control$nwstats.formula, 
                     control = dat$control$set.control.stergm))
                 if (dat$control$save.nwstats == TRUE) {
                     dat$stats$nwstats <- rbind(dat$stats$nwstats, tail(attributes(dat$nw)$stats, 
                       1))
                 }
                 if (dat$control$delete.nodes == TRUE) {
                     dat$nw <- network.extract(dat$nw, at = at)
                     inactive <- which(dat$attr$active == 0)
                     dat$attr <- deleteAttr(dat$attr, inactive)
                 }
             }
             return(dat)
         }, infection.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             status <- dat$attr$status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             inf.prob <- dat$param$inf.prob
             inf.prob.m2 <- dat$param$inf.prob.m2
             act.rate <- dat$param$act.rate
             nw <- dat$nw
             tea.status <- dat$control$tea.status
             idsInf <- which(active == 1 & status == "i")
             nActive <- sum(active == 1)
             nElig <- length(idsInf)
             nInf <- nInfM2 <- totInf <- 0
             if (nElig > 0 && nElig < nActive) {
                 del <- discord_edgelist(dat, at)
                 if (!(is.null(del))) {
                     del$infDur <- at - dat$attr$infTime[del$inf]
                     del$infDur[del$infDur == 0] <- 1
                     linf.prob <- length(inf.prob)
                     if (is.null(inf.prob.m2)) {
                       del$transProb <- ifelse(del$infDur <= linf.prob, inf.prob[del$infDur], 
                         inf.prob[linf.prob])
                     }
                     else {
                       del$transProb <- ifelse(del$sus <= nw %n% "bipartite", ifelse(del$infDur <= 
                         linf.prob, inf.prob[del$infDur], inf.prob[linf.prob]), ifelse(del$infDur <= 
                         linf.prob, inf.prob.m2[del$infDur], inf.prob.m2[linf.prob]))
                     }
                     if (!is.null(dat$param$inter.eff) && at >= dat$param$inter.start) {
                       del$transProb <- del$transProb * (1 - dat$param$inter.eff)
                     }
                     lact.rate <- length(act.rate)
                     del$actRate <- ifelse(del$infDur <= lact.rate, act.rate[del$infDur], 
                       act.rate[lact.rate])
                     del$finalProb <- 1 - (1 - del$transProb)^del$actRate
                     transmit <- rbinom(nrow(del), 1, del$finalProb)
                     del <- del[which(transmit == 1), ]
                     idsNewInf <- unique(del$sus)
                     nInf <- sum(mode[idsNewInf] == 1)
                     nInfM2 <- sum(mode[idsNewInf] == 2)
                     totInf <- nInf + nInfM2
                     if (totInf > 0) {
                       if (tea.status == TRUE) {
                         nw <- activate.vertex.attribute(nw, prefix = "testatus", value = "i", 
                           onset = at, terminus = Inf, v = idsNewInf)
                       }
                       dat$attr$status[idsNewInf] <- "i"
                       dat$attr$infTime[idsNewInf] <- at
                       if ("status" %in% dat$temp$fterms) {
                         nw <- set.vertex.attribute(nw, "status", dat$attr$status)
                       }
                     }
                     if (any(names(nw$gal) %in% "vertex.pid")) {
                       del$sus <- get.vertex.pid(nw, del$sus)
                       del$inf <- get.vertex.pid(nw, del$inf)
                     }
                 }
             }
             if (totInf > 0) {
                 del <- del[!duplicated(del$sus), ]
                 if (at == 2) {
                     dat$stats$transmat <- del
                 }
                 else {
                     dat$stats$transmat <- rbind(dat$stats$transmat, del)
                 }
             }
             if (at == 2) {
                 dat$epi$si.flow <- c(0, nInf)
                 if (modes == 2) {
                     dat$epi$si.flow.m2 <- c(0, nInfM2)
                 }
             }
             else {
                 dat$epi$si.flow[at] <- nInf
                 if (modes == 2) {
                     dat$epi$si.flow.m2[at] <- nInfM2
                 }
             }
             dat$nw <- nw
             return(dat)
         }, get_prev.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             modes <- dat$param$modes
             l <- lapply(1:length(dat$attr), function(x) dat$attr[[x]][active == 1])
             names(l) <- names(dat$attr)
             l$active <- l$infTime <- NULL
             status <- l$status
             if (modes == 2) {
                 mode <- idmode(dat$nw)[active == 1]
             }
             eb <- !is.null(dat$control$epi.by)
             if (eb == TRUE) {
                 ebn <- dat$control$epi.by
                 ebv <- dat$temp$epi.by.vals
                 ebun <- paste0(".", ebn, ebv)
                 assign(ebn, l[[ebn]])
             }
             if (modes == 1) {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]][at] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
             }
             else {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2 <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2 <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2 <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]] <- sum(status == "r" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2 <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2[at] <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2[at] <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2[at] <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]][at] <- sum(status == 
                             "r" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2[at] <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]][at] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
             }
             return(dat)
         }, verbose.FUN = function (x, type, s = 1, at = 2) 
         {
             if (type == "startup" && x$ncores == 1) {
                 if (x$verbose == TRUE) {
                     cat("\nStarting Network Simulation...")
                 }
             }
             if (type == "progress" && x$control$ncores == 1) {
                 if (x$control$verbose == TRUE) {
                     if (x$control$verbose.int == 0 && at == x$control$nsteps) {
                       cat("\nSim = ", s, "/", x$control$nsims, sep = "")
                     }
                     if (x$control$verbose.int > 0 && (at%%x$control$verbose.int == 0)) {
                       cat("\f")
                       cat("\nEpidemic Simulation")
                       cat("\n----------------------------")
                       cat("\nSimulation: ", s, "/", x$control$nsims, sep = "")
                       cat("\nTimestep: ", at, "/", x$control$nsteps, sep = "")
                       status <- x$attr$status
                       if (class(status) == "character") {
                         status <- ifelse(status == "i", 1, 0)
                       }
                       cat("\nPrevalence:", sum(status, na.rm = TRUE))
                       cat("\nPopulation Size:", sum(x$attr$active == 1))
                       cat("\n----------------------------")
                     }
                 }
             }
         }, module.order = NULL, save.nwstats = TRUE, nwstats.formula = "formation", delete.nodes = FALSE, 
         save.transmat = TRUE, save.network = TRUE, verbose = FALSE, verbose.int = 1, 
         skip.check = FALSE, bi.mods = c("initialize.FUN", "departures.FUN", "arrivals.FUN", 
         "recovery.FUN", "edges_correct.FUN", "resim_nets.FUN", "infection.FUN", "get_prev.FUN", 
         "verbose.FUN"), user.mods = character(0), attr.rules = list(), set.control.stergm = structure(list(
             MCMC.burnin.min = 1000, MCMC.burnin.max = 1e+05, MCMC.burnin.pval = 0.5, 
             MCMC.burnin.add = 1, MCMC.burnin = NULL, MCMC.burnin.mul = NULL, MCMC.prop.weights.form = "default", 
             MCMC.prop.args.form = NULL, MCMC.prop.weights.diss = "default", MCMC.prop.args.diss = NULL, 
             MCMC.init.maxedges = 20000, MCMC.packagenames = NULL, MCMC.init.maxchanges = 1e+06), class = c("control.simulate.network", 
         "control.list", "list")), set.control.ergm = structure(list(MCMC.burnin = 2e+05, 
             MCMC.interval = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, MCMC.init.maxedges = NULL, 
             MCMC.packagenames = NULL, MCMC.runtime.traceplot = FALSE, network.output = "network", 
             term.options = NULL, parallel = 0, parallel.type = NULL, parallel.version.check = TRUE), class = c("control.simulate.ergm", 
         "control.list", "list")), depend = TRUE), class = c("control.net", "list")), 
         1L)
  4: sim_nets(x, nw, nsteps = 1, control)
  5: suppressWarnings(sim <- simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm))
  6: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  7: simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, coef.form = x$coef.form, 
         coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, time.start = 1, time.offset = 0, 
         constraints = x$constraints, monitor = control$nwstats.formula, nsim = 1, control = control$set.control.stergm)
  8: simulate.network(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm)
  9: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  10: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  11: lapply(X = X, FUN = FUN, ...)
  12: FUN(X[[i]], ...)
  13: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  14: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  
  Starting Network Simulation...-- 6. Error: status.vector and infTime.vector (@test-net-long.R#812)  ----------
  'Calloc' could not allocate memory (176776148 of 16 bytes)
  1: netsim(est1, param, init, control) at testthat/test-net-long.R:812
  2: do.call(control[["initialize.FUN"]], list(x, param, init, control, s))
  3: (function (x, param, init, control, s) 
     {
         if (control$start == 1) {
             dat <- list()
             dat$param <- param
             dat$init <- init
             dat$control <- control
             dat$attr <- list()
             dat$stats <- list()
             dat$temp <- list()
             nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
             modes <- ifelse(nw %n% "bipartite", 2, 1)
             if (control$depend == TRUE) {
                 if (class(x$fit) == "stergm") {
                     nw <- network.collapse(nw, at = 1)
                 }
                 nw <- sim_nets(x, nw, nsteps = 1, control)
             }
             if (control$depend == FALSE) {
                 nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
             }
             nw <- activate.vertices(nw, onset = 1, terminus = Inf)
             dat$nw <- nw
             dat$nwparam <- list(x[-which(names(x) == "fit")])
             dat$param$modes <- modes
             if (control$use.pids == TRUE) {
                 dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
             }
             form <- get_nwparam(dat)$formation
             fterms <- get_formula_term_attr(form, nw)
             dat <- copy_toall_attr(dat, at = 1, fterms)
             dat$temp$fterms <- fterms
             dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
             dat <- init_status.net(dat)
             dat <- get_prev.net(dat, at = 1)
         }
         else {
             dat <- list()
             dat$nw <- x$network[[s]]
             dat$param <- x$param
             dat$control <- control
             dat$nwparam <- x$nwparam
             dat$epi <- sapply(x$epi, function(var) var[s])
             names(dat$epi) <- names(x$epi)
             dat$attr <- x$attr[[s]]
             dat$stats <- sapply(x$stats, function(var) var[[s]])
             dat$temp <- list()
         }
         return(dat)
     })(structure(list(fit = structure(list(coef = c(edges = -4.58496747858219), iterations = 7L, 
         MCMCtheta = c(edges = -4.58496747858219), gradient = NA, hessian = structure(-49.4956008703125, .Dim = c(1L, 
         1L)), covar = structure(0.0202038157415279, .Dim = c(1L, 1L)), failure = FALSE, 
         est.cov = structure(0, .Dim = c(1L, 1L)), glm = structure(list(coefficients = c(edges = -4.58496747858219), 
             residuals = c(`1` = -1.01020408163355, `2` = 98.9999999913385), fitted.values = c(`1` = 0.0101010101018938, 
             `2` = 0.0101010101018938), effects = c(edges = 32.2566721378818, 70.3557734423717
             ), R = structure(-7.03531100025525, .Dim = c(1L, 1L), .Dimnames = list("edges", 
                 "edges")), rank = 1L, qr = structure(list(qr = structure(c(-7.03531100025525, 
             0.100503781525921), .Dim = 2:1, .Dimnames = list(c("1", "2"), "edges")), 
                 rank = 1L, qraux = 1.99493667632618, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -4.58496747858219, `2` = -4.58496747858219
             ), deviance = 559.005225360835, aic = 561.005225360835, null.deviance = 6862.15708754346, 
             iter = 7L, weights = c(`1` = 48.9956453059659, `2` = 0.499955564346591), 
             prior.weights = c(`1` = 4900, `2` = 50), df.residual = 1L, df.null = 2L, 
             y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = 0:1, edges = c(1, 1), `offset(pl$foffset)` = c(0, 0), `(weights)` = c(4900, 
                 50)), terms = pl$zy ~ edges - 1 + offset(pl$foffset), row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ . - 1 + offset(pl$foffset), family = family, 
                 data = data.frame(pl$xmat), weights = pl$wend), formula = pl$zy ~ . - 
                 1 + offset(pl$foffset), terms = pl$zy ~ edges - 1 + offset(pl$foffset), 
             data = structure(list(edges = c(1, 1)), class = "data.frame", row.names = c(NA, 
             -2L)), offset = c(0, 0), control = list(epsilon = 1e-08, maxit = 25, trace = FALSE), 
             method = "glm.fit", contrasts = NULL, xlevels = structure(list(), .Names = character(0))), class = c("glm", 
         "lm")), glm.null = structure(list(coefficients = c(`(Intercept)` = -4.58496747858219), 
             residuals = c(`1` = -1.01020408163355, `2` = 98.9999999913385), fitted.values = c(`1` = 0.0101010101018938, 
             `2` = 0.0101010101018938), effects = c(`(Intercept)` = 32.2566721378818, 
             70.3557734423717), R = structure(-7.03531100025525, .Dim = c(1L, 1L), .Dimnames = list(
                 "(Intercept)", "(Intercept)")), rank = 1L, qr = structure(list(qr = structure(c(-7.03531100025525, 
             0.100503781525921), .Dim = 2:1, .Dimnames = list(c("1", "2"), "(Intercept)")), 
                 rank = 1L, qraux = 1.99493667632618, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -4.58496747858219, `2` = -4.58496747858219
             ), deviance = 559.005225360835, aic = 561.005225360835, null.deviance = 559.005225360834, 
             iter = 7L, weights = c(`1` = 48.9956453059659, `2` = 0.499955564346591), 
             prior.weights = c(`1` = 4900, `2` = 50), df.residual = 1L, df.null = 1L, 
             y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = 0:1, `(weights)` = c(4900, 50)), terms = pl$zy ~ 1, row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ 1, family = family, weights = pl$wend), formula = pl$zy ~ 
                 1, terms = pl$zy ~ 1, data = <environment>, offset = NULL, control = list(
                 epsilon = 1e-08, maxit = 25, trace = FALSE), method = "glm.fit", contrasts = NULL, 
             xlevels = NULL), class = c("glm", "lm")), theta1 = list(coef = c(edges = -4.58496747858219), 
             theta = c(edges = -4.58496747858219), independent = c(edges = TRUE)), MPLE_is_MLE = TRUE, 
         ergm_version = structure(list(c(3L, 10L, 1L)), class = c("package_version", "numeric_version"
         )), offset = FALSE, drop = 0, estimable = TRUE, network = structure(list(mel = list(
             list(inl = 26L, outl = 4L, atl = list(na = FALSE)), list(inl = 45L, outl = 7L, 
                 atl = list(na = FALSE)), list(inl = 22L, outl = 14L, atl = list(na = FALSE)), 
             list(inl = 27L, outl = 14L, atl = list(na = FALSE)), list(inl = 32L, outl = 14L, 
                 atl = list(na = FALSE)), list(inl = 55L, outl = 16L, atl = list(na = FALSE)), 
             list(inl = 46L, outl = 17L, atl = list(na = FALSE)), list(inl = 50L, outl = 20L, 
                 atl = list(na = FALSE)), list(inl = 68L, outl = 20L, atl = list(na = FALSE)), 
             list(inl = 32L, outl = 21L, atl = list(na = FALSE)), list(inl = 27L, outl = 22L, 
                 atl = list(na = FALSE)), list(inl = 42L, outl = 25L, atl = list(na = FALSE)), 
             list(inl = 98L, outl = 25L, atl = list(na = FALSE)), list(inl = 49L, outl = 27L, 
                 atl = list(na = FALSE)), list(inl = 73L, outl = 27L, atl = list(na = FALSE)), 
             list(inl = 70L, outl = 28L, atl = list(na = FALSE)), list(inl = 33L, outl = 29L, 
                 atl = list(na = FALSE)), list(inl = 89L, outl = 29L, atl = list(na = FALSE)), 
             list(inl = 71L, outl = 31L, atl = list(na = FALSE)), list(inl = 94L, outl = 31L, 
                 atl = list(na = FALSE)), list(inl = 98L, outl = 32L, atl = list(na = FALSE)), 
             list(inl = 37L, outl = 34L, atl = list(na = FALSE)), list(inl = 54L, outl = 37L, 
                 atl = list(na = FALSE)), list(inl = 97L, outl = 37L, atl = list(na = FALSE)), 
             list(inl = 40L, outl = 38L, atl = list(na = FALSE)), list(inl = 60L, outl = 38L, 
                 atl = list(na = FALSE)), list(inl = 95L, outl = 39L, atl = list(na = FALSE)), 
             list(inl = 66L, outl = 41L, atl = list(na = FALSE)), list(inl = 92L, outl = 42L, 
                 atl = list(na = FALSE)), list(inl = 68L, outl = 44L, atl = list(na = FALSE)), 
             list(inl = 84L, outl = 44L, atl = list(na = FALSE)), list(inl = 88L, outl = 49L, 
                 atl = list(na = FALSE)), list(inl = 56L, outl = 51L, atl = list(na = FALSE)), 
             list(inl = 87L, outl = 53L, atl = list(na = FALSE)), list(inl = 63L, outl = 54L, 
                 atl = list(na = FALSE)), list(inl = 66L, outl = 54L, atl = list(na = FALSE)), 
             list(inl = 87L, outl = 58L, atl = list(na = FALSE)), list(inl = 66L, outl = 61L, 
                 atl = list(na = FALSE)), list(inl = 94L, outl = 61L, atl = list(na = FALSE)), 
             list(inl = 99L, outl = 61L, atl = list(na = FALSE)), list(inl = 99L, outl = 62L, 
                 atl = list(na = FALSE)), list(inl = 89L, outl = 63L, atl = list(na = FALSE)), 
             list(inl = 72L, outl = 71L, atl = list(na = FALSE)), list(inl = 95L, outl = 74L, 
                 atl = list(na = FALSE)), list(inl = 78L, outl = 75L, atl = list(na = FALSE)), 
             list(inl = 77L, outl = 76L, atl = list(na = FALSE)), list(inl = 97L, outl = 76L, 
                 atl = list(na = FALSE)), list(inl = 91L, outl = 78L, atl = list(na = FALSE)), 
             list(inl = 99L, outl = 83L, atl = list(na = FALSE)), list(inl = 100L, outl = 83L, 
                 atl = list(na = FALSE))), gal = list(n = 100, mnext = 51L, directed = FALSE, 
             hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = FALSE), val = list(
             list(na = FALSE, vertex.names = 1L), list(na = FALSE, vertex.names = 2L), 
             list(na = FALSE, vertex.names = 3L), list(na = FALSE, vertex.names = 4L), 
             list(na = FALSE, vertex.names = 5L), list(na = FALSE, vertex.names = 6L), 
             list(na = FALSE, vertex.names = 7L), list(na = FALSE, vertex.names = 8L), 
             list(na = FALSE, vertex.names = 9L), list(na = FALSE, vertex.names = 10L), 
             list(na = FALSE, vertex.names = 11L), list(na = FALSE, vertex.names = 12L), 
             list(na = FALSE, vertex.names = 13L), list(na = FALSE, vertex.names = 14L), 
             list(na = FALSE, vertex.names = 15L), list(na = FALSE, vertex.names = 16L), 
             list(na = FALSE, vertex.names = 17L), list(na = FALSE, vertex.names = 18L), 
             list(na = FALSE, vertex.names = 19L), list(na = FALSE, vertex.names = 20L), 
             list(na = FALSE, vertex.names = 21L), list(na = FALSE, vertex.names = 22L), 
             list(na = FALSE, vertex.names = 23L), list(na = FALSE, vertex.names = 24L), 
             list(na = FALSE, vertex.names = 25L), list(na = FALSE, vertex.names = 26L), 
             list(na = FALSE, vertex.names = 27L), list(na = FALSE, vertex.names = 28L), 
             list(na = FALSE, vertex.names = 29L), list(na = FALSE, vertex.names = 30L), 
             list(na = FALSE, vertex.names = 31L), list(na = FALSE, vertex.names = 32L), 
             list(na = FALSE, vertex.names = 33L), list(na = FALSE, vertex.names = 34L), 
             list(na = FALSE, vertex.names = 35L), list(na = FALSE, vertex.names = 36L), 
             list(na = FALSE, vertex.names = 37L), list(na = FALSE, vertex.names = 38L), 
             list(na = FALSE, vertex.names = 39L), list(na = FALSE, vertex.names = 40L), 
             list(na = FALSE, vertex.names = 41L), list(na = FALSE, vertex.names = 42L), 
             list(na = FALSE, vertex.names = 43L), list(na = FALSE, vertex.names = 44L), 
             list(na = FALSE, vertex.names = 45L), list(na = FALSE, vertex.names = 46L), 
             list(na = FALSE, vertex.names = 47L), list(na = FALSE, vertex.names = 48L), 
             list(na = FALSE, vertex.names = 49L), list(na = FALSE, vertex.names = 50L), 
             list(na = FALSE, vertex.names = 51L), list(na = FALSE, vertex.names = 52L), 
             list(na = FALSE, vertex.names = 53L), list(na = FALSE, vertex.names = 54L), 
             list(na = FALSE, vertex.names = 55L), list(na = FALSE, vertex.names = 56L), 
             list(na = FALSE, vertex.names = 57L), list(na = FALSE, vertex.names = 58L), 
             list(na = FALSE, vertex.names = 59L), list(na = FALSE, vertex.names = 60L), 
             list(na = FALSE, vertex.names = 61L), list(na = FALSE, vertex.names = 62L), 
             list(na = FALSE, vertex.names = 63L), list(na = FALSE, vertex.names = 64L), 
             list(na = FALSE, vertex.names = 65L), list(na = FALSE, vertex.names = 66L), 
             list(na = FALSE, vertex.names = 67L), list(na = FALSE, vertex.names = 68L), 
             list(na = FALSE, vertex.names = 69L), list(na = FALSE, vertex.names = 70L), 
             list(na = FALSE, vertex.names = 71L), list(na = FALSE, vertex.names = 72L), 
             list(na = FALSE, vertex.names = 73L), list(na = FALSE, vertex.names = 74L), 
             list(na = FALSE, vertex.names = 75L), list(na = FALSE, vertex.names = 76L), 
             list(na = FALSE, vertex.names = 77L), list(na = FALSE, vertex.names = 78L), 
             list(na = FALSE, vertex.names = 79L), list(na = FALSE, vertex.names = 80L), 
             list(na = FALSE, vertex.names = 81L), list(na = FALSE, vertex.names = 82L), 
             list(na = FALSE, vertex.names = 83L), list(na = FALSE, vertex.names = 84L), 
             list(na = FALSE, vertex.names = 85L), list(na = FALSE, vertex.names = 86L), 
             list(na = FALSE, vertex.names = 87L), list(na = FALSE, vertex.names = 88L), 
             list(na = FALSE, vertex.names = 89L), list(na = FALSE, vertex.names = 90L), 
             list(na = FALSE, vertex.names = 91L), list(na = FALSE, vertex.names = 92L), 
             list(na = FALSE, vertex.names = 93L), list(na = FALSE, vertex.names = 94L), 
             list(na = FALSE, vertex.names = 95L), list(na = FALSE, vertex.names = 96L), 
             list(na = FALSE, vertex.names = 97L), list(na = FALSE, vertex.names = 98L), 
             list(na = FALSE, vertex.names = 99L), list(na = FALSE, vertex.names = 100L)), 
             iel = list(integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 3L, integer(0), integer(0), integer(0), 
                 1L, c(4L, 11L), integer(0), integer(0), integer(0), integer(0), c(5L, 
                 10L), 17L, integer(0), integer(0), integer(0), 22L, integer(0), integer(0), 
                 25L, integer(0), 12L, integer(0), integer(0), 2L, 7L, integer(0), integer(0), 
                 14L, 8L, integer(0), integer(0), integer(0), 23L, 6L, 33L, integer(0), 
                 integer(0), integer(0), 26L, integer(0), integer(0), 35L, integer(0), 
                 integer(0), c(28L, 36L, 38L), integer(0), c(9L, 30L), integer(0), 16L, 
                 19L, 43L, 15L, integer(0), integer(0), integer(0), 46L, 45L, integer(0), 
                 integer(0), integer(0), integer(0), integer(0), 31L, integer(0), integer(0), 
                 c(34L, 37L), 32L, c(18L, 42L), integer(0), 48L, 29L, integer(0), c(20L, 
                 39L), c(27L, 44L), integer(0), c(24L, 47L), c(13L, 21L), c(40L, 41L, 
                 49L), 50L), oel = list(integer(0), integer(0), integer(0), 1L, integer(0), 
                 integer(0), 2L, integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), 5:3, integer(0), 6L, 7L, integer(0), integer(0), 9:8, 10L, 
                 11L, integer(0), integer(0), 13:12, integer(0), 15:14, 16L, 18:17, integer(0), 
                 20:19, 21L, integer(0), 22L, integer(0), integer(0), 24:23, 26:25, 27L, 
                 integer(0), 28L, 29L, integer(0), 31:30, integer(0), integer(0), integer(0), 
                 integer(0), 32L, integer(0), 33L, integer(0), 34L, 36:35, integer(0), 
                 integer(0), integer(0), 37L, integer(0), integer(0), 40:38, 41L, 42L, 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), 43L, integer(0), integer(0), 44L, 45L, 47:46, integer(0), 
                 48L, integer(0), integer(0), integer(0), integer(0), 50:49, integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0))), class = "network"), 
         reference = ~Bernoulli, newnetwork = structure(list(mel = list(list(inl = 26L, 
             outl = 4L, atl = list(na = FALSE)), list(inl = 45L, outl = 7L, atl = list(
             na = FALSE)), list(inl = 22L, outl = 14L, atl = list(na = FALSE)), list(inl = 27L, 
             outl = 14L, atl = list(na = FALSE)), list(inl = 32L, outl = 14L, atl = list(
             na = FALSE)), list(inl = 55L, outl = 16L, atl = list(na = FALSE)), list(inl = 46L, 
             outl = 17L, atl = list(na = FALSE)), list(inl = 50L, outl = 20L, atl = list(
             na = FALSE)), list(inl = 68L, outl = 20L, atl = list(na = FALSE)), list(inl = 32L, 
             outl = 21L, atl = list(na = FALSE)), list(inl = 27L, outl = 22L, atl = list(
             na = FALSE)), list(inl = 42L, outl = 25L, atl = list(na = FALSE)), list(inl = 98L, 
             outl = 25L, atl = list(na = FALSE)), list(inl = 49L, outl = 27L, atl = list(
             na = FALSE)), list(inl = 73L, outl = 27L, atl = list(na = FALSE)), list(inl = 70L, 
             outl = 28L, atl = list(na = FALSE)), list(inl = 33L, outl = 29L, atl = list(
             na = FALSE)), list(inl = 89L, outl = 29L, atl = list(na = FALSE)), list(inl = 71L, 
             outl = 31L, atl = list(na = FALSE)), list(inl = 94L, outl = 31L, atl = list(
             na = FALSE)), list(inl = 98L, outl = 32L, atl = list(na = FALSE)), list(inl = 37L, 
             outl = 34L, atl = list(na = FALSE)), list(inl = 54L, outl = 37L, atl = list(
             na = FALSE)), list(inl = 97L, outl = 37L, atl = list(na = FALSE)), list(inl = 40L, 
             outl = 38L, atl = list(na = FALSE)), list(inl = 60L, outl = 38L, atl = list(
             na = FALSE)), list(inl = 95L, outl = 39L, atl = list(na = FALSE)), list(inl = 66L, 
             outl = 41L, atl = list(na = FALSE)), list(inl = 92L, outl = 42L, atl = list(
             na = FALSE)), list(inl = 68L, outl = 44L, atl = list(na = FALSE)), list(inl = 84L, 
             outl = 44L, atl = list(na = FALSE)), list(inl = 88L, outl = 49L, atl = list(
             na = FALSE)), list(inl = 56L, outl = 51L, atl = list(na = FALSE)), list(inl = 87L, 
             outl = 53L, atl = list(na = FALSE)), list(inl = 63L, outl = 54L, atl = list(
             na = FALSE)), list(inl = 66L, outl = 54L, atl = list(na = FALSE)), list(inl = 87L, 
             outl = 58L, atl = list(na = FALSE)), list(inl = 66L, outl = 61L, atl = list(
             na = FALSE)), list(inl = 94L, outl = 61L, atl = list(na = FALSE)), list(inl = 99L, 
             outl = 61L, atl = list(na = FALSE)), list(inl = 99L, outl = 62L, atl = list(
             na = FALSE)), list(inl = 89L, outl = 63L, atl = list(na = FALSE)), list(inl = 72L, 
             outl = 71L, atl = list(na = FALSE)), list(inl = 95L, outl = 74L, atl = list(
             na = FALSE)), list(inl = 78L, outl = 75L, atl = list(na = FALSE)), list(inl = 77L, 
             outl = 76L, atl = list(na = FALSE)), list(inl = 97L, outl = 76L, atl = list(
             na = FALSE)), list(inl = 91L, outl = 78L, atl = list(na = FALSE)), list(inl = 99L, 
             outl = 83L, atl = list(na = FALSE)), list(inl = 100L, outl = 83L, atl = list(
             na = FALSE))), gal = list(n = 100, mnext = 51L, directed = FALSE, hyper = FALSE, 
             loops = FALSE, multiple = FALSE, bipartite = FALSE), val = list(list(na = FALSE, 
             vertex.names = 1L), list(na = FALSE, vertex.names = 2L), list(na = FALSE, 
             vertex.names = 3L), list(na = FALSE, vertex.names = 4L), list(na = FALSE, 
             vertex.names = 5L), list(na = FALSE, vertex.names = 6L), list(na = FALSE, 
             vertex.names = 7L), list(na = FALSE, vertex.names = 8L), list(na = FALSE, 
             vertex.names = 9L), list(na = FALSE, vertex.names = 10L), list(na = FALSE, 
             vertex.names = 11L), list(na = FALSE, vertex.names = 12L), list(na = FALSE, 
             vertex.names = 13L), list(na = FALSE, vertex.names = 14L), list(na = FALSE, 
             vertex.names = 15L), list(na = FALSE, vertex.names = 16L), list(na = FALSE, 
             vertex.names = 17L), list(na = FALSE, vertex.names = 18L), list(na = FALSE, 
             vertex.names = 19L), list(na = FALSE, vertex.names = 20L), list(na = FALSE, 
             vertex.names = 21L), list(na = FALSE, vertex.names = 22L), list(na = FALSE, 
             vertex.names = 23L), list(na = FALSE, vertex.names = 24L), list(na = FALSE, 
             vertex.names = 25L), list(na = FALSE, vertex.names = 26L), list(na = FALSE, 
             vertex.names = 27L), list(na = FALSE, vertex.names = 28L), list(na = FALSE, 
             vertex.names = 29L), list(na = FALSE, vertex.names = 30L), list(na = FALSE, 
             vertex.names = 31L), list(na = FALSE, vertex.names = 32L), list(na = FALSE, 
             vertex.names = 33L), list(na = FALSE, vertex.names = 34L), list(na = FALSE, 
             vertex.names = 35L), list(na = FALSE, vertex.names = 36L), list(na = FALSE, 
             vertex.names = 37L), list(na = FALSE, vertex.names = 38L), list(na = FALSE, 
             vertex.names = 39L), list(na = FALSE, vertex.names = 40L), list(na = FALSE, 
             vertex.names = 41L), list(na = FALSE, vertex.names = 42L), list(na = FALSE, 
             vertex.names = 43L), list(na = FALSE, vertex.names = 44L), list(na = FALSE, 
             vertex.names = 45L), list(na = FALSE, vertex.names = 46L), list(na = FALSE, 
             vertex.names = 47L), list(na = FALSE, vertex.names = 48L), list(na = FALSE, 
             vertex.names = 49L), list(na = FALSE, vertex.names = 50L), list(na = FALSE, 
             vertex.names = 51L), list(na = FALSE, vertex.names = 52L), list(na = FALSE, 
             vertex.names = 53L), list(na = FALSE, vertex.names = 54L), list(na = FALSE, 
             vertex.names = 55L), list(na = FALSE, vertex.names = 56L), list(na = FALSE, 
             vertex.names = 57L), list(na = FALSE, vertex.names = 58L), list(na = FALSE, 
             vertex.names = 59L), list(na = FALSE, vertex.names = 60L), list(na = FALSE, 
             vertex.names = 61L), list(na = FALSE, vertex.names = 62L), list(na = FALSE, 
             vertex.names = 63L), list(na = FALSE, vertex.names = 64L), list(na = FALSE, 
             vertex.names = 65L), list(na = FALSE, vertex.names = 66L), list(na = FALSE, 
             vertex.names = 67L), list(na = FALSE, vertex.names = 68L), list(na = FALSE, 
             vertex.names = 69L), list(na = FALSE, vertex.names = 70L), list(na = FALSE, 
             vertex.names = 71L), list(na = FALSE, vertex.names = 72L), list(na = FALSE, 
             vertex.names = 73L), list(na = FALSE, vertex.names = 74L), list(na = FALSE, 
             vertex.names = 75L), list(na = FALSE, vertex.names = 76L), list(na = FALSE, 
             vertex.names = 77L), list(na = FALSE, vertex.names = 78L), list(na = FALSE, 
             vertex.names = 79L), list(na = FALSE, vertex.names = 80L), list(na = FALSE, 
             vertex.names = 81L), list(na = FALSE, vertex.names = 82L), list(na = FALSE, 
             vertex.names = 83L), list(na = FALSE, vertex.names = 84L), list(na = FALSE, 
             vertex.names = 85L), list(na = FALSE, vertex.names = 86L), list(na = FALSE, 
             vertex.names = 87L), list(na = FALSE, vertex.names = 88L), list(na = FALSE, 
             vertex.names = 89L), list(na = FALSE, vertex.names = 90L), list(na = FALSE, 
             vertex.names = 91L), list(na = FALSE, vertex.names = 92L), list(na = FALSE, 
             vertex.names = 93L), list(na = FALSE, vertex.names = 94L), list(na = FALSE, 
             vertex.names = 95L), list(na = FALSE, vertex.names = 96L), list(na = FALSE, 
             vertex.names = 97L), list(na = FALSE, vertex.names = 98L), list(na = FALSE, 
             vertex.names = 99L), list(na = FALSE, vertex.names = 100L)), iel = list(integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 3L, 
             integer(0), integer(0), integer(0), 1L, c(4L, 11L), integer(0), integer(0), 
             integer(0), integer(0), c(5L, 10L), 17L, integer(0), integer(0), integer(0), 
             22L, integer(0), integer(0), 25L, integer(0), 12L, integer(0), integer(0), 
             2L, 7L, integer(0), integer(0), 14L, 8L, integer(0), integer(0), integer(0), 
             23L, 6L, 33L, integer(0), integer(0), integer(0), 26L, integer(0), integer(0), 
             35L, integer(0), integer(0), c(28L, 36L, 38L), integer(0), c(9L, 30L), integer(0), 
             16L, 19L, 43L, 15L, integer(0), integer(0), integer(0), 46L, 45L, integer(0), 
             integer(0), integer(0), integer(0), integer(0), 31L, integer(0), integer(0), 
             c(34L, 37L), 32L, c(18L, 42L), integer(0), 48L, 29L, integer(0), c(20L, 39L
             ), c(27L, 44L), integer(0), c(24L, 47L), c(13L, 21L), c(40L, 41L, 49L), 50L), 
             oel = list(integer(0), integer(0), integer(0), 1L, integer(0), integer(0), 
                 2L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 5:3, integer(0), 6L, 7L, integer(0), integer(0), 9:8, 10L, 11L, integer(0), 
                 integer(0), 13:12, integer(0), 15:14, 16L, 18:17, integer(0), 20:19, 
                 21L, integer(0), 22L, integer(0), integer(0), 24:23, 26:25, 27L, integer(0), 
                 28L, 29L, integer(0), 31:30, integer(0), integer(0), integer(0), integer(0), 
                 32L, integer(0), 33L, integer(0), 34L, 36:35, integer(0), integer(0), 
                 integer(0), 37L, integer(0), integer(0), 40:38, 41L, 42L, integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 43L, integer(0), integer(0), 44L, 45L, 47:46, integer(0), 48L, integer(0), 
                 integer(0), integer(0), integer(0), 50:49, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0))), class = "network"), formula = TARGET_STATS ~ 
             edges, constraints = ~., target.stats = c(edges = 50), etamap = list(canonical = 1L, 
             offsetmap = FALSE, offset = FALSE, offsettheta = FALSE, curved = list(), 
             etalength = 1), target.esteq = structure(-50, .Dim = c(1L, 1L), .Dimnames = list(
             NULL, "edges")), estimate = "MLE", control = structure(list(drop = TRUE, 
             init = NA_real_, init.method = "MPLE", main.method = "MCMLE", force.main = FALSE, 
             main.hessian = TRUE, checkpoint = NULL, resume = NULL, MPLE.max.dyad.types = 1e+06, 
             MPLE.samplesize = 50000, MPLE.type = "glm", MCMC.prop.weights = "default", 
             MCMC.prop.args = list(), MCMC.interval = 1024, MCMC.burnin = 16384, MCMC.samplesize = 1024, 
             MCMC.effectiveSize = NULL, MCMC.effectiveSize.damp = 10, MCMC.effectiveSize.maxruns = 1000, 
             MCMC.effectiveSize.base = 0.5, MCMC.effectiveSize.points = 5, MCMC.effectiveSize.order = 1, 
             MCMC.return.stats = TRUE, MCMC.runtime.traceplot = FALSE, MCMC.init.maxedges = 20000, 
             MCMC.max.maxedges = Inf, MCMC.addto.se = TRUE, MCMC.compress = FALSE, MCMC.packagenames = NULL, 
             SAN.maxit = 4, SAN.nsteps.times = 8, SAN.control = structure(list(SAN.maxit = 4, 
                 SAN.tau = 1, SAN.invcov = NULL, SAN.invcov.diag = FALSE, SAN.nsteps.alloc = function (nsim) 
                 2^seq_len(nsim), SAN.nsteps = 131072, SAN.samplesize = 1024, SAN.init.maxedges = 20000, 
                 SAN.max.maxedges = Inf, SAN.prop.weights = "default", SAN.prop.args = list(), 
                 SAN.packagenames = NULL, term.options = NULL, seed = NULL, parallel = 0, 
                 parallel.type = NULL, parallel.version.check = TRUE), class = c("control.san", 
             "control.list", "list")), MCMLE.termination = "Hummel", MCMLE.maxit = 20, 
             MCMLE.conv.min.pval = 0.5, MCMLE.NR.maxit = 100, MCMLE.NR.reltol = 1.49011611938477e-08, 
             obs.MCMC.samplesize = 1024, obs.MCMC.interval = 1024, obs.MCMC.burnin = 16384, 
             obs.MCMC.burnin.min = 1638.4, obs.MCMC.prop.weights = "default", obs.MCMC.prop.args = list(), 
             obs.MCMC.impute.min_informative = function (nw) 
             network.size(nw)/4, obs.MCMC.impute.default_density = function (nw) 
             2/network.size(nw), MCMLE.check.degeneracy = FALSE, MCMLE.MCMC.precision = 0.005, 
             MCMLE.MCMC.max.ESS.frac = 0.1, MCMLE.metric = "lognormal", MCMLE.method = "BFGS", 
             MCMLE.trustregion = 20, MCMLE.dampening = FALSE, MCMLE.dampening.min.ess = 20, 
             MCMLE.dampening.level = 0.1, MCMLE.steplength.margin = 0.05, MCMLE.steplength = 1, 
             MCMLE.adaptive.trustregion = 3, MCMLE.sequential = TRUE, MCMLE.density.guard.min = 10000, 
             MCMLE.density.guard = 20.0855369231877, MCMLE.effectiveSize = NULL, MCMLE.last.boost = 4, 
             MCMLE.Hummel.esteq = TRUE, MCMLE.Hummel.miss.sample = 100, MCMLE.Hummel.maxit = 25, 
             MCMLE.steplength.min = 1e-04, MCMLE.effectiveSize.interval_drop = 2, MCMLE.save_intermediates = NULL, 
             SA.phase1_n = NULL, SA.initial_gain = NULL, SA.nsubphases = 4, SA.niterations = NULL, 
             SA.phase3_n = NULL, SA.trustregion = 0.5, RM.phase1n_base = 7, RM.phase2n_base = 100, 
             RM.phase2sub = 7, RM.init_gain = 0.5, RM.phase3n = 500, Step.MCMC.samplesize = 100, 
             Step.maxit = 50, Step.gridsize = 100, CD.nsteps = 8, CD.multiplicity = 1, 
             CD.nsteps.obs = 128, CD.multiplicity.obs = 1, CD.maxit = 60, CD.conv.min.pval = 0.5, 
             CD.NR.maxit = 100, CD.NR.reltol = 1.49011611938477e-08, CD.metric = "naive", 
             CD.method = "BFGS", CD.trustregion = 20, CD.dampening = FALSE, CD.dampening.min.ess = 20, 
             CD.dampening.level = 0.1, CD.steplength.margin = 0.5, CD.steplength = 1, 
             CD.adaptive.trustregion = 3, CD.adaptive.epsilon = 0.01, CD.Hummel.esteq = TRUE, 
             CD.Hummel.miss.sample = 100, CD.Hummel.maxit = 25, CD.steplength.min = 1e-04, 
             loglik.control = structure(list(nsteps = 20, MCMC.burnin = NULL, MCMC.interval = NULL, 
                 MCMC.samplesize = NULL, obs.MCMC.samplesize = NULL, obs.MCMC.interval = NULL, 
                 obs.MCMC.burnin = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 warn.dyads = NULL, MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, 
                 term.options = NULL, seed = NULL, parallel = NULL, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.logLik.ergm", "control.list", 
             "list")), term.options = NULL, seed = NULL, parallel = 0, parallel.type = NULL, 
             parallel.version.check = TRUE), class = c("control.ergm", "control.list", 
         "list"))), class = "ergm"), formation = ~edges, target.stats = 50, target.stats.names = "edges", 
         coef.form = c(edges = -7.52940645774863), coef.form.crude = c(edges = -4.58496747858219), 
         coef.diss = structure(list(dissolution = ~offset(edges), duration = 20, coef.crude = 2.94443897916644, 
             coef.adj = 2.94443897916644, d.rate = 0, model.type = "homog"), class = "disscoef"), 
         constraints = ~., edapprox = TRUE), class = "netest"), structure(list(inf.prob = 0.3, 
         rec.rate = 0.01, act.rate = 1, vital = FALSE), class = c("param.net", "list")), 
         structure(list(status.vector = c("s", "s", "i", "s", "s", "s", "s", "s", "s", 
         "i", "s", "s", "s", "s", "s", "s", "i", "s", "s", "s", "i", "s", "i", "s", "s", 
         "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", 
         "i", "s", "s", "i", "s", "s", "s", "s", "s", "i", "s", "s", "s", "s", "s", "s", 
         "s", "s", "s", "s", "s", "s", "s", "s", "s", "i", "s", "s", "s", "s", "s", "s", 
         "s", "s", "s", "s", "s", "i", "s", "s", "i", "s", "s", "s", "s", "s", "s", "s", 
         "s", "i", "s", "i", "s", "i", "i", "s", "s", "s", "i"), infTime.vector = c(NA, 
         NA, -475, NA, NA, NA, NA, NA, NA, -38, NA, NA, NA, NA, NA, NA, -190, NA, NA, 
         NA, -2, NA, -35, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
         NA, NA, NA, -45, NA, NA, -2, NA, NA, NA, NA, NA, -100, NA, NA, NA, NA, NA, NA, 
         NA, NA, NA, NA, NA, NA, NA, NA, NA, -7, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
         NA, -43, NA, NA, -17, NA, NA, NA, NA, NA, NA, NA, NA, -9, NA, -432, NA, -164, 
         -82, NA, NA, NA, -72)), class = c("init.net", "list")), structure(list(type = "SIS", 
             nsteps = 100, start = 1, nsims = 5, ncores = 1, rec.rand = TRUE, a.rand = TRUE, 
             d.rand = TRUE, tea.status = TRUE, use.pids = TRUE, initialize.FUN = function (x, 
                 param, init, control, s) 
             {
                 if (control$start == 1) {
                     dat <- list()
                     dat$param <- param
                     dat$init <- init
                     dat$control <- control
                     dat$attr <- list()
                     dat$stats <- list()
                     dat$temp <- list()
                     nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
                     modes <- ifelse(nw %n% "bipartite", 2, 1)
                     if (control$depend == TRUE) {
                       if (class(x$fit) == "stergm") {
                         nw <- network.collapse(nw, at = 1)
                       }
                       nw <- sim_nets(x, nw, nsteps = 1, control)
                     }
                     if (control$depend == FALSE) {
                       nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
                     }
                     nw <- activate.vertices(nw, onset = 1, terminus = Inf)
                     dat$nw <- nw
                     dat$nwparam <- list(x[-which(names(x) == "fit")])
                     dat$param$modes <- modes
                     if (control$use.pids == TRUE) {
                       dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
                     }
                     form <- get_nwparam(dat)$formation
                     fterms <- get_formula_term_attr(form, nw)
                     dat <- copy_toall_attr(dat, at = 1, fterms)
                     dat$temp$fterms <- fterms
                     dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
                     dat <- init_status.net(dat)
                     dat <- get_prev.net(dat, at = 1)
                 }
                 else {
                     dat <- list()
                     dat$nw <- x$network[[s]]
                     dat$param <- x$param
                     dat$control <- control
                     dat$nwparam <- x$nwparam
                     dat$epi <- sapply(x$epi, function(var) var[s])
                     names(dat$epi) <- names(x$epi)
                     dat$attr <- x$attr[[s]]
                     dat$stats <- sapply(x$stats, function(var) var[[s]])
                     dat$temp <- list()
                 }
                 return(dat)
             }, departures.FUN = function (dat, at) 
             {
                 if (dat$param$vital == FALSE) {
                     return(dat)
                 }
                 modes <- dat$param$modes
                 mode <- idmode(dat$nw)
                 type <- dat$control$type
                 d.rand <- dat$control$d.rand
                 nDepartures.sus <- nDeparturesM2.sus <- 0
                 idsElig.sus <- which(dat$attr$active == 1 & dat$attr$status == "s")
                 nElig.sus <- length(idsElig.sus)
                 if (nElig.sus > 0) {
                     mElig.sus <- mode[idsElig.sus]
                     rates.sus <- c(dat$param$ds.rate, dat$param$ds.rate.m2)
                     ratesElig.sus <- rates.sus[mElig.sus]
                     if (d.rand == TRUE) {
                       vecDepartures.sus <- which(rbinom(nElig.sus, 1, ratesElig.sus) == 
                         1)
                       if (length(vecDepartures.sus) > 0) {
                         idsDpt.sus <- idsElig.sus[vecDepartures.sus]
                         nDepartures.sus <- sum(mode[idsDpt.sus] == 1)
                         nDeparturesM2.sus <- sum(mode[idsDpt.sus] == 2)
                         dat$attr$active[idsDpt.sus] <- 0
                         dat$attr$exitTime[idsDpt.sus] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.sus, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.sus <- idsDptM2.sus <- NULL
                       nDepartures.sus <- min(round(sum(ratesElig.sus[mElig.sus == 1])), 
                         sum(mElig.sus == 1))
                       idsDpt.sus <- ssample(idsElig.sus[mElig.sus == 1], nDepartures.sus)
                       if (modes == 2) {
                         nDeparturesM2.sus <- min(round(sum(ratesElig.sus[mElig.sus == 
                           2])), sum(mElig.sus == 2))
                         idsDptM2.sus <- ssample(idsElig.sus[mElig.sus == 2], nDeparturesM2.sus)
                       }
                       totDpt.sus <- nDepartures.sus + nDeparturesM2.sus
                       if (totDpt.sus > 0) {
                         idsDptAll.sus <- c(idsDpt.sus, idsDptM2.sus)
                         dat$attr$active[idsDptAll.sus] <- 0
                         dat$attr$exitTime[idsDptAll.sus] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.sus, deactivate.edges = TRUE)
                       }
                     }
                 }
                 nDepartures.inf <- nDeparturesM2.inf <- 0
                 idsElig.inf <- which(dat$attr$active == 1 & dat$attr$status == "i")
                 nElig.inf <- length(idsElig.inf)
                 if (nElig.inf > 0) {
                     mElig.inf <- mode[idsElig.inf]
                     rates.inf <- c(dat$param$di.rate, dat$param$di.rate.m2)
                     ratesElig.inf <- rates.inf[mElig.inf]
                     if (d.rand == TRUE) {
                       vecDepartures.inf <- which(rbinom(nElig.inf, 1, ratesElig.inf) == 
                         1)
                       if (length(vecDepartures.inf) > 0) {
                         idsDpt.inf <- idsElig.inf[vecDepartures.inf]
                         nDepartures.inf <- sum(mode[idsDpt.inf] == 1)
                         nDeparturesM2.inf <- sum(mode[idsDpt.inf] == 2)
                         dat$attr$active[idsDpt.inf] <- 0
                         dat$attr$exitTime[idsDpt.inf] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.inf, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.inf <- idsDptM2.inf <- NULL
                       nDepartures.inf <- min(round(sum(ratesElig.inf[mElig.inf == 1])), 
                         sum(mElig.inf == 1))
                       idsDpt.inf <- ssample(idsElig.inf[mElig.inf == 1], nDepartures.inf)
                       if (modes == 2) {
                         nDeparturesM2.inf <- min(round(sum(ratesElig.inf[mElig.inf == 
                           2])), sum(mElig.inf == 2))
                         idsDptM2.inf <- ssample(idsElig.inf[mElig.inf == 2], nDeparturesM2.inf)
                       }
                       totDpt.inf <- nDepartures.inf + nDeparturesM2.inf
                       if (totDpt.inf > 0) {
                         idsDptAll.inf <- c(idsDpt.inf, idsDptM2.inf)
                         dat$attr$active[idsDptAll.inf] <- 0
                         dat$attr$exitTime[idsDptAll.inf] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.inf, deactivate.edges = TRUE)
                       }
                     }
                 }
                 if (type == "SIR") {
                     nDepartures.rec <- nDeparturesM2.rec <- 0
                     idsElig.rec <- which(dat$attr$active == 1 & dat$attr$status == "r")
                     nElig.rec <- length(idsElig.rec)
                     if (nElig.rec > 0) {
                       mElig.rec <- mode[idsElig.rec]
                       rates.rec <- c(dat$param$dr.rate, dat$param$dr.rate.m2)
                       ratesElig.rec <- rates.rec[mElig.rec]
                       if (d.rand == TRUE) {
                         vecDepartures.rec <- which(rbinom(nElig.rec, 1, ratesElig.rec) == 
                           1)
                         if (length(vecDepartures.rec) > 0) {
                           idsDpt.rec <- idsElig.rec[vecDepartures.rec]
                           nDepartures.rec <- sum(mode[idsDpt.rec] == 1)
                           nDeparturesM2.rec <- sum(mode[idsDpt.rec] == 2)
                           dat$attr$active[idsDpt.rec] <- 0
                           dat$attr$exitTime[idsDpt.rec] <- at
                           dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                             v = idsDpt.rec, deactivate.edges = TRUE)
                         }
                       }
                       if (d.rand == FALSE) {
                         idsDpt.rec <- idsDptM2.rec <- NULL
                         nDepartures.rec <- min(round(sum(ratesElig.rec[mElig.rec == 1])), 
                           sum(mElig.rec == 1))
                         idsDpt.rec <- ssample(idsElig.rec[mElig.rec == 1], nDepartures.rec)
                         if (modes == 2) {
                           nDeparturesM2.rec <- min(round(sum(ratesElig.rec[mElig.rec == 
                             2])), sum(mElig.rec == 2))
                           idsDptM2.rec <- ssample(idsElig.rec[mElig.rec == 2], nDeparturesM2.rec)
                         }
                         totDpt.rec <- nDepartures.rec + nDeparturesM2.rec
                         if (totDpt.rec > 0) {
                           idsDptAll.rec <- c(idsDpt.rec, idsDptM2.rec)
                           dat$attr$active[idsDptAll.rec] <- 0
                           dat$attr$exitTime[idsDptAll.rec] <- at
                           dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                             v = idsDptAll.rec, deactivate.edges = TRUE)
                         }
                       }
                     }
                 }
                 if (at == 2) {
                     dat$epi$ds.flow <- c(0, nDepartures.sus)
                     dat$epi$di.flow <- c(0, nDepartures.inf)
                     if (type == "SIR") {
                       dat$epi$dr.flow <- c(0, nDepartures.rec)
                     }
                     if (modes == 2) {
                       dat$epi$ds.flow.m2 <- c(0, nDeparturesM2.sus)
                       dat$epi$di.flow.m2 <- c(0, nDeparturesM2.inf)
                       if (type == "SIR") {
                         dat$epi$dr.flow.m2 <- c(0, nDeparturesM2.rec)
                       }
                     }
                 }
                 else {
                     dat$epi$ds.flow[at] <- nDepartures.sus
                     dat$epi$di.flow[at] <- nDepartures.inf
                     if (type == "SIR") {
                       dat$epi$dr.flow[at] <- nDepartures.rec
                     }
                     if (modes == 2) {
                       dat$epi$ds.flow.m2[at] <- nDeparturesM2.sus
                       dat$epi$di.flow.m2[at] <- nDeparturesM2.inf
                       if (type == "SIR") {
                         dat$epi$dr.flow.m2[at] <- nDeparturesM2.rec
                       }
                     }
                 }
                 return(dat)
             }, arrivals.FUN = function (dat, at) 
             {
                 if (dat$param$vital == FALSE) {
                     return(dat)
                 }
                 a.rate <- dat$param$a.rate
                 a.rate.m2 <- dat$param$a.rate.m2
                 modes <- dat$param$modes
                 tea.status <- dat$control$tea.status
                 nOld <- dat$epi$num[at - 1]
                 nCurr <- network.size(dat$nw)
                 a.rand <- dat$control$a.rand
                 delete.nodes <- dat$control$delete.nodes
                 nArrivals <- nArrivalsM2 <- 0
                 newNodes <- newNodesM2 <- NULL
                 if (modes == 1 && nOld > 0) {
                     if (a.rand == TRUE) {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                     }
                     if (a.rand == FALSE) {
                       nArrivals <- round(nOld * a.rate)
                     }
                     if (nArrivals > 0) {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals)
                       newNodes <- (nCurr + 1):(nCurr + nArrivals)
                       dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                 }
                 if (modes == 2 && nOld > 0) {
                     nOldM2 <- dat$epi$num.m2[at - 1]
                     if (a.rand == TRUE) {
                       if (is.na(a.rate.m2)) {
                         nArrivals <- sum(rbinom(nOld, 1, a.rate))
                         nArrivalsM2 <- sum(rbinom(nOld, 1, a.rate))
                       }
                       else {
                         nArrivals <- sum(rbinom(nOld, 1, a.rate))
                         nArrivalsM2 <- sum(rbinom(nOldM2, 1, a.rate.m2))
                       }
                     }
                     if (a.rand == FALSE) {
                       if (is.na(a.rate.m2)) {
                         nArrivals <- round(nOld * a.rate)
                         nArrivalsM2 <- round(nOld * a.rate)
                       }
                       else {
                         nArrivals <- round(nOld * a.rate)
                         nArrivalsM2 <- round(nOldM2 * a.rate.m2)
                       }
                     }
                     nCurrM1 <- length(modeids(dat$nw, 1))
                     nCurrM2 <- length(modeids(dat$nw, 2))
                     prefixes <- unique(substr(dat$nw %v% "vertex.names", 1, 1))
                     if (nArrivals > 0) {
                       newNodeIDs <- (nCurrM1 + 1):(nCurrM1 + nArrivals)
                       if (delete.nodes == FALSE) {
                         newPids <- paste0(prefixes[1], newNodeIDs)
                         dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE, 
                           vertex.pid = newPids)
                       }
                       else {
                         dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE)
                       }
                       newNodes <- newNodeIDs
                     }
                     if (nArrivalsM2 > 0) {
                       newNodeIDs <- (nCurrM2 + 1):(nCurrM2 + nArrivalsM2)
                       if (delete.nodes == FALSE) {
                         newPids <- paste0(prefixes[2], newNodeIDs)
                         dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE, 
                           vertex.pid = newPids)
                       }
                       else {
                         dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE)
                       }
                       newSize <- network.size(dat$nw)
                       newNodesM2 <- (newSize - nArrivalsM2 + 1):newSize
                     }
                     newNodes <- c(newNodes, newNodesM2)
                     if (!is.null(newNodes)) {
                       dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                 }
                 if (length(newNodes) > 0) {
                     fterms <- dat$temp$fterms
                     curr.tab <- get_attr_prop(dat$nw, fterms)
                     if (length(curr.tab) > 0) {
                       dat$nw <- update_nwattr(dat$nw, newNodes, dat$control$attr.rules, 
                         curr.tab, dat$temp$t1.tab)
                     }
                     dat <- copy_toall_attr(dat, at, fterms)
                     if (tea.status == TRUE) {
                       if ("status" %in% fterms) {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = dat$attr$status[newNodes], onset = at, terminus = Inf, 
                           v = newNodes)
                       }
                       else {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = "s", onset = at, terminus = Inf, v = newNodes)
                       }
                     }
                     if (modes == 1) {
                       if (!("status" %in% fterms)) {
                         dat$attr$status <- c(dat$attr$status, rep("s", length(newNodes)))
                       }
                       dat$attr$active <- c(dat$attr$active, rep(1, length(newNodes)))
                       dat$attr$infTime <- c(dat$attr$infTime, rep(NA, length(newNodes)))
                       dat$attr$entrTime <- c(dat$attr$entrTime, rep(at, length(newNodes)))
                       dat$attr$exitTime <- c(dat$attr$exitTime, rep(NA, length(newNodes)))
                     }
                     if (modes == 2) {
                       if (!("status" %in% fterms)) {
                         dat <- split_bip(dat, "status", "s", nCurrM1, nCurrM2, nArrivals, 
                           nArrivalsM2)
                       }
                       dat <- split_bip(dat, "active", 1, nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                       dat <- split_bip(dat, "infTime", NA, nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                       dat <- split_bip(dat, "entrTime", at, nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                       dat <- split_bip(dat, "exitTime", NA, nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                     }
                     newNodesInf <- intersect(newNodes, which(dat$attr$status == "i"))
                     dat$attr$infTime[newNodesInf] <- at
                     if (length(unique(sapply(dat$attr, length))) != 1) {
                       stop("Attribute list of unequal length. Check arrivals.net module.")
                     }
                 }
                 if (at == 2) {
                     dat$epi$a.flow <- c(0, nArrivals)
                     if (modes == 2) {
                       dat$epi$a.flow.m2 <- c(0, nArrivalsM2)
                     }
                 }
                 else {
                     dat$epi$a.flow[at] <- nArrivals
                     if (modes == 2) {
                       dat$epi$a.flow.m2[at] <- nArrivalsM2
                     }
                 }
                 return(dat)
             }, recovery.FUN = function (dat, at) 
             {
                 if (!(dat$control$type %in% c("SIR", "SIS"))) {
                     return(dat)
                 }
                 active <- dat$attr$active
                 status <- dat$attr$status
                 infTime <- dat$attr$infTime
                 tea.status <- dat$control$tea.status
                 modes <- dat$param$modes
                 mode <- idmode(dat$nw)
                 type <- dat$control$type
                 recovState <- ifelse(type == "SIR", "r", "s")
                 rec.rand <- dat$control$rec.rand
                 rec.rate <- dat$param$rec.rate
                 rec.rate.m2 <- dat$param$rec.rate.m2
                 nRecov <- nRecovM2 <- 0
                 idsElig <- which(active == 1 & status == "i")
                 nElig <- length(idsElig)
                 infDur <- at - infTime[active == 1 & status == "i"]
                 infDur[infDur == 0] <- 1
                 lrec.rate <- length(rec.rate)
                 if (lrec.rate == 1) {
                     mElig <- mode[idsElig]
                     rates <- c(rec.rate, rec.rate.m2)
                     ratesElig <- rates[mElig]
                 }
                 else {
                     mElig <- mode[idsElig]
                     if (is.null(rec.rate.m2)) {
                       rates <- ifelse(infDur <= lrec.rate, rec.rate[infDur], rec.rate[lrec.rate])
                     }
                     else {
                       rates <- rep(NA, length(infDur))
                       rates[mElig == 1] <- ifelse(infDur[mElig == 1] <= lrec.rate, rec.rate[infDur[mElig == 
                         1]], rec.rate[lrec.rate])
                       rates[mElig == 2] <- ifelse(infDur[mElig == 2] <= length(rec.rate.m2), 
                         rec.rate.m2[infDur[mElig == 2]], rec.rate.m2[length(rec.rate.m2)])
                     }
                     ratesElig <- rates
                 }
                 if (nElig > 0) {
                     if (rec.rand == TRUE) {
                       vecRecov <- which(rbinom(nElig, 1, ratesElig) == 1)
                       if (length(vecRecov) > 0) {
                         idsRecov <- idsElig[vecRecov]
                         nRecov <- sum(mode[idsRecov] == 1)
                         nRecovM2 <- sum(mode[idsRecov] == 2)
                         status[idsRecov] <- recovState
                         if (tea.status == TRUE) {
                           dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                             value = recovState, onset = at, terminus = Inf, v = idsRecov)
                         }
                       }
                     }
                     else {
                       idsRecov <- idsRecovM2 <- NULL
                       nRecov <- min(round(sum(ratesElig[mElig == 1])), sum(mElig == 1))
                       if (nRecov > 0) {
                         idsRecov <- ssample(idsElig[mElig == 1], nRecov)
                         status[idsRecov] <- recovState
                       }
                       if (modes == 2) {
                         nRecovM2 <- min(round(sum(ratesElig[mElig == 2])), sum(mElig == 
                           2))
                         if (nRecovM2 > 0) {
                           idsRecovM2 <- ssample(idsElig[mElig == 2], nRecovM2)
                           status[idsRecovM2] <- recovState
                         }
                       }
                       totRecov <- nRecov + nRecovM2
                       if (tea.status == TRUE & totRecov > 0) {
                         allids <- c(idsRecov, idsRecovM2)
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = recovState, onset = at, terminus = Inf, v = allids)
                       }
                     }
                 }
                 dat$attr$status <- status
                 if ("status" %in% dat$temp$fterms) {
                     dat$nw <- set.vertex.attribute(dat$nw, "status", dat$attr$status)
                 }
                 outName <- ifelse(type == "SIR", "ir.flow", "is.flow")
                 outName[2] <- paste0(outName, ".m2")
                 if (at == 2) {
                     dat$epi[[outName[1]]] <- c(0, nRecov)
                 }
                 else {
                     dat$epi[[outName[1]]][at] <- nRecov
                 }
                 if (modes == 2) {
                     if (at == 2) {
                       dat$epi[[outName[2]]] <- c(0, nRecovM2)
                     }
                     else {
                       dat$epi[[outName[2]]][at] <- nRecovM2
                     }
                 }
                 return(dat)
             }, edges_correct.FUN = function (dat, at) 
             {
                 if (dat$control$depend == TRUE) {
                     if (dat$param$modes == 1) {
                       old.num <- dat$epi$num[at - 1]
                       new.num <- sum(dat$attr$active == 1)
                       dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                         log(old.num) - log(new.num)
                     }
                     if (dat$param$modes == 2) {
                       mode <- idmode(dat$nw)
                       old.num.m1 <- dat$epi$num[at - 1]
                       old.num.m2 <- dat$epi$num.m2[at - 1]
                       new.num.m1 <- sum(dat$attr$active == 1 & mode == 1)
                       new.num.m2 <- sum(dat$attr$active == 1 & mode == 2)
                       dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                         log(2 * old.num.m1 * old.num.m2/(old.num.m1 + old.num.m2)) - 
                         log(2 * new.num.m1 * new.num.m2/(new.num.m1 + new.num.m2))
                     }
                 }
                 return(dat)
             }, resim_nets.FUN = function (dat, at) 
             {
                 idsActive <- which(dat$attr$active == 1)
                 anyActive <- ifelse(length(idsActive) > 0, TRUE, FALSE)
                 if (dat$param$modes == 2) {
                     nActiveM1 <- length(intersect(modeids(dat$nw, mode = 1), idsActive))
                     nActiveM2 <- length(intersect(modeids(dat$nw, mode = 2), idsActive))
                     anyActive <- ifelse(nActiveM1 > 0 & nActiveM2 > 0, TRUE, FALSE)
                 }
                 nwparam <- get_nwparam(dat)
                 statOnNw <- ("status" %in% dat$temp$fterms)
                 status <- dat$attr$status
                 if (statOnNw == TRUE && length(unique(status)) == 1) {
                     stop("Stopping simulation because status in formation formula and ", 
                       "no longer any discordant nodes", call. = TRUE)
                 }
                 if (dat$control$save.nwstats == TRUE) {
                     if (at == 2) {
                       nwstats <- attributes(dat$nw)$stats
                       dat$stats$nwstats <- as.data.frame(nwstats)
                     }
                 }
                 if (anyActive > 0 & dat$control$depend == TRUE) {
                     suppressWarnings(dat$nw <- simulate(dat$nw, formation = nwparam$formation, 
                       dissolution = nwparam$coef.diss$dissolution, coef.form = nwparam$coef.form, 
                       coef.diss = nwparam$coef.diss$coef.adj, constraints = nwparam$constraints, 
                       time.start = at, time.slices = 1, time.offset = 0, monitor = dat$control$nwstats.formula, 
                       control = dat$control$set.control.stergm))
                     if (dat$control$save.nwstats == TRUE) {
                       dat$stats$nwstats <- rbind(dat$stats$nwstats, tail(attributes(dat$nw)$stats, 
                         1))
                     }
                     if (dat$control$delete.nodes == TRUE) {
                       dat$nw <- network.extract(dat$nw, at = at)
                       inactive <- which(dat$attr$active == 0)
                       dat$attr <- deleteAttr(dat$attr, inactive)
                     }
                 }
                 return(dat)
             }, infection.FUN = function (dat, at) 
             {
                 active <- dat$attr$active
                 status <- dat$attr$status
                 modes <- dat$param$modes
                 mode <- idmode(dat$nw)
                 inf.prob <- dat$param$inf.prob
                 inf.prob.m2 <- dat$param$inf.prob.m2
                 act.rate <- dat$param$act.rate
                 nw <- dat$nw
                 tea.status <- dat$control$tea.status
                 idsInf <- which(active == 1 & status == "i")
                 nActive <- sum(active == 1)
                 nElig <- length(idsInf)
                 nInf <- nInfM2 <- totInf <- 0
                 if (nElig > 0 && nElig < nActive) {
                     del <- discord_edgelist(dat, at)
                     if (!(is.null(del))) {
                       del$infDur <- at - dat$attr$infTime[del$inf]
                       del$infDur[del$infDur == 0] <- 1
                       linf.prob <- length(inf.prob)
                       if (is.null(inf.prob.m2)) {
                         del$transProb <- ifelse(del$infDur <= linf.prob, inf.prob[del$infDur], 
                           inf.prob[linf.prob])
                       }
                       else {
                         del$transProb <- ifelse(del$sus <= nw %n% "bipartite", ifelse(del$infDur <= 
                           linf.prob, inf.prob[del$infDur], inf.prob[linf.prob]), ifelse(del$infDur <= 
                           linf.prob, inf.prob.m2[del$infDur], inf.prob.m2[linf.prob]))
                       }
                       if (!is.null(dat$param$inter.eff) && at >= dat$param$inter.start) {
                         del$transProb <- del$transProb * (1 - dat$param$inter.eff)
                       }
                       lact.rate <- length(act.rate)
                       del$actRate <- ifelse(del$infDur <= lact.rate, act.rate[del$infDur], 
                         act.rate[lact.rate])
                       del$finalProb <- 1 - (1 - del$transProb)^del$actRate
                       transmit <- rbinom(nrow(del), 1, del$finalProb)
                       del <- del[which(transmit == 1), ]
                       idsNewInf <- unique(del$sus)
                       nInf <- sum(mode[idsNewInf] == 1)
                       nInfM2 <- sum(mode[idsNewInf] == 2)
                       totInf <- nInf + nInfM2
                       if (totInf > 0) {
                         if (tea.status == TRUE) {
                           nw <- activate.vertex.attribute(nw, prefix = "testatus", value = "i", 
                             onset = at, terminus = Inf, v = idsNewInf)
                         }
                         dat$attr$status[idsNewInf] <- "i"
                         dat$attr$infTime[idsNewInf] <- at
                         if ("status" %in% dat$temp$fterms) {
                           nw <- set.vertex.attribute(nw, "status", dat$attr$status)
                         }
                       }
                       if (any(names(nw$gal) %in% "vertex.pid")) {
                         del$sus <- get.vertex.pid(nw, del$sus)
                         del$inf <- get.vertex.pid(nw, del$inf)
                       }
                     }
                 }
                 if (totInf > 0) {
                     del <- del[!duplicated(del$sus), ]
                     if (at == 2) {
                       dat$stats$transmat <- del
                     }
                     else {
                       dat$stats$transmat <- rbind(dat$stats$transmat, del)
                     }
                 }
                 if (at == 2) {
                     dat$epi$si.flow <- c(0, nInf)
                     if (modes == 2) {
                       dat$epi$si.flow.m2 <- c(0, nInfM2)
                     }
                 }
                 else {
                     dat$epi$si.flow[at] <- nInf
                     if (modes == 2) {
                       dat$epi$si.flow.m2[at] <- nInfM2
                     }
                 }
                 dat$nw <- nw
                 return(dat)
             }, get_prev.FUN = function (dat, at) 
             {
                 active <- dat$attr$active
                 modes <- dat$param$modes
                 l <- lapply(1:length(dat$attr), function(x) dat$attr[[x]][active == 1])
                 names(l) <- names(dat$attr)
                 l$active <- l$infTime <- NULL
                 status <- l$status
                 if (modes == 2) {
                     mode <- idmode(dat$nw)[active == 1]
                 }
                 eb <- !is.null(dat$control$epi.by)
                 if (eb == TRUE) {
                     ebn <- dat$control$epi.by
                     ebv <- dat$temp$epi.by.vals
                     ebun <- paste0(".", ebn, ebv)
                     assign(ebn, l[[ebn]])
                 }
                 if (modes == 1) {
                     if (at == 1) {
                       dat$epi <- list()
                       dat$epi$s.num <- sum(status == "s")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & 
                             get(ebn) == ebv[i])
                         }
                       }
                       dat$epi$i.num <- sum(status == "i")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & 
                             get(ebn) == ebv[i])
                         }
                       }
                       if (dat$control$type == "SIR") {
                         dat$epi$r.num <- sum(status == "r")
                         if (eb == TRUE) {
                           for (i in 1:length(ebun)) {
                             dat$epi[[paste0("r.num", ebun[i])]] <- sum(status == "r" & 
                               get(ebn) == ebv[i])
                           }
                         }
                       }
                       dat$epi$num <- length(status)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("num", ebun[i])]] <- sum(get(ebn) == ebv[i])
                         }
                       }
                     }
                     else {
                       dat$epi$s.num[at] <- sum(status == "s")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                             get(ebn) == ebv[i])
                         }
                       }
                       dat$epi$i.num[at] <- sum(status == "i")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                             get(ebn) == ebv[i])
                         }
                       }
                       if (dat$control$type == "SIR") {
                         dat$epi$r.num[at] <- sum(status == "r")
                         if (eb == TRUE) {
                           for (i in 1:length(ebun)) {
                             dat$epi[[paste0("r.num", ebun[i])]][at] <- sum(status == 
                               "r" & get(ebn) == ebv[i])
                           }
                         }
                       }
                       dat$epi$num[at] <- length(status)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("num", ebun[i])]][at] <- sum(get(ebn) == ebv[i])
                         }
                       }
                     }
                 }
                 else {
                     if (at == 1) {
                       dat$epi <- list()
                       dat$epi$s.num <- sum(status == "s" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                       dat$epi$i.num <- sum(status == "i" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                       if (dat$control$type == "SIR") {
                         dat$epi$r.num <- sum(status == "r" & mode == 1)
                         if (eb == TRUE) {
                           for (i in 1:length(ebun)) {
                             dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "r" & 
                               mode == 1 & get(ebn) == ebv[i])
                           }
                         }
                       }
                       dat$epi$num <- sum(mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("num", ebun[i])]] <- sum(mode == 1 & get(ebn) == 
                             ebv[i])
                         }
                       }
                       dat$epi$s.num.m2 <- sum(status == "s" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num.m2", ebun[i])]] <- sum(status == "s" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                       dat$epi$i.num.m2 <- sum(status == "i" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("i.num.m2", ebun[i])]] <- sum(status == "i" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                       if (dat$control$type == "SIR") {
                         dat$epi$r.num.m2 <- sum(status == "r" & mode == 2)
                         if (eb == TRUE) {
                           for (i in 1:length(ebun)) {
                             dat$epi[[paste0("r.num.m2", ebun[i])]] <- sum(status == "r" & 
                               mode == 2 & get(ebn) == ebv[i])
                           }
                         }
                       }
                       dat$epi$num.m2 <- sum(mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("num.m2", ebun[i])]] <- sum(mode == 2 & get(ebn) == 
                             ebv[i])
                         }
                       }
                     }
                     else {
                       dat$epi$s.num[at] <- sum(status == "s" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                       dat$epi$i.num[at] <- sum(status == "i" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                       if (dat$control$type == "SIR") {
                         dat$epi$r.num[at] <- sum(status == "r" & mode == 1)
                         if (eb == TRUE) {
                           for (i in 1:length(ebun)) {
                             dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == 
                               "r" & mode == 1 & get(ebn) == ebv[i])
                           }
                         }
                       }
                       dat$epi$num[at] <- sum(mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("num", ebun[i])]][at] <- sum(mode == 1 & get(ebn) == 
                             ebv[i])
                         }
                       }
                       dat$epi$s.num.m2[at] <- sum(status == "s" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num.m2", ebun[i])]][at] <- sum(status == 
                             "s" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                       dat$epi$i.num.m2[at] <- sum(status == "i" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("i.num.m2", ebun[i])]][at] <- sum(status == 
                             "i" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                       if (dat$control$type == "SIR") {
                         dat$epi$r.num.m2[at] <- sum(status == "r" & mode == 2)
                         if (eb == TRUE) {
                           for (i in 1:length(ebun)) {
                             dat$epi[[paste0("r.num.m2", ebun[i])]][at] <- sum(status == 
                               "r" & mode == 2 & get(ebn) == ebv[i])
                           }
                         }
                       }
                       dat$epi$num.m2[at] <- sum(mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("num.m2", ebun[i])]][at] <- sum(mode == 2 & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                 }
                 return(dat)
             }, verbose.FUN = function (x, type, s = 1, at = 2) 
             {
                 if (type == "startup" && x$ncores == 1) {
                     if (x$verbose == TRUE) {
                       cat("\nStarting Network Simulation...")
                     }
                 }
                 if (type == "progress" && x$control$ncores == 1) {
                     if (x$control$verbose == TRUE) {
                       if (x$control$verbose.int == 0 && at == x$control$nsteps) {
                         cat("\nSim = ", s, "/", x$control$nsims, sep = "")
                       }
                       if (x$control$verbose.int > 0 && (at%%x$control$verbose.int == 
                         0)) {
                         cat("\f")
                         cat("\nEpidemic Simulation")
                         cat("\n----------------------------")
                         cat("\nSimulation: ", s, "/", x$control$nsims, sep = "")
                         cat("\nTimestep: ", at, "/", x$control$nsteps, sep = "")
                         status <- x$attr$status
                         if (class(status) == "character") {
                           status <- ifelse(status == "i", 1, 0)
                         }
                         cat("\nPrevalence:", sum(status, na.rm = TRUE))
                         cat("\nPopulation Size:", sum(x$attr$active == 1))
                         cat("\n----------------------------")
                       }
                     }
                 }
             }, module.order = NULL, save.nwstats = TRUE, nwstats.formula = "formation", 
             delete.nodes = FALSE, save.transmat = TRUE, save.network = TRUE, verbose = TRUE, 
             verbose.int = 0, skip.check = FALSE, bi.mods = c("initialize.FUN", "departures.FUN", 
             "arrivals.FUN", "recovery.FUN", "edges_correct.FUN", "resim_nets.FUN", "infection.FUN", 
             "get_prev.FUN", "verbose.FUN"), user.mods = character(0), attr.rules = list(), 
             set.control.stergm = structure(list(MCMC.burnin.min = 1000, MCMC.burnin.max = 1e+05, 
                 MCMC.burnin.pval = 0.5, MCMC.burnin.add = 1, MCMC.burnin = NULL, MCMC.burnin.mul = NULL, 
                 MCMC.prop.weights.form = "default", MCMC.prop.args.form = NULL, MCMC.prop.weights.diss = "default", 
                 MCMC.prop.args.diss = NULL, MCMC.init.maxedges = 20000, MCMC.packagenames = NULL, 
                 MCMC.init.maxchanges = 1e+06), class = c("control.simulate.network", 
             "control.list", "list")), set.control.ergm = structure(list(MCMC.burnin = 2e+05, 
                 MCMC.interval = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, MCMC.runtime.traceplot = FALSE, 
                 network.output = "network", term.options = NULL, parallel = 0, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.simulate.ergm", "control.list", 
             "list")), depend = FALSE), class = c("control.net", "list")), 1L)
  4: sim_nets(x, nw, nsteps = control$nsteps, control)
  5: suppressWarnings(sim <- simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm))
  6: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  7: simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, coef.form = x$coef.form, 
         coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, time.start = 1, time.offset = 0, 
         constraints = x$constraints, monitor = control$nwstats.formula, nsim = 1, control = control$set.control.stergm)
  8: simulate.network(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm)
  9: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  10: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  11: lapply(X = X, FUN = FUN, ...)
  12: FUN(X[[i]], ...)
  13: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  14: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 7. Error: Updating attributes in open populations (@test-netattr.R#27)  -----
  'Calloc' could not allocate memory (272245122 of 16 bytes)
  1: netsim(est1, param, init, control) at testthat/test-netattr.R:27
  2: do.call(control[["initialize.FUN"]], list(x, param, init, control, s))
  3: (function (x, param, init, control, s) 
     {
         if (control$start == 1) {
             dat <- list()
             dat$param <- param
             dat$init <- init
             dat$control <- control
             dat$attr <- list()
             dat$stats <- list()
             dat$temp <- list()
             nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
             modes <- ifelse(nw %n% "bipartite", 2, 1)
             if (control$depend == TRUE) {
                 if (class(x$fit) == "stergm") {
                     nw <- network.collapse(nw, at = 1)
                 }
                 nw <- sim_nets(x, nw, nsteps = 1, control)
             }
             if (control$depend == FALSE) {
                 nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
             }
             nw <- activate.vertices(nw, onset = 1, terminus = Inf)
             dat$nw <- nw
             dat$nwparam <- list(x[-which(names(x) == "fit")])
             dat$param$modes <- modes
             if (control$use.pids == TRUE) {
                 dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
             }
             form <- get_nwparam(dat)$formation
             fterms <- get_formula_term_attr(form, nw)
             dat <- copy_toall_attr(dat, at = 1, fterms)
             dat$temp$fterms <- fterms
             dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
             dat <- init_status.net(dat)
             dat <- get_prev.net(dat, at = 1)
         }
         else {
             dat <- list()
             dat$nw <- x$network[[s]]
             dat$param <- x$param
             dat$control <- control
             dat$nwparam <- x$nwparam
             dat$epi <- sapply(x$epi, function(var) var[s])
             names(dat$epi) <- names(x$epi)
             dat$attr <- x$attr[[s]]
             dat$stats <- sapply(x$stats, function(var) var[[s]])
             dat$temp <- list()
         }
         return(dat)
     })(structure(list(fit = structure(list(coef = c(edges = -4.72348850110673, nodefactor.risk.1 = 1.35987690967088
     ), iterations = 6L, MCMCtheta = c(edges = -4.72348850110673, nodefactor.risk.1 = 1.35987690967088
     ), gradient = c(NA, NA), hessian = structure(c(-23.1136107010428, -32.6051668262922, 
     -32.6051668262922, -55.2193201356035), .Dim = c(2L, 2L)), covar = structure(c(0.258976973161905, 
     -0.15291726506911, -0.15291726506911, 0.108402148441867), .Dim = c(2L, 2L)), failure = FALSE, 
         est.cov = structure(c(0, 0, 0, 0), .Dim = c(2L, 2L)), glm = structure(list(coefficients = c(edges = -4.72348850110673, 
         nodefactor.risk.1 = 1.35987690967088), residuals = c(`1` = 8.41670346692911, 
         `2` = 113.56023505936, `3` = -1.13483079166627, `4` = -1.00888413212244, `5` = -1.03461003564482, 
         `6` = 29.8933536579455), fitted.values = c(`1` = 0.118811361708203, `2` = 0.00880589934916284, 
         `3` = 0.118811361708203, `4` = 0.00880589934916284, `5` = 0.0334522520103463, 
         `6` = 0.0334522520103463), effects = c(edges = 13.4863610124788, nodefactor.risk.1 = 4.13029103641708, 
         -1.93378422692384, -12.8971091028202, -15.7902003634961, 14.6985997304562), R = structure(c(-4.80766166665697, 
         0, -6.78191792330604, 3.03725359776621), .Dim = c(2L, 2L), .Dimnames = list(c("edges", 
         "nodefactor.risk.1"), c("edges", "nodefactor.risk.1"))), rank = 2L, qr = structure(list(
             qr = structure(c(-4.80766166665697, 0.0274821063117698, 0.655980902487975, 
             0.278912916938489, 0.646736289414078, 0.118274640435175, -6.78191792330604, 
             3.03725359776621, -0.492454350952589, 0.673597256371032, 0.538203084420259, 
             0.0984261705007743), .Dim = c(6L, 2L), .Dimnames = list(c("1", "2", "3", 
             "4", "5", "6"), c("edges", "nodefactor.risk.1"))), rank = 2L, qraux = c(1.24266160708574, 
             1.06637150983935), pivot = 1:2, tol = 1e-11), class = "qr"), family = structure(list(
             family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -2.00373468176497, `2` = -4.72348850110673, 
         `3` = -2.00373468176497, `4` = -4.72348850110673, `5` = -3.36361159143585, `6` = -3.36361159143585
         ), deviance = 190.290404120797, aic = 194.290404120797, null.deviance = 866.433975699932, 
             iter = 6L, weights = c(`1` = 1.36103700472707, `2` = 0.0174569281673671, 
             `3` = 9.94603964992856, `4` = 1.79806360123881, `5` = 9.66767974620496, `6` = 0.323333770776085
             ), prior.weights = c(`1` = 13, `2` = 2, `3` = 95, `4` = 206, `5` = 299, `6` = 10
             ), df.residual = 4L, df.null = 6L, y = c(`1` = 1, `2` = 1, `3` = 0, `4` = 0, 
             `5` = 0, `6` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = c(1L, 1L, 0L, 0L, 0L, 1L), edges = c(1, 1, 1, 1, 1, 1), nodefactor.risk.1 = c(2, 
                 0, 2, 0, 1, 1), `offset(pl$foffset)` = c(0, 0, 0, 0, 0, 0), `(weights)` = c(13, 
                 2, 95, 206, 299, 10)), terms = pl$zy ~ (edges + nodefactor.risk.1) - 
                 1 + offset(pl$foffset), row.names = c(NA, 6L), class = "data.frame"), 
             call = glm(formula = pl$zy ~ . - 1 + offset(pl$foffset), family = family, 
                 data = data.frame(pl$xmat), weights = pl$wend), formula = pl$zy ~ . - 
                 1 + offset(pl$foffset), terms = pl$zy ~ (edges + nodefactor.risk.1) - 
                 1 + offset(pl$foffset), data = structure(list(edges = c(1, 1, 1, 1, 1, 
             1), nodefactor.risk.1 = c(2, 0, 2, 0, 1, 1)), class = "data.frame", row.names = c(NA, 
             -6L)), offset = c(0, 0, 0, 0, 0, 0), control = list(epsilon = 1e-08, maxit = 25, 
                 trace = FALSE), method = "glm.fit", contrasts = NULL, xlevels = structure(list(), .Names = character(0))), class = c("glm", 
         "lm")), glm.null = structure(list(coefficients = c(`(Intercept)` = -3.17805383034789), 
             residuals = c(`1` = 24.9999999999987, `2` = 24.9999999999987, `3` = -1.04166666666667, 
             `4` = -1.04166666666667, `5` = -1.04166666666667, `6` = 24.9999999999987), 
             fitted.values = c(`1` = 0.0400000000000021, `2` = 0.0400000000000021, `3` = 0.0400000000000021, 
             `4` = 0.0400000000000021, `5` = 0.0400000000000021, `6` = 0.0400000000000021
             ), effects = c(`(Intercept)` = 15.5692229687331, 6.05494548365706, -8.00806191418309, 
             -11.7923192924379, -14.206961833365, 13.5392697015125), R = structure(-4.89898025642591, .Dim = c(1L, 
             1L), .Dimnames = list("(Intercept)", "(Intercept)")), rank = 1L, qr = structure(list(
                 qr = structure(c(-4.89898025642591, 0.0565685424949238, 0.389871773792359, 
                 0.574108003776293, 0.691664658631623, 0.126491106406735), .Dim = c(6L, 
                 1L), .Dimnames = list(c("1", "2", "3", "4", "5", "6"), "(Intercept)")), 
                 rank = 1L, qraux = 1.14422205101856, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -3.17805383034789, `2` = -3.17805383034789, 
             `3` = -3.17805383034789, `4` = -3.17805383034789, `5` = -3.17805383034789, 
             `6` = -3.17805383034789), deviance = 209.930184667716, aic = 211.930184667716, 
             null.deviance = 209.930184667716, iter = 6L, weights = c(`1` = 0.499200157099298, 
             `2` = 0.0768000241691228, `3` = 3.64800114803333, `4` = 7.91040248941965, 
             `5` = 11.4816036132839, `6` = 0.384000120845614), prior.weights = c(`1` = 13, 
             `2` = 2, `3` = 95, `4` = 206, `5` = 299, `6` = 10), df.residual = 5L, df.null = 5L, 
             y = c(`1` = 1, `2` = 1, `3` = 0, `4` = 0, `5` = 0, `6` = 1), converged = TRUE, 
             boundary = FALSE, model = structure(list(`pl$zy` = c(1L, 1L, 0L, 0L, 0L, 
             1L), `(weights)` = c(13, 2, 95, 206, 299, 10)), terms = pl$zy ~ 1, row.names = c(NA, 
             6L), class = "data.frame"), call = glm(formula = pl$zy ~ 1, family = family, 
                 weights = pl$wend), formula = pl$zy ~ 1, terms = pl$zy ~ 1, data = <environment>, 
             offset = NULL, control = list(epsilon = 1e-08, maxit = 25, trace = FALSE), 
             method = "glm.fit", contrasts = NULL, xlevels = NULL), class = c("glm", "lm"
         )), theta1 = list(coef = c(edges = -4.72348850110673, nodefactor.risk.1 = 1.35987690967088
         ), theta = c(edges = -4.72348850110673, nodefactor.risk.1 = 1.35987690967088), 
             independent = c(edges = TRUE, nodefactor.risk.1 = TRUE)), MPLE_is_MLE = TRUE, 
         ergm_version = structure(list(c(3L, 10L, 1L)), class = c("package_version", "numeric_version"
         )), offset = c(FALSE, FALSE), drop = c(0, 0), estimable = c(TRUE, TRUE), network = structure(list(
             mel = list(list(inl = 47L, outl = 1L, atl = list(na = FALSE)), list(inl = 38L, 
                 outl = 2L, atl = list(na = FALSE)), list(inl = 31L, outl = 4L, atl = list(
                 na = FALSE)), list(inl = 41L, outl = 4L, atl = list(na = FALSE)), list(
                 inl = 42L, outl = 4L, atl = list(na = FALSE)), list(inl = 27L, outl = 7L, 
                 atl = list(na = FALSE)), list(inl = 40L, outl = 7L, atl = list(na = FALSE)), 
                 list(inl = 34L, outl = 9L, atl = list(na = FALSE)), list(inl = 41L, outl = 9L, 
                     atl = list(na = FALSE)), list(inl = 40L, outl = 14L, atl = list(na = FALSE)), 
                 list(inl = 43L, outl = 14L, atl = list(na = FALSE)), list(inl = 38L, 
                     outl = 17L, atl = list(na = FALSE)), list(inl = 43L, outl = 17L, 
                     atl = list(na = FALSE)), list(inl = 45L, outl = 18L, atl = list(na = FALSE)), 
                 list(inl = 48L, outl = 19L, atl = list(na = FALSE)), list(inl = 34L, 
                     outl = 20L, atl = list(na = FALSE)), list(inl = 27L, outl = 21L, 
                     atl = list(na = FALSE)), list(inl = 29L, outl = 21L, atl = list(na = FALSE)), 
                 list(inl = 34L, outl = 21L, atl = list(na = FALSE)), list(inl = 35L, 
                     outl = 21L, atl = list(na = FALSE)), list(inl = 43L, outl = 21L, 
                     atl = list(na = FALSE)), list(inl = 26L, outl = 23L, atl = list(na = FALSE)), 
                 list(inl = 31L, outl = 23L, atl = list(na = FALSE)), list(inl = 38L, 
                     outl = 23L, atl = list(na = FALSE)), list(inl = 43L, outl = 25L, 
                     atl = list(na = FALSE))), gal = list(n = 50, mnext = 26L, directed = FALSE, 
                 hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = 25), val = list(
                 list(na = FALSE, vertex.names = 1L, risk = 1L), list(na = FALSE, vertex.names = 2L, 
                     risk = 0L), list(na = FALSE, vertex.names = 3L, risk = 0L), list(
                     na = FALSE, vertex.names = 4L, risk = 1L), list(na = FALSE, vertex.names = 5L, 
                     risk = 0L), list(na = FALSE, vertex.names = 6L, risk = 0L), list(
                     na = FALSE, vertex.names = 7L, risk = 1L), list(na = FALSE, vertex.names = 8L, 
                     risk = 0L), list(na = FALSE, vertex.names = 9L, risk = 0L), list(
                     na = FALSE, vertex.names = 10L, risk = 1L), list(na = FALSE, vertex.names = 11L, 
                     risk = 1L), list(na = FALSE, vertex.names = 12L, risk = 0L), list(
                     na = FALSE, vertex.names = 13L, risk = 0L), list(na = FALSE, vertex.names = 14L, 
                     risk = 1L), list(na = FALSE, vertex.names = 15L, risk = 0L), list(
                     na = FALSE, vertex.names = 16L, risk = 0L), list(na = FALSE, vertex.names = 17L, 
                     risk = 1L), list(na = FALSE, vertex.names = 18L, risk = 0L), list(
                     na = FALSE, vertex.names = 19L, risk = 0L), list(na = FALSE, vertex.names = 20L, 
                     risk = 0L), list(na = FALSE, vertex.names = 21L, risk = 1L), list(
                     na = FALSE, vertex.names = 22L, risk = 0L), list(na = FALSE, vertex.names = 23L, 
                     risk = 1L), list(na = FALSE, vertex.names = 24L, risk = 0L), list(
                     na = FALSE, vertex.names = 25L, risk = 0L), list(na = FALSE, vertex.names = 26L, 
                     risk = 0L), list(na = FALSE, vertex.names = 27L, risk = 1L), list(
                     na = FALSE, vertex.names = 28L, risk = 0L), list(na = FALSE, vertex.names = 29L, 
                     risk = 1L), list(na = FALSE, vertex.names = 30L, risk = 0L), list(
                     na = FALSE, vertex.names = 31L, risk = 1L), list(na = FALSE, vertex.names = 32L, 
                     risk = 0L), list(na = FALSE, vertex.names = 33L, risk = 1L), list(
                     na = FALSE, vertex.names = 34L, risk = 1L), list(na = FALSE, vertex.names = 35L, 
                     risk = 0L), list(na = FALSE, vertex.names = 36L, risk = 0L), list(
                     na = FALSE, vertex.names = 37L, risk = 0L), list(na = FALSE, vertex.names = 38L, 
                     risk = 1L), list(na = FALSE, vertex.names = 39L, risk = 1L), list(
                     na = FALSE, vertex.names = 40L, risk = 1L), list(na = FALSE, vertex.names = 41L, 
                     risk = 0L), list(na = FALSE, vertex.names = 42L, risk = 0L), list(
                     na = FALSE, vertex.names = 43L, risk = 1L), list(na = FALSE, vertex.names = 44L, 
                     risk = 1L), list(na = FALSE, vertex.names = 45L, risk = 0L), list(
                     na = FALSE, vertex.names = 46L, risk = 0L), list(na = FALSE, vertex.names = 47L, 
                     risk = 0L), list(na = FALSE, vertex.names = 48L, risk = 1L), list(
                     na = FALSE, vertex.names = 49L, risk = 1L), list(na = FALSE, vertex.names = 50L, 
                     risk = 0L)), iel = list(integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 22L, c(6L, 17L), integer(0), 18L, 
                 integer(0), c(3L, 23L), integer(0), integer(0), c(8L, 16L, 19L), 20L, 
                 integer(0), integer(0), c(2L, 12L, 24L), integer(0), c(7L, 10L), c(4L, 
                 9L), 5L, c(11L, 13L, 21L, 25L), integer(0), 14L, integer(0), 1L, 15L, 
                 integer(0), integer(0)), oel = list(1L, 2L, integer(0), 5:3, integer(0), 
                 integer(0), 7:6, integer(0), 9:8, integer(0), integer(0), integer(0), 
                 integer(0), 11:10, integer(0), integer(0), 13:12, 14L, 15L, 16L, 21:17, 
                 integer(0), 24:22, integer(0), 25L, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0))), class = "network"), 
         reference = ~Bernoulli, newnetwork = structure(list(mel = list(list(inl = 47L, 
             outl = 1L, atl = list(na = FALSE)), list(inl = 38L, outl = 2L, atl = list(
             na = FALSE)), list(inl = 31L, outl = 4L, atl = list(na = FALSE)), list(inl = 41L, 
             outl = 4L, atl = list(na = FALSE)), list(inl = 42L, outl = 4L, atl = list(
             na = FALSE)), list(inl = 27L, outl = 7L, atl = list(na = FALSE)), list(inl = 40L, 
             outl = 7L, atl = list(na = FALSE)), list(inl = 34L, outl = 9L, atl = list(
             na = FALSE)), list(inl = 41L, outl = 9L, atl = list(na = FALSE)), list(inl = 40L, 
             outl = 14L, atl = list(na = FALSE)), list(inl = 43L, outl = 14L, atl = list(
             na = FALSE)), list(inl = 38L, outl = 17L, atl = list(na = FALSE)), list(inl = 43L, 
             outl = 17L, atl = list(na = FALSE)), list(inl = 45L, outl = 18L, atl = list(
             na = FALSE)), list(inl = 48L, outl = 19L, atl = list(na = FALSE)), list(inl = 34L, 
             outl = 20L, atl = list(na = FALSE)), list(inl = 27L, outl = 21L, atl = list(
             na = FALSE)), list(inl = 29L, outl = 21L, atl = list(na = FALSE)), list(inl = 34L, 
             outl = 21L, atl = list(na = FALSE)), list(inl = 35L, outl = 21L, atl = list(
             na = FALSE)), list(inl = 43L, outl = 21L, atl = list(na = FALSE)), list(inl = 26L, 
             outl = 23L, atl = list(na = FALSE)), list(inl = 31L, outl = 23L, atl = list(
             na = FALSE)), list(inl = 38L, outl = 23L, atl = list(na = FALSE)), list(inl = 43L, 
             outl = 25L, atl = list(na = FALSE))), gal = list(n = 50, mnext = 26L, directed = FALSE, 
             hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = 25), val = list(
             list(na = FALSE, vertex.names = 1L, risk = 1L), list(na = FALSE, vertex.names = 2L, 
                 risk = 0L), list(na = FALSE, vertex.names = 3L, risk = 0L), list(na = FALSE, 
                 vertex.names = 4L, risk = 1L), list(na = FALSE, vertex.names = 5L, risk = 0L), 
             list(na = FALSE, vertex.names = 6L, risk = 0L), list(na = FALSE, vertex.names = 7L, 
                 risk = 1L), list(na = FALSE, vertex.names = 8L, risk = 0L), list(na = FALSE, 
                 vertex.names = 9L, risk = 0L), list(na = FALSE, vertex.names = 10L, risk = 1L), 
             list(na = FALSE, vertex.names = 11L, risk = 1L), list(na = FALSE, vertex.names = 12L, 
                 risk = 0L), list(na = FALSE, vertex.names = 13L, risk = 0L), list(na = FALSE, 
                 vertex.names = 14L, risk = 1L), list(na = FALSE, vertex.names = 15L, 
                 risk = 0L), list(na = FALSE, vertex.names = 16L, risk = 0L), list(na = FALSE, 
                 vertex.names = 17L, risk = 1L), list(na = FALSE, vertex.names = 18L, 
                 risk = 0L), list(na = FALSE, vertex.names = 19L, risk = 0L), list(na = FALSE, 
                 vertex.names = 20L, risk = 0L), list(na = FALSE, vertex.names = 21L, 
                 risk = 1L), list(na = FALSE, vertex.names = 22L, risk = 0L), list(na = FALSE, 
                 vertex.names = 23L, risk = 1L), list(na = FALSE, vertex.names = 24L, 
                 risk = 0L), list(na = FALSE, vertex.names = 25L, risk = 0L), list(na = FALSE, 
                 vertex.names = 26L, risk = 0L), list(na = FALSE, vertex.names = 27L, 
                 risk = 1L), list(na = FALSE, vertex.names = 28L, risk = 0L), list(na = FALSE, 
                 vertex.names = 29L, risk = 1L), list(na = FALSE, vertex.names = 30L, 
                 risk = 0L), list(na = FALSE, vertex.names = 31L, risk = 1L), list(na = FALSE, 
                 vertex.names = 32L, risk = 0L), list(na = FALSE, vertex.names = 33L, 
                 risk = 1L), list(na = FALSE, vertex.names = 34L, risk = 1L), list(na = FALSE, 
                 vertex.names = 35L, risk = 0L), list(na = FALSE, vertex.names = 36L, 
                 risk = 0L), list(na = FALSE, vertex.names = 37L, risk = 0L), list(na = FALSE, 
                 vertex.names = 38L, risk = 1L), list(na = FALSE, vertex.names = 39L, 
                 risk = 1L), list(na = FALSE, vertex.names = 40L, risk = 1L), list(na = FALSE, 
                 vertex.names = 41L, risk = 0L), list(na = FALSE, vertex.names = 42L, 
                 risk = 0L), list(na = FALSE, vertex.names = 43L, risk = 1L), list(na = FALSE, 
                 vertex.names = 44L, risk = 1L), list(na = FALSE, vertex.names = 45L, 
                 risk = 0L), list(na = FALSE, vertex.names = 46L, risk = 0L), list(na = FALSE, 
                 vertex.names = 47L, risk = 0L), list(na = FALSE, vertex.names = 48L, 
                 risk = 1L), list(na = FALSE, vertex.names = 49L, risk = 1L), list(na = FALSE, 
                 vertex.names = 50L, risk = 0L)), iel = list(integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), 22L, c(6L, 17L), integer(0), 18L, integer(0), c(3L, 23L), integer(0), 
             integer(0), c(8L, 16L, 19L), 20L, integer(0), integer(0), c(2L, 12L, 24L), 
             integer(0), c(7L, 10L), c(4L, 9L), 5L, c(11L, 13L, 21L, 25L), integer(0), 
             14L, integer(0), 1L, 15L, integer(0), integer(0)), oel = list(1L, 2L, integer(0), 
             5:3, integer(0), integer(0), 7:6, integer(0), 9:8, integer(0), integer(0), 
             integer(0), integer(0), 11:10, integer(0), integer(0), 13:12, 14L, 15L, 16L, 
             21:17, integer(0), 24:22, integer(0), 25L, integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0))), class = "network"), formula = TARGET_STATS ~ edges + nodefactor("risk"), 
         constraints = ~., target.stats = c(edges = 25, nodefactor.risk.1 = 36), etamap = list(
             canonical = 1:2, offsetmap = c(FALSE, FALSE), offset = c(FALSE, FALSE), offsettheta = c(FALSE, 
             FALSE), curved = list(), etalength = 2), target.esteq = structure(c(-25, 
         -36), .Dim = 1:2, .Dimnames = list(NULL, c("edges", "nodefactor.risk.1"))), estimate = "MLE", 
         control = structure(list(drop = TRUE, init = c(NA_real_, NA_real_), init.method = "MPLE", 
             main.method = "MCMLE", force.main = FALSE, main.hessian = TRUE, checkpoint = NULL, 
             resume = NULL, MPLE.max.dyad.types = 1e+06, MPLE.samplesize = 50000, MPLE.type = "glm", 
             MCMC.prop.weights = "default", MCMC.prop.args = list(), MCMC.interval = 1024, 
             MCMC.burnin = 16384, MCMC.samplesize = 1024, MCMC.effectiveSize = NULL, MCMC.effectiveSize.damp = 10, 
             MCMC.effectiveSize.maxruns = 1000, MCMC.effectiveSize.base = 0.5, MCMC.effectiveSize.points = 5, 
             MCMC.effectiveSize.order = 1, MCMC.return.stats = TRUE, MCMC.runtime.traceplot = FALSE, 
             MCMC.init.maxedges = 20000, MCMC.max.maxedges = Inf, MCMC.addto.se = TRUE, 
             MCMC.compress = FALSE, MCMC.packagenames = NULL, SAN.maxit = 4, SAN.nsteps.times = 8, 
             SAN.control = structure(list(SAN.maxit = 4, SAN.tau = 1, SAN.invcov = NULL, 
                 SAN.invcov.diag = FALSE, SAN.nsteps.alloc = function (nsim) 
                 2^seq_len(nsim), SAN.nsteps = 131072, SAN.samplesize = 1024, SAN.init.maxedges = 20000, 
                 SAN.max.maxedges = Inf, SAN.prop.weights = "default", SAN.prop.args = list(), 
                 SAN.packagenames = NULL, term.options = NULL, seed = NULL, parallel = 0, 
                 parallel.type = NULL, parallel.version.check = TRUE), class = c("control.san", 
             "control.list", "list")), MCMLE.termination = "Hummel", MCMLE.maxit = 20, 
             MCMLE.conv.min.pval = 0.5, MCMLE.NR.maxit = 100, MCMLE.NR.reltol = 1.49011611938477e-08, 
             obs.MCMC.samplesize = 1024, obs.MCMC.interval = 1024, obs.MCMC.burnin = 16384, 
             obs.MCMC.burnin.min = 1638.4, obs.MCMC.prop.weights = "default", obs.MCMC.prop.args = list(), 
             obs.MCMC.impute.min_informative = function (nw) 
             network.size(nw)/4, obs.MCMC.impute.default_density = function (nw) 
             2/network.size(nw), MCMLE.check.degeneracy = FALSE, MCMLE.MCMC.precision = 0.005, 
             MCMLE.MCMC.max.ESS.frac = 0.1, MCMLE.metric = "lognormal", MCMLE.method = "BFGS", 
             MCMLE.trustregion = 20, MCMLE.dampening = FALSE, MCMLE.dampening.min.ess = 20, 
             MCMLE.dampening.level = 0.1, MCMLE.steplength.margin = 0.05, MCMLE.steplength = 1, 
             MCMLE.adaptive.trustregion = 3, MCMLE.sequential = TRUE, MCMLE.density.guard.min = 10000, 
             MCMLE.density.guard = 20.0855369231877, MCMLE.effectiveSize = NULL, MCMLE.last.boost = 4, 
             MCMLE.Hummel.esteq = TRUE, MCMLE.Hummel.miss.sample = 100, MCMLE.Hummel.maxit = 25, 
             MCMLE.steplength.min = 1e-04, MCMLE.effectiveSize.interval_drop = 2, MCMLE.save_intermediates = NULL, 
             SA.phase1_n = NULL, SA.initial_gain = NULL, SA.nsubphases = 4, SA.niterations = NULL, 
             SA.phase3_n = NULL, SA.trustregion = 0.5, RM.phase1n_base = 7, RM.phase2n_base = 100, 
             RM.phase2sub = 7, RM.init_gain = 0.5, RM.phase3n = 500, Step.MCMC.samplesize = 100, 
             Step.maxit = 50, Step.gridsize = 100, CD.nsteps = 8, CD.multiplicity = 1, 
             CD.nsteps.obs = 128, CD.multiplicity.obs = 1, CD.maxit = 60, CD.conv.min.pval = 0.5, 
             CD.NR.maxit = 100, CD.NR.reltol = 1.49011611938477e-08, CD.metric = "naive", 
             CD.method = "BFGS", CD.trustregion = 20, CD.dampening = FALSE, CD.dampening.min.ess = 20, 
             CD.dampening.level = 0.1, CD.steplength.margin = 0.5, CD.steplength = 1, 
             CD.adaptive.trustregion = 3, CD.adaptive.epsilon = 0.01, CD.Hummel.esteq = TRUE, 
             CD.Hummel.miss.sample = 100, CD.Hummel.maxit = 25, CD.steplength.min = 1e-04, 
             loglik.control = structure(list(nsteps = 20, MCMC.burnin = NULL, MCMC.interval = NULL, 
                 MCMC.samplesize = NULL, obs.MCMC.samplesize = NULL, obs.MCMC.interval = NULL, 
                 obs.MCMC.burnin = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 warn.dyads = NULL, MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, 
                 term.options = NULL, seed = NULL, parallel = NULL, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.logLik.ergm", "control.list", 
             "list")), term.options = NULL, seed = NULL, parallel = 0, parallel.type = NULL, 
             parallel.version.check = TRUE), class = c("control.ergm", "control.list", 
         "list"))), class = "ergm"), formation = ~edges + nodefactor("risk"), target.stats = c(25, 
     36), target.stats.names = c("edges", "nodefactor.risk.1"), coef.form = c(edges = -8.33440641375095, 
     nodefactor.risk.1 = 1.35987690967088), coef.form.crude = c(edges = -4.72348850110673, 
     nodefactor.risk.1 = 1.35987690967088), coef.diss = structure(list(dissolution = ~offset(edges), 
         duration = 38, coef.crude = 3.61091791264423, coef.adj = 3.77561332661396, d.rate = 0.002, 
         model.type = "homog"), class = "disscoef"), constraints = ~., edapprox = TRUE), class = "netest"), 
         structure(list(inf.prob = c(0.411, 0.411, 0.411, 0.0176, 0.0176, 0.0176, 0.0176, 
         0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 
         0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 
         0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 
         0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 
         0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 
         0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 
         0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 
         0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 
         0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 
         0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.0176, 0.1228, 0.1228, 0.1228, 0.1228, 
         0.1228, 0.1228, 0.1228, 0.1228, 0.1228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), act.rate = 1, 
             a.rate = 0.05, ds.rate = 0.002, di.rate = 0.008, inf.prob.m2 = c(0.2055, 
             0.2055, 0.2055, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 
             0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 
             0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 
             0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 
             0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 
             0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 
             0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 
             0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 
             0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 
             0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 0.0088, 
             0.0088, 0.0088, 0.0614, 0.0614, 0.0614, 0.0614, 0.0614, 0.0614, 0.0614, 0.0614, 
             0.0614, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), a.rate.m2 = NA, ds.rate.m2 = 0.002, 
             di.rate.m2 = 0.008, vital = TRUE), class = c("param.net", "list")), structure(list(
             i.num = 10, i.num.m2 = 10), class = c("init.net", "list")), structure(list(
             type = "SI", nsteps = 10, start = 1, nsims = 1, ncores = 1, rec.rand = TRUE, 
             a.rand = TRUE, d.rand = TRUE, tea.status = TRUE, epi.by = "risk", use.pids = TRUE, 
             initialize.FUN = function (x, param, init, control, s) 
             {
                 if (control$start == 1) {
                     dat <- list()
                     dat$param <- param
                     dat$init <- init
                     dat$control <- control
                     dat$attr <- list()
                     dat$stats <- list()
                     dat$temp <- list()
                     nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
                     modes <- ifelse(nw %n% "bipartite", 2, 1)
                     if (control$depend == TRUE) {
                       if (class(x$fit) == "stergm") {
                         nw <- network.collapse(nw, at = 1)
                       }
                       nw <- sim_nets(x, nw, nsteps = 1, control)
                     }
                     if (control$depend == FALSE) {
                       nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
                     }
                     nw <- activate.vertices(nw, onset = 1, terminus = Inf)
                     dat$nw <- nw
                     dat$nwparam <- list(x[-which(names(x) == "fit")])
                     dat$param$modes <- modes
                     if (control$use.pids == TRUE) {
                       dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
                     }
                     form <- get_nwparam(dat)$formation
                     fterms <- get_formula_term_attr(form, nw)
                     dat <- copy_toall_attr(dat, at = 1, fterms)
                     dat$temp$fterms <- fterms
                     dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
                     dat <- init_status.net(dat)
                     dat <- get_prev.net(dat, at = 1)
                 }
                 else {
                     dat <- list()
                     dat$nw <- x$network[[s]]
                     dat$param <- x$param
                     dat$control <- control
                     dat$nwparam <- x$nwparam
                     dat$epi <- sapply(x$epi, function(var) var[s])
                     names(dat$epi) <- names(x$epi)
                     dat$attr <- x$attr[[s]]
                     dat$stats <- sapply(x$stats, function(var) var[[s]])
                     dat$temp <- list()
                 }
                 return(dat)
             }, departures.FUN = function (dat, at) 
             {
                 if (dat$param$vital == FALSE) {
                     return(dat)
                 }
                 modes <- dat$param$modes
                 mode <- idmode(dat$nw)
                 type <- dat$control$type
                 d.rand <- dat$control$d.rand
                 nDepartures.sus <- nDeparturesM2.sus <- 0
                 idsElig.sus <- which(dat$attr$active == 1 & dat$attr$status == "s")
                 nElig.sus <- length(idsElig.sus)
                 if (nElig.sus > 0) {
                     mElig.sus <- mode[idsElig.sus]
                     rates.sus <- c(dat$param$ds.rate, dat$param$ds.rate.m2)
                     ratesElig.sus <- rates.sus[mElig.sus]
                     if (d.rand == TRUE) {
                       vecDepartures.sus <- which(rbinom(nElig.sus, 1, ratesElig.sus) == 
                         1)
                       if (length(vecDepartures.sus) > 0) {
                         idsDpt.sus <- idsElig.sus[vecDepartures.sus]
                         nDepartures.sus <- sum(mode[idsDpt.sus] == 1)
                         nDeparturesM2.sus <- sum(mode[idsDpt.sus] == 2)
                         dat$attr$active[idsDpt.sus] <- 0
                         dat$attr$exitTime[idsDpt.sus] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.sus, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.sus <- idsDptM2.sus <- NULL
                       nDepartures.sus <- min(round(sum(ratesElig.sus[mElig.sus == 1])), 
                         sum(mElig.sus == 1))
                       idsDpt.sus <- ssample(idsElig.sus[mElig.sus == 1], nDepartures.sus)
                       if (modes == 2) {
                         nDeparturesM2.sus <- min(round(sum(ratesElig.sus[mElig.sus == 
                           2])), sum(mElig.sus == 2))
                         idsDptM2.sus <- ssample(idsElig.sus[mElig.sus == 2], nDeparturesM2.sus)
                       }
                       totDpt.sus <- nDepartures.sus + nDeparturesM2.sus
                       if (totDpt.sus > 0) {
                         idsDptAll.sus <- c(idsDpt.sus, idsDptM2.sus)
                         dat$attr$active[idsDptAll.sus] <- 0
                         dat$attr$exitTime[idsDptAll.sus] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.sus, deactivate.edges = TRUE)
                       }
                     }
                 }
                 nDepartures.inf <- nDeparturesM2.inf <- 0
                 idsElig.inf <- which(dat$attr$active == 1 & dat$attr$status == "i")
                 nElig.inf <- length(idsElig.inf)
                 if (nElig.inf > 0) {
                     mElig.inf <- mode[idsElig.inf]
                     rates.inf <- c(dat$param$di.rate, dat$param$di.rate.m2)
                     ratesElig.inf <- rates.inf[mElig.inf]
                     if (d.rand == TRUE) {
                       vecDepartures.inf <- which(rbinom(nElig.inf, 1, ratesElig.inf) == 
                         1)
                       if (length(vecDepartures.inf) > 0) {
                         idsDpt.inf <- idsElig.inf[vecDepartures.inf]
                         nDepartures.inf <- sum(mode[idsDpt.inf] == 1)
                         nDeparturesM2.inf <- sum(mode[idsDpt.inf] == 2)
                         dat$attr$active[idsDpt.inf] <- 0
                         dat$attr$exitTime[idsDpt.inf] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.inf, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.inf <- idsDptM2.inf <- NULL
                       nDepartures.inf <- min(round(sum(ratesElig.inf[mElig.inf == 1])), 
                         sum(mElig.inf == 1))
                       idsDpt.inf <- ssample(idsElig.inf[mElig.inf == 1], nDepartures.inf)
                       if (modes == 2) {
                         nDeparturesM2.inf <- min(round(sum(ratesElig.inf[mElig.inf == 
                           2])), sum(mElig.inf == 2))
                         idsDptM2.inf <- ssample(idsElig.inf[mElig.inf == 2], nDeparturesM2.inf)
                       }
                       totDpt.inf <- nDepartures.inf + nDeparturesM2.inf
                       if (totDpt.inf > 0) {
                         idsDptAll.inf <- c(idsDpt.inf, idsDptM2.inf)
                         dat$attr$active[idsDptAll.inf] <- 0
                         dat$attr$exitTime[idsDptAll.inf] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.inf, deactivate.edges = TRUE)
                       }
                     }
                 }
                 if (type == "SIR") {
                     nDepartures.rec <- nDeparturesM2.rec <- 0
                     idsElig.rec <- which(dat$attr$active == 1 & dat$attr$status == "r")
                     nElig.rec <- length(idsElig.rec)
                     if (nElig.rec > 0) {
                       mElig.rec <- mode[idsElig.rec]
                       rates.rec <- c(dat$param$dr.rate, dat$param$dr.rate.m2)
                       ratesElig.rec <- rates.rec[mElig.rec]
                       if (d.rand == TRUE) {
                         vecDepartures.rec <- which(rbinom(nElig.rec, 1, ratesElig.rec) == 
                           1)
                         if (length(vecDepartures.rec) > 0) {
                           idsDpt.rec <- idsElig.rec[vecDepartures.rec]
                           nDepartures.rec <- sum(mode[idsDpt.rec] == 1)
                           nDeparturesM2.rec <- sum(mode[idsDpt.rec] == 2)
                           dat$attr$active[idsDpt.rec] <- 0
                           dat$attr$exitTime[idsDpt.rec] <- at
                           dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                             v = idsDpt.rec, deactivate.edges = TRUE)
                         }
                       }
                       if (d.rand == FALSE) {
                         idsDpt.rec <- idsDptM2.rec <- NULL
                         nDepartures.rec <- min(round(sum(ratesElig.rec[mElig.rec == 1])), 
                           sum(mElig.rec == 1))
                         idsDpt.rec <- ssample(idsElig.rec[mElig.rec == 1], nDepartures.rec)
                         if (modes == 2) {
                           nDeparturesM2.rec <- min(round(sum(ratesElig.rec[mElig.rec == 
                             2])), sum(mElig.rec == 2))
                           idsDptM2.rec <- ssample(idsElig.rec[mElig.rec == 2], nDeparturesM2.rec)
                         }
                         totDpt.rec <- nDepartures.rec + nDeparturesM2.rec
                         if (totDpt.rec > 0) {
                           idsDptAll.rec <- c(idsDpt.rec, idsDptM2.rec)
                           dat$attr$active[idsDptAll.rec] <- 0
                           dat$attr$exitTime[idsDptAll.rec] <- at
                           dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                             v = idsDptAll.rec, deactivate.edges = TRUE)
                         }
                       }
                     }
                 }
                 if (at == 2) {
                     dat$epi$ds.flow <- c(0, nDepartures.sus)
                     dat$epi$di.flow <- c(0, nDepartures.inf)
                     if (type == "SIR") {
                       dat$epi$dr.flow <- c(0, nDepartures.rec)
                     }
                     if (modes == 2) {
                       dat$epi$ds.flow.m2 <- c(0, nDeparturesM2.sus)
                       dat$epi$di.flow.m2 <- c(0, nDeparturesM2.inf)
                       if (type == "SIR") {
                         dat$epi$dr.flow.m2 <- c(0, nDeparturesM2.rec)
                       }
                     }
                 }
                 else {
                     dat$epi$ds.flow[at] <- nDepartures.sus
                     dat$epi$di.flow[at] <- nDepartures.inf
                     if (type == "SIR") {
                       dat$epi$dr.flow[at] <- nDepartures.rec
                     }
                     if (modes == 2) {
                       dat$epi$ds.flow.m2[at] <- nDeparturesM2.sus
                       dat$epi$di.flow.m2[at] <- nDeparturesM2.inf
                       if (type == "SIR") {
                         dat$epi$dr.flow.m2[at] <- nDeparturesM2.rec
                       }
                     }
                 }
                 return(dat)
             }, arrivals.FUN = function (dat, at) 
             {
                 if (dat$param$vital == FALSE) {
                     return(dat)
                 }
                 a.rate <- dat$param$a.rate
                 a.rate.m2 <- dat$param$a.rate.m2
                 modes <- dat$param$modes
                 tea.status <- dat$control$tea.status
                 nOld <- dat$epi$num[at - 1]
                 nCurr <- network.size(dat$nw)
                 a.rand <- dat$control$a.rand
                 delete.nodes <- dat$control$delete.nodes
                 nArrivals <- nArrivalsM2 <- 0
                 newNodes <- newNodesM2 <- NULL
                 if (modes == 1 && nOld > 0) {
                     if (a.rand == TRUE) {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                     }
                     if (a.rand == FALSE) {
                       nArrivals <- round(nOld * a.rate)
                     }
                     if (nArrivals > 0) {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals)
                       newNodes <- (nCurr + 1):(nCurr + nArrivals)
                       dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                 }
                 if (modes == 2 && nOld > 0) {
                     nOldM2 <- dat$epi$num.m2[at - 1]
                     if (a.rand == TRUE) {
                       if (is.na(a.rate.m2)) {
                         nArrivals <- sum(rbinom(nOld, 1, a.rate))
                         nArrivalsM2 <- sum(rbinom(nOld, 1, a.rate))
                       }
                       else {
                         nArrivals <- sum(rbinom(nOld, 1, a.rate))
                         nArrivalsM2 <- sum(rbinom(nOldM2, 1, a.rate.m2))
                       }
                     }
                     if (a.rand == FALSE) {
                       if (is.na(a.rate.m2)) {
                         nArrivals <- round(nOld * a.rate)
                         nArrivalsM2 <- round(nOld * a.rate)
                       }
                       else {
                         nArrivals <- round(nOld * a.rate)
                         nArrivalsM2 <- round(nOldM2 * a.rate.m2)
                       }
                     }
                     nCurrM1 <- length(modeids(dat$nw, 1))
                     nCurrM2 <- length(modeids(dat$nw, 2))
                     prefixes <- unique(substr(dat$nw %v% "vertex.names", 1, 1))
                     if (nArrivals > 0) {
                       newNodeIDs <- (nCurrM1 + 1):(nCurrM1 + nArrivals)
                       if (delete.nodes == FALSE) {
                         newPids <- paste0(prefixes[1], newNodeIDs)
                         dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE, 
                           vertex.pid = newPids)
                       }
                       else {
                         dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE)
                       }
                       newNodes <- newNodeIDs
                     }
                     if (nArrivalsM2 > 0) {
                       newNodeIDs <- (nCurrM2 + 1):(nCurrM2 + nArrivalsM2)
                       if (delete.nodes == FALSE) {
                         newPids <- paste0(prefixes[2], newNodeIDs)
                         dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE, 
                           vertex.pid = newPids)
                       }
                       else {
                         dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE)
                       }
                       newSize <- network.size(dat$nw)
                       newNodesM2 <- (newSize - nArrivalsM2 + 1):newSize
                     }
                     newNodes <- c(newNodes, newNodesM2)
                     if (!is.null(newNodes)) {
                       dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                 }
                 if (length(newNodes) > 0) {
                     fterms <- dat$temp$fterms
                     curr.tab <- get_attr_prop(dat$nw, fterms)
                     if (length(curr.tab) > 0) {
                       dat$nw <- update_nwattr(dat$nw, newNodes, dat$control$attr.rules, 
                         curr.tab, dat$temp$t1.tab)
                     }
                     dat <- copy_toall_attr(dat, at, fterms)
                     if (tea.status == TRUE) {
                       if ("status" %in% fterms) {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = dat$attr$status[newNodes], onset = at, terminus = Inf, 
                           v = newNodes)
                       }
                       else {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = "s", onset = at, terminus = Inf, v = newNodes)
                       }
                     }
                     if (modes == 1) {
                       if (!("status" %in% fterms)) {
                         dat$attr$status <- c(dat$attr$status, rep("s", length(newNodes)))
                       }
                       dat$attr$active <- c(dat$attr$active, rep(1, length(newNodes)))
                       dat$attr$infTime <- c(dat$attr$infTime, rep(NA, length(newNodes)))
                       dat$attr$entrTime <- c(dat$attr$entrTime, rep(at, length(newNodes)))
                       dat$attr$exitTime <- c(dat$attr$exitTime, rep(NA, length(newNodes)))
                     }
                     if (modes == 2) {
                       if (!("status" %in% fterms)) {
                         dat <- split_bip(dat, "status", "s", nCurrM1, nCurrM2, nArrivals, 
                           nArrivalsM2)
                       }
                       dat <- split_bip(dat, "active", 1, nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                       dat <- split_bip(dat, "infTime", NA, nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                       dat <- split_bip(dat, "entrTime", at, nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                       dat <- split_bip(dat, "exitTime", NA, nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                     }
                     newNodesInf <- intersect(newNodes, which(dat$attr$status == "i"))
                     dat$attr$infTime[newNodesInf] <- at
                     if (length(unique(sapply(dat$attr, length))) != 1) {
                       stop("Attribute list of unequal length. Check arrivals.net module.")
                     }
                 }
                 if (at == 2) {
                     dat$epi$a.flow <- c(0, nArrivals)
                     if (modes == 2) {
                       dat$epi$a.flow.m2 <- c(0, nArrivalsM2)
                     }
                 }
                 else {
                     dat$epi$a.flow[at] <- nArrivals
                     if (modes == 2) {
                       dat$epi$a.flow.m2[at] <- nArrivalsM2
                     }
                 }
                 return(dat)
             }, recovery.FUN = function (dat, at) 
             {
                 if (!(dat$control$type %in% c("SIR", "SIS"))) {
                     return(dat)
                 }
                 active <- dat$attr$active
                 status <- dat$attr$status
                 infTime <- dat$attr$infTime
                 tea.status <- dat$control$tea.status
                 modes <- dat$param$modes
                 mode <- idmode(dat$nw)
                 type <- dat$control$type
                 recovState <- ifelse(type == "SIR", "r", "s")
                 rec.rand <- dat$control$rec.rand
                 rec.rate <- dat$param$rec.rate
                 rec.rate.m2 <- dat$param$rec.rate.m2
                 nRecov <- nRecovM2 <- 0
                 idsElig <- which(active == 1 & status == "i")
                 nElig <- length(idsElig)
                 infDur <- at - infTime[active == 1 & status == "i"]
                 infDur[infDur == 0] <- 1
                 lrec.rate <- length(rec.rate)
                 if (lrec.rate == 1) {
                     mElig <- mode[idsElig]
                     rates <- c(rec.rate, rec.rate.m2)
                     ratesElig <- rates[mElig]
                 }
                 else {
                     mElig <- mode[idsElig]
                     if (is.null(rec.rate.m2)) {
                       rates <- ifelse(infDur <= lrec.rate, rec.rate[infDur], rec.rate[lrec.rate])
                     }
                     else {
                       rates <- rep(NA, length(infDur))
                       rates[mElig == 1] <- ifelse(infDur[mElig == 1] <= lrec.rate, rec.rate[infDur[mElig == 
                         1]], rec.rate[lrec.rate])
                       rates[mElig == 2] <- ifelse(infDur[mElig == 2] <= length(rec.rate.m2), 
                         rec.rate.m2[infDur[mElig == 2]], rec.rate.m2[length(rec.rate.m2)])
                     }
                     ratesElig <- rates
                 }
                 if (nElig > 0) {
                     if (rec.rand == TRUE) {
                       vecRecov <- which(rbinom(nElig, 1, ratesElig) == 1)
                       if (length(vecRecov) > 0) {
                         idsRecov <- idsElig[vecRecov]
                         nRecov <- sum(mode[idsRecov] == 1)
                         nRecovM2 <- sum(mode[idsRecov] == 2)
                         status[idsRecov] <- recovState
                         if (tea.status == TRUE) {
                           dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                             value = recovState, onset = at, terminus = Inf, v = idsRecov)
                         }
                       }
                     }
                     else {
                       idsRecov <- idsRecovM2 <- NULL
                       nRecov <- min(round(sum(ratesElig[mElig == 1])), sum(mElig == 1))
                       if (nRecov > 0) {
                         idsRecov <- ssample(idsElig[mElig == 1], nRecov)
                         status[idsRecov] <- recovState
                       }
                       if (modes == 2) {
                         nRecovM2 <- min(round(sum(ratesElig[mElig == 2])), sum(mElig == 
                           2))
                         if (nRecovM2 > 0) {
                           idsRecovM2 <- ssample(idsElig[mElig == 2], nRecovM2)
                           status[idsRecovM2] <- recovState
                         }
                       }
                       totRecov <- nRecov + nRecovM2
                       if (tea.status == TRUE & totRecov > 0) {
                         allids <- c(idsRecov, idsRecovM2)
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = recovState, onset = at, terminus = Inf, v = allids)
                       }
                     }
                 }
                 dat$attr$status <- status
                 if ("status" %in% dat$temp$fterms) {
                     dat$nw <- set.vertex.attribute(dat$nw, "status", dat$attr$status)
                 }
                 outName <- ifelse(type == "SIR", "ir.flow", "is.flow")
                 outName[2] <- paste0(outName, ".m2")
                 if (at == 2) {
                     dat$epi[[outName[1]]] <- c(0, nRecov)
                 }
                 else {
                     dat$epi[[outName[1]]][at] <- nRecov
                 }
                 if (modes == 2) {
                     if (at == 2) {
                       dat$epi[[outName[2]]] <- c(0, nRecovM2)
                     }
                     else {
                       dat$epi[[outName[2]]][at] <- nRecovM2
                     }
                 }
                 return(dat)
             }, edges_correct.FUN = function (dat, at) 
             {
                 if (dat$control$depend == TRUE) {
                     if (dat$param$modes == 1) {
                       old.num <- dat$epi$num[at - 1]
                       new.num <- sum(dat$attr$active == 1)
                       dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                         log(old.num) - log(new.num)
                     }
                     if (dat$param$modes == 2) {
                       mode <- idmode(dat$nw)
                       old.num.m1 <- dat$epi$num[at - 1]
                       old.num.m2 <- dat$epi$num.m2[at - 1]
                       new.num.m1 <- sum(dat$attr$active == 1 & mode == 1)
                       new.num.m2 <- sum(dat$attr$active == 1 & mode == 2)
                       dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                         log(2 * old.num.m1 * old.num.m2/(old.num.m1 + old.num.m2)) - 
                         log(2 * new.num.m1 * new.num.m2/(new.num.m1 + new.num.m2))
                     }
                 }
                 return(dat)
             }, resim_nets.FUN = function (dat, at) 
             {
                 idsActive <- which(dat$attr$active == 1)
                 anyActive <- ifelse(length(idsActive) > 0, TRUE, FALSE)
                 if (dat$param$modes == 2) {
                     nActiveM1 <- length(intersect(modeids(dat$nw, mode = 1), idsActive))
                     nActiveM2 <- length(intersect(modeids(dat$nw, mode = 2), idsActive))
                     anyActive <- ifelse(nActiveM1 > 0 & nActiveM2 > 0, TRUE, FALSE)
                 }
                 nwparam <- get_nwparam(dat)
                 statOnNw <- ("status" %in% dat$temp$fterms)
                 status <- dat$attr$status
                 if (statOnNw == TRUE && length(unique(status)) == 1) {
                     stop("Stopping simulation because status in formation formula and ", 
                       "no longer any discordant nodes", call. = TRUE)
                 }
                 if (dat$control$save.nwstats == TRUE) {
                     if (at == 2) {
                       nwstats <- attributes(dat$nw)$stats
                       dat$stats$nwstats <- as.data.frame(nwstats)
                     }
                 }
                 if (anyActive > 0 & dat$control$depend == TRUE) {
                     suppressWarnings(dat$nw <- simulate(dat$nw, formation = nwparam$formation, 
                       dissolution = nwparam$coef.diss$dissolution, coef.form = nwparam$coef.form, 
                       coef.diss = nwparam$coef.diss$coef.adj, constraints = nwparam$constraints, 
                       time.start = at, time.slices = 1, time.offset = 0, monitor = dat$control$nwstats.formula, 
                       control = dat$control$set.control.stergm))
                     if (dat$control$save.nwstats == TRUE) {
                       dat$stats$nwstats <- rbind(dat$stats$nwstats, tail(attributes(dat$nw)$stats, 
                         1))
                     }
                     if (dat$control$delete.nodes == TRUE) {
                       dat$nw <- network.extract(dat$nw, at = at)
                       inactive <- which(dat$attr$active == 0)
                       dat$attr <- deleteAttr(dat$attr, inactive)
                     }
                 }
                 return(dat)
             }, infection.FUN = function (dat, at) 
             {
                 active <- dat$attr$active
                 status <- dat$attr$status
                 modes <- dat$param$modes
                 mode <- idmode(dat$nw)
                 inf.prob <- dat$param$inf.prob
                 inf.prob.m2 <- dat$param$inf.prob.m2
                 act.rate <- dat$param$act.rate
                 nw <- dat$nw
                 tea.status <- dat$control$tea.status
                 idsInf <- which(active == 1 & status == "i")
                 nActive <- sum(active == 1)
                 nElig <- length(idsInf)
                 nInf <- nInfM2 <- totInf <- 0
                 if (nElig > 0 && nElig < nActive) {
                     del <- discord_edgelist(dat, at)
                     if (!(is.null(del))) {
                       del$infDur <- at - dat$attr$infTime[del$inf]
                       del$infDur[del$infDur == 0] <- 1
                       linf.prob <- length(inf.prob)
                       if (is.null(inf.prob.m2)) {
                         del$transProb <- ifelse(del$infDur <= linf.prob, inf.prob[del$infDur], 
                           inf.prob[linf.prob])
                       }
                       else {
                         del$transProb <- ifelse(del$sus <= nw %n% "bipartite", ifelse(del$infDur <= 
                           linf.prob, inf.prob[del$infDur], inf.prob[linf.prob]), ifelse(del$infDur <= 
                           linf.prob, inf.prob.m2[del$infDur], inf.prob.m2[linf.prob]))
                       }
                       if (!is.null(dat$param$inter.eff) && at >= dat$param$inter.start) {
                         del$transProb <- del$transProb * (1 - dat$param$inter.eff)
                       }
                       lact.rate <- length(act.rate)
                       del$actRate <- ifelse(del$infDur <= lact.rate, act.rate[del$infDur], 
                         act.rate[lact.rate])
                       del$finalProb <- 1 - (1 - del$transProb)^del$actRate
                       transmit <- rbinom(nrow(del), 1, del$finalProb)
                       del <- del[which(transmit == 1), ]
                       idsNewInf <- unique(del$sus)
                       nInf <- sum(mode[idsNewInf] == 1)
                       nInfM2 <- sum(mode[idsNewInf] == 2)
                       totInf <- nInf + nInfM2
                       if (totInf > 0) {
                         if (tea.status == TRUE) {
                           nw <- activate.vertex.attribute(nw, prefix = "testatus", value = "i", 
                             onset = at, terminus = Inf, v = idsNewInf)
                         }
                         dat$attr$status[idsNewInf] <- "i"
                         dat$attr$infTime[idsNewInf] <- at
                         if ("status" %in% dat$temp$fterms) {
                           nw <- set.vertex.attribute(nw, "status", dat$attr$status)
                         }
                       }
                       if (any(names(nw$gal) %in% "vertex.pid")) {
                         del$sus <- get.vertex.pid(nw, del$sus)
                         del$inf <- get.vertex.pid(nw, del$inf)
                       }
                     }
                 }
                 if (totInf > 0) {
                     del <- del[!duplicated(del$sus), ]
                     if (at == 2) {
                       dat$stats$transmat <- del
                     }
                     else {
                       dat$stats$transmat <- rbind(dat$stats$transmat, del)
                     }
                 }
                 if (at == 2) {
                     dat$epi$si.flow <- c(0, nInf)
                     if (modes == 2) {
                       dat$epi$si.flow.m2 <- c(0, nInfM2)
                     }
                 }
                 else {
                     dat$epi$si.flow[at] <- nInf
                     if (modes == 2) {
                       dat$epi$si.flow.m2[at] <- nInfM2
                     }
                 }
                 dat$nw <- nw
                 return(dat)
             }, get_prev.FUN = function (dat, at) 
             {
                 active <- dat$attr$active
                 modes <- dat$param$modes
                 l <- lapply(1:length(dat$attr), function(x) dat$attr[[x]][active == 1])
                 names(l) <- names(dat$attr)
                 l$active <- l$infTime <- NULL
                 status <- l$status
                 if (modes == 2) {
                     mode <- idmode(dat$nw)[active == 1]
                 }
                 eb <- !is.null(dat$control$epi.by)
                 if (eb == TRUE) {
                     ebn <- dat$control$epi.by
                     ebv <- dat$temp$epi.by.vals
                     ebun <- paste0(".", ebn, ebv)
                     assign(ebn, l[[ebn]])
                 }
                 if (modes == 1) {
                     if (at == 1) {
                       dat$epi <- list()
                       dat$epi$s.num <- sum(status == "s")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & 
                             get(ebn) == ebv[i])
                         }
                       }
                       dat$epi$i.num <- sum(status == "i")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & 
                             get(ebn) == ebv[i])
                         }
                       }
                       if (dat$control$type == "SIR") {
                         dat$epi$r.num <- sum(status == "r")
                         if (eb == TRUE) {
                           for (i in 1:length(ebun)) {
                             dat$epi[[paste0("r.num", ebun[i])]] <- sum(status == "r" & 
                               get(ebn) == ebv[i])
                           }
                         }
                       }
                       dat$epi$num <- length(status)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("num", ebun[i])]] <- sum(get(ebn) == ebv[i])
                         }
                       }
                     }
                     else {
                       dat$epi$s.num[at] <- sum(status == "s")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                             get(ebn) == ebv[i])
                         }
                       }
                       dat$epi$i.num[at] <- sum(status == "i")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                             get(ebn) == ebv[i])
                         }
                       }
                       if (dat$control$type == "SIR") {
                         dat$epi$r.num[at] <- sum(status == "r")
                         if (eb == TRUE) {
                           for (i in 1:length(ebun)) {
                             dat$epi[[paste0("r.num", ebun[i])]][at] <- sum(status == 
                               "r" & get(ebn) == ebv[i])
                           }
                         }
                       }
                       dat$epi$num[at] <- length(status)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("num", ebun[i])]][at] <- sum(get(ebn) == ebv[i])
                         }
                       }
                     }
                 }
                 else {
                     if (at == 1) {
                       dat$epi <- list()
                       dat$epi$s.num <- sum(status == "s" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                       dat$epi$i.num <- sum(status == "i" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                       if (dat$control$type == "SIR") {
                         dat$epi$r.num <- sum(status == "r" & mode == 1)
                         if (eb == TRUE) {
                           for (i in 1:length(ebun)) {
                             dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "r" & 
                               mode == 1 & get(ebn) == ebv[i])
                           }
                         }
                       }
                       dat$epi$num <- sum(mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("num", ebun[i])]] <- sum(mode == 1 & get(ebn) == 
                             ebv[i])
                         }
                       }
                       dat$epi$s.num.m2 <- sum(status == "s" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num.m2", ebun[i])]] <- sum(status == "s" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                       dat$epi$i.num.m2 <- sum(status == "i" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("i.num.m2", ebun[i])]] <- sum(status == "i" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                       if (dat$control$type == "SIR") {
                         dat$epi$r.num.m2 <- sum(status == "r" & mode == 2)
                         if (eb == TRUE) {
                           for (i in 1:length(ebun)) {
                             dat$epi[[paste0("r.num.m2", ebun[i])]] <- sum(status == "r" & 
                               mode == 2 & get(ebn) == ebv[i])
                           }
                         }
                       }
                       dat$epi$num.m2 <- sum(mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("num.m2", ebun[i])]] <- sum(mode == 2 & get(ebn) == 
                             ebv[i])
                         }
                       }
                     }
                     else {
                       dat$epi$s.num[at] <- sum(status == "s" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                       dat$epi$i.num[at] <- sum(status == "i" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                       if (dat$control$type == "SIR") {
                         dat$epi$r.num[at] <- sum(status == "r" & mode == 1)
                         if (eb == TRUE) {
                           for (i in 1:length(ebun)) {
                             dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == 
                               "r" & mode == 1 & get(ebn) == ebv[i])
                           }
                         }
                       }
                       dat$epi$num[at] <- sum(mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("num", ebun[i])]][at] <- sum(mode == 1 & get(ebn) == 
                             ebv[i])
                         }
                       }
                       dat$epi$s.num.m2[at] <- sum(status == "s" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num.m2", ebun[i])]][at] <- sum(status == 
                             "s" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                       dat$epi$i.num.m2[at] <- sum(status == "i" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("i.num.m2", ebun[i])]][at] <- sum(status == 
                             "i" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                       if (dat$control$type == "SIR") {
                         dat$epi$r.num.m2[at] <- sum(status == "r" & mode == 2)
                         if (eb == TRUE) {
                           for (i in 1:length(ebun)) {
                             dat$epi[[paste0("r.num.m2", ebun[i])]][at] <- sum(status == 
                               "r" & mode == 2 & get(ebn) == ebv[i])
                           }
                         }
                       }
                       dat$epi$num.m2[at] <- sum(mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("num.m2", ebun[i])]][at] <- sum(mode == 2 & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                 }
                 return(dat)
             }, verbose.FUN = function (x, type, s = 1, at = 2) 
             {
                 if (type == "startup" && x$ncores == 1) {
                     if (x$verbose == TRUE) {
                       cat("\nStarting Network Simulation...")
                     }
                 }
                 if (type == "progress" && x$control$ncores == 1) {
                     if (x$control$verbose == TRUE) {
                       if (x$control$verbose.int == 0 && at == x$control$nsteps) {
                         cat("\nSim = ", s, "/", x$control$nsims, sep = "")
                       }
                       if (x$control$verbose.int > 0 && (at%%x$control$verbose.int == 
                         0)) {
                         cat("\f")
                         cat("\nEpidemic Simulation")
                         cat("\n----------------------------")
                         cat("\nSimulation: ", s, "/", x$control$nsims, sep = "")
                         cat("\nTimestep: ", at, "/", x$control$nsteps, sep = "")
                         status <- x$attr$status
                         if (class(status) == "character") {
                           status <- ifelse(status == "i", 1, 0)
                         }
                         cat("\nPrevalence:", sum(status, na.rm = TRUE))
                         cat("\nPopulation Size:", sum(x$attr$active == 1))
                         cat("\n----------------------------")
                       }
                     }
                 }
             }, module.order = NULL, save.nwstats = TRUE, nwstats.formula = "formation", 
             delete.nodes = FALSE, save.transmat = TRUE, save.network = TRUE, verbose = FALSE, 
             verbose.int = 1, skip.check = FALSE, bi.mods = c("initialize.FUN", "departures.FUN", 
             "arrivals.FUN", "recovery.FUN", "edges_correct.FUN", "resim_nets.FUN", "infection.FUN", 
             "get_prev.FUN", "verbose.FUN"), user.mods = character(0), attr.rules = list(), 
             set.control.stergm = structure(list(MCMC.burnin.min = 1000, MCMC.burnin.max = 1e+05, 
                 MCMC.burnin.pval = 0.5, MCMC.burnin.add = 1, MCMC.burnin = NULL, MCMC.burnin.mul = NULL, 
                 MCMC.prop.weights.form = "default", MCMC.prop.args.form = NULL, MCMC.prop.weights.diss = "default", 
                 MCMC.prop.args.diss = NULL, MCMC.init.maxedges = 20000, MCMC.packagenames = NULL, 
                 MCMC.init.maxchanges = 1e+06), class = c("control.simulate.network", 
             "control.list", "list")), set.control.ergm = structure(list(MCMC.burnin = 2e+05, 
                 MCMC.interval = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, MCMC.runtime.traceplot = FALSE, 
                 network.output = "network", term.options = NULL, parallel = 0, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.simulate.ergm", "control.list", 
             "list")), depend = TRUE, pid.prefix = c("F", "M")), class = c("control.net", 
         "list")), 1L)
  4: sim_nets(x, nw, nsteps = 1, control)
  5: suppressWarnings(sim <- simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm))
  6: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  7: simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, coef.form = x$coef.form, 
         coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, time.start = 1, time.offset = 0, 
         constraints = x$constraints, monitor = control$nwstats.formula, nsim = 1, control = control$set.control.stergm)
  8: simulate.network(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm)
  9: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  10: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  11: lapply(X = X, FUN = FUN, ...)
  12: FUN(X[[i]], ...)
  13: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  14: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 8. Error: Serosorting model in open population (@test-netattr.R#77)  --------
  'Calloc' could not allocate memory (195294703 of 16 bytes)
  1: netsim(est, param, init, control) at testthat/test-netattr.R:77
  2: do.call(control[["initialize.FUN"]], list(x, param, init, control, s))
  3: (function (x, param, init, control, s) 
     {
         if (control$start == 1) {
             dat <- list()
             dat$param <- param
             dat$init <- init
             dat$control <- control
             dat$attr <- list()
             dat$stats <- list()
             dat$temp <- list()
             nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
             modes <- ifelse(nw %n% "bipartite", 2, 1)
             if (control$depend == TRUE) {
                 if (class(x$fit) == "stergm") {
                     nw <- network.collapse(nw, at = 1)
                 }
                 nw <- sim_nets(x, nw, nsteps = 1, control)
             }
             if (control$depend == FALSE) {
                 nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
             }
             nw <- activate.vertices(nw, onset = 1, terminus = Inf)
             dat$nw <- nw
             dat$nwparam <- list(x[-which(names(x) == "fit")])
             dat$param$modes <- modes
             if (control$use.pids == TRUE) {
                 dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
             }
             form <- get_nwparam(dat)$formation
             fterms <- get_formula_term_attr(form, nw)
             dat <- copy_toall_attr(dat, at = 1, fterms)
             dat$temp$fterms <- fterms
             dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
             dat <- init_status.net(dat)
             dat <- get_prev.net(dat, at = 1)
         }
         else {
             dat <- list()
             dat$nw <- x$network[[s]]
             dat$param <- x$param
             dat$control <- control
             dat$nwparam <- x$nwparam
             dat$epi <- sapply(x$epi, function(var) var[s])
             names(dat$epi) <- names(x$epi)
             dat$attr <- x$attr[[s]]
             dat$stats <- sapply(x$stats, function(var) var[[s]])
             dat$temp <- list()
         }
         return(dat)
     })(structure(list(fit = structure(list(coef = c(edges = -4.53341909890728, nodefactor.status.s = -0.41260891465525, 
     nodematch.status = 0.429304944719421, nodematch.race = -0.0581965626825193), iterations = 7L, 
         MCMCtheta = c(edges = -4.53341909890728, nodefactor.status.s = -0.41260891465525, 
         nodematch.status = 0.429304944719421, nodematch.race = -0.0581965626825193), 
         gradient = c(NA, NA, NA, NA), hessian = structure(c(-35.7239667526952, -54.6183906130336, 
         -24.7996201590049, -17.8665589342161, -54.6183906130336, -98.3124346323769, -43.6940440193433, 
         -27.9161308133894, -24.7996201590049, -43.6940440193433, -24.7996201590049, -12.8879619423824, 
         -17.8665589342161, -27.9161308133894, -12.8879619423824, -17.8665589342161), .Dim = c(4L, 
         4L)), covar = structure(c(0.208788368317373, -0.0950347293570366, -0.0160159907250755, 
         -0.0487454957077871, -0.0950347293570366, 0.0961695509473017, -0.0731107625256821, 
         -0.00249009598374672, -0.0160159907250755, -0.0731107625256821, 0.187902188964934, 
         -0.00529234576761911, -0.0487454957077871, -0.00249009598374672, -0.00529234576761911, 
         0.112424316025019), .Dim = c(4L, 4L)), failure = FALSE, est.cov = structure(c(0, 
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), .Dim = c(4L, 4L)), glm = structure(list(
             coefficients = c(edges = -4.53341909890728, nodefactor.status.s = -0.41260891465525, 
             nodematch.status = 0.429304944719421, nodematch.race = -0.0581965626825193
             ), residuals = c(`1` = -1.01650463292445, `2` = -1.01557153490811, `3` = -1.00670954206989, 
             `4` = 139.287103411009, `5` = 150.041468044033, `6` = -1.00723133231758, 
             `7` = -1.00711160008363, `8` = 65.2197449320889, `9` = 61.5890482131595, 
             `10` = 147.573725291225, `11` = -1.00682250517965, `12` = 141.615331042335
             ), fitted.values = c(`1` = 0.0162366529279524, `2` = 0.0153327799892696, 
             `3` = 0.00666482415185731, `4` = 0.00717941557768772, `5` = 0.00666482415185731, 
             `6` = 0.00717941557768772, `7` = 0.00706138235627226, `8` = 0.0153327799892696, 
             `9` = 0.0162366529279524, `10` = 0.00677627401508351, `11` = 0.00677627401508351, 
             `12` = 0.00706138235627226), effects = c(edges = 29.2592098012514, nodefactor.status.s = -0.952121088140113, 
             nodematch.status = 0.984708674880323, nodematch.race = -0.173567020073647, 
             30.9500502273686, -16.6403748445843, -21.8969654782323, 12.7841450494592, 
             7.1648562617801, 40.6374156707959, 27.2238930330303, 25.01782413084), R = structure(c(-5.97695296557495, 
             0, 0, 0, -9.13816637467541, 3.84790201812991, 0, 0, -4.14920784919031, 1.50156951583218, 
             2.30845909046401, 0, -2.9892420163118, 0.155913516335699, 0.108670118076771, 
             2.98242734747944), .Dim = c(4L, 4L), .Dimnames = list(c("edges", "nodefactor.status.s", 
             "nodematch.status", "nodematch.race"), c("edges", "nodefactor.status.s", 
             "nodematch.status", "nodematch.race"))), rank = 4L, qr = structure(list(qr = structure(c(-5.97695296557495, 
             0.197183780866567, 0.37182119418744, 0.0489319212405214, 0.0333457394789286, 
             0.536766300103432, 0.406761022765855, 0.0290731623729852, 0.0211452447426461, 
             0.0434053966908439, 0.564937537648265, 0.0313264040735585, -9.13816637467541, 
             3.84790201812991, 0.154576570040249, -0.0556636578205836, 0.0138627655300091, 
             -0.61061112870907, 0.169102043423358, 0.0572459287724277, 0.0416356211575334, 
             -0.0493768298426224, -0.642657982528074, 0.0130232707792995, -4.14920784919031, 
             1.50156951583218, 2.30845909046401, -0.011231230444075, 0.0592441885944705, 
             -0.123202724484131, 0.72267783297617, -0.040570109282034, -0.0295071062101464, 
             -0.00996274007626032, -0.129668803328768, 0.0556565072456482, -2.9892420163118, 
             0.155913516335699, 0.108670118076771, 2.98242734747944, -0.0237786814780769, 
             0.339139853057384, 0.525112810580523, -0.0360003896425272, 0.016192768896321, 
             -0.0595624567307515, -0.775227741412399, 0.0404411808599383), .Dim = c(12L, 
             4L), .Dimnames = list(c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", 
             "11", "12"), c("edges", "nodefactor.status.s", "nodematch.status", "nodematch.race"
             ))), rank = 4L, qraux = c(1.20609835187722, 1.38826077912509, 1.6606014830105, 
             1.03091618191404), pivot = 1:4, tol = 1e-11), class = "qr"), family = structure(list(
                 family = "binomial", link = "logit", linkfun = function (mu) 
                 .Call(C_logit_link, mu), linkinv = function (eta) 
                 .Call(C_logit_linkinv, eta), variance = function (mu) 
                 mu * (1 - mu), dev.resids = function (y, mu, wt) 
                 .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, 
                     dev) 
                 {
                     m <- if (any(n > 1)) 
                       n
                     else wt
                     -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), 
                       mu, log = TRUE))
                 }, mu.eta = function (eta) 
                 .Call(C_logit_mu_eta, eta), initialize = {
                     if (NCOL(y) == 1) {
                       if (is.factor(y)) 
                         y <- y != levels(y)[1L]
                       n <- rep.int(1, nobs)
                       y[weights == 0] <- 0
                       if (any(y < 0 | y > 1)) 
                         stop("y values must be 0 <= y <= 1")
                       mustart <- (weights * y + 0.5)/(weights + 1)
                       m <- weights * y
                       if (any(abs(m - round(m)) > 0.001)) 
                         warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                           domain = NA)
                     }
                     else if (NCOL(y) == 2) {
                       if (any(abs(y - round(y)) > 0.001)) 
                         warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                           domain = NA)
                       n <- (y1 <- y[, 1L]) + y[, 2L]
                       y <- y1/n
                       if (any(n0 <- n == 0)) 
                         y[n0] <- 0
                       weights <- weights * n
                       mustart <- (n * y + 0.5)/(n + 1)
                     }
                     else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                       "binomial"), domain = NA)
                 }, validmu = function (mu) 
                 all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
                 TRUE, simulate = function (object, nsim) 
                 {
                     ftd <- fitted(object)
                     n <- length(ftd)
                     ntot <- n * nsim
                     wts <- object$prior.weights
                     if (any(wts%%1 != 0)) 
                       stop("cannot simulate from non-integer prior.weights")
                     if (!is.null(m <- object$model)) {
                       y <- model.response(m)
                       if (is.factor(y)) {
                         yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                         split(yy, rep(seq_len(nsim), each = n))
                       }
                       else if (is.matrix(y) && ncol(y) == 2) {
                         yy <- vector("list", nsim)
                         for (i in seq_len(nsim)) {
                           Y <- rbinom(n, size = wts, prob = ftd)
                           YY <- cbind(Y, wts - Y)
                           colnames(YY) <- colnames(y)
                           yy[[i]] <- YY
                         }
                         yy
                       }
                       else rbinom(ntot, size = wts, prob = ftd)/wts
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }), class = "family"), linear.predictors = c(`1` = -4.10411415418786, 
             `2` = -4.16231071687037, `3` = -5.00422457624505, `4` = -4.92933198349836, 
             `5` = -5.00422457624505, `6` = -4.92933198349836, `7` = -4.94602801356253, 
             `8` = -4.16231071687037, `9` = -4.10411415418786, `10` = -4.98752854618087, 
             `11` = -4.98752854618087, `12` = -4.94602801356253), deviance = 424.700943373071, 
             aic = 432.700943373072, null.deviance = 6862.15708754346, iter = 7L, weights = c(`1` = 1.51743016858569, 
             `2` = 1.38899939263426, `3` = 4.93887414349455, `4` = 0.0855350694963773, 
             `5` = 0.0397228483390983, `6` = 10.2927200293974, `7` = 5.91069211599663, 
             `8` = 0.0301956389703101, `9` = 0.0159729491430073, `10` = 0.0673049701336726, 
             `11` = 11.4014619406441, `12` = 0.0350574858600037), prior.weights = c(`1` = 95, 
             `2` = 92, `3` = 746, `4` = 12, `5` = 6, `6` = 1444, `7` = 843, `8` = 2, `9` = 1, 
             `10` = 10, `11` = 1694, `12` = 5), df.residual = 8L, df.null = 12L, y = c(`1` = 0, 
             `2` = 0, `3` = 0, `4` = 1, `5` = 1, `6` = 0, `7` = 0, `8` = 1, `9` = 1, `10` = 1, 
             `11` = 0, `12` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = c(0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 1L), edges = c(1, 
                 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), nodefactor.status.s = c(0, 0, 1, 2, 
                 1, 2, 1, 0, 0, 2, 2, 1), nodematch.status = c(1, 1, 0, 1, 0, 1, 0, 1, 
                 1, 1, 1, 0), nodematch.race = c(0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0), 
                 `offset(pl$foffset)` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), `(weights)` = c(95, 
                 92, 746, 12, 6, 1444, 843, 2, 1, 10, 1694, 5)), terms = pl$zy ~ (edges + 
                 nodefactor.status.s + nodematch.status + nodematch.race) - 1 + offset(pl$foffset), row.names = c(NA, 
             12L), class = "data.frame"), call = glm(formula = pl$zy ~ . - 1 + offset(pl$foffset), 
                 family = family, data = data.frame(pl$xmat), weights = pl$wend), formula = pl$zy ~ 
                 . - 1 + offset(pl$foffset), terms = pl$zy ~ (edges + nodefactor.status.s + 
                 nodematch.status + nodematch.race) - 1 + offset(pl$foffset), data = structure(list(
                 edges = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), nodefactor.status.s = c(0, 
                 0, 1, 2, 1, 2, 1, 0, 0, 2, 2, 1), nodematch.status = c(1, 1, 0, 1, 0, 
                 1, 0, 1, 1, 1, 1, 0), nodematch.race = c(0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 
                 1, 0)), class = "data.frame", row.names = c(NA, -12L)), offset = c(0, 
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), control = list(epsilon = 1e-08, maxit = 25, 
                 trace = FALSE), method = "glm.fit", contrasts = NULL, xlevels = structure(list(), .Names = character(0))), class = c("glm", 
         "lm")), glm.null = structure(list(coefficients = c(`(Intercept)` = -4.91632461462486), 
             residuals = c(`1` = -1.00732600732601, `2` = -1.00732600732601, `3` = -1.00732600732601, 
             `4` = 137.499999999979, `5` = 137.499999999979, `6` = -1.00732600732601, 
             `7` = -1.00732600732601, `8` = 137.499999999979, `9` = 137.499999999979, 
             `10` = 137.499999999979, `11` = -1.00732600732601, `12` = 137.499999999979
             ), fitted.values = c(`1` = 0.00727272727272838, `2` = 0.00727272727272838, 
             `3` = 0.00727272727272838, `4` = 0.00727272727272838, `5` = 0.00727272727272838, 
             `6` = 0.00727272727272838, `7` = 0.00727272727272838, `8` = 0.00727272727272838, 
             `9` = 0.00727272727272838, `10` = 0.00727272727272838, `11` = 0.00727272727272838, 
             `12` = 0.00727272727272838), effects = c(`(Intercept)` = 29.3904947724681, 
             -0.721076130889588, -2.05331991714656, 40.5082791000097, 28.6436788458141, 
             -2.85674057153672, -2.18273490456584, 16.537435692212, 11.6937329213995, 
             36.9788303813173, -3.09416813361734, 26.1479817229766), R = structure(-5.97814364922906, .Dim = c(1L, 
             1L), .Dimnames = list("(Intercept)", "(Intercept)")), rank = 1L, qr = structure(list(
                 qr = structure(c(-5.97814364922906, 0.136329962172145, 0.388210085787413, 
                 0.0492365963917331, 0.0348155311911396, 0.540108481434213, 0.412677877166962, 
                 0.0201007563051842, 0.014213381090374, 0.0449466574975495, 0.584997625826141, 
                 0.0317820863081864), .Dim = c(12L, 1L), .Dimnames = list(c("1", "2", 
                 "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"), "(Intercept)")), 
                 rank = 1L, qraux = 1.13853490243227, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -4.91632461462486, `2` = -4.91632461462486, 
             `3` = -4.91632461462486, `4` = -4.91632461462486, `5` = -4.91632461462486, 
             `6` = -4.91632461462486, `7` = -4.91632461462486, `8` = -4.91632461462486, 
             `9` = -4.91632461462486, `10` = -4.91632461462486, `11` = -4.91632461462486, 
             `12` = -4.91632461462486), deviance = 426.238466820955, aic = 428.238466820956, 
             null.deviance = 426.238466820955, iter = 7L, weights = c(`1` = 0.6858846750763, 
             `2` = 0.664225159021259, `3` = 5.38599965902021, `4` = 0.0866380642201642, 
             `5` = 0.0433190321100821, `6` = 10.4254470611598, `7` = 6.08632401146654, 
             `8` = 0.0144396773700274, `9` = 0.00721983868501369, `10` = 0.0721983868501369, 
             `11` = 12.2304067324132, `12` = 0.0360991934250684), prior.weights = c(`1` = 95, 
             `2` = 92, `3` = 746, `4` = 12, `5` = 6, `6` = 1444, `7` = 843, `8` = 2, `9` = 1, 
             `10` = 10, `11` = 1694, `12` = 5), df.residual = 11L, df.null = 11L, y = c(`1` = 0, 
             `2` = 0, `3` = 0, `4` = 1, `5` = 1, `6` = 0, `7` = 0, `8` = 1, `9` = 1, `10` = 1, 
             `11` = 0, `12` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = c(0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 1L), `(weights)` = c(95, 
                 92, 746, 12, 6, 1444, 843, 2, 1, 10, 1694, 5)), terms = pl$zy ~ 1, row.names = c(NA, 
             12L), class = "data.frame"), call = glm(formula = pl$zy ~ 1, family = family, 
                 weights = pl$wend), formula = pl$zy ~ 1, terms = pl$zy ~ 1, data = <environment>, 
             offset = NULL, control = list(epsilon = 1e-08, maxit = 25, trace = FALSE), 
             method = "glm.fit", contrasts = NULL, xlevels = NULL), class = c("glm", "lm"
         )), theta1 = list(coef = c(edges = -4.53341909890728, nodefactor.status.s = -0.41260891465525, 
         nodematch.status = 0.429304944719421, nodematch.race = -0.0581965626825193), 
             theta = c(edges = -4.53341909890728, nodefactor.status.s = -0.41260891465525, 
             nodematch.status = 0.429304944719421, nodematch.race = -0.0581965626825193
             ), independent = c(edges = TRUE, nodefactor.status.s = TRUE, nodematch.status = TRUE, 
             nodematch.race = TRUE)), MPLE_is_MLE = TRUE, ergm_version = structure(list(
             c(3L, 10L, 1L)), class = c("package_version", "numeric_version")), offset = c(FALSE, 
         FALSE, FALSE, FALSE), drop = c(0, 0, 0, 0), estimable = c(TRUE, TRUE, TRUE, TRUE
         ), network = structure(list(mel = list(list(inl = 85L, outl = 1L, atl = list(
             na = FALSE)), list(inl = 99L, outl = 1L, atl = list(na = FALSE)), list(inl = 36L, 
             outl = 3L, atl = list(na = FALSE)), list(inl = 45L, outl = 3L, atl = list(
             na = FALSE)), list(inl = 89L, outl = 3L, atl = list(na = FALSE)), list(inl = 98L, 
             outl = 3L, atl = list(na = FALSE)), list(inl = 16L, outl = 8L, atl = list(
             na = FALSE)), list(inl = 27L, outl = 10L, atl = list(na = FALSE)), list(inl = 30L, 
             outl = 10L, atl = list(na = FALSE)), list(inl = 39L, outl = 10L, atl = list(
             na = FALSE)), list(inl = 77L, outl = 12L, atl = list(na = FALSE)), list(inl = 34L, 
             outl = 15L, atl = list(na = FALSE)), list(inl = 76L, outl = 15L, atl = list(
             na = FALSE)), list(inl = 46L, outl = 17L, atl = list(na = FALSE)), list(inl = 68L, 
             outl = 17L, atl = list(na = FALSE)), list(inl = 62L, outl = 18L, atl = list(
             na = FALSE)), list(inl = 86L, outl = 18L, atl = list(na = FALSE)), list(inl = 36L, 
             outl = 20L, atl = list(na = FALSE)), list(inl = 65L, outl = 21L, atl = list(
             na = FALSE)), list(inl = 82L, outl = 22L, atl = list(na = FALSE)), list(inl = 99L, 
             outl = 23L, atl = list(na = FALSE)), list(inl = 30L, outl = 26L, atl = list(
             na = FALSE)), list(inl = 84L, outl = 28L, atl = list(na = FALSE)), list(inl = 49L, 
             outl = 34L, atl = list(na = FALSE)), list(inl = 80L, outl = 34L, atl = list(
             na = FALSE)), list(inl = 73L, outl = 39L, atl = list(na = FALSE)), list(inl = 64L, 
             outl = 40L, atl = list(na = FALSE)), list(inl = 79L, outl = 44L, atl = list(
             na = FALSE)), list(inl = 80L, outl = 44L, atl = list(na = FALSE)), list(inl = 81L, 
             outl = 48L, atl = list(na = FALSE)), list(inl = 80L, outl = 49L, atl = list(
             na = FALSE)), list(inl = 93L, outl = 52L, atl = list(na = FALSE)), list(inl = 99L, 
             outl = 64L, atl = list(na = FALSE)), list(inl = 70L, outl = 65L, atl = list(
             na = FALSE)), list(inl = 82L, outl = 76L, atl = list(na = FALSE)), list(inl = 91L, 
             outl = 83L, atl = list(na = FALSE))), gal = list(n = 100, mnext = 37L, directed = FALSE, 
             hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = FALSE), val = list(
             list(na = FALSE, vertex.names = 1L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 2L, status = "i", race = 0L), list(na = FALSE, vertex.names = 3L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 4L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 5L, status = "s", race = 0L), 
             list(na = FALSE, vertex.names = 6L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 7L, status = "s", race = 0L), list(na = FALSE, vertex.names = 8L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 9L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 10L, status = "i", race = 1L), 
             list(na = FALSE, vertex.names = 11L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 12L, status = "s", race = 1L), list(na = FALSE, vertex.names = 13L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 14L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 15L, status = "i", race = 0L), 
             list(na = FALSE, vertex.names = 16L, status = "s", race = 0L), list(na = FALSE, 
                 vertex.names = 17L, status = "s", race = 1L), list(na = FALSE, vertex.names = 18L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 19L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 20L, status = "s", race = 0L), 
             list(na = FALSE, vertex.names = 21L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 22L, status = "i", race = 0L), list(na = FALSE, vertex.names = 23L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 24L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 25L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 26L, status = "i", race = 0L), list(na = FALSE, 
                 vertex.names = 27L, status = "i", race = 1L), list(na = FALSE, vertex.names = 28L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 29L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 30L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 31L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 32L, status = "s", race = 0L), list(na = FALSE, vertex.names = 33L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 34L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 35L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 36L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 37L, status = "s", race = 1L), list(na = FALSE, vertex.names = 38L, 
                 status = "s", race = 0L), list(na = FALSE, vertex.names = 39L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 40L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 41L, status = "s", race = 0L), list(na = FALSE, 
                 vertex.names = 42L, status = "s", race = 0L), list(na = FALSE, vertex.names = 43L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 44L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 45L, status = "s", race = 0L), 
             list(na = FALSE, vertex.names = 46L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 47L, status = "s", race = 1L), list(na = FALSE, vertex.names = 48L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 49L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 50L, status = "i", race = 1L), 
             list(na = FALSE, vertex.names = 51L, status = "s", race = 0L), list(na = FALSE, 
                 vertex.names = 52L, status = "i", race = 0L), list(na = FALSE, vertex.names = 53L, 
                 status = "s", race = 0L), list(na = FALSE, vertex.names = 54L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 55L, status = "s", race = 0L), 
             list(na = FALSE, vertex.names = 56L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 57L, status = "s", race = 0L), list(na = FALSE, vertex.names = 58L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 59L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 60L, status = "s", race = 0L), 
             list(na = FALSE, vertex.names = 61L, status = "i", race = 0L), list(na = FALSE, 
                 vertex.names = 62L, status = "s", race = 1L), list(na = FALSE, vertex.names = 63L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 64L, status = "i", 
                 race = 0L), list(na = FALSE, vertex.names = 65L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 66L, status = "i", race = 0L), list(na = FALSE, 
                 vertex.names = 67L, status = "i", race = 1L), list(na = FALSE, vertex.names = 68L, 
                 status = "s", race = 0L), list(na = FALSE, vertex.names = 69L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 70L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 71L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 72L, status = "s", race = 0L), list(na = FALSE, vertex.names = 73L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 74L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 75L, status = "s", race = 0L), 
             list(na = FALSE, vertex.names = 76L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 77L, status = "s", race = 1L), list(na = FALSE, vertex.names = 78L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 79L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 80L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 81L, status = "s", race = 0L), list(na = FALSE, 
                 vertex.names = 82L, status = "i", race = 1L), list(na = FALSE, vertex.names = 83L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 84L, status = "i", 
                 race = 0L), list(na = FALSE, vertex.names = 85L, status = "i", race = 1L), 
             list(na = FALSE, vertex.names = 86L, status = "i", race = 0L), list(na = FALSE, 
                 vertex.names = 87L, status = "s", race = 0L), list(na = FALSE, vertex.names = 88L, 
                 status = "i", race = 1L), list(na = FALSE, vertex.names = 89L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 90L, status = "i", race = 1L), 
             list(na = FALSE, vertex.names = 91L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 92L, status = "s", race = 1L), list(na = FALSE, vertex.names = 93L, 
                 status = "i", race = 0L), list(na = FALSE, vertex.names = 94L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 95L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 96L, status = "s", race = 0L), list(na = FALSE, 
                 vertex.names = 97L, status = "s", race = 1L), list(na = FALSE, vertex.names = 98L, 
                 status = "s", race = 0L), list(na = FALSE, vertex.names = 99L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 100L, status = "i", race = 0L)), 
             iel = list(integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 7L, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), 8L, integer(0), integer(0), c(9L, 22L), integer(0), integer(0), 
                 integer(0), 12L, integer(0), c(3L, 18L), integer(0), integer(0), 10L, 
                 integer(0), integer(0), integer(0), integer(0), integer(0), 4L, 14L, 
                 integer(0), integer(0), 24L, integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 16L, integer(0), 27L, 19L, integer(0), integer(0), 
                 15L, integer(0), 34L, integer(0), integer(0), 26L, integer(0), integer(0), 
                 13L, 11L, integer(0), 28L, c(25L, 29L, 31L), 30L, c(20L, 35L), integer(0), 
                 23L, 1L, 17L, integer(0), integer(0), 5L, integer(0), 36L, integer(0), 
                 32L, integer(0), integer(0), integer(0), integer(0), 6L, c(2L, 21L, 33L
                 ), integer(0)), oel = list(2:1, integer(0), 6:3, integer(0), integer(0), 
                 integer(0), integer(0), 7L, integer(0), 10:8, integer(0), 11L, integer(0), 
                 integer(0), 13:12, integer(0), 15:14, 17:16, integer(0), 18L, 19L, 20L, 
                 21L, integer(0), integer(0), 22L, integer(0), 23L, integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 25:24, integer(0), integer(0), integer(0), 
                 integer(0), 26L, 27L, integer(0), integer(0), integer(0), 29:28, integer(0), 
                 integer(0), integer(0), 30L, 31L, integer(0), integer(0), 32L, integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), 33L, 34L, integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 35L, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 36L, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0))), class = "network"), reference = ~Bernoulli, 
         newnetwork = structure(list(mel = list(list(inl = 85L, outl = 1L, atl = list(
             na = FALSE)), list(inl = 99L, outl = 1L, atl = list(na = FALSE)), list(inl = 36L, 
             outl = 3L, atl = list(na = FALSE)), list(inl = 45L, outl = 3L, atl = list(
             na = FALSE)), list(inl = 89L, outl = 3L, atl = list(na = FALSE)), list(inl = 98L, 
             outl = 3L, atl = list(na = FALSE)), list(inl = 16L, outl = 8L, atl = list(
             na = FALSE)), list(inl = 27L, outl = 10L, atl = list(na = FALSE)), list(inl = 30L, 
             outl = 10L, atl = list(na = FALSE)), list(inl = 39L, outl = 10L, atl = list(
             na = FALSE)), list(inl = 77L, outl = 12L, atl = list(na = FALSE)), list(inl = 34L, 
             outl = 15L, atl = list(na = FALSE)), list(inl = 76L, outl = 15L, atl = list(
             na = FALSE)), list(inl = 46L, outl = 17L, atl = list(na = FALSE)), list(inl = 68L, 
             outl = 17L, atl = list(na = FALSE)), list(inl = 62L, outl = 18L, atl = list(
             na = FALSE)), list(inl = 86L, outl = 18L, atl = list(na = FALSE)), list(inl = 36L, 
             outl = 20L, atl = list(na = FALSE)), list(inl = 65L, outl = 21L, atl = list(
             na = FALSE)), list(inl = 82L, outl = 22L, atl = list(na = FALSE)), list(inl = 99L, 
             outl = 23L, atl = list(na = FALSE)), list(inl = 30L, outl = 26L, atl = list(
             na = FALSE)), list(inl = 84L, outl = 28L, atl = list(na = FALSE)), list(inl = 49L, 
             outl = 34L, atl = list(na = FALSE)), list(inl = 80L, outl = 34L, atl = list(
             na = FALSE)), list(inl = 73L, outl = 39L, atl = list(na = FALSE)), list(inl = 64L, 
             outl = 40L, atl = list(na = FALSE)), list(inl = 79L, outl = 44L, atl = list(
             na = FALSE)), list(inl = 80L, outl = 44L, atl = list(na = FALSE)), list(inl = 81L, 
             outl = 48L, atl = list(na = FALSE)), list(inl = 80L, outl = 49L, atl = list(
             na = FALSE)), list(inl = 93L, outl = 52L, atl = list(na = FALSE)), list(inl = 99L, 
             outl = 64L, atl = list(na = FALSE)), list(inl = 70L, outl = 65L, atl = list(
             na = FALSE)), list(inl = 82L, outl = 76L, atl = list(na = FALSE)), list(inl = 91L, 
             outl = 83L, atl = list(na = FALSE))), gal = list(n = 100, mnext = 37L, directed = FALSE, 
             hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = FALSE), val = list(
             list(na = FALSE, vertex.names = 1L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 2L, status = "i", race = 0L), list(na = FALSE, vertex.names = 3L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 4L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 5L, status = "s", race = 0L), 
             list(na = FALSE, vertex.names = 6L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 7L, status = "s", race = 0L), list(na = FALSE, vertex.names = 8L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 9L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 10L, status = "i", race = 1L), 
             list(na = FALSE, vertex.names = 11L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 12L, status = "s", race = 1L), list(na = FALSE, vertex.names = 13L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 14L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 15L, status = "i", race = 0L), 
             list(na = FALSE, vertex.names = 16L, status = "s", race = 0L), list(na = FALSE, 
                 vertex.names = 17L, status = "s", race = 1L), list(na = FALSE, vertex.names = 18L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 19L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 20L, status = "s", race = 0L), 
             list(na = FALSE, vertex.names = 21L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 22L, status = "i", race = 0L), list(na = FALSE, vertex.names = 23L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 24L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 25L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 26L, status = "i", race = 0L), list(na = FALSE, 
                 vertex.names = 27L, status = "i", race = 1L), list(na = FALSE, vertex.names = 28L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 29L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 30L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 31L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 32L, status = "s", race = 0L), list(na = FALSE, vertex.names = 33L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 34L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 35L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 36L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 37L, status = "s", race = 1L), list(na = FALSE, vertex.names = 38L, 
                 status = "s", race = 0L), list(na = FALSE, vertex.names = 39L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 40L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 41L, status = "s", race = 0L), list(na = FALSE, 
                 vertex.names = 42L, status = "s", race = 0L), list(na = FALSE, vertex.names = 43L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 44L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 45L, status = "s", race = 0L), 
             list(na = FALSE, vertex.names = 46L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 47L, status = "s", race = 1L), list(na = FALSE, vertex.names = 48L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 49L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 50L, status = "i", race = 1L), 
             list(na = FALSE, vertex.names = 51L, status = "s", race = 0L), list(na = FALSE, 
                 vertex.names = 52L, status = "i", race = 0L), list(na = FALSE, vertex.names = 53L, 
                 status = "s", race = 0L), list(na = FALSE, vertex.names = 54L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 55L, status = "s", race = 0L), 
             list(na = FALSE, vertex.names = 56L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 57L, status = "s", race = 0L), list(na = FALSE, vertex.names = 58L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 59L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 60L, status = "s", race = 0L), 
             list(na = FALSE, vertex.names = 61L, status = "i", race = 0L), list(na = FALSE, 
                 vertex.names = 62L, status = "s", race = 1L), list(na = FALSE, vertex.names = 63L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 64L, status = "i", 
                 race = 0L), list(na = FALSE, vertex.names = 65L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 66L, status = "i", race = 0L), list(na = FALSE, 
                 vertex.names = 67L, status = "i", race = 1L), list(na = FALSE, vertex.names = 68L, 
                 status = "s", race = 0L), list(na = FALSE, vertex.names = 69L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 70L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 71L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 72L, status = "s", race = 0L), list(na = FALSE, vertex.names = 73L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 74L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 75L, status = "s", race = 0L), 
             list(na = FALSE, vertex.names = 76L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 77L, status = "s", race = 1L), list(na = FALSE, vertex.names = 78L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 79L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 80L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 81L, status = "s", race = 0L), list(na = FALSE, 
                 vertex.names = 82L, status = "i", race = 1L), list(na = FALSE, vertex.names = 83L, 
                 status = "s", race = 1L), list(na = FALSE, vertex.names = 84L, status = "i", 
                 race = 0L), list(na = FALSE, vertex.names = 85L, status = "i", race = 1L), 
             list(na = FALSE, vertex.names = 86L, status = "i", race = 0L), list(na = FALSE, 
                 vertex.names = 87L, status = "s", race = 0L), list(na = FALSE, vertex.names = 88L, 
                 status = "i", race = 1L), list(na = FALSE, vertex.names = 89L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 90L, status = "i", race = 1L), 
             list(na = FALSE, vertex.names = 91L, status = "s", race = 1L), list(na = FALSE, 
                 vertex.names = 92L, status = "s", race = 1L), list(na = FALSE, vertex.names = 93L, 
                 status = "i", race = 0L), list(na = FALSE, vertex.names = 94L, status = "s", 
                 race = 1L), list(na = FALSE, vertex.names = 95L, status = "s", race = 1L), 
             list(na = FALSE, vertex.names = 96L, status = "s", race = 0L), list(na = FALSE, 
                 vertex.names = 97L, status = "s", race = 1L), list(na = FALSE, vertex.names = 98L, 
                 status = "s", race = 0L), list(na = FALSE, vertex.names = 99L, status = "s", 
                 race = 0L), list(na = FALSE, vertex.names = 100L, status = "i", race = 0L)), 
             iel = list(integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 7L, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), 8L, integer(0), integer(0), c(9L, 22L), integer(0), integer(0), 
                 integer(0), 12L, integer(0), c(3L, 18L), integer(0), integer(0), 10L, 
                 integer(0), integer(0), integer(0), integer(0), integer(0), 4L, 14L, 
                 integer(0), integer(0), 24L, integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 16L, integer(0), 27L, 19L, integer(0), integer(0), 
                 15L, integer(0), 34L, integer(0), integer(0), 26L, integer(0), integer(0), 
                 13L, 11L, integer(0), 28L, c(25L, 29L, 31L), 30L, c(20L, 35L), integer(0), 
                 23L, 1L, 17L, integer(0), integer(0), 5L, integer(0), 36L, integer(0), 
                 32L, integer(0), integer(0), integer(0), integer(0), 6L, c(2L, 21L, 33L
                 ), integer(0)), oel = list(2:1, integer(0), 6:3, integer(0), integer(0), 
                 integer(0), integer(0), 7L, integer(0), 10:8, integer(0), 11L, integer(0), 
                 integer(0), 13:12, integer(0), 15:14, 17:16, integer(0), 18L, 19L, 20L, 
                 21L, integer(0), integer(0), 22L, integer(0), 23L, integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 25:24, integer(0), integer(0), integer(0), 
                 integer(0), 26L, 27L, integer(0), integer(0), integer(0), 29:28, integer(0), 
                 integer(0), integer(0), 30L, 31L, integer(0), integer(0), 32L, integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), 33L, 34L, integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 35L, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 36L, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0))), class = "network"), formula = TARGET_STATS ~ 
             edges + nodefactor("status", base = 1) + nodematch("status") + nodematch("race"), 
         constraints = ~., target.stats = c(edges = 36, nodefactor.status.s = 55, nodematch.status = 25, 
         nodematch.race = 18), etamap = list(canonical = 1:4, offsetmap = c(FALSE, FALSE, 
         FALSE, FALSE), offset = c(FALSE, FALSE, FALSE, FALSE), offsettheta = c(FALSE, 
         FALSE, FALSE, FALSE), curved = list(), etalength = 4), target.esteq = structure(c(-36, 
         -55, -25, -18), .Dim = c(1L, 4L), .Dimnames = list(NULL, c("edges", "nodefactor.status.s", 
         "nodematch.status", "nodematch.race"))), estimate = "MLE", control = structure(list(
             drop = TRUE, init = c(NA_real_, NA_real_, NA_real_, NA_real_), init.method = "MPLE", 
             main.method = "MCMLE", force.main = FALSE, main.hessian = TRUE, checkpoint = NULL, 
             resume = NULL, MPLE.max.dyad.types = 1e+06, MPLE.samplesize = 50000, MPLE.type = "glm", 
             MCMC.prop.weights = "default", MCMC.prop.args = list(), MCMC.interval = 1024, 
             MCMC.burnin = 16384, MCMC.samplesize = 1024, MCMC.effectiveSize = NULL, MCMC.effectiveSize.damp = 10, 
             MCMC.effectiveSize.maxruns = 1000, MCMC.effectiveSize.base = 0.5, MCMC.effectiveSize.points = 5, 
             MCMC.effectiveSize.order = 1, MCMC.return.stats = TRUE, MCMC.runtime.traceplot = FALSE, 
             MCMC.init.maxedges = 20000, MCMC.max.maxedges = Inf, MCMC.addto.se = TRUE, 
             MCMC.compress = FALSE, MCMC.packagenames = NULL, SAN.maxit = 4, SAN.nsteps.times = 8, 
             SAN.control = structure(list(SAN.maxit = 4, SAN.tau = 1, SAN.invcov = NULL, 
                 SAN.invcov.diag = FALSE, SAN.nsteps.alloc = function (nsim) 
                 2^seq_len(nsim), SAN.nsteps = 131072, SAN.samplesize = 1024, SAN.init.maxedges = 20000, 
                 SAN.max.maxedges = Inf, SAN.prop.weights = "default", SAN.prop.args = list(), 
                 SAN.packagenames = NULL, term.options = NULL, seed = NULL, parallel = 0, 
                 parallel.type = NULL, parallel.version.check = TRUE), class = c("control.san", 
             "control.list", "list")), MCMLE.termination = "Hummel", MCMLE.maxit = 20, 
             MCMLE.conv.min.pval = 0.5, MCMLE.NR.maxit = 100, MCMLE.NR.reltol = 1.49011611938477e-08, 
             obs.MCMC.samplesize = 1024, obs.MCMC.interval = 1024, obs.MCMC.burnin = 16384, 
             obs.MCMC.burnin.min = 1638.4, obs.MCMC.prop.weights = "default", obs.MCMC.prop.args = list(), 
             obs.MCMC.impute.min_informative = function (nw) 
             network.size(nw)/4, obs.MCMC.impute.default_density = function (nw) 
             2/network.size(nw), MCMLE.check.degeneracy = FALSE, MCMLE.MCMC.precision = 0.005, 
             MCMLE.MCMC.max.ESS.frac = 0.1, MCMLE.metric = "lognormal", MCMLE.method = "BFGS", 
             MCMLE.trustregion = 20, MCMLE.dampening = FALSE, MCMLE.dampening.min.ess = 20, 
             MCMLE.dampening.level = 0.1, MCMLE.steplength.margin = 0.05, MCMLE.steplength = 1, 
             MCMLE.adaptive.trustregion = 3, MCMLE.sequential = TRUE, MCMLE.density.guard.min = 10000, 
             MCMLE.density.guard = 20.0855369231877, MCMLE.effectiveSize = NULL, MCMLE.last.boost = 4, 
             MCMLE.Hummel.esteq = TRUE, MCMLE.Hummel.miss.sample = 100, MCMLE.Hummel.maxit = 25, 
             MCMLE.steplength.min = 1e-04, MCMLE.effectiveSize.interval_drop = 2, MCMLE.save_intermediates = NULL, 
             SA.phase1_n = NULL, SA.initial_gain = NULL, SA.nsubphases = 4, SA.niterations = NULL, 
             SA.phase3_n = NULL, SA.trustregion = 0.5, RM.phase1n_base = 7, RM.phase2n_base = 100, 
             RM.phase2sub = 7, RM.init_gain = 0.5, RM.phase3n = 500, Step.MCMC.samplesize = 100, 
             Step.maxit = 50, Step.gridsize = 100, CD.nsteps = 8, CD.multiplicity = 1, 
             CD.nsteps.obs = 128, CD.multiplicity.obs = 1, CD.maxit = 60, CD.conv.min.pval = 0.5, 
             CD.NR.maxit = 100, CD.NR.reltol = 1.49011611938477e-08, CD.metric = "naive", 
             CD.method = "BFGS", CD.trustregion = 20, CD.dampening = FALSE, CD.dampening.min.ess = 20, 
             CD.dampening.level = 0.1, CD.steplength.margin = 0.5, CD.steplength = 1, 
             CD.adaptive.trustregion = 3, CD.adaptive.epsilon = 0.01, CD.Hummel.esteq = TRUE, 
             CD.Hummel.miss.sample = 100, CD.Hummel.maxit = 25, CD.steplength.min = 1e-04, 
             loglik.control = structure(list(nsteps = 20, MCMC.burnin = NULL, MCMC.interval = NULL, 
                 MCMC.samplesize = NULL, obs.MCMC.samplesize = NULL, obs.MCMC.interval = NULL, 
                 obs.MCMC.burnin = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 warn.dyads = NULL, MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, 
                 term.options = NULL, seed = NULL, parallel = NULL, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.logLik.ergm", "control.list", 
             "list")), term.options = NULL, seed = NULL, parallel = 0, parallel.type = NULL, 
             parallel.version.check = TRUE), class = c("control.ergm", "control.list", 
         "list"))), class = "ergm"), formation = ~edges + nodefactor("status", base = 1) + 
         nodematch("status") + nodematch("race"), target.stats = c(36, 55, 25, 18), target.stats.names = c("edges", 
     "nodefactor.status.s", "nodematch.status", "nodematch.race"), coef.form = c(edges = -8.4252393970179, 
     nodefactor.status.s = -0.41260891465525, nodematch.status = 0.429304944719421, nodematch.race = -0.0581965626825193
     ), coef.form.crude = c(edges = -4.53341909890728, nodefactor.status.s = -0.41260891465525, 
     nodematch.status = 0.429304944719421, nodematch.race = -0.0581965626825193), coef.diss = structure(list(
         dissolution = ~offset(edges), duration = 50, coef.crude = 3.89182029811063, coef.adj = 9.19013766465877, 
         d.rate = 0.01, model.type = "homog"), class = "disscoef"), constraints = ~., 
         edapprox = TRUE), class = "netest"), structure(list(inf.prob = 0.03, a.rate = 0.01, 
         ds.rate = 0.01, di.rate = 0.01, act.rate = 1, vital = TRUE), class = c("param.net", 
     "list")), structure(list(), class = c("init.net", "list")), structure(list(type = "SI", 
         nsteps = 10, start = 1, nsims = 1, ncores = 1, rec.rand = TRUE, a.rand = TRUE, 
         d.rand = TRUE, tea.status = TRUE, use.pids = TRUE, initialize.FUN = function (x, 
             param, init, control, s) 
         {
             if (control$start == 1) {
                 dat <- list()
                 dat$param <- param
                 dat$init <- init
                 dat$control <- control
                 dat$attr <- list()
                 dat$stats <- list()
                 dat$temp <- list()
                 nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
                 modes <- ifelse(nw %n% "bipartite", 2, 1)
                 if (control$depend == TRUE) {
                     if (class(x$fit) == "stergm") {
                       nw <- network.collapse(nw, at = 1)
                     }
                     nw <- sim_nets(x, nw, nsteps = 1, control)
                 }
                 if (control$depend == FALSE) {
                     nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
                 }
                 nw <- activate.vertices(nw, onset = 1, terminus = Inf)
                 dat$nw <- nw
                 dat$nwparam <- list(x[-which(names(x) == "fit")])
                 dat$param$modes <- modes
                 if (control$use.pids == TRUE) {
                     dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
                 }
                 form <- get_nwparam(dat)$formation
                 fterms <- get_formula_term_attr(form, nw)
                 dat <- copy_toall_attr(dat, at = 1, fterms)
                 dat$temp$fterms <- fterms
                 dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
                 dat <- init_status.net(dat)
                 dat <- get_prev.net(dat, at = 1)
             }
             else {
                 dat <- list()
                 dat$nw <- x$network[[s]]
                 dat$param <- x$param
                 dat$control <- control
                 dat$nwparam <- x$nwparam
                 dat$epi <- sapply(x$epi, function(var) var[s])
                 names(dat$epi) <- names(x$epi)
                 dat$attr <- x$attr[[s]]
                 dat$stats <- sapply(x$stats, function(var) var[[s]])
                 dat$temp <- list()
             }
             return(dat)
         }, departures.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             d.rand <- dat$control$d.rand
             nDepartures.sus <- nDeparturesM2.sus <- 0
             idsElig.sus <- which(dat$attr$active == 1 & dat$attr$status == "s")
             nElig.sus <- length(idsElig.sus)
             if (nElig.sus > 0) {
                 mElig.sus <- mode[idsElig.sus]
                 rates.sus <- c(dat$param$ds.rate, dat$param$ds.rate.m2)
                 ratesElig.sus <- rates.sus[mElig.sus]
                 if (d.rand == TRUE) {
                     vecDepartures.sus <- which(rbinom(nElig.sus, 1, ratesElig.sus) == 
                       1)
                     if (length(vecDepartures.sus) > 0) {
                       idsDpt.sus <- idsElig.sus[vecDepartures.sus]
                       nDepartures.sus <- sum(mode[idsDpt.sus] == 1)
                       nDeparturesM2.sus <- sum(mode[idsDpt.sus] == 2)
                       dat$attr$active[idsDpt.sus] <- 0
                       dat$attr$exitTime[idsDpt.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.sus, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.sus <- idsDptM2.sus <- NULL
                     nDepartures.sus <- min(round(sum(ratesElig.sus[mElig.sus == 1])), 
                       sum(mElig.sus == 1))
                     idsDpt.sus <- ssample(idsElig.sus[mElig.sus == 1], nDepartures.sus)
                     if (modes == 2) {
                       nDeparturesM2.sus <- min(round(sum(ratesElig.sus[mElig.sus == 2])), 
                         sum(mElig.sus == 2))
                       idsDptM2.sus <- ssample(idsElig.sus[mElig.sus == 2], nDeparturesM2.sus)
                     }
                     totDpt.sus <- nDepartures.sus + nDeparturesM2.sus
                     if (totDpt.sus > 0) {
                       idsDptAll.sus <- c(idsDpt.sus, idsDptM2.sus)
                       dat$attr$active[idsDptAll.sus] <- 0
                       dat$attr$exitTime[idsDptAll.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.sus, deactivate.edges = TRUE)
                     }
                 }
             }
             nDepartures.inf <- nDeparturesM2.inf <- 0
             idsElig.inf <- which(dat$attr$active == 1 & dat$attr$status == "i")
             nElig.inf <- length(idsElig.inf)
             if (nElig.inf > 0) {
                 mElig.inf <- mode[idsElig.inf]
                 rates.inf <- c(dat$param$di.rate, dat$param$di.rate.m2)
                 ratesElig.inf <- rates.inf[mElig.inf]
                 if (d.rand == TRUE) {
                     vecDepartures.inf <- which(rbinom(nElig.inf, 1, ratesElig.inf) == 
                       1)
                     if (length(vecDepartures.inf) > 0) {
                       idsDpt.inf <- idsElig.inf[vecDepartures.inf]
                       nDepartures.inf <- sum(mode[idsDpt.inf] == 1)
                       nDeparturesM2.inf <- sum(mode[idsDpt.inf] == 2)
                       dat$attr$active[idsDpt.inf] <- 0
                       dat$attr$exitTime[idsDpt.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.inf, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.inf <- idsDptM2.inf <- NULL
                     nDepartures.inf <- min(round(sum(ratesElig.inf[mElig.inf == 1])), 
                       sum(mElig.inf == 1))
                     idsDpt.inf <- ssample(idsElig.inf[mElig.inf == 1], nDepartures.inf)
                     if (modes == 2) {
                       nDeparturesM2.inf <- min(round(sum(ratesElig.inf[mElig.inf == 2])), 
                         sum(mElig.inf == 2))
                       idsDptM2.inf <- ssample(idsElig.inf[mElig.inf == 2], nDeparturesM2.inf)
                     }
                     totDpt.inf <- nDepartures.inf + nDeparturesM2.inf
                     if (totDpt.inf > 0) {
                       idsDptAll.inf <- c(idsDpt.inf, idsDptM2.inf)
                       dat$attr$active[idsDptAll.inf] <- 0
                       dat$attr$exitTime[idsDptAll.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.inf, deactivate.edges = TRUE)
                     }
                 }
             }
             if (type == "SIR") {
                 nDepartures.rec <- nDeparturesM2.rec <- 0
                 idsElig.rec <- which(dat$attr$active == 1 & dat$attr$status == "r")
                 nElig.rec <- length(idsElig.rec)
                 if (nElig.rec > 0) {
                     mElig.rec <- mode[idsElig.rec]
                     rates.rec <- c(dat$param$dr.rate, dat$param$dr.rate.m2)
                     ratesElig.rec <- rates.rec[mElig.rec]
                     if (d.rand == TRUE) {
                       vecDepartures.rec <- which(rbinom(nElig.rec, 1, ratesElig.rec) == 
                         1)
                       if (length(vecDepartures.rec) > 0) {
                         idsDpt.rec <- idsElig.rec[vecDepartures.rec]
                         nDepartures.rec <- sum(mode[idsDpt.rec] == 1)
                         nDeparturesM2.rec <- sum(mode[idsDpt.rec] == 2)
                         dat$attr$active[idsDpt.rec] <- 0
                         dat$attr$exitTime[idsDpt.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.rec, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.rec <- idsDptM2.rec <- NULL
                       nDepartures.rec <- min(round(sum(ratesElig.rec[mElig.rec == 1])), 
                         sum(mElig.rec == 1))
                       idsDpt.rec <- ssample(idsElig.rec[mElig.rec == 1], nDepartures.rec)
                       if (modes == 2) {
                         nDeparturesM2.rec <- min(round(sum(ratesElig.rec[mElig.rec == 
                           2])), sum(mElig.rec == 2))
                         idsDptM2.rec <- ssample(idsElig.rec[mElig.rec == 2], nDeparturesM2.rec)
                       }
                       totDpt.rec <- nDepartures.rec + nDeparturesM2.rec
                       if (totDpt.rec > 0) {
                         idsDptAll.rec <- c(idsDpt.rec, idsDptM2.rec)
                         dat$attr$active[idsDptAll.rec] <- 0
                         dat$attr$exitTime[idsDptAll.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.rec, deactivate.edges = TRUE)
                       }
                     }
                 }
             }
             if (at == 2) {
                 dat$epi$ds.flow <- c(0, nDepartures.sus)
                 dat$epi$di.flow <- c(0, nDepartures.inf)
                 if (type == "SIR") {
                     dat$epi$dr.flow <- c(0, nDepartures.rec)
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2 <- c(0, nDeparturesM2.sus)
                     dat$epi$di.flow.m2 <- c(0, nDeparturesM2.inf)
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2 <- c(0, nDeparturesM2.rec)
                     }
                 }
             }
             else {
                 dat$epi$ds.flow[at] <- nDepartures.sus
                 dat$epi$di.flow[at] <- nDepartures.inf
                 if (type == "SIR") {
                     dat$epi$dr.flow[at] <- nDepartures.rec
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2[at] <- nDeparturesM2.sus
                     dat$epi$di.flow.m2[at] <- nDeparturesM2.inf
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2[at] <- nDeparturesM2.rec
                     }
                 }
             }
             return(dat)
         }, arrivals.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             a.rate <- dat$param$a.rate
             a.rate.m2 <- dat$param$a.rate.m2
             modes <- dat$param$modes
             tea.status <- dat$control$tea.status
             nOld <- dat$epi$num[at - 1]
             nCurr <- network.size(dat$nw)
             a.rand <- dat$control$a.rand
             delete.nodes <- dat$control$delete.nodes
             nArrivals <- nArrivalsM2 <- 0
             newNodes <- newNodesM2 <- NULL
             if (modes == 1 && nOld > 0) {
                 if (a.rand == TRUE) {
                     nArrivals <- sum(rbinom(nOld, 1, a.rate))
                 }
                 if (a.rand == FALSE) {
                     nArrivals <- round(nOld * a.rate)
                 }
                 if (nArrivals > 0) {
                     dat$nw <- add.vertices(dat$nw, nv = nArrivals)
                     newNodes <- (nCurr + 1):(nCurr + nArrivals)
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (modes == 2 && nOld > 0) {
                 nOldM2 <- dat$epi$num.m2[at - 1]
                 if (a.rand == TRUE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOld, 1, a.rate))
                     }
                     else {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOldM2, 1, a.rate.m2))
                     }
                 }
                 if (a.rand == FALSE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOld * a.rate)
                     }
                     else {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOldM2 * a.rate.m2)
                     }
                 }
                 nCurrM1 <- length(modeids(dat$nw, 1))
                 nCurrM2 <- length(modeids(dat$nw, 2))
                 prefixes <- unique(substr(dat$nw %v% "vertex.names", 1, 1))
                 if (nArrivals > 0) {
                     newNodeIDs <- (nCurrM1 + 1):(nCurrM1 + nArrivals)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[1], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE)
                     }
                     newNodes <- newNodeIDs
                 }
                 if (nArrivalsM2 > 0) {
                     newNodeIDs <- (nCurrM2 + 1):(nCurrM2 + nArrivalsM2)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[2], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE)
                     }
                     newSize <- network.size(dat$nw)
                     newNodesM2 <- (newSize - nArrivalsM2 + 1):newSize
                 }
                 newNodes <- c(newNodes, newNodesM2)
                 if (!is.null(newNodes)) {
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (length(newNodes) > 0) {
                 fterms <- dat$temp$fterms
                 curr.tab <- get_attr_prop(dat$nw, fterms)
                 if (length(curr.tab) > 0) {
                     dat$nw <- update_nwattr(dat$nw, newNodes, dat$control$attr.rules, 
                       curr.tab, dat$temp$t1.tab)
                 }
                 dat <- copy_toall_attr(dat, at, fterms)
                 if (tea.status == TRUE) {
                     if ("status" %in% fterms) {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = dat$attr$status[newNodes], onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                     else {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = "s", onset = at, terminus = Inf, v = newNodes)
                     }
                 }
                 if (modes == 1) {
                     if (!("status" %in% fterms)) {
                       dat$attr$status <- c(dat$attr$status, rep("s", length(newNodes)))
                     }
                     dat$attr$active <- c(dat$attr$active, rep(1, length(newNodes)))
                     dat$attr$infTime <- c(dat$attr$infTime, rep(NA, length(newNodes)))
                     dat$attr$entrTime <- c(dat$attr$entrTime, rep(at, length(newNodes)))
                     dat$attr$exitTime <- c(dat$attr$exitTime, rep(NA, length(newNodes)))
                 }
                 if (modes == 2) {
                     if (!("status" %in% fterms)) {
                       dat <- split_bip(dat, "status", "s", nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                     }
                     dat <- split_bip(dat, "active", 1, nCurrM1, nCurrM2, nArrivals, nArrivalsM2)
                     dat <- split_bip(dat, "infTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "entrTime", at, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "exitTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                 }
                 newNodesInf <- intersect(newNodes, which(dat$attr$status == "i"))
                 dat$attr$infTime[newNodesInf] <- at
                 if (length(unique(sapply(dat$attr, length))) != 1) {
                     stop("Attribute list of unequal length. Check arrivals.net module.")
                 }
             }
             if (at == 2) {
                 dat$epi$a.flow <- c(0, nArrivals)
                 if (modes == 2) {
                     dat$epi$a.flow.m2 <- c(0, nArrivalsM2)
                 }
             }
             else {
                 dat$epi$a.flow[at] <- nArrivals
                 if (modes == 2) {
                     dat$epi$a.flow.m2[at] <- nArrivalsM2
                 }
             }
             return(dat)
         }, recovery.FUN = function (dat, at) 
         {
             if (!(dat$control$type %in% c("SIR", "SIS"))) {
                 return(dat)
             }
             active <- dat$attr$active
             status <- dat$attr$status
             infTime <- dat$attr$infTime
             tea.status <- dat$control$tea.status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             recovState <- ifelse(type == "SIR", "r", "s")
             rec.rand <- dat$control$rec.rand
             rec.rate <- dat$param$rec.rate
             rec.rate.m2 <- dat$param$rec.rate.m2
             nRecov <- nRecovM2 <- 0
             idsElig <- which(active == 1 & status == "i")
             nElig <- length(idsElig)
             infDur <- at - infTime[active == 1 & status == "i"]
             infDur[infDur == 0] <- 1
             lrec.rate <- length(rec.rate)
             if (lrec.rate == 1) {
                 mElig <- mode[idsElig]
                 rates <- c(rec.rate, rec.rate.m2)
                 ratesElig <- rates[mElig]
             }
             else {
                 mElig <- mode[idsElig]
                 if (is.null(rec.rate.m2)) {
                     rates <- ifelse(infDur <= lrec.rate, rec.rate[infDur], rec.rate[lrec.rate])
                 }
                 else {
                     rates <- rep(NA, length(infDur))
                     rates[mElig == 1] <- ifelse(infDur[mElig == 1] <= lrec.rate, rec.rate[infDur[mElig == 
                       1]], rec.rate[lrec.rate])
                     rates[mElig == 2] <- ifelse(infDur[mElig == 2] <= length(rec.rate.m2), 
                       rec.rate.m2[infDur[mElig == 2]], rec.rate.m2[length(rec.rate.m2)])
                 }
                 ratesElig <- rates
             }
             if (nElig > 0) {
                 if (rec.rand == TRUE) {
                     vecRecov <- which(rbinom(nElig, 1, ratesElig) == 1)
                     if (length(vecRecov) > 0) {
                       idsRecov <- idsElig[vecRecov]
                       nRecov <- sum(mode[idsRecov] == 1)
                       nRecovM2 <- sum(mode[idsRecov] == 2)
                       status[idsRecov] <- recovState
                       if (tea.status == TRUE) {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = recovState, onset = at, terminus = Inf, v = idsRecov)
                       }
                     }
                 }
                 else {
                     idsRecov <- idsRecovM2 <- NULL
                     nRecov <- min(round(sum(ratesElig[mElig == 1])), sum(mElig == 1))
                     if (nRecov > 0) {
                       idsRecov <- ssample(idsElig[mElig == 1], nRecov)
                       status[idsRecov] <- recovState
                     }
                     if (modes == 2) {
                       nRecovM2 <- min(round(sum(ratesElig[mElig == 2])), sum(mElig == 
                         2))
                       if (nRecovM2 > 0) {
                         idsRecovM2 <- ssample(idsElig[mElig == 2], nRecovM2)
                         status[idsRecovM2] <- recovState
                       }
                     }
                     totRecov <- nRecov + nRecovM2
                     if (tea.status == TRUE & totRecov > 0) {
                       allids <- c(idsRecov, idsRecovM2)
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = recovState, onset = at, terminus = Inf, v = allids)
                     }
                 }
             }
             dat$attr$status <- status
             if ("status" %in% dat$temp$fterms) {
                 dat$nw <- set.vertex.attribute(dat$nw, "status", dat$attr$status)
             }
             outName <- ifelse(type == "SIR", "ir.flow", "is.flow")
             outName[2] <- paste0(outName, ".m2")
             if (at == 2) {
                 dat$epi[[outName[1]]] <- c(0, nRecov)
             }
             else {
                 dat$epi[[outName[1]]][at] <- nRecov
             }
             if (modes == 2) {
                 if (at == 2) {
                     dat$epi[[outName[2]]] <- c(0, nRecovM2)
                 }
                 else {
                     dat$epi[[outName[2]]][at] <- nRecovM2
                 }
             }
             return(dat)
         }, edges_correct.FUN = function (dat, at) 
         {
             if (dat$control$depend == TRUE) {
                 if (dat$param$modes == 1) {
                     old.num <- dat$epi$num[at - 1]
                     new.num <- sum(dat$attr$active == 1)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(old.num) - log(new.num)
                 }
                 if (dat$param$modes == 2) {
                     mode <- idmode(dat$nw)
                     old.num.m1 <- dat$epi$num[at - 1]
                     old.num.m2 <- dat$epi$num.m2[at - 1]
                     new.num.m1 <- sum(dat$attr$active == 1 & mode == 1)
                     new.num.m2 <- sum(dat$attr$active == 1 & mode == 2)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(2 * old.num.m1 * old.num.m2/(old.num.m1 + old.num.m2)) - log(2 * 
                       new.num.m1 * new.num.m2/(new.num.m1 + new.num.m2))
                 }
             }
             return(dat)
         }, resim_nets.FUN = function (dat, at) 
         {
             idsActive <- which(dat$attr$active == 1)
             anyActive <- ifelse(length(idsActive) > 0, TRUE, FALSE)
             if (dat$param$modes == 2) {
                 nActiveM1 <- length(intersect(modeids(dat$nw, mode = 1), idsActive))
                 nActiveM2 <- length(intersect(modeids(dat$nw, mode = 2), idsActive))
                 anyActive <- ifelse(nActiveM1 > 0 & nActiveM2 > 0, TRUE, FALSE)
             }
             nwparam <- get_nwparam(dat)
             statOnNw <- ("status" %in% dat$temp$fterms)
             status <- dat$attr$status
             if (statOnNw == TRUE && length(unique(status)) == 1) {
                 stop("Stopping simulation because status in formation formula and ", 
                     "no longer any discordant nodes", call. = TRUE)
             }
             if (dat$control$save.nwstats == TRUE) {
                 if (at == 2) {
                     nwstats <- attributes(dat$nw)$stats
                     dat$stats$nwstats <- as.data.frame(nwstats)
                 }
             }
             if (anyActive > 0 & dat$control$depend == TRUE) {
                 suppressWarnings(dat$nw <- simulate(dat$nw, formation = nwparam$formation, 
                     dissolution = nwparam$coef.diss$dissolution, coef.form = nwparam$coef.form, 
                     coef.diss = nwparam$coef.diss$coef.adj, constraints = nwparam$constraints, 
                     time.start = at, time.slices = 1, time.offset = 0, monitor = dat$control$nwstats.formula, 
                     control = dat$control$set.control.stergm))
                 if (dat$control$save.nwstats == TRUE) {
                     dat$stats$nwstats <- rbind(dat$stats$nwstats, tail(attributes(dat$nw)$stats, 
                       1))
                 }
                 if (dat$control$delete.nodes == TRUE) {
                     dat$nw <- network.extract(dat$nw, at = at)
                     inactive <- which(dat$attr$active == 0)
                     dat$attr <- deleteAttr(dat$attr, inactive)
                 }
             }
             return(dat)
         }, infection.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             status <- dat$attr$status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             inf.prob <- dat$param$inf.prob
             inf.prob.m2 <- dat$param$inf.prob.m2
             act.rate <- dat$param$act.rate
             nw <- dat$nw
             tea.status <- dat$control$tea.status
             idsInf <- which(active == 1 & status == "i")
             nActive <- sum(active == 1)
             nElig <- length(idsInf)
             nInf <- nInfM2 <- totInf <- 0
             if (nElig > 0 && nElig < nActive) {
                 del <- discord_edgelist(dat, at)
                 if (!(is.null(del))) {
                     del$infDur <- at - dat$attr$infTime[del$inf]
                     del$infDur[del$infDur == 0] <- 1
                     linf.prob <- length(inf.prob)
                     if (is.null(inf.prob.m2)) {
                       del$transProb <- ifelse(del$infDur <= linf.prob, inf.prob[del$infDur], 
                         inf.prob[linf.prob])
                     }
                     else {
                       del$transProb <- ifelse(del$sus <= nw %n% "bipartite", ifelse(del$infDur <= 
                         linf.prob, inf.prob[del$infDur], inf.prob[linf.prob]), ifelse(del$infDur <= 
                         linf.prob, inf.prob.m2[del$infDur], inf.prob.m2[linf.prob]))
                     }
                     if (!is.null(dat$param$inter.eff) && at >= dat$param$inter.start) {
                       del$transProb <- del$transProb * (1 - dat$param$inter.eff)
                     }
                     lact.rate <- length(act.rate)
                     del$actRate <- ifelse(del$infDur <= lact.rate, act.rate[del$infDur], 
                       act.rate[lact.rate])
                     del$finalProb <- 1 - (1 - del$transProb)^del$actRate
                     transmit <- rbinom(nrow(del), 1, del$finalProb)
                     del <- del[which(transmit == 1), ]
                     idsNewInf <- unique(del$sus)
                     nInf <- sum(mode[idsNewInf] == 1)
                     nInfM2 <- sum(mode[idsNewInf] == 2)
                     totInf <- nInf + nInfM2
                     if (totInf > 0) {
                       if (tea.status == TRUE) {
                         nw <- activate.vertex.attribute(nw, prefix = "testatus", value = "i", 
                           onset = at, terminus = Inf, v = idsNewInf)
                       }
                       dat$attr$status[idsNewInf] <- "i"
                       dat$attr$infTime[idsNewInf] <- at
                       if ("status" %in% dat$temp$fterms) {
                         nw <- set.vertex.attribute(nw, "status", dat$attr$status)
                       }
                     }
                     if (any(names(nw$gal) %in% "vertex.pid")) {
                       del$sus <- get.vertex.pid(nw, del$sus)
                       del$inf <- get.vertex.pid(nw, del$inf)
                     }
                 }
             }
             if (totInf > 0) {
                 del <- del[!duplicated(del$sus), ]
                 if (at == 2) {
                     dat$stats$transmat <- del
                 }
                 else {
                     dat$stats$transmat <- rbind(dat$stats$transmat, del)
                 }
             }
             if (at == 2) {
                 dat$epi$si.flow <- c(0, nInf)
                 if (modes == 2) {
                     dat$epi$si.flow.m2 <- c(0, nInfM2)
                 }
             }
             else {
                 dat$epi$si.flow[at] <- nInf
                 if (modes == 2) {
                     dat$epi$si.flow.m2[at] <- nInfM2
                 }
             }
             dat$nw <- nw
             return(dat)
         }, get_prev.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             modes <- dat$param$modes
             l <- lapply(1:length(dat$attr), function(x) dat$attr[[x]][active == 1])
             names(l) <- names(dat$attr)
             l$active <- l$infTime <- NULL
             status <- l$status
             if (modes == 2) {
                 mode <- idmode(dat$nw)[active == 1]
             }
             eb <- !is.null(dat$control$epi.by)
             if (eb == TRUE) {
                 ebn <- dat$control$epi.by
                 ebv <- dat$temp$epi.by.vals
                 ebun <- paste0(".", ebn, ebv)
                 assign(ebn, l[[ebn]])
             }
             if (modes == 1) {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]][at] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
             }
             else {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2 <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2 <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2 <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]] <- sum(status == "r" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2 <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2[at] <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2[at] <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2[at] <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]][at] <- sum(status == 
                             "r" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2[at] <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]][at] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
             }
             return(dat)
         }, verbose.FUN = function (x, type, s = 1, at = 2) 
         {
             if (type == "startup" && x$ncores == 1) {
                 if (x$verbose == TRUE) {
                     cat("\nStarting Network Simulation...")
                 }
             }
             if (type == "progress" && x$control$ncores == 1) {
                 if (x$control$verbose == TRUE) {
                     if (x$control$verbose.int == 0 && at == x$control$nsteps) {
                       cat("\nSim = ", s, "/", x$control$nsims, sep = "")
                     }
                     if (x$control$verbose.int > 0 && (at%%x$control$verbose.int == 0)) {
                       cat("\f")
                       cat("\nEpidemic Simulation")
                       cat("\n----------------------------")
                       cat("\nSimulation: ", s, "/", x$control$nsims, sep = "")
                       cat("\nTimestep: ", at, "/", x$control$nsteps, sep = "")
                       status <- x$attr$status
                       if (class(status) == "character") {
                         status <- ifelse(status == "i", 1, 0)
                       }
                       cat("\nPrevalence:", sum(status, na.rm = TRUE))
                       cat("\nPopulation Size:", sum(x$attr$active == 1))
                       cat("\n----------------------------")
                     }
                 }
             }
         }, module.order = NULL, save.nwstats = TRUE, nwstats.formula = ~edges + meandeg + 
             nodefactor("status", base = 0) + nodematch("status"), delete.nodes = FALSE, 
         save.transmat = TRUE, save.network = FALSE, verbose = FALSE, verbose.int = 1, 
         skip.check = FALSE, bi.mods = c("initialize.FUN", "departures.FUN", "arrivals.FUN", 
         "recovery.FUN", "edges_correct.FUN", "resim_nets.FUN", "infection.FUN", "get_prev.FUN", 
         "verbose.FUN"), user.mods = character(0), attr.rules = list(status = "s"), set.control.stergm = structure(list(
             MCMC.burnin.min = 1000, MCMC.burnin.max = 1e+05, MCMC.burnin.pval = 0.5, 
             MCMC.burnin.add = 1, MCMC.burnin = NULL, MCMC.burnin.mul = NULL, MCMC.prop.weights.form = "default", 
             MCMC.prop.args.form = NULL, MCMC.prop.weights.diss = "default", MCMC.prop.args.diss = NULL, 
             MCMC.init.maxedges = 20000, MCMC.packagenames = NULL, MCMC.init.maxchanges = 1e+06), class = c("control.simulate.network", 
         "control.list", "list")), set.control.ergm = structure(list(MCMC.burnin = 2e+05, 
             MCMC.interval = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, MCMC.init.maxedges = NULL, 
             MCMC.packagenames = NULL, MCMC.runtime.traceplot = FALSE, network.output = "network", 
             term.options = NULL, parallel = 0, parallel.type = NULL, parallel.version.check = TRUE), class = c("control.simulate.ergm", 
         "control.list", "list")), depend = TRUE), class = c("control.net", "list")), 
         1L)
  4: sim_nets(x, nw, nsteps = 1, control)
  5: suppressWarnings(sim <- simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm))
  6: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  7: simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, coef.form = x$coef.form, 
         coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, time.start = 1, time.offset = 0, 
         constraints = x$constraints, monitor = control$nwstats.formula, nsim = 1, control = control$set.control.stergm)
  8: simulate.network(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm)
  9: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  10: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  11: lapply(X = X, FUN = FUN, ...)
  12: FUN(X[[i]], ...)
  13: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  14: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 9. Error: Edges only models (@test-netdx.R#12)  -----------------------------
  'Calloc' could not allocate memory (160147627 of 16 bytes)
  1: netdx(est1, nsims = 1, nsteps = 10, verbose = FALSE) at testthat/test-netdx.R:12
  2: simulate(fit.sim, formation = formation, dissolution = dissolution, coef.form = coef.form, 
         coef.diss = coef.diss$coef.crude, time.slices = nsteps, constraints = constraints, 
         monitor = nwstats.formula, nsim = 1, control = set.control.stergm)
  3: simulate.network(fit.sim, formation = formation, dissolution = dissolution, coef.form = coef.form, 
         coef.diss = coef.diss$coef.crude, time.slices = nsteps, constraints = constraints, 
         monitor = nwstats.formula, nsim = 1, control = set.control.stergm)
  4: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  5: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  6: lapply(X = X, FUN = FUN, ...)
  7: FUN(X[[i]], ...)
  8: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  9: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  
  Network Diagnostics
  -----------------------
  - Simulating 2 networks
    |-- 10. Error: Formation plot color vector length (@test-netdx.R#69)  -----------
  'Calloc' could not allocate memory (138430771 of 16 bytes)
  1: netdx(est, nsims = 2, nsteps = 500, nwstats.formula = ~edges + meandeg + degree(0:4) + 
         concurrent) at testthat/test-netdx.R:69
  2: simulate(fit.sim, formation = formation, dissolution = dissolution, coef.form = coef.form, 
         coef.diss = coef.diss$coef.crude, time.slices = nsteps, constraints = constraints, 
         monitor = nwstats.formula, nsim = 1, control = set.control.stergm)
  3: simulate.network(fit.sim, formation = formation, dissolution = dissolution, coef.form = coef.form, 
         coef.diss = coef.diss$coef.crude, time.slices = nsteps, constraints = constraints, 
         monitor = nwstats.formula, nsim = 1, control = set.control.stergm)
  4: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  5: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  6: lapply(X = X, FUN = FUN, ...)
  7: FUN(X[[i]], ...)
  8: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  9: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 11. Error: Offset terms (@test-netdx.R#93)  ---------------------------------
  'Calloc' could not allocate memory (270121510 of 16 bytes)
  1: netdx(est2, nsims = 2, nsteps = 50, verbose = FALSE) at testthat/test-netdx.R:93
  2: simulate(fit.sim, formation = formation, dissolution = dissolution, coef.form = coef.form, 
         coef.diss = coef.diss$coef.crude, time.slices = nsteps, constraints = constraints, 
         monitor = nwstats.formula, nsim = 1, control = set.control.stergm)
  3: simulate.network(fit.sim, formation = formation, dissolution = dissolution, coef.form = coef.form, 
         coef.diss = coef.diss$coef.crude, time.slices = nsteps, constraints = constraints, 
         monitor = nwstats.formula, nsim = 1, control = set.control.stergm)
  4: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  5: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  6: lapply(X = X, FUN = FUN, ...)
  7: FUN(X[[i]], ...)
  8: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  9: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 12. Error: Faux offset term (@test-netdx.R#129)  ----------------------------
  'Calloc' could not allocate memory (139711767 of 16 bytes)
  1: netdx(est3, nsims = 2, nsteps = 50, verbose = FALSE) at testthat/test-netdx.R:129
  2: simulate(fit.sim, formation = formation, dissolution = dissolution, coef.form = coef.form, 
         coef.diss = coef.diss$coef.crude, time.slices = nsteps, constraints = constraints, 
         monitor = nwstats.formula, nsim = 1, control = set.control.stergm)
  3: simulate.network(fit.sim, formation = formation, dissolution = dissolution, coef.form = coef.form, 
         coef.diss = coef.diss$coef.crude, time.slices = nsteps, constraints = constraints, 
         monitor = nwstats.formula, nsim = 1, control = set.control.stergm)
  4: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  5: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  6: lapply(X = X, FUN = FUN, ...)
  7: FUN(X[[i]], ...)
  8: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  9: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 13. Error: More complicated faux offset term (@test-netdx.R#155)  -----------
  'Calloc' could not allocate memory (307022839 of 16 bytes)
  1: netdx(fit, nsteps = 10, verbose = FALSE) at testthat/test-netdx.R:155
  2: simulate(fit.sim, formation = formation, dissolution = dissolution, coef.form = coef.form, 
         coef.diss = coef.diss$coef.crude, time.slices = nsteps, constraints = constraints, 
         monitor = nwstats.formula, nsim = 1, control = set.control.stergm)
  3: simulate.network(fit.sim, formation = formation, dissolution = dissolution, coef.form = coef.form, 
         coef.diss = coef.diss$coef.crude, time.slices = nsteps, constraints = constraints, 
         monitor = nwstats.formula, nsim = 1, control = set.control.stergm)
  4: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  5: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  6: lapply(X = X, FUN = FUN, ...)
  7: FUN(X[[i]], ...)
  8: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  9: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  
  Network Diagnostics
  -----------------------
  - Simulating 250 networks
  - Calculating formation statistics-- 14. Error: netsim works with standard offset models (@test-netoffset.R#13)  -
  'Calloc' could not allocate memory (162716244 of 16 bytes)
  1: netsim(est, param, init, control) at testthat/test-netoffset.R:13
  2: do.call(control[["initialize.FUN"]], list(x, param, init, control, s))
  3: (function (x, param, init, control, s) 
     {
         if (control$start == 1) {
             dat <- list()
             dat$param <- param
             dat$init <- init
             dat$control <- control
             dat$attr <- list()
             dat$stats <- list()
             dat$temp <- list()
             nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
             modes <- ifelse(nw %n% "bipartite", 2, 1)
             if (control$depend == TRUE) {
                 if (class(x$fit) == "stergm") {
                     nw <- network.collapse(nw, at = 1)
                 }
                 nw <- sim_nets(x, nw, nsteps = 1, control)
             }
             if (control$depend == FALSE) {
                 nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
             }
             nw <- activate.vertices(nw, onset = 1, terminus = Inf)
             dat$nw <- nw
             dat$nwparam <- list(x[-which(names(x) == "fit")])
             dat$param$modes <- modes
             if (control$use.pids == TRUE) {
                 dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
             }
             form <- get_nwparam(dat)$formation
             fterms <- get_formula_term_attr(form, nw)
             dat <- copy_toall_attr(dat, at = 1, fterms)
             dat$temp$fterms <- fterms
             dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
             dat <- init_status.net(dat)
             dat <- get_prev.net(dat, at = 1)
         }
         else {
             dat <- list()
             dat$nw <- x$network[[s]]
             dat$param <- x$param
             dat$control <- control
             dat$nwparam <- x$nwparam
             dat$epi <- sapply(x$epi, function(var) var[s])
             names(dat$epi) <- names(x$epi)
             dat$attr <- x$attr[[s]]
             dat$stats <- sapply(x$stats, function(var) var[[s]])
             dat$temp <- list()
         }
         return(dat)
     })(structure(list(fit = structure(list(coef = c(edges = -3.15496019602587, `offset(nodematch.race)` = -Inf
     ), sample = structure(c(5, -4, 2, 5, 0, 4, 1, 11, -4, -7, -1, 0, 3, 8, -7, 6, 4, 
     3, 4, -2, 3, 3, -3, 1, 1, 1, -3, -1, 10, -3, -2, 3, 6, 6, 0, -2, 3, 6, 5, -5, 1, 
     3, -6, 8, 2, -5, 8, 7, 6, 1, 3, 5, 6, 4, -2, 5, 0, 4, 4, -2, 3, 5, -4, 4, 2, 0, -10, 
     3, -9, 0, 4, 3, -9, 3, 2, 3, -4, -5, 4, 8, 3, -2, 5, -1, 8, 0, -2, -1, 10, 3, 0, 
     -6, -2, 0, 7, 2, 1, 0, 9, -4, 2, 1, 6, 3, 1, 4, 7, 1, 5, 3, 4, -5, -1, 1, -5, 1, 
     1, -3, 0, 0, -2, 4, 0, -2, -5, 5, 4, 3, 3, -11, -1, 0, 5, -1, 6, 2, -2, -8, 2, -1, 
     9, -4, 3, 9, 2, 4, 0, -5, 4, 4, 2, 5, 5, 4, 6, 14, 1, -5, 3, 3, 2, 4, -6, 5, 5, -5, 
     6, 0, -6, -2, 0, -2, 17, 5, -9, 1, -1, 1, 2, 4, 1, 7, 4, 2, -3, 0, 1, -1, -4, -3, 
     1, -4, -5, 3, 4, 0, 4, 2, -1, 12, 9, 2, -1, -8, -6, 2, -6, 0, 2, -1, 0, 8, 0, 9, 
     2, -3, 4, 0, -5, 13, 0, 3, -6, 1, 2, 11, -3, 1, 1, 0, 1, -1, 0, 3, -6, -5, -9, 6, 
     -6, 7, -5, -3, -3, 3, -2, 0, 2, 3, 4, 1, -5, -1, 3, 3, -3, 1, -6, 1, 11, 1, 9, -4, 
     0, 2, -6, -3, 6, 8, -6, -2, 4, 3, 12, 11, 6, -4, 1, 7, 5, -2, -4, 0, 1, 2, 5, -2, 
     2, 0, 1, -8, -1, 6, -3, 4, 2, 0, -6, 2, 5, 0, 8, 2, -6, 4, 8, 9, -2, 3, 0, -7, 1, 
     2, 6, -5, 4, 16, 9, -6, 0, -6, 9, 5, 11, -2, -3, -4, 5, 5, 5, -2, 5, -4, 8, 2, 4, 
     -1, -2, -6, 0, 1, 1, 4, 16, 10, 8, 2, 2, -4, 9, 7, 3, 10, 4, 4, 3, 3, 9, 2, 9, -5, 
     6, 5, 2, 5, -2, 5, 2, 8, 0, 3, -4, 2, 5, 6, 5, 9, 4, 0, -11, 5, 4, -4, -10, 6, -2, 
     -7, -1, -7, 9, -2, -4, -2, 7, 0, 6, 0, -6, 7, 2, 6, 9, 4, 11, 4, -7, 2, 8, 0, 2, 
     11, -1, -9, 0, 0, 2, -6, -1, -5, 1, -1, -2, 3, 13, 8, 6, -1, 7, -3, -1, -6, 2, 3, 
     8, -1, 2, 1, -2, -4, 0, -2, 3, -8, 0, -6, 4, -9, -2, 4, 0, -2, -5, 1, -12, -5, -3, 
     1, 0, 3, 1, -1, 3, -14, 5, 10, -5, 4, 7, 2, 14, -4, 3, 6, 15, 2, 3, 2, 1, -7, 5, 
     2, 2, 1, -5, 4, 2, 4, 4, 0, -3, 0, 2, -3, 8, -2, 4, 2, -4, 0, -2, 1, 5, 3, 0, -7, 
     11, 0, 5, 2, 4, -5, -1, -2, 5, -7, -8, -1, -1, -2, 4, -2, 8, 6, -1, 5, 1, 6, 5, 3, 
     2, 1, 2, 2, -1, 5, 1, -1, 7, 18, 10, 0, -9, 9, 3, -1, -3, 4, 1, -2, -1, 4, 5, 5, 
     10, 0, 1, 7, 6, 8, 0, -4, 6, -5, -4, -6, -2, 2, -1, 1, 2, 0, -1, -7, 11, -1, 6, 7, 
     -9, -5, 14, 0, 0, -4, 4, 7, -1, 6, 1, 6, 8, 1, 3, 7, 2, 1, 2, 4, 1, 2, -2, 1, 6, 
     -1, 0, 2, 0, 14, 1, -2, 2, 2, -4, -4, 6, -5, 5, -4, 1, 3, 2, 13, 3, -6, 12, 0, 1, 
     -3, 3, -1, 1, 1, 0, -2, -1, 0, -2, -3, 4, 8, 0, 2, 7, -1, 0, 6, -1, 0, 7, -3, 10, 
     -5, -5, 6, 4, 9, -9, 1, -3, -6, -6, -1, -9, 3, 0, 1, 0, 1, 1, 1, 9, 6, 2, -3, 0, 
     2, 2, 7, 4, 4, -8, -3, 2, -9, 4, 7, 4, 2, 5, 2, 3, -2, -1, 3, -2, -6, 9, -5, 10, 
     -6, -1, 3, 0, 3, 0, 1, -2, -1, -7, 0, 7, -2, -2, 3, 3, 0, 6, 0, -5, 3, 1, -1, 6, 
     3, 7, 2, 1, 5, -1, -4, 1, -5, 1, 2, 4, 3, 2, -1, 5, 3, -2, -4, -2, 7, -2, 0, 5, -8, 
     5, -7, 1, 7, 5, -2, -5, 7, 2, -1, 9, -1, 3, 10, 1, 0, -7, -3, -6, 7, -5, 3, 0, -3, 
     13, 1, 0, 4, -6, 6, 1, -5, 1, 3, 4, 2, 4, 2, -3, 11, -2, 4, 3, 0, -4, 3, 5, 4, -1, 
     0, 0, 5, 6, 8, -3, -6, -2, 0, -3, 5, 11, 2, 5, -7, 0, -4, -5, -4, 8, 5, -5, 0, 12, 
     3, 0, 9, 9, -2, 6, 0, 1, 10, -4, -1, -2, -4, 9, 10, 6, 5, 10, -2, -6, 4, 5, -1, -1, 
     -1, 0, 0, -9, 4, 0, -10, 8, 4, 10, -2, 4, 3, -4, 2, -5, 4, 2, -9, 1, -2, 2, -1, 3, 
     15, -1, 3, 4, 6, -12, 6, 1, -7, 2, 3, -3, 1, 9, -2, 0, -5, 3, 2, 0, 1, 3, 1, -7, 
     4, -4, 0, 0, 7, -2, -6, 3, 8, -5, -6, 4, -4, 8, -1, 6, 4, 3, 11, 4, 2, 7, -3, -1, 
     2, -3, 4, 4, 6, 12, 1, 2, 8, 3, 1, 8, 7, 0, -5, -4, 10, -6, 6, -2, -8, -6, 5, 5, 
     6, 9, 2, 3, 8, -5, 12, -3, 3, 1, 0, -2, -1, 8, 7, -2, 5, 0, 3, 6, 5, 4, 14, -4, 0, 
     4, 0, -1, -1, -2, 1, -5, -2, 2, 1, -3, -1, 9, -7, -4, -8, -4, -1, -3, -4, 6, 4, 0, 
     8, 15, -1, 0, -9, 10, 0, 4, 1, -2, 7, 0, 10, 9, 3, 3, 7, 7, 7, 2, -7, -6, -2, -2, 
     -1, 8, -14, -4, 0, 5, -3, 6, -3, -5, -1, -3, -5, -5, 0, 3, 0, 6, 1, 6, -2, 1, 13, 
     11, -6, 7, 8, 0, 7, 4, -3, 2, 3, -8, -4, 2, -2, 0, 8, -5, -1, 1, 1, -3, 3, 3, -1, 
     -3, -1, 0, 3, 2, 0, 2, 9, 4, -6, 0, -5, 2, 3, 2, 3, -3, 3, -2, 3, 2, -1, -2, 7, 1, 
     -1, -3, 16, 10, 3, 7, -4, -1, -3, -3, 5, -7, 1, -3, 6, -6, -1, -4, 6, 4, 4, -3, 5, 
     2, -5, 4, -1, -6, 2, 1, -3, -5, -2, -4, 1, 2, 1, 1, 2, 5, 2, 7, -4, 0, 0, 9, 3, 1, 
     0, -2, -5, 7, -5, -1, 4, 2, -1, -3, 4, 0, 5, -6, 1, 2, 7, -1, 5, -1, -2, 5, -7, 2, 
     4, -5, 2, -7, 3, -4, -5, -9, -2, -3, 3, -7, 3, 4, 6, 0, 4, 6, -8, -3, -5, 2, 5, 12, 
     4, 3, -1, 9, 2, 6, -8, 6, 7, -4, 2, -5, 1, 1, 0, 1, 4, 3, 8, 8, -2, 6, -3, 6, 14, 
     0, 10, 5, -2, -4, 6, 0, 8, 5, 0, 5, -3, -10, 3, 9, 0, 3, 9, 2, 3, 1, -2, -1, -3, 
     -6, -10, -4, 10, -3, 6, 10, 3, -7, -7, -1, -7, -4, 6, 3, 3, 6, 4, -1, 5, 6, 3, 3, 
     7, -2, 1, -2, -3, 2, 3, 5, -3, 13, 6, -2, -7, 2, 1, -7, 5, 1, 10, 0, 1, 2, -1, -6, 
     -2, 1, -5, -8, 6, -3, 14, 8, 3, 11, 1, -8, 1, 4, -3, -1, 3, 3, 1, 3, -1, 3, -1, -2, 
     0, 6, -4, 2, 5, -5, -4, 2, 6, 0, -1, 1, 1, -3, 7, 2, 12, -2, 0, 0, -2, -2, -5, 5, 
     -6, 3, -2, -5, -3, 8, -2, 8, 6, 9, -1, 7, 1, -2, -6, 6, 8, 2, 3, -2, 6, 4, 0, 10, 
     -5, -7, 2, 12, 4, -2, -2, -1, -6, 2, 1, -2, 1, 4, -2, -4, 5, 0, -4, 1, 1, 5, 3, 4, 
     3, 0, 7, -4, 8, 2, 4, -3, 2, 2, 9, 6, -2, 1, 8, -3, 0, -2, 5, 1, 12, 7, 5, 0, 5, 
     -1, 1, 14, 1, 3, 2, -3, 2, -1, 4, -8, 3, 1, 13, -1, 1, 11, 9, -6, 1, -2, -12, 7, 
     2, 1, 3, -6, -3, -2, 2, -4, 6, 3, 4, 3, -2, 3, -2, -1, 9, -9, -7, 9, -1, 5, 3, 2, 
     14, 2, 6, 0, 11, -3, 7, -4, -4, -4, 3, 4, 8, 0, -8, 5, 11, -5, 4, 3, 9, -5, 3, -8, 
     0, 0, -4, -4, 10, -5, 2, -1, 8, 5, 6, -7, 5, -1, 6, -5, 1, -7, -5, 0, 12, -2, -1, 
     12, 5, -7, 2, -1, 4, 7, 2, 6, 10, 4, 0, -1, -9, -3, 1, 0, -1, 3, -3, -3, 1, 1, -4, 
     13, -3, 2, -6, 5, -1, 0, 17, 8, -2, 2, 8, 1, 1, 2, 4, 0, 6, -11, -4, 5, 10, 0, -1, 
     17, 11, -3, 8, 8, 4, 1, -1, 3, 7, -8, 2, 4, -2, 1, 0, 3, -3, 10, -3, -7, 0, -3, 8, 
     2, 5, 1, 2, 5, 6, 5, 11, 4, 5, 2, 1, 1, -2, 6, -1, 5, 5, 4, 1, 2, -3, 1, 3, 9, -1, 
     3, 2, -1, 1, 1, 0, 4, 4, -6, 2, -4, -1, 0, 7, 0, -3, 6, 2, 4, -1, 3, -2, 5, -4, 1, 
     -9, 2, 14, -7, 15, -4, -5, -8, 3, 7, -1, -4, -1, 5, 6, -1, 17, 10, -1, 0, -4, 7, 
     7, 4, 4, -2, 2, 1, 4, 8, 1, 4, -1, -3, 1, -5, 2, 2, 2, 0, 1, 4, 4, 7, -6, 4, -1, 
     -4, 4, -11, -1, 2, -5, 0, -5, 3, 3, -1, -5, -4, -2, -8, -4, -5, 1, -2, -6, 7, 1, 
     15, 3, 5, -7, 12, 0, 10, -2, 1, -6, -1, 6, 2, -4, -4, -4, 1, -8, 0, -1, 9, 6, -12, 
     -8, 5, 8, 1, 10, 1, 7, 2, -3, 14, 6, 0, -1, -8, 4, 5, 5, 8, 4, 5, -3, 8, 5, -5, -1, 
     -8, 6, 7, 2, 2, 0, 4, 3, 0, 0, -3, 1, 1, 5, -4, 3, -7, -1, -1, -8, 8, 8, 2, 1, 0, 
     2, 6, 7, -7, -5, -8, -5, 7, 2, 9, 4, 3, -5, 6, 3, 1, 4, -6, 2, 5, 2, -6, 2, 9, 0, 
     -1, 2, -4, -6, 9, 2, -4, 3, 0, 0, -3, -1, 9, 3, -7, 8, -4, -5, -16, 2, 3, 5, 8, 9, 
     -2, -5, 5, 6, 6, 0, -5, 5, -7, -3, 4, 8, 13, 9, 3, -2, 5, 8, -9, 9, 19, -1, 4, 4, 
     4, 3, 2, 0, -13, -1, 6, -2, 15, 11, -1, 15, -2, -3, 1, 1, 3, -2, 4, 9, -3, -1, -1, 
     8, -4, 1, 14, 7, 9, 7, 3, 4, 7, 7, 3, 8, 9, 3, 2, 0, -5, -1, -6, 1, 10, 5, 4, 2, 
     6, 4, 5, -5, -6, 4, 0, -2, -1, -3, 2, 0, 0, -3, 2, 5, 0, 5, -1, 3, -1, -3, 12, -5, 
     3, 0, 2, 5, 8, 6, 4, 7, -5, 0, -1, 9, 1, 2, 1, 8, 0, -3, 8, 3, 16, 4, -3, 3, -6, 
     3, 0, 3, -3, 7, -4, 2, -4, 5, 2, 2, -1, -6, 2, -2, -6, -3, -2, 0, 0, 3, 2, 2, 0, 
     4, 0, -7, 4, -4, 1, 14, 5, 5, 2, 10, -3, 2, 7, -1, -11, 0, -4, -2, 0, -2, -2, 8, 
     -11, 2, -3, -3, -3, -3, 3, -2, -1, 8, 10, 1, -4, 9, 11, -5, 3, 4, 4, 2, 3, -3, 11, 
     2, -4, -5, 1, 3, 4, 3, 0, -6, -2, -2, -9, -3, -3, -5, 2, 1, 8, 1, 2, 6, 6, 3, -4, 
     -1, -5, 0, -2, 5, 10, 4, -6, -2, 0, 8, -2, 3, 8, 10, -1, 6, 0, 4, 5, 3, 1, 3, 2, 
     7, 0, -4, -2, 6, 4, 10, 2, 5, 1, -7, 7, 0, 5, 4, -3, 0, 2, 5, 1, 1, 1, 1, -3, -1, 
     4, 7, 5, -4, 3, 11, -7, 12, -4, 0, 4, -6, -7, 3, -4, -1, 4, 2, 4, -1, 0, -3, -1, 
     4, 0, 3, 5, -5, 5, 2, 6, 1, 4, 3, 1, -4, -4, -5, -11, 2, -5, 1, -1, -7, -6, 0, -1, 
     3, -2, 11, 0, 6, 5, 1, 5, 2, -6, -1, -1, 4, 7, 21, 7, 8, -4, 8, 4, 9, 4, -4, 6, -2, 
     0, 2, -2, 4, 4, 3, 10, 14, 3, -3, 11, -1, -3, 12, 1, 1, 4, 3, 2, -3, 9, 5, 13, 0, 
     8, -5, 7, -5, 3, 7, -13, 0, 6, -2, 0, 4, -3, 4, 7, 2, 1, -7, 3, 2, 5, 2, -6, -5, 
     -5, -6, 2, 2, -9, 4, -6, 3, 4, 2, 2, 4, 3, -2, 7, 4, 5, -1, 3, 8, -4, -3, -2, 3, 
     -11, 0, -4, 0, 5, 0, -5, -3, 4, -7, 2, -4, 0, -2, 1, 3, -2, 0, -6, -2, 9, 12, 5, 
     0, 3, 7, -3, 3, 10, 3, 6, 0, -5, 1, 5, -5, 5, 1, -3, 1, 1, -5, -3, 2, 2, -2, 3, 1, 
     4, 1, 4, 2, -11, 2, 5, 11, 4, 2, -5, -3, 1, 3, 1, 10, 5, 7, 3, -8, -6, 4, 0, 3, 3, 
     6, 6, 2, -2, -8, 0, -2, 2, -7, -5, 4, 6, -5, -5, 4, 1, 0, -5, -3, 6, 1, 0, 5, -1, 
     0, -1, 6, 8, 2, 5, 10, 10, 3, 1, 3, 4, -3, -7, 5, -5, 11, 4, 14, 5, -6, 3, 5, -1, 
     11, 0, 3, -6, 10, 0, 3, -2, -3, -3, 11, 3, 1, -3, -6, -1, 7, 3, 2, 1, 6, 2, 0, 7, 
     4, 8, 5, 3, 1, 4, 5, -2, -5, 4, -10, -1, 6, 9, -2, 4, 4, 5, -3, -4, 1, -5, -3, -2, 
     -6, -4, 10, 2, 5, 1, -1, -15, -8, 1, 3, 12, -3, 8, -1, 1, 9, 0, -2, 0, 11, 0, 7, 
     3, -6, -1, 6, 2, -1, -5, 5, -1, 4, 3, 5, 1, -1, 3, -6, -9, -3, 3, 2, -3, -1, -2, 
     8, 6, 8, 2, -4, 0, -4, -1, -8, -4, -5, 8, 7, -2, -4, -4, -6, 11, 7, -4, -13, 4, 3, 
     8, 9, 4, -2, 9, 5, -3, 9, 0, -1, 1, 5, 0, 7, 0, -3, -1, 1, -3, -4, 1, 4, 0, -2, -6, 
     -1, -3, -1, 8, -1, 7, 8, 7, -1, -3, 12, -9, -1, 6, 7, 9, 11, 0, 0, -6, -1, 2, 4, 
     -2, 5, -8, 5, 0, 1, 5, 3, -2, 1, -1, -2, 4, -2, 7, 0, 9, -1, 3, -4, -4, 2, -10, 5, 
     14, 4, 8, 8, 1, 8, -6, -3, 4, -4, 4, -1, -3, 1, 13, 1, 5, -1, 5, 0, -4, 5, 3, -1, 
     7, 2, 8, 18, 0, -1, -1, -1, 3, 4, -2, 12, 2, 3, 4, 3, 1, 0, -4, -4, 2, 0, 5, 11, 
     7, -2, 0, -2, 4, 0, 0, -7, 7, 2, -4, -4, -7, 8, 5, -7, 1, 2, 3, 0, -2, 0, 2, 4, 0, 
     12, 5, -2, -2, -3, 3, -5, 5, 9, 9, -2, 8, 5, 0, 5, 6, 7, -7, 2, -9, -1, 2, 6, 1, 
     -6, 0, -2, -2, 0, -11, -13, 1, -5, 4, 8, 5, 1, 0, 2, 3, 5, 0, 3, -4, 2, -4, 0, 1, 
     11, 0, -4, 2, 3, 3, 9, 5, 14, 8, -3, -3, 3, 4, 5, 4, -2, 4, 0, 1, 4, -6, 6, 4, -4, 
     5, 0, 7, 12, 1, 4, 3, -7, -8, 7, -2, -4, -4, -1, 0, 1, -3, 3, -3, -3, 8, 0, 1, 2, 
     3, 3, 6, 1, -3, -3, -5, 0, 4, 0, -7, 2, 7, 2, 3, 0, 0, -5, -6, -4, 5, 7, 0, -1, 5, 
     0, -4, 3, -1, -4, -8, 9, 0, 3, 4, 1, -5, 3, 0, -2, -7, 3, 2, -6, -9, -3, 3, -6, -6, 
     -5, 4, 0, -1, 6, 1, 7, -5, -4, 9, 2, 0, 1, -2, -6, 1, -6, 1, -1, -2, 2, 6, 5, 3, 
     1, -2, 4, 1, 3, -3, -3, -4, 13, -2, 14, -1, -3, 3, 6, -2, -1, 3, -9, 2, 1, 8, 1, 
     -4, 7, 2, 0, -2, 5, 6, 2, 4, -1, -2, 6, 0, 3, -6, 6, 2, 10, -5, -4, 1, 0, 0, 4, -4, 
     -7, 4, 2, 9, -6, 4, -2, 3, 4, 9, -4, 1, -7, -3, 6, -3, 1, -2, -2, 3, 3, -8, -1, -2, 
     -3, 6, -2, 12, 4, 3, 5, 1, -2, -6, 7, -1, 2, 5, 4, -9, -2, 6, 2, -2, -11, -3, -3, 
     -5, -1, 8, 6, 7, 0, 2, 6, 3, -14, 6, 11, 5, 1, 5, 0, 1, 2, -6, 4, 3, 4, -1, -1, -6, 
     1, -7, 0, 12, 9, 7, 4, -6, -4, 5, 4, -1, -2, 6, -6, -3, 6, 1, 0, 5, 5, 3, 6, 1, 1, 
     -3, 1, 4, 4, 2, 4, -6, 8, 4, -2, -6, 8, -5, 7, -1, -3, -2, 6, 5, 0, 3, 2, -5, 0, 
     2, -8, 3, 6, 4, -1, -2, -2, -3, 4, -1, 4, 3, 0, -1, 5, -9, -1, 6, 1, 0, 1, 1, 9, 
     6, 3, -2, -9, 10, 6, 5, 6, 7, -5, 1, 2, -1, 8, 0, 1, 3, -3, -6, -11, 14, 4, 5, 0, 
     -3, 2, 3, -5, 5, -8, 21, 2, 1, 3, 9, 10, 6, 7, -7, -6, 0, -5, -3, -11, -7, -8, 6, 
     0, 13, 8, 6, 7, 8, -3, -3, 0, -4, 0, 0, 2, -3, -6, -3, -3, 8, -5, 1, 9, 12, 1, -1, 
     3, -4, 1, 13, -1, 3, 8, -1, 4, 1, -2, -5, 2, -1, 2, -11, 0, -10, 2, -3, -10, -6, 
     -9, 15, 0, -5, 9, 2, 8, 2, 9, -2, -6, 2, -3, 7, 1, -4, 4, -6, -4, 16, 2, 0, -6, 0, 
     3, 1, -1, 3, 3, 4, 0, 4, 9, 7, -7, -2, 8, 6, 13, -6, 1, 7, 6, 10, -10, 3, 3, 13, 
     1, 12, 2, -1, 4, 4, 10, 4, 2, -2, 5, -2, 5, -4, -2, 9, 2, 3, -5, 12, 0, -2, 1, 11, 
     6, -7, -4, -3, 1, 1, -2, -5, -2, 6, 5, 4, 1, 4, -5, -7, 3, -3, 1, 1, -4, -1, 4, 1, 
     8, -4, 4, -2, -2, 5, -1, 1, 0, -3, 2, 8, 2, 1, 9, -4, 6, 5, 5, 6, -9, 0, -2, -1, 
     -5, 5, 1, 1, 1, 13, 6, 9, -8, 4, -13, -1, 4, 3, -5, -4, -5, -6, -6, 2, -7, 2, -7, 
     8, -4, -2, -4, -1, 0, 1, 4, 0, 7, -5, 10, 5, 0, 8, 0, 3, 7, -1, 0, 0, -1, 15, 4, 
     3, 8, -3, -1, 2, -1, 8, 0, 5, 13, -3, -3, -4, 7, -9, 3, 8, 14, -6, 7, 1, 2, -1, -5, 
     -1, 2, -4, -2, 7, 0, -1, -6, 1, 8, 5, 11, -3, 2, 2, -6, -1, -1, 4, 0, 2, -5, -4, 
     -4, -1, -1, 7, 7, -3, -2, 2, 1, -5, -5, -1, 8, 7, -2, -5, 6, -5, -4, 7, -1, 7, 8, 
     -2, -5, 0, 1, -6, 4, -6, 14, 2, 6, 6, 3, 3, -2, 5, 3, 0, -6, 5, -4, 2, 2, 8, -3, 
     3, -4, 5, 3, 1, 5, -2, 2, -12, -4, 3, 7, -4, 4, -4, 5, 10, 4, 4, -1, 0, -4, -2, -7, 
     3, -4, 3, -1, 0, -3, 1, -6, -1, 0, 2, 5, -6, 8, 12, -5, 2, 6, 4, 1, 9, 0, 3, 7, 1, 
     6, 4, 8, -3, 2, 1, 0, 10, 6, 3, 2, 12, 3, 7, 4, -1, 8, -1, -2, 2, -6, 0, -3, -1, 
     0, -1, 9, 8, 1, 3, 15, 5, -2, 2, 5, 0, 1, 0, -3, 0, -3, 2, 3, -2, 2, -3, 6, 0, -4, 
     10, -8, 7, 10, 4, 8, 3, 8, 9, 0, -2, 12, 5, 7, -7, 6, 5, 2, 2, -1, -6, 5, -1, 1, 
     -4, -1, -2, 12, 3, -1, 8, 2, -3, -2, 4, 1, 10, -5, -3, -5, 10, 1, 8, -2, 5, -8, -3, 
     2, 7, 5, -6, 12, -2, 4, -1, 3, -5, 2, -4, 3, -3, -3, -6, 3, 5, -3, 3, 2, 4, 0, 3, 
     3, -2, -2, -4, 1, 5, -3, -8, 2, -1, 2, -2, 9, 4, 1, 4, 3, 8, 5, -1, 4, -6, -5, -1, 
     -3, -5, 7, 10, -1, 7, 2, 0, -3, 9, 8, -5, 0, 5, 4, -2, 0, -12, 6, 5, 3, -2, -3, -1, 
     8, -5, 7, 11, 1, 15, 1, -7, 3, 2, 2, 0, -4, -11, 14, 2, 0, 1, -3, -8, 3, -6, -4, 
     -2, 3, 7, 2, 2, 10, 0, -2, -4, 3, -10, -4, 3, 8, -4, 1, 2, 2, 3, 9, 7, 6, 2, 5, 1, 
     5, -4, 1, 3, 0, 5, -3, 5, 0, -1, -2, -3, 4, -5, -7, 10, 12, -1, 0, -3, 4, 3, -4, 
     -2, 6, -4, 4, -6, 11, -10, 3, -5, 1, -4, 3, 6, -7, -5, 2, 11, -3, 5, -2, 2, 2, 6, 
     4, -1, -7, -8, -1, 5, 6, 2, -5, -5, -2, 6, -3, -2, 9, 1, 1, -4, 3, -1, -7, -8, -5, 
     -1, 7, 6, -2, -2, -6, 13, -1, -8, 4, 7, -7, 8, -1, 4, -2, 9, -2, 7, 5, 1, 3, 4, 0, 
     11, 6, 6, -1, 0, -1, -3, 0, 6, 6, 5, -4, -1, 7, 9, 6, -7, -2, 2, 10, -2, -2, -6, 
     -4, -1, -4, -8, -8, 7, 6, 3, 2, 5, 0, 11, -3, 1, 7, -3, -2, 3, -5, -1, 8, 0, 2, 10, 
     -2, 4, 1, -3, 3, 3, 6, 2, 5, 4, -4, 1, 3, -2, 5, -1, -8, 2, -5, -3, 14, 7, 4, -2, 
     0, 0, 2, 0, 2, 1, -3, 0, 1, 2, 7, 3, 6, 3, 5, -1, -5, -3, -6, 1, 7, 1, 14, 7, -3, 
     -3, 9, -1, 4, -1, -1, -6, 6, -1, 6, 3, 2, -3, 7, 4, -3, 3, 1, 5, 0, 6, 12, 3, 1, 
     1, 7, -4, -5, 2, 7, 2, -2, 7, 6, 7, -5, -1, -5, 4, 1, -5, -1, -10, 1, -2, -2, -6, 
     0, -9, -1, 4, 3, -2, -3, 7, 6, 1, -4, -4, 5, 14, -5, 3, 7, 5, 3, -7, 4, 0, 1, 0, 
     7, -3, 9, 1, 7, 9, 2, 0, -2, 7, -4, -2, 4, -2, 11, 3, -1, 1, 5, -6, -4, 6, -4, 7, 
     3, 1, -5, -6, 5, -2, -5, 1, -2, 3, 12, 0, -5, -3, 22, 1, -8, 7, -1, -7, -4, 11, -1, 
     0, 4, -4, -4, 8, -10, -3, 4, -3, -2, 7, 2, 3, -3, -3, 3, 0, -6, 3, 10, 2, 1, 5, -3, 
     -4, 4, 0, 3, -5, 1, -3, -1, 8, 0, -5, 2, 1, -7, 6, 9, -5, 9, 10, 6, 2, 1, -5, 0, 
     -4, 3, 0, -12, -2, 4, 4, 6, 5, 0, 5, -8, -2, -1, 5, -5, -1, 0, -10, -4, -2, 6, -3, 
     -5, 5, 6, 5, 3, -2, -3, 2, 5, -4, -4, -6, 0, -1, 7, -7, -5, 2, -1, -7, 1, 5, 1, 0, 
     1, 1, -8, -3, -2, 4, -2, 1, 3, -9, -2, 6, 2, 3, 6, 0, 0, -3, 1, 0, 6, -5, -5, 4, 
     -4, 3, -4, -8, 3, -3, 12, -3, -3, 6, 0, 12, 3, 4, -7, 2, -2, 6, 9, -3, 6, -6, 7, 
     8, 7, -8, 15, 4, -2, -8, 1, -4, 5, 4, 2, 10, 2, 9, 1, 6, -1, -4, 2, -1, 9, 8, 0, 
     4, 0, -2, 2, 0, 2, 6, -9, -4, -3, 5, 5, -2, -2, 8, 8, 3, -7, 0, 4, 9, 1, -1, -10, 
     14, 7, 1, -4, 0, -1, -5, 2, -3, 3, -1, -7, 13, 0, -2, -8, 5, -2, -2, 2, -6, 6, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 
     -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15), .Dim = c(4096L, 
     2L), .Dimnames = list(NULL, c("edges", "offset(nodematch.race)")), mcpar = c(16384, 
     4209664, 1024), class = "mcmc"), iterations = 3L, MCMCtheta = c(edges = -3.10465526876021, 
     `offset(nodematch.race)` = -Inf), loglikelihood = structure(0.0322081718149874, .Dim = c(1L, 
     1L)), gradient = c(-0.0247691001350905, NA), hessian = structure(c(-25.4551124060401, 
     NA, NA, NA), .Dim = c(2L, 2L), .Dimnames = list(c("edges", "offset(nodematch.race)"
     ), c("edges", "offset(nodematch.race)"))), covar = structure(c(0.0392848392907789, 
     NA, NA, NA), .Dim = c(2L, 2L), .Dimnames = list(c("edges", "offset(nodematch.race)"
     ), c("edges", "offset(nodematch.race)"))), failure = FALSE, network = structure(list(
         mel = list(list(inl = 20L, outl = 2L, atl = list(na = FALSE)), list(inl = 38L, 
             outl = 2L, atl = list(na = FALSE)), list(inl = 38L, outl = 3L, atl = list(
             na = FALSE)), list(inl = 5L, outl = 4L, atl = list(na = FALSE)), list(inl = 28L, 
             outl = 4L, atl = list(na = FALSE)), list(inl = 34L, outl = 5L, atl = list(
             na = FALSE)), list(inl = 43L, outl = 5L, atl = list(na = FALSE)), list(inl = 24L, 
             outl = 9L, atl = list(na = FALSE)), list(inl = 37L, outl = 12L, atl = list(
             na = FALSE)), list(inl = 43L, outl = 13L, atl = list(na = FALSE)), list(inl = 23L, 
             outl = 15L, atl = list(na = FALSE)), list(inl = 32L, outl = 15L, atl = list(
             na = FALSE)), list(inl = 24L, outl = 17L, atl = list(na = FALSE)), list(inl = 28L, 
             outl = 20L, atl = list(na = FALSE)), list(inl = 29L, outl = 22L, atl = list(
             na = FALSE)), list(inl = 33L, outl = 22L, atl = list(na = FALSE)), list(inl = 41L, 
             outl = 24L, atl = list(na = FALSE)), list(inl = 36L, outl = 25L, atl = list(
             na = FALSE)), list(inl = 37L, outl = 25L, atl = list(na = FALSE)), list(inl = 31L, 
             outl = 26L, atl = list(na = FALSE)), list(inl = 50L, outl = 26L, atl = list(
             na = FALSE)), list(inl = 49L, outl = 30L, atl = list(na = FALSE)), list(inl = 36L, 
             outl = 31L, atl = list(na = FALSE)), list(inl = 43L, outl = 42L, atl = list(
             na = FALSE)), list(inl = 49L, outl = 43L, atl = list(na = FALSE))), gal = list(
             n = 50, mnext = 26L, directed = FALSE, hyper = FALSE, loops = FALSE, multiple = FALSE, 
             bipartite = FALSE), val = list(list(na = FALSE, vertex.names = 1L, race = 0L), 
             list(na = FALSE, vertex.names = 2L, race = 0L), list(na = FALSE, vertex.names = 3L, 
                 race = 1L), list(na = FALSE, vertex.names = 4L, race = 1L), list(na = FALSE, 
                 vertex.names = 5L, race = 1L), list(na = FALSE, vertex.names = 6L, race = 0L), 
             list(na = FALSE, vertex.names = 7L, race = 1L), list(na = FALSE, vertex.names = 8L, 
                 race = 1L), list(na = FALSE, vertex.names = 9L, race = 0L), list(na = FALSE, 
                 vertex.names = 10L, race = 1L), list(na = FALSE, vertex.names = 11L, 
                 race = 1L), list(na = FALSE, vertex.names = 12L, race = 1L), list(na = FALSE, 
                 vertex.names = 13L, race = 1L), list(na = FALSE, vertex.names = 14L, 
                 race = 1L), list(na = FALSE, vertex.names = 15L, race = 1L), list(na = FALSE, 
                 vertex.names = 16L, race = 1L), list(na = FALSE, vertex.names = 17L, 
                 race = 0L), list(na = FALSE, vertex.names = 18L, race = 0L), list(na = FALSE, 
                 vertex.names = 19L, race = 0L), list(na = FALSE, vertex.names = 20L, 
                 race = 0L), list(na = FALSE, vertex.names = 21L, race = 1L), list(na = FALSE, 
                 vertex.names = 22L, race = 0L), list(na = FALSE, vertex.names = 23L, 
                 race = 0L), list(na = FALSE, vertex.names = 24L, race = 1L), list(na = FALSE, 
                 vertex.names = 25L, race = 1L), list(na = FALSE, vertex.names = 26L, 
                 race = 1L), list(na = FALSE, vertex.names = 27L, race = 1L), list(na = FALSE, 
                 vertex.names = 28L, race = 1L), list(na = FALSE, vertex.names = 29L, 
                 race = 0L), list(na = FALSE, vertex.names = 30L, race = 0L), list(na = FALSE, 
                 vertex.names = 31L, race = 0L), list(na = FALSE, vertex.names = 32L, 
                 race = 0L), list(na = FALSE, vertex.names = 33L, race = 0L), list(na = FALSE, 
                 vertex.names = 34L, race = 1L), list(na = FALSE, vertex.names = 35L, 
                 race = 0L), list(na = FALSE, vertex.names = 36L, race = 1L), list(na = FALSE, 
                 vertex.names = 37L, race = 1L), list(na = FALSE, vertex.names = 38L, 
                 race = 0L), list(na = FALSE, vertex.names = 39L, race = 1L), list(na = FALSE, 
                 vertex.names = 40L, race = 0L), list(na = FALSE, vertex.names = 41L, 
                 race = 1L), list(na = FALSE, vertex.names = 42L, race = 0L), list(na = FALSE, 
                 vertex.names = 43L, race = 1L), list(na = FALSE, vertex.names = 44L, 
                 race = 0L), list(na = FALSE, vertex.names = 45L, race = 0L), list(na = FALSE, 
                 vertex.names = 46L, race = 1L), list(na = FALSE, vertex.names = 47L, 
                 race = 1L), list(na = FALSE, vertex.names = 48L, race = 1L), list(na = FALSE, 
                 vertex.names = 49L, race = 1L), list(na = FALSE, vertex.names = 50L, 
                 race = 1L)), iel = list(integer(0), integer(0), integer(0), integer(0), 
             4L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), 1L, integer(0), integer(0), 11L, c(8L, 13L), integer(0), integer(0), 
             integer(0), c(5L, 14L), 15L, integer(0), 20L, 12L, 16L, 6L, integer(0), c(18L, 
             23L), c(9L, 19L), 2:3, integer(0), integer(0), 17L, integer(0), c(7L, 10L, 
             24L), integer(0), integer(0), integer(0), integer(0), integer(0), c(22L, 
             25L), 21L), oel = list(integer(0), 2:1, 3L, 5:4, 7:6, integer(0), integer(0), 
             integer(0), 8L, integer(0), integer(0), 9L, 10L, integer(0), 12:11, integer(0), 
             13L, integer(0), integer(0), 14L, integer(0), 16:15, integer(0), 17L, 19:18, 
             21:20, integer(0), integer(0), integer(0), 22L, 23L, integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), 24L, 25L, integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0))), class = "network"), newnetworks = list(structure(list(
         mel = list(list(inl = 5L, outl = 1L, atl = list(na = FALSE)), list(inl = 4L, 
             outl = 2L, atl = list(na = FALSE)), list(inl = 47L, outl = 2L, atl = list(
             na = FALSE)), list(inl = 6L, outl = 3L, atl = list(na = FALSE)), list(inl = 9L, 
             outl = 5L, atl = list(na = FALSE)), list(inl = 31L, outl = 5L, atl = list(
             na = FALSE)), list(inl = 25L, outl = 6L, atl = list(na = FALSE)), list(inl = 50L, 
             outl = 6L, atl = list(na = FALSE)), list(inl = 23L, outl = 7L, atl = list(
             na = FALSE)), list(inl = 32L, outl = 7L, atl = list(na = FALSE)), list(inl = 44L, 
             outl = 7L, atl = list(na = FALSE)), list(inl = 22L, outl = 8L, atl = list(
             na = FALSE)), list(inl = 16L, outl = 9L, atl = list(na = FALSE)), list(inl = 28L, 
             outl = 9L, atl = list(na = FALSE)), list(inl = 39L, outl = 9L, atl = list(
             na = FALSE)), list(inl = 43L, outl = 9L, atl = list(na = FALSE)), list(inl = 17L, 
             outl = 10L, atl = list(na = FALSE)), list(inl = 20L, outl = 10L, atl = list(
             na = FALSE)), list(inl = 44L, outl = 10L, atl = list(na = FALSE)), list(inl = 44L, 
             outl = 11L, atl = list(na = FALSE)), list(inl = 18L, outl = 12L, atl = list(
             na = FALSE)), list(inl = 38L, outl = 16L, atl = list(na = FALSE)), list(inl = 47L, 
             outl = 18L, atl = list(na = FALSE)), list(inl = 39L, outl = 19L, atl = list(
             na = FALSE)), list(inl = 28L, outl = 20L, atl = list(na = FALSE)), list(inl = 42L, 
             outl = 21L, atl = list(na = FALSE)), list(inl = 32L, outl = 27L, atl = list(
             na = FALSE)), list(inl = 45L, outl = 27L, atl = list(na = FALSE)), list(inl = 50L, 
             outl = 29L, atl = list(na = FALSE)), list(inl = 46L, outl = 35L, atl = list(
             na = FALSE)), list(inl = 40L, outl = 36L, atl = list(na = FALSE))), gal = list(
             n = 50, mnext = 32L, directed = FALSE, hyper = FALSE, loops = FALSE, multiple = FALSE, 
             bipartite = FALSE), val = list(list(na = FALSE, vertex.names = 1L, race = 0L), 
             list(na = FALSE, vertex.names = 2L, race = 0L), list(na = FALSE, vertex.names = 3L, 
                 race = 1L), list(na = FALSE, vertex.names = 4L, race = 1L), list(na = FALSE, 
                 vertex.names = 5L, race = 1L), list(na = FALSE, vertex.names = 6L, race = 0L), 
             list(na = FALSE, vertex.names = 7L, race = 1L), list(na = FALSE, vertex.names = 8L, 
                 race = 1L), list(na = FALSE, vertex.names = 9L, race = 0L), list(na = FALSE, 
                 vertex.names = 10L, race = 1L), list(na = FALSE, vertex.names = 11L, 
                 race = 1L), list(na = FALSE, vertex.names = 12L, race = 1L), list(na = FALSE, 
                 vertex.names = 13L, race = 1L), list(na = FALSE, vertex.names = 14L, 
                 race = 1L), list(na = FALSE, vertex.names = 15L, race = 1L), list(na = FALSE, 
                 vertex.names = 16L, race = 1L), list(na = FALSE, vertex.names = 17L, 
                 race = 0L), list(na = FALSE, vertex.names = 18L, race = 0L), list(na = FALSE, 
                 vertex.names = 19L, race = 0L), list(na = FALSE, vertex.names = 20L, 
                 race = 0L), list(na = FALSE, vertex.names = 21L, race = 1L), list(na = FALSE, 
                 vertex.names = 22L, race = 0L), list(na = FALSE, vertex.names = 23L, 
                 race = 0L), list(na = FALSE, vertex.names = 24L, race = 1L), list(na = FALSE, 
                 vertex.names = 25L, race = 1L), list(na = FALSE, vertex.names = 26L, 
                 race = 1L), list(na = FALSE, vertex.names = 27L, race = 1L), list(na = FALSE, 
                 vertex.names = 28L, race = 1L), list(na = FALSE, vertex.names = 29L, 
                 race = 0L), list(na = FALSE, vertex.names = 30L, race = 0L), list(na = FALSE, 
                 vertex.names = 31L, race = 0L), list(na = FALSE, vertex.names = 32L, 
                 race = 0L), list(na = FALSE, vertex.names = 33L, race = 0L), list(na = FALSE, 
                 vertex.names = 34L, race = 1L), list(na = FALSE, vertex.names = 35L, 
                 race = 0L), list(na = FALSE, vertex.names = 36L, race = 1L), list(na = FALSE, 
                 vertex.names = 37L, race = 1L), list(na = FALSE, vertex.names = 38L, 
                 race = 0L), list(na = FALSE, vertex.names = 39L, race = 1L), list(na = FALSE, 
                 vertex.names = 40L, race = 0L), list(na = FALSE, vertex.names = 41L, 
                 race = 1L), list(na = FALSE, vertex.names = 42L, race = 0L), list(na = FALSE, 
                 vertex.names = 43L, race = 1L), list(na = FALSE, vertex.names = 44L, 
                 race = 0L), list(na = FALSE, vertex.names = 45L, race = 0L), list(na = FALSE, 
                 vertex.names = 46L, race = 1L), list(na = FALSE, vertex.names = 47L, 
                 race = 1L), list(na = FALSE, vertex.names = 48L, race = 1L), list(na = FALSE, 
                 vertex.names = 49L, race = 1L), list(na = FALSE, vertex.names = 50L, 
                 race = 1L)), iel = list(integer(0), integer(0), integer(0), 2L, 1L, 4L, 
             integer(0), integer(0), 5L, integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), 13L, 17L, 21L, integer(0), 18L, integer(0), 12L, 
             9L, integer(0), 7L, integer(0), integer(0), c(14L, 25L), integer(0), integer(0), 
             6L, c(10L, 27L), integer(0), integer(0), integer(0), integer(0), integer(0), 
             22L, c(15L, 24L), 31L, integer(0), 26L, 16L, c(11L, 19L, 20L), 28L, 30L, 
             c(3L, 23L), integer(0), integer(0), c(8L, 29L)), oel = list(1L, 3:2, 4L, 
             integer(0), 6:5, 8:7, 11:9, 12L, 16:13, 19:17, 20L, 21L, integer(0), integer(0), 
             integer(0), 22L, integer(0), 23L, 24L, 25L, 26L, integer(0), integer(0), 
             integer(0), integer(0), integer(0), 28:27, integer(0), 29L, integer(0), integer(0), 
             integer(0), integer(0), integer(0), 30L, 31L, integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0))), class = "network")), newnetwork = structure(list(
         mel = list(list(inl = 5L, outl = 1L, atl = list(na = FALSE)), list(inl = 4L, 
             outl = 2L, atl = list(na = FALSE)), list(inl = 47L, outl = 2L, atl = list(
             na = FALSE)), list(inl = 6L, outl = 3L, atl = list(na = FALSE)), list(inl = 9L, 
             outl = 5L, atl = list(na = FALSE)), list(inl = 31L, outl = 5L, atl = list(
             na = FALSE)), list(inl = 25L, outl = 6L, atl = list(na = FALSE)), list(inl = 50L, 
             outl = 6L, atl = list(na = FALSE)), list(inl = 23L, outl = 7L, atl = list(
             na = FALSE)), list(inl = 32L, outl = 7L, atl = list(na = FALSE)), list(inl = 44L, 
             outl = 7L, atl = list(na = FALSE)), list(inl = 22L, outl = 8L, atl = list(
             na = FALSE)), list(inl = 16L, outl = 9L, atl = list(na = FALSE)), list(inl = 28L, 
             outl = 9L, atl = list(na = FALSE)), list(inl = 39L, outl = 9L, atl = list(
             na = FALSE)), list(inl = 43L, outl = 9L, atl = list(na = FALSE)), list(inl = 17L, 
             outl = 10L, atl = list(na = FALSE)), list(inl = 20L, outl = 10L, atl = list(
             na = FALSE)), list(inl = 44L, outl = 10L, atl = list(na = FALSE)), list(inl = 44L, 
             outl = 11L, atl = list(na = FALSE)), list(inl = 18L, outl = 12L, atl = list(
             na = FALSE)), list(inl = 38L, outl = 16L, atl = list(na = FALSE)), list(inl = 47L, 
             outl = 18L, atl = list(na = FALSE)), list(inl = 39L, outl = 19L, atl = list(
             na = FALSE)), list(inl = 28L, outl = 20L, atl = list(na = FALSE)), list(inl = 42L, 
             outl = 21L, atl = list(na = FALSE)), list(inl = 32L, outl = 27L, atl = list(
             na = FALSE)), list(inl = 45L, outl = 27L, atl = list(na = FALSE)), list(inl = 50L, 
             outl = 29L, atl = list(na = FALSE)), list(inl = 46L, outl = 35L, atl = list(
             na = FALSE)), list(inl = 40L, outl = 36L, atl = list(na = FALSE))), gal = list(
             n = 50, mnext = 32L, directed = FALSE, hyper = FALSE, loops = FALSE, multiple = FALSE, 
             bipartite = FALSE), val = list(list(na = FALSE, vertex.names = 1L, race = 0L), 
             list(na = FALSE, vertex.names = 2L, race = 0L), list(na = FALSE, vertex.names = 3L, 
                 race = 1L), list(na = FALSE, vertex.names = 4L, race = 1L), list(na = FALSE, 
                 vertex.names = 5L, race = 1L), list(na = FALSE, vertex.names = 6L, race = 0L), 
             list(na = FALSE, vertex.names = 7L, race = 1L), list(na = FALSE, vertex.names = 8L, 
                 race = 1L), list(na = FALSE, vertex.names = 9L, race = 0L), list(na = FALSE, 
                 vertex.names = 10L, race = 1L), list(na = FALSE, vertex.names = 11L, 
                 race = 1L), list(na = FALSE, vertex.names = 12L, race = 1L), list(na = FALSE, 
                 vertex.names = 13L, race = 1L), list(na = FALSE, vertex.names = 14L, 
                 race = 1L), list(na = FALSE, vertex.names = 15L, race = 1L), list(na = FALSE, 
                 vertex.names = 16L, race = 1L), list(na = FALSE, vertex.names = 17L, 
                 race = 0L), list(na = FALSE, vertex.names = 18L, race = 0L), list(na = FALSE, 
                 vertex.names = 19L, race = 0L), list(na = FALSE, vertex.names = 20L, 
                 race = 0L), list(na = FALSE, vertex.names = 21L, race = 1L), list(na = FALSE, 
                 vertex.names = 22L, race = 0L), list(na = FALSE, vertex.names = 23L, 
                 race = 0L), list(na = FALSE, vertex.names = 24L, race = 1L), list(na = FALSE, 
                 vertex.names = 25L, race = 1L), list(na = FALSE, vertex.names = 26L, 
                 race = 1L), list(na = FALSE, vertex.names = 27L, race = 1L), list(na = FALSE, 
                 vertex.names = 28L, race = 1L), list(na = FALSE, vertex.names = 29L, 
                 race = 0L), list(na = FALSE, vertex.names = 30L, race = 0L), list(na = FALSE, 
                 vertex.names = 31L, race = 0L), list(na = FALSE, vertex.names = 32L, 
                 race = 0L), list(na = FALSE, vertex.names = 33L, race = 0L), list(na = FALSE, 
                 vertex.names = 34L, race = 1L), list(na = FALSE, vertex.names = 35L, 
                 race = 0L), list(na = FALSE, vertex.names = 36L, race = 1L), list(na = FALSE, 
                 vertex.names = 37L, race = 1L), list(na = FALSE, vertex.names = 38L, 
                 race = 0L), list(na = FALSE, vertex.names = 39L, race = 1L), list(na = FALSE, 
                 vertex.names = 40L, race = 0L), list(na = FALSE, vertex.names = 41L, 
                 race = 1L), list(na = FALSE, vertex.names = 42L, race = 0L), list(na = FALSE, 
                 vertex.names = 43L, race = 1L), list(na = FALSE, vertex.names = 44L, 
                 race = 0L), list(na = FALSE, vertex.names = 45L, race = 0L), list(na = FALSE, 
                 vertex.names = 46L, race = 1L), list(na = FALSE, vertex.names = 47L, 
                 race = 1L), list(na = FALSE, vertex.names = 48L, race = 1L), list(na = FALSE, 
                 vertex.names = 49L, race = 1L), list(na = FALSE, vertex.names = 50L, 
                 race = 1L)), iel = list(integer(0), integer(0), integer(0), 2L, 1L, 4L, 
             integer(0), integer(0), 5L, integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), 13L, 17L, 21L, integer(0), 18L, integer(0), 12L, 
             9L, integer(0), 7L, integer(0), integer(0), c(14L, 25L), integer(0), integer(0), 
             6L, c(10L, 27L), integer(0), integer(0), integer(0), integer(0), integer(0), 
             22L, c(15L, 24L), 31L, integer(0), 26L, 16L, c(11L, 19L, 20L), 28L, 30L, 
             c(3L, 23L), integer(0), integer(0), c(8L, 29L)), oel = list(1L, 3:2, 4L, 
             integer(0), 6:5, 8:7, 11:9, 12L, 16:13, 19:17, 20L, 21L, integer(0), integer(0), 
             integer(0), 22L, integer(0), 23L, 24L, 25L, 26L, integer(0), integer(0), 
             integer(0), integer(0), integer(0), 28:27, integer(0), 29L, integer(0), integer(0), 
             integer(0), integer(0), integer(0), 30L, 31L, integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0))), class = "network"), coef.init = c(edges = -4.09267645883374, 
     `offset(nodematch.race)` = -Inf), est.cov = structure(c(1.01253353163491e-05, 0, 
     0, 0), .Dim = c(2L, 2L), .Dimnames = list(c("edges", "offset(nodematch.race)"), c("edges", 
     "offset(nodematch.race)"))), coef.hist = structure(c(-4.09267645883374, -2.78011430662444, 
     -3.10465526876021, -3.15496019602587, -Inf, -Inf, -Inf, -Inf), .Dim = c(4L, 2L), .Dimnames = list(
         c("init", "mcmc.init", "mcmc.init", "mcmc.init"), c("edges", "offset(nodematch.race)"
         ))), stats.hist = structure(c(-13.290794413895, 10.70703125, 1.280517578125, 
     -13.3220178933324, -15, -15), .Dim = 3:2, .Dimnames = list(NULL, c("edges", "offset(nodematch.race)"
     ))), steplen.hist = c(0.888134526222163, 1, 1), control = structure(list(drop = TRUE, 
         init = c(edges = -4.09267645883374, `offset(nodematch.race)` = -Inf), init.method = "MPLE", 
         main.method = "MCMLE", force.main = FALSE, main.hessian = TRUE, checkpoint = NULL, 
         resume = NULL, MPLE.max.dyad.types = 1e+06, MPLE.samplesize = 50000, MPLE.type = "glm", 
         MCMC.prop.weights = "default", MCMC.prop.args = list(), MCMC.interval = 1024, 
         MCMC.burnin = 16384, MCMC.samplesize = 4096, MCMC.effectiveSize.damp = 10, MCMC.effectiveSize.maxruns = 1000, 
         MCMC.effectiveSize.base = 0.5, MCMC.effectiveSize.points = 5, MCMC.effectiveSize.order = 1, 
         MCMC.return.stats = TRUE, MCMC.runtime.traceplot = FALSE, MCMC.init.maxedges = 10000, 
         MCMC.max.maxedges = 10000, MCMC.addto.se = TRUE, MCMC.compress = FALSE, MCMC.packagenames = NULL, 
         SAN.maxit = 4, SAN.nsteps.times = 8, SAN.control = structure(list(SAN.maxit = 4, 
             SAN.tau = 1, SAN.invcov = NULL, SAN.invcov.diag = FALSE, SAN.nsteps.alloc = function (nsim) 
             2^seq_len(nsim), SAN.nsteps = 131072, SAN.samplesize = 1024, SAN.init.maxedges = 20000, 
             SAN.max.maxedges = Inf, SAN.prop.weights = "default", SAN.prop.args = list(), 
             SAN.packagenames = NULL, term.options = NULL, seed = NULL, parallel = 0, 
             parallel.type = NULL, parallel.version.check = TRUE), class = c("control.san", 
         "control.list", "list")), MCMLE.termination = "Hummel", MCMLE.maxit = 20, MCMLE.conv.min.pval = 0.5, 
         MCMLE.NR.maxit = 100, MCMLE.NR.reltol = 1.49011611938477e-08, obs.MCMC.samplesize = 1024, 
         obs.MCMC.interval = 1024, obs.MCMC.burnin = 16384, obs.MCMC.burnin.min = 1638.4, 
         obs.MCMC.prop.weights = "default", obs.MCMC.prop.args = list(), obs.MCMC.impute.min_informative = function (nw) 
         network.size(nw)/4, obs.MCMC.impute.default_density = function (nw) 
         2/network.size(nw), MCMLE.check.degeneracy = FALSE, MCMLE.MCMC.precision = 0.005, 
         MCMLE.MCMC.max.ESS.frac = 0.1, MCMLE.metric = "lognormal", MCMLE.method = "BFGS", 
         MCMLE.trustregion = 20, MCMLE.dampening = FALSE, MCMLE.dampening.min.ess = 20, 
         MCMLE.dampening.level = 0.1, MCMLE.steplength.margin = 0.05, MCMLE.steplength = 1, 
         MCMLE.adaptive.trustregion = 3, MCMLE.sequential = TRUE, MCMLE.density.guard.min = 10000, 
         MCMLE.density.guard = 20.0855369231877, MCMLE.effectiveSize = NULL, MCMLE.last.boost = 4, 
         MCMLE.Hummel.esteq = TRUE, MCMLE.Hummel.miss.sample = 100, MCMLE.Hummel.maxit = 25, 
         MCMLE.steplength.min = 1e-04, MCMLE.effectiveSize.interval_drop = 2, MCMLE.save_intermediates = NULL, 
         SA.phase1_n = NULL, SA.initial_gain = NULL, SA.nsubphases = 4, SA.niterations = NULL, 
         SA.phase3_n = NULL, SA.trustregion = 0.5, RM.phase1n_base = 7, RM.phase2n_base = 100, 
         RM.phase2sub = 7, RM.init_gain = 0.5, RM.phase3n = 500, Step.MCMC.samplesize = 100, 
         Step.maxit = 50, Step.gridsize = 100, CD.nsteps = 8, CD.multiplicity = 1, CD.nsteps.obs = 128, 
         CD.multiplicity.obs = 1, CD.maxit = 60, CD.conv.min.pval = 0.5, CD.NR.maxit = 100, 
         CD.NR.reltol = 1.49011611938477e-08, CD.metric = "naive", CD.method = "BFGS", 
         CD.trustregion = 20, CD.dampening = FALSE, CD.dampening.min.ess = 20, CD.dampening.level = 0.1, 
         CD.steplength.margin = 0.5, CD.steplength = 1, CD.adaptive.trustregion = 3, CD.adaptive.epsilon = 0.01, 
         CD.Hummel.esteq = TRUE, CD.Hummel.miss.sample = 100, CD.Hummel.maxit = 25, CD.steplength.min = 1e-04, 
         loglik.control = structure(list(nsteps = 20, MCMC.burnin = NULL, MCMC.interval = NULL, 
             MCMC.samplesize = NULL, obs.MCMC.samplesize = NULL, obs.MCMC.interval = NULL, 
             obs.MCMC.burnin = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
             warn.dyads = NULL, MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, term.options = NULL, 
             seed = NULL, parallel = NULL, parallel.type = NULL, parallel.version.check = TRUE), class = c("control.logLik.ergm", 
         "control.list", "list")), term.options = NULL, seed = NULL, parallel = 0, parallel.type = NULL, 
         parallel.version.check = TRUE, MCMC.base.samplesize = 1024, obs.MCMC.base.samplesize = 1024), class = c("control.ergm", 
     "control.list", "list")), etamap = list(canonical = 1:2, offsetmap = c(FALSE, TRUE
     ), offset = c(FALSE, TRUE), offsettheta = c(FALSE, TRUE), curved = list(), etalength = 2), 
         ergm_version = structure(list(c(3L, 10L, 1L)), class = c("package_version", "numeric_version"
         )), MPLE_is_MLE = TRUE, formula = TARGET_STATS ~ edges + offset(nodematch("race")), 
         target.stats = c(edges = 25, `offset(nodematch.race)` = NA), target.esteq = structure(-25, .Dim = c(1L, 
         1L), .Dimnames = list(NULL, "edges")), constraints = ~., reference = ~Bernoulli, 
         estimate = "MLE", offset = c(FALSE, TRUE), drop = c(0, 0), estimable = c(TRUE, 
         TRUE), null.lik = structure(-849.105296185933, class = "logLik", df = 0, nobs = 1225)), class = "ergm"), 
         formation = ~edges + offset(nodematch("race")), target.stats = 25, target.stats.names = "edges", 
         coef.form = c(edges = -5.35218477336209, `offset(nodematch.race)` = -Inf), coef.form.crude = c(edges = -3.15496019602587, 
         `offset(nodematch.race)` = -Inf), coef.diss = structure(list(dissolution = ~offset(edges), 
             duration = 10, coef.crude = 2.19722457733622, coef.adj = 2.19722457733622, 
             d.rate = 0, model.type = "homog"), class = "disscoef"), constraints = ~., 
         edapprox = TRUE), class = "netest"), structure(list(inf.prob = 0.3, act.rate = 0.5, 
         vital = FALSE), class = c("param.net", "list")), structure(list(i.num = 10), class = c("init.net", 
     "list")), structure(list(type = "SI", nsteps = 5, start = 1, nsims = 2, ncores = 1, 
         rec.rand = TRUE, a.rand = TRUE, d.rand = TRUE, tea.status = TRUE, use.pids = TRUE, 
         initialize.FUN = function (x, param, init, control, s) 
         {
             if (control$start == 1) {
                 dat <- list()
                 dat$param <- param
                 dat$init <- init
                 dat$control <- control
                 dat$attr <- list()
                 dat$stats <- list()
                 dat$temp <- list()
                 nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
                 modes <- ifelse(nw %n% "bipartite", 2, 1)
                 if (control$depend == TRUE) {
                     if (class(x$fit) == "stergm") {
                       nw <- network.collapse(nw, at = 1)
                     }
                     nw <- sim_nets(x, nw, nsteps = 1, control)
                 }
                 if (control$depend == FALSE) {
                     nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
                 }
                 nw <- activate.vertices(nw, onset = 1, terminus = Inf)
                 dat$nw <- nw
                 dat$nwparam <- list(x[-which(names(x) == "fit")])
                 dat$param$modes <- modes
                 if (control$use.pids == TRUE) {
                     dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
                 }
                 form <- get_nwparam(dat)$formation
                 fterms <- get_formula_term_attr(form, nw)
                 dat <- copy_toall_attr(dat, at = 1, fterms)
                 dat$temp$fterms <- fterms
                 dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
                 dat <- init_status.net(dat)
                 dat <- get_prev.net(dat, at = 1)
             }
             else {
                 dat <- list()
                 dat$nw <- x$network[[s]]
                 dat$param <- x$param
                 dat$control <- control
                 dat$nwparam <- x$nwparam
                 dat$epi <- sapply(x$epi, function(var) var[s])
                 names(dat$epi) <- names(x$epi)
                 dat$attr <- x$attr[[s]]
                 dat$stats <- sapply(x$stats, function(var) var[[s]])
                 dat$temp <- list()
             }
             return(dat)
         }, departures.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             d.rand <- dat$control$d.rand
             nDepartures.sus <- nDeparturesM2.sus <- 0
             idsElig.sus <- which(dat$attr$active == 1 & dat$attr$status == "s")
             nElig.sus <- length(idsElig.sus)
             if (nElig.sus > 0) {
                 mElig.sus <- mode[idsElig.sus]
                 rates.sus <- c(dat$param$ds.rate, dat$param$ds.rate.m2)
                 ratesElig.sus <- rates.sus[mElig.sus]
                 if (d.rand == TRUE) {
                     vecDepartures.sus <- which(rbinom(nElig.sus, 1, ratesElig.sus) == 
                       1)
                     if (length(vecDepartures.sus) > 0) {
                       idsDpt.sus <- idsElig.sus[vecDepartures.sus]
                       nDepartures.sus <- sum(mode[idsDpt.sus] == 1)
                       nDeparturesM2.sus <- sum(mode[idsDpt.sus] == 2)
                       dat$attr$active[idsDpt.sus] <- 0
                       dat$attr$exitTime[idsDpt.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.sus, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.sus <- idsDptM2.sus <- NULL
                     nDepartures.sus <- min(round(sum(ratesElig.sus[mElig.sus == 1])), 
                       sum(mElig.sus == 1))
                     idsDpt.sus <- ssample(idsElig.sus[mElig.sus == 1], nDepartures.sus)
                     if (modes == 2) {
                       nDeparturesM2.sus <- min(round(sum(ratesElig.sus[mElig.sus == 2])), 
                         sum(mElig.sus == 2))
                       idsDptM2.sus <- ssample(idsElig.sus[mElig.sus == 2], nDeparturesM2.sus)
                     }
                     totDpt.sus <- nDepartures.sus + nDeparturesM2.sus
                     if (totDpt.sus > 0) {
                       idsDptAll.sus <- c(idsDpt.sus, idsDptM2.sus)
                       dat$attr$active[idsDptAll.sus] <- 0
                       dat$attr$exitTime[idsDptAll.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.sus, deactivate.edges = TRUE)
                     }
                 }
             }
             nDepartures.inf <- nDeparturesM2.inf <- 0
             idsElig.inf <- which(dat$attr$active == 1 & dat$attr$status == "i")
             nElig.inf <- length(idsElig.inf)
             if (nElig.inf > 0) {
                 mElig.inf <- mode[idsElig.inf]
                 rates.inf <- c(dat$param$di.rate, dat$param$di.rate.m2)
                 ratesElig.inf <- rates.inf[mElig.inf]
                 if (d.rand == TRUE) {
                     vecDepartures.inf <- which(rbinom(nElig.inf, 1, ratesElig.inf) == 
                       1)
                     if (length(vecDepartures.inf) > 0) {
                       idsDpt.inf <- idsElig.inf[vecDepartures.inf]
                       nDepartures.inf <- sum(mode[idsDpt.inf] == 1)
                       nDeparturesM2.inf <- sum(mode[idsDpt.inf] == 2)
                       dat$attr$active[idsDpt.inf] <- 0
                       dat$attr$exitTime[idsDpt.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.inf, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.inf <- idsDptM2.inf <- NULL
                     nDepartures.inf <- min(round(sum(ratesElig.inf[mElig.inf == 1])), 
                       sum(mElig.inf == 1))
                     idsDpt.inf <- ssample(idsElig.inf[mElig.inf == 1], nDepartures.inf)
                     if (modes == 2) {
                       nDeparturesM2.inf <- min(round(sum(ratesElig.inf[mElig.inf == 2])), 
                         sum(mElig.inf == 2))
                       idsDptM2.inf <- ssample(idsElig.inf[mElig.inf == 2], nDeparturesM2.inf)
                     }
                     totDpt.inf <- nDepartures.inf + nDeparturesM2.inf
                     if (totDpt.inf > 0) {
                       idsDptAll.inf <- c(idsDpt.inf, idsDptM2.inf)
                       dat$attr$active[idsDptAll.inf] <- 0
                       dat$attr$exitTime[idsDptAll.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.inf, deactivate.edges = TRUE)
                     }
                 }
             }
             if (type == "SIR") {
                 nDepartures.rec <- nDeparturesM2.rec <- 0
                 idsElig.rec <- which(dat$attr$active == 1 & dat$attr$status == "r")
                 nElig.rec <- length(idsElig.rec)
                 if (nElig.rec > 0) {
                     mElig.rec <- mode[idsElig.rec]
                     rates.rec <- c(dat$param$dr.rate, dat$param$dr.rate.m2)
                     ratesElig.rec <- rates.rec[mElig.rec]
                     if (d.rand == TRUE) {
                       vecDepartures.rec <- which(rbinom(nElig.rec, 1, ratesElig.rec) == 
                         1)
                       if (length(vecDepartures.rec) > 0) {
                         idsDpt.rec <- idsElig.rec[vecDepartures.rec]
                         nDepartures.rec <- sum(mode[idsDpt.rec] == 1)
                         nDeparturesM2.rec <- sum(mode[idsDpt.rec] == 2)
                         dat$attr$active[idsDpt.rec] <- 0
                         dat$attr$exitTime[idsDpt.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.rec, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.rec <- idsDptM2.rec <- NULL
                       nDepartures.rec <- min(round(sum(ratesElig.rec[mElig.rec == 1])), 
                         sum(mElig.rec == 1))
                       idsDpt.rec <- ssample(idsElig.rec[mElig.rec == 1], nDepartures.rec)
                       if (modes == 2) {
                         nDeparturesM2.rec <- min(round(sum(ratesElig.rec[mElig.rec == 
                           2])), sum(mElig.rec == 2))
                         idsDptM2.rec <- ssample(idsElig.rec[mElig.rec == 2], nDeparturesM2.rec)
                       }
                       totDpt.rec <- nDepartures.rec + nDeparturesM2.rec
                       if (totDpt.rec > 0) {
                         idsDptAll.rec <- c(idsDpt.rec, idsDptM2.rec)
                         dat$attr$active[idsDptAll.rec] <- 0
                         dat$attr$exitTime[idsDptAll.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.rec, deactivate.edges = TRUE)
                       }
                     }
                 }
             }
             if (at == 2) {
                 dat$epi$ds.flow <- c(0, nDepartures.sus)
                 dat$epi$di.flow <- c(0, nDepartures.inf)
                 if (type == "SIR") {
                     dat$epi$dr.flow <- c(0, nDepartures.rec)
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2 <- c(0, nDeparturesM2.sus)
                     dat$epi$di.flow.m2 <- c(0, nDeparturesM2.inf)
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2 <- c(0, nDeparturesM2.rec)
                     }
                 }
             }
             else {
                 dat$epi$ds.flow[at] <- nDepartures.sus
                 dat$epi$di.flow[at] <- nDepartures.inf
                 if (type == "SIR") {
                     dat$epi$dr.flow[at] <- nDepartures.rec
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2[at] <- nDeparturesM2.sus
                     dat$epi$di.flow.m2[at] <- nDeparturesM2.inf
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2[at] <- nDeparturesM2.rec
                     }
                 }
             }
             return(dat)
         }, arrivals.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             a.rate <- dat$param$a.rate
             a.rate.m2 <- dat$param$a.rate.m2
             modes <- dat$param$modes
             tea.status <- dat$control$tea.status
             nOld <- dat$epi$num[at - 1]
             nCurr <- network.size(dat$nw)
             a.rand <- dat$control$a.rand
             delete.nodes <- dat$control$delete.nodes
             nArrivals <- nArrivalsM2 <- 0
             newNodes <- newNodesM2 <- NULL
             if (modes == 1 && nOld > 0) {
                 if (a.rand == TRUE) {
                     nArrivals <- sum(rbinom(nOld, 1, a.rate))
                 }
                 if (a.rand == FALSE) {
                     nArrivals <- round(nOld * a.rate)
                 }
                 if (nArrivals > 0) {
                     dat$nw <- add.vertices(dat$nw, nv = nArrivals)
                     newNodes <- (nCurr + 1):(nCurr + nArrivals)
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (modes == 2 && nOld > 0) {
                 nOldM2 <- dat$epi$num.m2[at - 1]
                 if (a.rand == TRUE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOld, 1, a.rate))
                     }
                     else {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOldM2, 1, a.rate.m2))
                     }
                 }
                 if (a.rand == FALSE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOld * a.rate)
                     }
                     else {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOldM2 * a.rate.m2)
                     }
                 }
                 nCurrM1 <- length(modeids(dat$nw, 1))
                 nCurrM2 <- length(modeids(dat$nw, 2))
                 prefixes <- unique(substr(dat$nw %v% "vertex.names", 1, 1))
                 if (nArrivals > 0) {
                     newNodeIDs <- (nCurrM1 + 1):(nCurrM1 + nArrivals)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[1], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE)
                     }
                     newNodes <- newNodeIDs
                 }
                 if (nArrivalsM2 > 0) {
                     newNodeIDs <- (nCurrM2 + 1):(nCurrM2 + nArrivalsM2)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[2], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE)
                     }
                     newSize <- network.size(dat$nw)
                     newNodesM2 <- (newSize - nArrivalsM2 + 1):newSize
                 }
                 newNodes <- c(newNodes, newNodesM2)
                 if (!is.null(newNodes)) {
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (length(newNodes) > 0) {
                 fterms <- dat$temp$fterms
                 curr.tab <- get_attr_prop(dat$nw, fterms)
                 if (length(curr.tab) > 0) {
                     dat$nw <- update_nwattr(dat$nw, newNodes, dat$control$attr.rules, 
                       curr.tab, dat$temp$t1.tab)
                 }
                 dat <- copy_toall_attr(dat, at, fterms)
                 if (tea.status == TRUE) {
                     if ("status" %in% fterms) {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = dat$attr$status[newNodes], onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                     else {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = "s", onset = at, terminus = Inf, v = newNodes)
                     }
                 }
                 if (modes == 1) {
                     if (!("status" %in% fterms)) {
                       dat$attr$status <- c(dat$attr$status, rep("s", length(newNodes)))
                     }
                     dat$attr$active <- c(dat$attr$active, rep(1, length(newNodes)))
                     dat$attr$infTime <- c(dat$attr$infTime, rep(NA, length(newNodes)))
                     dat$attr$entrTime <- c(dat$attr$entrTime, rep(at, length(newNodes)))
                     dat$attr$exitTime <- c(dat$attr$exitTime, rep(NA, length(newNodes)))
                 }
                 if (modes == 2) {
                     if (!("status" %in% fterms)) {
                       dat <- split_bip(dat, "status", "s", nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                     }
                     dat <- split_bip(dat, "active", 1, nCurrM1, nCurrM2, nArrivals, nArrivalsM2)
                     dat <- split_bip(dat, "infTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "entrTime", at, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "exitTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                 }
                 newNodesInf <- intersect(newNodes, which(dat$attr$status == "i"))
                 dat$attr$infTime[newNodesInf] <- at
                 if (length(unique(sapply(dat$attr, length))) != 1) {
                     stop("Attribute list of unequal length. Check arrivals.net module.")
                 }
             }
             if (at == 2) {
                 dat$epi$a.flow <- c(0, nArrivals)
                 if (modes == 2) {
                     dat$epi$a.flow.m2 <- c(0, nArrivalsM2)
                 }
             }
             else {
                 dat$epi$a.flow[at] <- nArrivals
                 if (modes == 2) {
                     dat$epi$a.flow.m2[at] <- nArrivalsM2
                 }
             }
             return(dat)
         }, recovery.FUN = function (dat, at) 
         {
             if (!(dat$control$type %in% c("SIR", "SIS"))) {
                 return(dat)
             }
             active <- dat$attr$active
             status <- dat$attr$status
             infTime <- dat$attr$infTime
             tea.status <- dat$control$tea.status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             recovState <- ifelse(type == "SIR", "r", "s")
             rec.rand <- dat$control$rec.rand
             rec.rate <- dat$param$rec.rate
             rec.rate.m2 <- dat$param$rec.rate.m2
             nRecov <- nRecovM2 <- 0
             idsElig <- which(active == 1 & status == "i")
             nElig <- length(idsElig)
             infDur <- at - infTime[active == 1 & status == "i"]
             infDur[infDur == 0] <- 1
             lrec.rate <- length(rec.rate)
             if (lrec.rate == 1) {
                 mElig <- mode[idsElig]
                 rates <- c(rec.rate, rec.rate.m2)
                 ratesElig <- rates[mElig]
             }
             else {
                 mElig <- mode[idsElig]
                 if (is.null(rec.rate.m2)) {
                     rates <- ifelse(infDur <= lrec.rate, rec.rate[infDur], rec.rate[lrec.rate])
                 }
                 else {
                     rates <- rep(NA, length(infDur))
                     rates[mElig == 1] <- ifelse(infDur[mElig == 1] <= lrec.rate, rec.rate[infDur[mElig == 
                       1]], rec.rate[lrec.rate])
                     rates[mElig == 2] <- ifelse(infDur[mElig == 2] <= length(rec.rate.m2), 
                       rec.rate.m2[infDur[mElig == 2]], rec.rate.m2[length(rec.rate.m2)])
                 }
                 ratesElig <- rates
             }
             if (nElig > 0) {
                 if (rec.rand == TRUE) {
                     vecRecov <- which(rbinom(nElig, 1, ratesElig) == 1)
                     if (length(vecRecov) > 0) {
                       idsRecov <- idsElig[vecRecov]
                       nRecov <- sum(mode[idsRecov] == 1)
                       nRecovM2 <- sum(mode[idsRecov] == 2)
                       status[idsRecov] <- recovState
                       if (tea.status == TRUE) {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = recovState, onset = at, terminus = Inf, v = idsRecov)
                       }
                     }
                 }
                 else {
                     idsRecov <- idsRecovM2 <- NULL
                     nRecov <- min(round(sum(ratesElig[mElig == 1])), sum(mElig == 1))
                     if (nRecov > 0) {
                       idsRecov <- ssample(idsElig[mElig == 1], nRecov)
                       status[idsRecov] <- recovState
                     }
                     if (modes == 2) {
                       nRecovM2 <- min(round(sum(ratesElig[mElig == 2])), sum(mElig == 
                         2))
                       if (nRecovM2 > 0) {
                         idsRecovM2 <- ssample(idsElig[mElig == 2], nRecovM2)
                         status[idsRecovM2] <- recovState
                       }
                     }
                     totRecov <- nRecov + nRecovM2
                     if (tea.status == TRUE & totRecov > 0) {
                       allids <- c(idsRecov, idsRecovM2)
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = recovState, onset = at, terminus = Inf, v = allids)
                     }
                 }
             }
             dat$attr$status <- status
             if ("status" %in% dat$temp$fterms) {
                 dat$nw <- set.vertex.attribute(dat$nw, "status", dat$attr$status)
             }
             outName <- ifelse(type == "SIR", "ir.flow", "is.flow")
             outName[2] <- paste0(outName, ".m2")
             if (at == 2) {
                 dat$epi[[outName[1]]] <- c(0, nRecov)
             }
             else {
                 dat$epi[[outName[1]]][at] <- nRecov
             }
             if (modes == 2) {
                 if (at == 2) {
                     dat$epi[[outName[2]]] <- c(0, nRecovM2)
                 }
                 else {
                     dat$epi[[outName[2]]][at] <- nRecovM2
                 }
             }
             return(dat)
         }, edges_correct.FUN = function (dat, at) 
         {
             if (dat$control$depend == TRUE) {
                 if (dat$param$modes == 1) {
                     old.num <- dat$epi$num[at - 1]
                     new.num <- sum(dat$attr$active == 1)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(old.num) - log(new.num)
                 }
                 if (dat$param$modes == 2) {
                     mode <- idmode(dat$nw)
                     old.num.m1 <- dat$epi$num[at - 1]
                     old.num.m2 <- dat$epi$num.m2[at - 1]
                     new.num.m1 <- sum(dat$attr$active == 1 & mode == 1)
                     new.num.m2 <- sum(dat$attr$active == 1 & mode == 2)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(2 * old.num.m1 * old.num.m2/(old.num.m1 + old.num.m2)) - log(2 * 
                       new.num.m1 * new.num.m2/(new.num.m1 + new.num.m2))
                 }
             }
             return(dat)
         }, resim_nets.FUN = function (dat, at) 
         {
             idsActive <- which(dat$attr$active == 1)
             anyActive <- ifelse(length(idsActive) > 0, TRUE, FALSE)
             if (dat$param$modes == 2) {
                 nActiveM1 <- length(intersect(modeids(dat$nw, mode = 1), idsActive))
                 nActiveM2 <- length(intersect(modeids(dat$nw, mode = 2), idsActive))
                 anyActive <- ifelse(nActiveM1 > 0 & nActiveM2 > 0, TRUE, FALSE)
             }
             nwparam <- get_nwparam(dat)
             statOnNw <- ("status" %in% dat$temp$fterms)
             status <- dat$attr$status
             if (statOnNw == TRUE && length(unique(status)) == 1) {
                 stop("Stopping simulation because status in formation formula and ", 
                     "no longer any discordant nodes", call. = TRUE)
             }
             if (dat$control$save.nwstats == TRUE) {
                 if (at == 2) {
                     nwstats <- attributes(dat$nw)$stats
                     dat$stats$nwstats <- as.data.frame(nwstats)
                 }
             }
             if (anyActive > 0 & dat$control$depend == TRUE) {
                 suppressWarnings(dat$nw <- simulate(dat$nw, formation = nwparam$formation, 
                     dissolution = nwparam$coef.diss$dissolution, coef.form = nwparam$coef.form, 
                     coef.diss = nwparam$coef.diss$coef.adj, constraints = nwparam$constraints, 
                     time.start = at, time.slices = 1, time.offset = 0, monitor = dat$control$nwstats.formula, 
                     control = dat$control$set.control.stergm))
                 if (dat$control$save.nwstats == TRUE) {
                     dat$stats$nwstats <- rbind(dat$stats$nwstats, tail(attributes(dat$nw)$stats, 
                       1))
                 }
                 if (dat$control$delete.nodes == TRUE) {
                     dat$nw <- network.extract(dat$nw, at = at)
                     inactive <- which(dat$attr$active == 0)
                     dat$attr <- deleteAttr(dat$attr, inactive)
                 }
             }
             return(dat)
         }, infection.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             status <- dat$attr$status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             inf.prob <- dat$param$inf.prob
             inf.prob.m2 <- dat$param$inf.prob.m2
             act.rate <- dat$param$act.rate
             nw <- dat$nw
             tea.status <- dat$control$tea.status
             idsInf <- which(active == 1 & status == "i")
             nActive <- sum(active == 1)
             nElig <- length(idsInf)
             nInf <- nInfM2 <- totInf <- 0
             if (nElig > 0 && nElig < nActive) {
                 del <- discord_edgelist(dat, at)
                 if (!(is.null(del))) {
                     del$infDur <- at - dat$attr$infTime[del$inf]
                     del$infDur[del$infDur == 0] <- 1
                     linf.prob <- length(inf.prob)
                     if (is.null(inf.prob.m2)) {
                       del$transProb <- ifelse(del$infDur <= linf.prob, inf.prob[del$infDur], 
                         inf.prob[linf.prob])
                     }
                     else {
                       del$transProb <- ifelse(del$sus <= nw %n% "bipartite", ifelse(del$infDur <= 
                         linf.prob, inf.prob[del$infDur], inf.prob[linf.prob]), ifelse(del$infDur <= 
                         linf.prob, inf.prob.m2[del$infDur], inf.prob.m2[linf.prob]))
                     }
                     if (!is.null(dat$param$inter.eff) && at >= dat$param$inter.start) {
                       del$transProb <- del$transProb * (1 - dat$param$inter.eff)
                     }
                     lact.rate <- length(act.rate)
                     del$actRate <- ifelse(del$infDur <= lact.rate, act.rate[del$infDur], 
                       act.rate[lact.rate])
                     del$finalProb <- 1 - (1 - del$transProb)^del$actRate
                     transmit <- rbinom(nrow(del), 1, del$finalProb)
                     del <- del[which(transmit == 1), ]
                     idsNewInf <- unique(del$sus)
                     nInf <- sum(mode[idsNewInf] == 1)
                     nInfM2 <- sum(mode[idsNewInf] == 2)
                     totInf <- nInf + nInfM2
                     if (totInf > 0) {
                       if (tea.status == TRUE) {
                         nw <- activate.vertex.attribute(nw, prefix = "testatus", value = "i", 
                           onset = at, terminus = Inf, v = idsNewInf)
                       }
                       dat$attr$status[idsNewInf] <- "i"
                       dat$attr$infTime[idsNewInf] <- at
                       if ("status" %in% dat$temp$fterms) {
                         nw <- set.vertex.attribute(nw, "status", dat$attr$status)
                       }
                     }
                     if (any(names(nw$gal) %in% "vertex.pid")) {
                       del$sus <- get.vertex.pid(nw, del$sus)
                       del$inf <- get.vertex.pid(nw, del$inf)
                     }
                 }
             }
             if (totInf > 0) {
                 del <- del[!duplicated(del$sus), ]
                 if (at == 2) {
                     dat$stats$transmat <- del
                 }
                 else {
                     dat$stats$transmat <- rbind(dat$stats$transmat, del)
                 }
             }
             if (at == 2) {
                 dat$epi$si.flow <- c(0, nInf)
                 if (modes == 2) {
                     dat$epi$si.flow.m2 <- c(0, nInfM2)
                 }
             }
             else {
                 dat$epi$si.flow[at] <- nInf
                 if (modes == 2) {
                     dat$epi$si.flow.m2[at] <- nInfM2
                 }
             }
             dat$nw <- nw
             return(dat)
         }, get_prev.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             modes <- dat$param$modes
             l <- lapply(1:length(dat$attr), function(x) dat$attr[[x]][active == 1])
             names(l) <- names(dat$attr)
             l$active <- l$infTime <- NULL
             status <- l$status
             if (modes == 2) {
                 mode <- idmode(dat$nw)[active == 1]
             }
             eb <- !is.null(dat$control$epi.by)
             if (eb == TRUE) {
                 ebn <- dat$control$epi.by
                 ebv <- dat$temp$epi.by.vals
                 ebun <- paste0(".", ebn, ebv)
                 assign(ebn, l[[ebn]])
             }
             if (modes == 1) {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]][at] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
             }
             else {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2 <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2 <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2 <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]] <- sum(status == "r" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2 <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2[at] <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2[at] <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2[at] <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]][at] <- sum(status == 
                             "r" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2[at] <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]][at] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
             }
             return(dat)
         }, verbose.FUN = function (x, type, s = 1, at = 2) 
         {
             if (type == "startup" && x$ncores == 1) {
                 if (x$verbose == TRUE) {
                     cat("\nStarting Network Simulation...")
                 }
             }
             if (type == "progress" && x$control$ncores == 1) {
                 if (x$control$verbose == TRUE) {
                     if (x$control$verbose.int == 0 && at == x$control$nsteps) {
                       cat("\nSim = ", s, "/", x$control$nsims, sep = "")
                     }
                     if (x$control$verbose.int > 0 && (at%%x$control$verbose.int == 0)) {
                       cat("\f")
                       cat("\nEpidemic Simulation")
                       cat("\n----------------------------")
                       cat("\nSimulation: ", s, "/", x$control$nsims, sep = "")
                       cat("\nTimestep: ", at, "/", x$control$nsteps, sep = "")
                       status <- x$attr$status
                       if (class(status) == "character") {
                         status <- ifelse(status == "i", 1, 0)
                       }
                       cat("\nPrevalence:", sum(status, na.rm = TRUE))
                       cat("\nPopulation Size:", sum(x$attr$active == 1))
                       cat("\n----------------------------")
                     }
                 }
             }
         }, module.order = NULL, save.nwstats = TRUE, nwstats.formula = "formation", delete.nodes = FALSE, 
         save.transmat = TRUE, save.network = TRUE, verbose = FALSE, verbose.int = 1, 
         skip.check = FALSE, bi.mods = c("initialize.FUN", "departures.FUN", "arrivals.FUN", 
         "recovery.FUN", "edges_correct.FUN", "resim_nets.FUN", "infection.FUN", "get_prev.FUN", 
         "verbose.FUN"), user.mods = character(0), attr.rules = list(), set.control.stergm = structure(list(
             MCMC.burnin.min = 1000, MCMC.burnin.max = 1e+05, MCMC.burnin.pval = 0.5, 
             MCMC.burnin.add = 1, MCMC.burnin = NULL, MCMC.burnin.mul = NULL, MCMC.prop.weights.form = "default", 
             MCMC.prop.args.form = NULL, MCMC.prop.weights.diss = "default", MCMC.prop.args.diss = NULL, 
             MCMC.init.maxedges = 20000, MCMC.packagenames = NULL, MCMC.init.maxchanges = 1e+06), class = c("control.simulate.network", 
         "control.list", "list")), set.control.ergm = structure(list(MCMC.burnin = 2e+05, 
             MCMC.interval = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, MCMC.init.maxedges = NULL, 
             MCMC.packagenames = NULL, MCMC.runtime.traceplot = FALSE, network.output = "network", 
             term.options = NULL, parallel = 0, parallel.type = NULL, parallel.version.check = TRUE), class = c("control.simulate.ergm", 
         "control.list", "list")), depend = FALSE), class = c("control.net", "list")), 
         1L)
  4: sim_nets(x, nw, nsteps = control$nsteps, control)
  5: suppressWarnings(sim <- simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm))
  6: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  7: simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, coef.form = x$coef.form, 
         coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, time.start = 1, time.offset = 0, 
         constraints = x$constraints, monitor = control$nwstats.formula, nsim = 1, control = control$set.control.stergm)
  8: simulate.network(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm)
  9: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  10: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  11: lapply(X = X, FUN = FUN, ...)
  12: FUN(X[[i]], ...)
  13: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  14: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 15. Error: netsim works with faux offset models (@test-netoffset.R#31)  -----
  'Calloc' could not allocate memory (313768490 of 16 bytes)
  1: netsim(est, param, init, control) at testthat/test-netoffset.R:31
  2: do.call(control[["initialize.FUN"]], list(x, param, init, control, s))
  3: (function (x, param, init, control, s) 
     {
         if (control$start == 1) {
             dat <- list()
             dat$param <- param
             dat$init <- init
             dat$control <- control
             dat$attr <- list()
             dat$stats <- list()
             dat$temp <- list()
             nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
             modes <- ifelse(nw %n% "bipartite", 2, 1)
             if (control$depend == TRUE) {
                 if (class(x$fit) == "stergm") {
                     nw <- network.collapse(nw, at = 1)
                 }
                 nw <- sim_nets(x, nw, nsteps = 1, control)
             }
             if (control$depend == FALSE) {
                 nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
             }
             nw <- activate.vertices(nw, onset = 1, terminus = Inf)
             dat$nw <- nw
             dat$nwparam <- list(x[-which(names(x) == "fit")])
             dat$param$modes <- modes
             if (control$use.pids == TRUE) {
                 dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
             }
             form <- get_nwparam(dat)$formation
             fterms <- get_formula_term_attr(form, nw)
             dat <- copy_toall_attr(dat, at = 1, fterms)
             dat$temp$fterms <- fterms
             dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
             dat <- init_status.net(dat)
             dat <- get_prev.net(dat, at = 1)
         }
         else {
             dat <- list()
             dat$nw <- x$network[[s]]
             dat$param <- x$param
             dat$control <- control
             dat$nwparam <- x$nwparam
             dat$epi <- sapply(x$epi, function(var) var[s])
             names(dat$epi) <- names(x$epi)
             dat$attr <- x$attr[[s]]
             dat$stats <- sapply(x$stats, function(var) var[[s]])
             dat$temp <- list()
         }
         return(dat)
     })(structure(list(fit = structure(list(coef = c(edges = -3.1763857730721, nodematch.race = -Inf
     ), iterations = 6L, MCMCtheta = c(edges = -3.1763857730721, nodematch.race = -Inf
     ), gradient = c(NA, NA), hessian = structure(c(-23.9988282331312, 0, 0, 0), .Dim = c(2L, 
     2L)), covar = structure(c(0.0416687010834748, 0, 0, 0), .Dim = c(2L, 2L)), failure = FALSE, 
         est.cov = structure(c(0, 0, 0, 0), .Dim = c(2L, 2L)), glm = structure(list(coefficients = c(edges = -3.1763857730721), 
             residuals = c(`1` = -1.04173622705239, `2` = 24.9599999958034), fitted.values = c(`1` = 0.0400641025708387, 
             `2` = 0.0400641025708387), effects = c(edges = 15.5606688625266, 24.9797677876524
             ), R = structure(-4.89885989115133, .Dim = c(1L, 1L), .Dimnames = list("edges", 
                 "edges")), rank = 1L, qr = structure(list(qr = structure(c(-4.89885989115133, 
             0.200160192256359), .Dim = 2:1, .Dimnames = list(c("1", "2"), "edges")), 
                 rank = 1L, qraux = 1.97976318436441, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -3.1763857730721, `2` = -3.1763857730721
             ), deviance = 209.848473939327, aic = 211.848473939327, null.deviance = 865.047681338812, 
             iter = 6L, weights = c(`1` = 23.0373367173808, `2` = 0.96149151575045), prior.weights = c(`1` = 599, 
             `2` = 25), df.residual = 1L, df.null = 2L, y = c(`1` = 0, `2` = 1), converged = TRUE, 
             boundary = FALSE, model = structure(list(`pl$zy` = 0:1, edges = c(1, 1), 
                 `offset(pl$foffset)` = c(0, 0), `(weights)` = c(599, 25)), terms = pl$zy ~ 
                 edges - 1 + offset(pl$foffset), row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ . - 1 + offset(pl$foffset), family = family, 
                 data = data.frame(pl$xmat), weights = pl$wend), formula = pl$zy ~ . - 
                 1 + offset(pl$foffset), terms = pl$zy ~ edges - 1 + offset(pl$foffset), 
             data = structure(list(edges = c(1, 1)), class = "data.frame", row.names = c(NA, 
             -2L)), offset = c(0, 0), control = list(epsilon = 1e-08, maxit = 25, trace = FALSE), 
             method = "glm.fit", contrasts = NULL, xlevels = structure(list(), .Names = character(0))), class = c("glm", 
         "lm")), glm.null = structure(list(coefficients = c(`(Intercept)` = -3.1763857730721), 
             residuals = c(`1` = -1.04173622705239, `2` = 24.9599999958034), fitted.values = c(`1` = 0.0400641025708387, 
             `2` = 0.0400641025708387), effects = c(`(Intercept)` = 15.5606688625266, 
             24.9797677876524), R = structure(-4.89885989115133, .Dim = c(1L, 1L), .Dimnames = list(
                 "(Intercept)", "(Intercept)")), rank = 1L, qr = structure(list(qr = structure(c(-4.89885989115133, 
             0.200160192256359), .Dim = 2:1, .Dimnames = list(c("1", "2"), "(Intercept)")), 
                 rank = 1L, qraux = 1.97976318436441, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -3.1763857730721, `2` = -3.1763857730721
             ), deviance = 209.848473939327, aic = 211.848473939327, null.deviance = 209.848473939327, 
             iter = 6L, weights = c(`1` = 23.0373367173808, `2` = 0.96149151575045), prior.weights = c(`1` = 599, 
             `2` = 25), df.residual = 1L, df.null = 1L, y = c(`1` = 0, `2` = 1), converged = TRUE, 
             boundary = FALSE, model = structure(list(`pl$zy` = 0:1, `(weights)` = c(599, 
             25)), terms = pl$zy ~ 1, row.names = 1:2, class = "data.frame"), call = glm(formula = pl$zy ~ 
                 1, family = family, weights = pl$wend), formula = pl$zy ~ 1, terms = pl$zy ~ 
                 1, data = <environment>, offset = NULL, control = list(epsilon = 1e-08, 
                 maxit = 25, trace = FALSE), method = "glm.fit", contrasts = NULL, xlevels = NULL), class = c("glm", 
         "lm")), theta1 = list(coef = c(edges = -3.1763857730721), theta = c(edges = -3.1763857730721), 
             independent = c(edges = TRUE)), MPLE_is_MLE = TRUE, ergm_version = structure(list(
             c(3L, 10L, 1L)), class = c("package_version", "numeric_version")), offset = c(FALSE, 
         TRUE), drop = c(0, -1), estimable = c(TRUE, TRUE), network = structure(list(mel = list(
             list(inl = 50L, outl = 2L, atl = list(na = FALSE)), list(inl = 48L, outl = 3L, 
                 atl = list(na = FALSE)), list(inl = 40L, outl = 4L, atl = list(na = FALSE)), 
             list(inl = 47L, outl = 4L, atl = list(na = FALSE)), list(inl = 14L, outl = 5L, 
                 atl = list(na = FALSE)), list(inl = 18L, outl = 5L, atl = list(na = FALSE)), 
             list(inl = 16L, outl = 7L, atl = list(na = FALSE)), list(inl = 11L, outl = 8L, 
                 atl = list(na = FALSE)), list(inl = 18L, outl = 13L, atl = list(na = FALSE)), 
             list(inl = 23L, outl = 14L, atl = list(na = FALSE)), list(inl = 18L, outl = 17L, 
                 atl = list(na = FALSE)), list(inl = 41L, outl = 17L, atl = list(na = FALSE)), 
             list(inl = 29L, outl = 18L, atl = list(na = FALSE)), list(inl = 30L, outl = 20L, 
                 atl = list(na = FALSE)), list(inl = 35L, outl = 20L, atl = list(na = FALSE)), 
             list(inl = 23L, outl = 21L, atl = list(na = FALSE)), list(inl = 41L, outl = 22L, 
                 atl = list(na = FALSE)), list(inl = 49L, outl = 22L, atl = list(na = FALSE)), 
             list(inl = 45L, outl = 23L, atl = list(na = FALSE)), list(inl = 29L, outl = 24L, 
                 atl = list(na = FALSE)), list(inl = 47L, outl = 24L, atl = list(na = FALSE)), 
             list(inl = 39L, outl = 26L, atl = list(na = FALSE)), list(inl = 43L, outl = 32L, 
                 atl = list(na = FALSE)), list(inl = 49L, outl = 32L, atl = list(na = FALSE)), 
             list(inl = 46L, outl = 39L, atl = list(na = FALSE))), gal = list(n = 50, 
             mnext = 26L, directed = FALSE, hyper = FALSE, loops = FALSE, multiple = FALSE, 
             bipartite = FALSE), val = list(list(na = FALSE, vertex.names = 1L, race = 0L), 
             list(na = FALSE, vertex.names = 2L, race = 1L), list(na = FALSE, vertex.names = 3L, 
                 race = 0L), list(na = FALSE, vertex.names = 4L, race = 1L), list(na = FALSE, 
                 vertex.names = 5L, race = 0L), list(na = FALSE, vertex.names = 6L, race = 0L), 
             list(na = FALSE, vertex.names = 7L, race = 1L), list(na = FALSE, vertex.names = 8L, 
                 race = 0L), list(na = FALSE, vertex.names = 9L, race = 0L), list(na = FALSE, 
                 vertex.names = 10L, race = 0L), list(na = FALSE, vertex.names = 11L, 
                 race = 1L), list(na = FALSE, vertex.names = 12L, race = 0L), list(na = FALSE, 
                 vertex.names = 13L, race = 0L), list(na = FALSE, vertex.names = 14L, 
                 race = 1L), list(na = FALSE, vertex.names = 15L, race = 1L), list(na = FALSE, 
                 vertex.names = 16L, race = 0L), list(na = FALSE, vertex.names = 17L, 
                 race = 0L), list(na = FALSE, vertex.names = 18L, race = 1L), list(na = FALSE, 
                 vertex.names = 19L, race = 0L), list(na = FALSE, vertex.names = 20L, 
                 race = 0L), list(na = FALSE, vertex.names = 21L, race = 1L), list(na = FALSE, 
                 vertex.names = 22L, race = 0L), list(na = FALSE, vertex.names = 23L, 
                 race = 0L), list(na = FALSE, vertex.names = 24L, race = 1L), list(na = FALSE, 
                 vertex.names = 25L, race = 1L), list(na = FALSE, vertex.names = 26L, 
                 race = 1L), list(na = FALSE, vertex.names = 27L, race = 0L), list(na = FALSE, 
                 vertex.names = 28L, race = 0L), list(na = FALSE, vertex.names = 29L, 
                 race = 0L), list(na = FALSE, vertex.names = 30L, race = 1L), list(na = FALSE, 
                 vertex.names = 31L, race = 1L), list(na = FALSE, vertex.names = 32L, 
                 race = 0L), list(na = FALSE, vertex.names = 33L, race = 1L), list(na = FALSE, 
                 vertex.names = 34L, race = 0L), list(na = FALSE, vertex.names = 35L, 
                 race = 1L), list(na = FALSE, vertex.names = 36L, race = 0L), list(na = FALSE, 
                 vertex.names = 37L, race = 1L), list(na = FALSE, vertex.names = 38L, 
                 race = 0L), list(na = FALSE, vertex.names = 39L, race = 0L), list(na = FALSE, 
                 vertex.names = 40L, race = 0L), list(na = FALSE, vertex.names = 41L, 
                 race = 1L), list(na = FALSE, vertex.names = 42L, race = 1L), list(na = FALSE, 
                 vertex.names = 43L, race = 1L), list(na = FALSE, vertex.names = 44L, 
                 race = 1L), list(na = FALSE, vertex.names = 45L, race = 1L), list(na = FALSE, 
                 vertex.names = 46L, race = 1L), list(na = FALSE, vertex.names = 47L, 
                 race = 0L), list(na = FALSE, vertex.names = 48L, race = 1L), list(na = FALSE, 
                 vertex.names = 49L, race = 1L), list(na = FALSE, vertex.names = 50L, 
                 race = 0L)), iel = list(integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 8L, 
             integer(0), integer(0), 5L, integer(0), 7L, integer(0), c(6L, 9L, 11L), integer(0), 
             integer(0), integer(0), integer(0), c(10L, 16L), integer(0), integer(0), 
             integer(0), integer(0), integer(0), c(13L, 20L), 14L, integer(0), integer(0), 
             integer(0), integer(0), 15L, integer(0), integer(0), integer(0), 22L, 3L, 
             c(12L, 17L), integer(0), 23L, integer(0), 19L, 25L, c(4L, 21L), 2L, c(18L, 
             24L), 1L), oel = list(integer(0), 1L, 2L, 4:3, 6:5, integer(0), 7L, 8L, integer(0), 
             integer(0), integer(0), integer(0), 9L, 10L, integer(0), integer(0), 12:11, 
             13L, integer(0), 15:14, 16L, 18:17, 19L, 21:20, integer(0), 22L, integer(0), 
             integer(0), integer(0), integer(0), integer(0), 24:23, integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), 25L, integer(0), integer(0), 
             integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
             integer(0), integer(0))), class = "network"), reference = ~Bernoulli, newnetwork = structure(list(
             mel = list(list(inl = 50L, outl = 2L, atl = list(na = FALSE)), list(inl = 48L, 
                 outl = 3L, atl = list(na = FALSE)), list(inl = 40L, outl = 4L, atl = list(
                 na = FALSE)), list(inl = 47L, outl = 4L, atl = list(na = FALSE)), list(
                 inl = 14L, outl = 5L, atl = list(na = FALSE)), list(inl = 18L, outl = 5L, 
                 atl = list(na = FALSE)), list(inl = 16L, outl = 7L, atl = list(na = FALSE)), 
                 list(inl = 11L, outl = 8L, atl = list(na = FALSE)), list(inl = 18L, outl = 13L, 
                     atl = list(na = FALSE)), list(inl = 23L, outl = 14L, atl = list(na = FALSE)), 
                 list(inl = 18L, outl = 17L, atl = list(na = FALSE)), list(inl = 41L, 
                     outl = 17L, atl = list(na = FALSE)), list(inl = 29L, outl = 18L, 
                     atl = list(na = FALSE)), list(inl = 30L, outl = 20L, atl = list(na = FALSE)), 
                 list(inl = 35L, outl = 20L, atl = list(na = FALSE)), list(inl = 23L, 
                     outl = 21L, atl = list(na = FALSE)), list(inl = 41L, outl = 22L, 
                     atl = list(na = FALSE)), list(inl = 49L, outl = 22L, atl = list(na = FALSE)), 
                 list(inl = 45L, outl = 23L, atl = list(na = FALSE)), list(inl = 29L, 
                     outl = 24L, atl = list(na = FALSE)), list(inl = 47L, outl = 24L, 
                     atl = list(na = FALSE)), list(inl = 39L, outl = 26L, atl = list(na = FALSE)), 
                 list(inl = 43L, outl = 32L, atl = list(na = FALSE)), list(inl = 49L, 
                     outl = 32L, atl = list(na = FALSE)), list(inl = 46L, outl = 39L, 
                     atl = list(na = FALSE))), gal = list(n = 50, mnext = 26L, directed = FALSE, 
                 hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = FALSE), val = list(
                 list(na = FALSE, vertex.names = 1L, race = 0L), list(na = FALSE, vertex.names = 2L, 
                     race = 1L), list(na = FALSE, vertex.names = 3L, race = 0L), list(
                     na = FALSE, vertex.names = 4L, race = 1L), list(na = FALSE, vertex.names = 5L, 
                     race = 0L), list(na = FALSE, vertex.names = 6L, race = 0L), list(
                     na = FALSE, vertex.names = 7L, race = 1L), list(na = FALSE, vertex.names = 8L, 
                     race = 0L), list(na = FALSE, vertex.names = 9L, race = 0L), list(
                     na = FALSE, vertex.names = 10L, race = 0L), list(na = FALSE, vertex.names = 11L, 
                     race = 1L), list(na = FALSE, vertex.names = 12L, race = 0L), list(
                     na = FALSE, vertex.names = 13L, race = 0L), list(na = FALSE, vertex.names = 14L, 
                     race = 1L), list(na = FALSE, vertex.names = 15L, race = 1L), list(
                     na = FALSE, vertex.names = 16L, race = 0L), list(na = FALSE, vertex.names = 17L, 
                     race = 0L), list(na = FALSE, vertex.names = 18L, race = 1L), list(
                     na = FALSE, vertex.names = 19L, race = 0L), list(na = FALSE, vertex.names = 20L, 
                     race = 0L), list(na = FALSE, vertex.names = 21L, race = 1L), list(
                     na = FALSE, vertex.names = 22L, race = 0L), list(na = FALSE, vertex.names = 23L, 
                     race = 0L), list(na = FALSE, vertex.names = 24L, race = 1L), list(
                     na = FALSE, vertex.names = 25L, race = 1L), list(na = FALSE, vertex.names = 26L, 
                     race = 1L), list(na = FALSE, vertex.names = 27L, race = 0L), list(
                     na = FALSE, vertex.names = 28L, race = 0L), list(na = FALSE, vertex.names = 29L, 
                     race = 0L), list(na = FALSE, vertex.names = 30L, race = 1L), list(
                     na = FALSE, vertex.names = 31L, race = 1L), list(na = FALSE, vertex.names = 32L, 
                     race = 0L), list(na = FALSE, vertex.names = 33L, race = 1L), list(
                     na = FALSE, vertex.names = 34L, race = 0L), list(na = FALSE, vertex.names = 35L, 
                     race = 1L), list(na = FALSE, vertex.names = 36L, race = 0L), list(
                     na = FALSE, vertex.names = 37L, race = 1L), list(na = FALSE, vertex.names = 38L, 
                     race = 0L), list(na = FALSE, vertex.names = 39L, race = 0L), list(
                     na = FALSE, vertex.names = 40L, race = 0L), list(na = FALSE, vertex.names = 41L, 
                     race = 1L), list(na = FALSE, vertex.names = 42L, race = 1L), list(
                     na = FALSE, vertex.names = 43L, race = 1L), list(na = FALSE, vertex.names = 44L, 
                     race = 1L), list(na = FALSE, vertex.names = 45L, race = 1L), list(
                     na = FALSE, vertex.names = 46L, race = 1L), list(na = FALSE, vertex.names = 47L, 
                     race = 0L), list(na = FALSE, vertex.names = 48L, race = 1L), list(
                     na = FALSE, vertex.names = 49L, race = 1L), list(na = FALSE, vertex.names = 50L, 
                     race = 0L)), iel = list(integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 8L, integer(0), integer(0), 5L, integer(0), 7L, integer(0), c(6L, 9L, 
                 11L), integer(0), integer(0), integer(0), integer(0), c(10L, 16L), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), c(13L, 20L), 14L, integer(0), 
                 integer(0), integer(0), integer(0), 15L, integer(0), integer(0), integer(0), 
                 22L, 3L, c(12L, 17L), integer(0), 23L, integer(0), 19L, 25L, c(4L, 21L
                 ), 2L, c(18L, 24L), 1L), oel = list(integer(0), 1L, 2L, 4:3, 6:5, integer(0), 
                 7L, 8L, integer(0), integer(0), integer(0), integer(0), 9L, 10L, integer(0), 
                 integer(0), 12:11, 13L, integer(0), 15:14, 16L, 18:17, 19L, 21:20, integer(0), 
                 22L, integer(0), integer(0), integer(0), integer(0), integer(0), 24:23, 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 25L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0))), class = "network"), 
         formula = TARGET_STATS ~ edges + nodematch("race"), constraints = ~., target.stats = c(edges = 25, 
         nodematch.race = 0), etamap = list(canonical = 1:2, offsetmap = c(FALSE, TRUE
         ), offset = c(FALSE, FALSE), offsettheta = c(FALSE, TRUE), curved = list(), etalength = 2), 
         target.esteq = structure(-25, .Dim = c(1L, 1L), .Dimnames = list(NULL, "edges")), 
         estimate = "MLE", control = structure(list(drop = TRUE, init = c(NA, -Inf), init.method = "MPLE", 
             main.method = "MCMLE", force.main = FALSE, main.hessian = TRUE, checkpoint = NULL, 
             resume = NULL, MPLE.max.dyad.types = 1e+06, MPLE.samplesize = 50000, MPLE.type = "glm", 
             MCMC.prop.weights = "default", MCMC.prop.args = list(), MCMC.interval = 1024, 
             MCMC.burnin = 16384, MCMC.samplesize = 1024, MCMC.effectiveSize = NULL, MCMC.effectiveSize.damp = 10, 
             MCMC.effectiveSize.maxruns = 1000, MCMC.effectiveSize.base = 0.5, MCMC.effectiveSize.points = 5, 
             MCMC.effectiveSize.order = 1, MCMC.return.stats = TRUE, MCMC.runtime.traceplot = FALSE, 
             MCMC.init.maxedges = 20000, MCMC.max.maxedges = Inf, MCMC.addto.se = TRUE, 
             MCMC.compress = FALSE, MCMC.packagenames = NULL, SAN.maxit = 4, SAN.nsteps.times = 8, 
             SAN.control = structure(list(SAN.maxit = 4, SAN.tau = 1, SAN.invcov = NULL, 
                 SAN.invcov.diag = FALSE, SAN.nsteps.alloc = function (nsim) 
                 2^seq_len(nsim), SAN.nsteps = 131072, SAN.samplesize = 1024, SAN.init.maxedges = 20000, 
                 SAN.max.maxedges = Inf, SAN.prop.weights = "default", SAN.prop.args = list(), 
                 SAN.packagenames = NULL, term.options = NULL, seed = NULL, parallel = 0, 
                 parallel.type = NULL, parallel.version.check = TRUE), class = c("control.san", 
             "control.list", "list")), MCMLE.termination = "Hummel", MCMLE.maxit = 20, 
             MCMLE.conv.min.pval = 0.5, MCMLE.NR.maxit = 100, MCMLE.NR.reltol = 1.49011611938477e-08, 
             obs.MCMC.samplesize = 1024, obs.MCMC.interval = 1024, obs.MCMC.burnin = 16384, 
             obs.MCMC.burnin.min = 1638.4, obs.MCMC.prop.weights = "default", obs.MCMC.prop.args = list(), 
             obs.MCMC.impute.min_informative = function (nw) 
             network.size(nw)/4, obs.MCMC.impute.default_density = function (nw) 
             2/network.size(nw), MCMLE.check.degeneracy = FALSE, MCMLE.MCMC.precision = 0.005, 
             MCMLE.MCMC.max.ESS.frac = 0.1, MCMLE.metric = "lognormal", MCMLE.method = "BFGS", 
             MCMLE.trustregion = 20, MCMLE.dampening = FALSE, MCMLE.dampening.min.ess = 20, 
             MCMLE.dampening.level = 0.1, MCMLE.steplength.margin = 0.05, MCMLE.steplength = 1, 
             MCMLE.adaptive.trustregion = 3, MCMLE.sequential = TRUE, MCMLE.density.guard.min = 10000, 
             MCMLE.density.guard = 20.0855369231877, MCMLE.effectiveSize = NULL, MCMLE.last.boost = 4, 
             MCMLE.Hummel.esteq = TRUE, MCMLE.Hummel.miss.sample = 100, MCMLE.Hummel.maxit = 25, 
             MCMLE.steplength.min = 1e-04, MCMLE.effectiveSize.interval_drop = 2, MCMLE.save_intermediates = NULL, 
             SA.phase1_n = NULL, SA.initial_gain = NULL, SA.nsubphases = 4, SA.niterations = NULL, 
             SA.phase3_n = NULL, SA.trustregion = 0.5, RM.phase1n_base = 7, RM.phase2n_base = 100, 
             RM.phase2sub = 7, RM.init_gain = 0.5, RM.phase3n = 500, Step.MCMC.samplesize = 100, 
             Step.maxit = 50, Step.gridsize = 100, CD.nsteps = 8, CD.multiplicity = 1, 
             CD.nsteps.obs = 128, CD.multiplicity.obs = 1, CD.maxit = 60, CD.conv.min.pval = 0.5, 
             CD.NR.maxit = 100, CD.NR.reltol = 1.49011611938477e-08, CD.metric = "naive", 
             CD.method = "BFGS", CD.trustregion = 20, CD.dampening = FALSE, CD.dampening.min.ess = 20, 
             CD.dampening.level = 0.1, CD.steplength.margin = 0.5, CD.steplength = 1, 
             CD.adaptive.trustregion = 3, CD.adaptive.epsilon = 0.01, CD.Hummel.esteq = TRUE, 
             CD.Hummel.miss.sample = 100, CD.Hummel.maxit = 25, CD.steplength.min = 1e-04, 
             loglik.control = structure(list(nsteps = 20, MCMC.burnin = NULL, MCMC.interval = NULL, 
                 MCMC.samplesize = NULL, obs.MCMC.samplesize = NULL, obs.MCMC.interval = NULL, 
                 obs.MCMC.burnin = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 warn.dyads = NULL, MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, 
                 term.options = NULL, seed = NULL, parallel = NULL, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.logLik.ergm", "control.list", 
             "list")), term.options = NULL, seed = NULL, parallel = 0, parallel.type = NULL, 
             parallel.version.check = TRUE), class = c("control.ergm", "control.list", 
         "list"))), class = "ergm"), formation = ~edges + nodematch("race"), target.stats = c(25, 
     0), target.stats.names = c("edges", "nodematch.race"), coef.form = c(edges = -5.37361035040832, 
     nodematch.race = -Inf), coef.form.crude = c(edges = -3.1763857730721, nodematch.race = -Inf
     ), coef.diss = structure(list(dissolution = ~offset(edges), duration = 10, coef.crude = 2.19722457733622, 
         coef.adj = 2.19722457733622, d.rate = 0, model.type = "homog"), class = "disscoef"), 
         constraints = ~., edapprox = TRUE), class = "netest"), structure(list(inf.prob = 0.3, 
         act.rate = 0.5, vital = FALSE), class = c("param.net", "list")), structure(list(
         i.num = 10), class = c("init.net", "list")), structure(list(type = "SI", nsteps = 5, 
         start = 1, nsims = 2, ncores = 1, rec.rand = TRUE, a.rand = TRUE, d.rand = TRUE, 
         tea.status = TRUE, use.pids = TRUE, initialize.FUN = function (x, param, init, 
             control, s) 
         {
             if (control$start == 1) {
                 dat <- list()
                 dat$param <- param
                 dat$init <- init
                 dat$control <- control
                 dat$attr <- list()
                 dat$stats <- list()
                 dat$temp <- list()
                 nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
                 modes <- ifelse(nw %n% "bipartite", 2, 1)
                 if (control$depend == TRUE) {
                     if (class(x$fit) == "stergm") {
                       nw <- network.collapse(nw, at = 1)
                     }
                     nw <- sim_nets(x, nw, nsteps = 1, control)
                 }
                 if (control$depend == FALSE) {
                     nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
                 }
                 nw <- activate.vertices(nw, onset = 1, terminus = Inf)
                 dat$nw <- nw
                 dat$nwparam <- list(x[-which(names(x) == "fit")])
                 dat$param$modes <- modes
                 if (control$use.pids == TRUE) {
                     dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
                 }
                 form <- get_nwparam(dat)$formation
                 fterms <- get_formula_term_attr(form, nw)
                 dat <- copy_toall_attr(dat, at = 1, fterms)
                 dat$temp$fterms <- fterms
                 dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
                 dat <- init_status.net(dat)
                 dat <- get_prev.net(dat, at = 1)
             }
             else {
                 dat <- list()
                 dat$nw <- x$network[[s]]
                 dat$param <- x$param
                 dat$control <- control
                 dat$nwparam <- x$nwparam
                 dat$epi <- sapply(x$epi, function(var) var[s])
                 names(dat$epi) <- names(x$epi)
                 dat$attr <- x$attr[[s]]
                 dat$stats <- sapply(x$stats, function(var) var[[s]])
                 dat$temp <- list()
             }
             return(dat)
         }, departures.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             d.rand <- dat$control$d.rand
             nDepartures.sus <- nDeparturesM2.sus <- 0
             idsElig.sus <- which(dat$attr$active == 1 & dat$attr$status == "s")
             nElig.sus <- length(idsElig.sus)
             if (nElig.sus > 0) {
                 mElig.sus <- mode[idsElig.sus]
                 rates.sus <- c(dat$param$ds.rate, dat$param$ds.rate.m2)
                 ratesElig.sus <- rates.sus[mElig.sus]
                 if (d.rand == TRUE) {
                     vecDepartures.sus <- which(rbinom(nElig.sus, 1, ratesElig.sus) == 
                       1)
                     if (length(vecDepartures.sus) > 0) {
                       idsDpt.sus <- idsElig.sus[vecDepartures.sus]
                       nDepartures.sus <- sum(mode[idsDpt.sus] == 1)
                       nDeparturesM2.sus <- sum(mode[idsDpt.sus] == 2)
                       dat$attr$active[idsDpt.sus] <- 0
                       dat$attr$exitTime[idsDpt.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.sus, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.sus <- idsDptM2.sus <- NULL
                     nDepartures.sus <- min(round(sum(ratesElig.sus[mElig.sus == 1])), 
                       sum(mElig.sus == 1))
                     idsDpt.sus <- ssample(idsElig.sus[mElig.sus == 1], nDepartures.sus)
                     if (modes == 2) {
                       nDeparturesM2.sus <- min(round(sum(ratesElig.sus[mElig.sus == 2])), 
                         sum(mElig.sus == 2))
                       idsDptM2.sus <- ssample(idsElig.sus[mElig.sus == 2], nDeparturesM2.sus)
                     }
                     totDpt.sus <- nDepartures.sus + nDeparturesM2.sus
                     if (totDpt.sus > 0) {
                       idsDptAll.sus <- c(idsDpt.sus, idsDptM2.sus)
                       dat$attr$active[idsDptAll.sus] <- 0
                       dat$attr$exitTime[idsDptAll.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.sus, deactivate.edges = TRUE)
                     }
                 }
             }
             nDepartures.inf <- nDeparturesM2.inf <- 0
             idsElig.inf <- which(dat$attr$active == 1 & dat$attr$status == "i")
             nElig.inf <- length(idsElig.inf)
             if (nElig.inf > 0) {
                 mElig.inf <- mode[idsElig.inf]
                 rates.inf <- c(dat$param$di.rate, dat$param$di.rate.m2)
                 ratesElig.inf <- rates.inf[mElig.inf]
                 if (d.rand == TRUE) {
                     vecDepartures.inf <- which(rbinom(nElig.inf, 1, ratesElig.inf) == 
                       1)
                     if (length(vecDepartures.inf) > 0) {
                       idsDpt.inf <- idsElig.inf[vecDepartures.inf]
                       nDepartures.inf <- sum(mode[idsDpt.inf] == 1)
                       nDeparturesM2.inf <- sum(mode[idsDpt.inf] == 2)
                       dat$attr$active[idsDpt.inf] <- 0
                       dat$attr$exitTime[idsDpt.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.inf, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.inf <- idsDptM2.inf <- NULL
                     nDepartures.inf <- min(round(sum(ratesElig.inf[mElig.inf == 1])), 
                       sum(mElig.inf == 1))
                     idsDpt.inf <- ssample(idsElig.inf[mElig.inf == 1], nDepartures.inf)
                     if (modes == 2) {
                       nDeparturesM2.inf <- min(round(sum(ratesElig.inf[mElig.inf == 2])), 
                         sum(mElig.inf == 2))
                       idsDptM2.inf <- ssample(idsElig.inf[mElig.inf == 2], nDeparturesM2.inf)
                     }
                     totDpt.inf <- nDepartures.inf + nDeparturesM2.inf
                     if (totDpt.inf > 0) {
                       idsDptAll.inf <- c(idsDpt.inf, idsDptM2.inf)
                       dat$attr$active[idsDptAll.inf] <- 0
                       dat$attr$exitTime[idsDptAll.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.inf, deactivate.edges = TRUE)
                     }
                 }
             }
             if (type == "SIR") {
                 nDepartures.rec <- nDeparturesM2.rec <- 0
                 idsElig.rec <- which(dat$attr$active == 1 & dat$attr$status == "r")
                 nElig.rec <- length(idsElig.rec)
                 if (nElig.rec > 0) {
                     mElig.rec <- mode[idsElig.rec]
                     rates.rec <- c(dat$param$dr.rate, dat$param$dr.rate.m2)
                     ratesElig.rec <- rates.rec[mElig.rec]
                     if (d.rand == TRUE) {
                       vecDepartures.rec <- which(rbinom(nElig.rec, 1, ratesElig.rec) == 
                         1)
                       if (length(vecDepartures.rec) > 0) {
                         idsDpt.rec <- idsElig.rec[vecDepartures.rec]
                         nDepartures.rec <- sum(mode[idsDpt.rec] == 1)
                         nDeparturesM2.rec <- sum(mode[idsDpt.rec] == 2)
                         dat$attr$active[idsDpt.rec] <- 0
                         dat$attr$exitTime[idsDpt.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.rec, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.rec <- idsDptM2.rec <- NULL
                       nDepartures.rec <- min(round(sum(ratesElig.rec[mElig.rec == 1])), 
                         sum(mElig.rec == 1))
                       idsDpt.rec <- ssample(idsElig.rec[mElig.rec == 1], nDepartures.rec)
                       if (modes == 2) {
                         nDeparturesM2.rec <- min(round(sum(ratesElig.rec[mElig.rec == 
                           2])), sum(mElig.rec == 2))
                         idsDptM2.rec <- ssample(idsElig.rec[mElig.rec == 2], nDeparturesM2.rec)
                       }
                       totDpt.rec <- nDepartures.rec + nDeparturesM2.rec
                       if (totDpt.rec > 0) {
                         idsDptAll.rec <- c(idsDpt.rec, idsDptM2.rec)
                         dat$attr$active[idsDptAll.rec] <- 0
                         dat$attr$exitTime[idsDptAll.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.rec, deactivate.edges = TRUE)
                       }
                     }
                 }
             }
             if (at == 2) {
                 dat$epi$ds.flow <- c(0, nDepartures.sus)
                 dat$epi$di.flow <- c(0, nDepartures.inf)
                 if (type == "SIR") {
                     dat$epi$dr.flow <- c(0, nDepartures.rec)
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2 <- c(0, nDeparturesM2.sus)
                     dat$epi$di.flow.m2 <- c(0, nDeparturesM2.inf)
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2 <- c(0, nDeparturesM2.rec)
                     }
                 }
             }
             else {
                 dat$epi$ds.flow[at] <- nDepartures.sus
                 dat$epi$di.flow[at] <- nDepartures.inf
                 if (type == "SIR") {
                     dat$epi$dr.flow[at] <- nDepartures.rec
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2[at] <- nDeparturesM2.sus
                     dat$epi$di.flow.m2[at] <- nDeparturesM2.inf
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2[at] <- nDeparturesM2.rec
                     }
                 }
             }
             return(dat)
         }, arrivals.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             a.rate <- dat$param$a.rate
             a.rate.m2 <- dat$param$a.rate.m2
             modes <- dat$param$modes
             tea.status <- dat$control$tea.status
             nOld <- dat$epi$num[at - 1]
             nCurr <- network.size(dat$nw)
             a.rand <- dat$control$a.rand
             delete.nodes <- dat$control$delete.nodes
             nArrivals <- nArrivalsM2 <- 0
             newNodes <- newNodesM2 <- NULL
             if (modes == 1 && nOld > 0) {
                 if (a.rand == TRUE) {
                     nArrivals <- sum(rbinom(nOld, 1, a.rate))
                 }
                 if (a.rand == FALSE) {
                     nArrivals <- round(nOld * a.rate)
                 }
                 if (nArrivals > 0) {
                     dat$nw <- add.vertices(dat$nw, nv = nArrivals)
                     newNodes <- (nCurr + 1):(nCurr + nArrivals)
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (modes == 2 && nOld > 0) {
                 nOldM2 <- dat$epi$num.m2[at - 1]
                 if (a.rand == TRUE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOld, 1, a.rate))
                     }
                     else {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOldM2, 1, a.rate.m2))
                     }
                 }
                 if (a.rand == FALSE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOld * a.rate)
                     }
                     else {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOldM2 * a.rate.m2)
                     }
                 }
                 nCurrM1 <- length(modeids(dat$nw, 1))
                 nCurrM2 <- length(modeids(dat$nw, 2))
                 prefixes <- unique(substr(dat$nw %v% "vertex.names", 1, 1))
                 if (nArrivals > 0) {
                     newNodeIDs <- (nCurrM1 + 1):(nCurrM1 + nArrivals)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[1], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE)
                     }
                     newNodes <- newNodeIDs
                 }
                 if (nArrivalsM2 > 0) {
                     newNodeIDs <- (nCurrM2 + 1):(nCurrM2 + nArrivalsM2)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[2], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE)
                     }
                     newSize <- network.size(dat$nw)
                     newNodesM2 <- (newSize - nArrivalsM2 + 1):newSize
                 }
                 newNodes <- c(newNodes, newNodesM2)
                 if (!is.null(newNodes)) {
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (length(newNodes) > 0) {
                 fterms <- dat$temp$fterms
                 curr.tab <- get_attr_prop(dat$nw, fterms)
                 if (length(curr.tab) > 0) {
                     dat$nw <- update_nwattr(dat$nw, newNodes, dat$control$attr.rules, 
                       curr.tab, dat$temp$t1.tab)
                 }
                 dat <- copy_toall_attr(dat, at, fterms)
                 if (tea.status == TRUE) {
                     if ("status" %in% fterms) {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = dat$attr$status[newNodes], onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                     else {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = "s", onset = at, terminus = Inf, v = newNodes)
                     }
                 }
                 if (modes == 1) {
                     if (!("status" %in% fterms)) {
                       dat$attr$status <- c(dat$attr$status, rep("s", length(newNodes)))
                     }
                     dat$attr$active <- c(dat$attr$active, rep(1, length(newNodes)))
                     dat$attr$infTime <- c(dat$attr$infTime, rep(NA, length(newNodes)))
                     dat$attr$entrTime <- c(dat$attr$entrTime, rep(at, length(newNodes)))
                     dat$attr$exitTime <- c(dat$attr$exitTime, rep(NA, length(newNodes)))
                 }
                 if (modes == 2) {
                     if (!("status" %in% fterms)) {
                       dat <- split_bip(dat, "status", "s", nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                     }
                     dat <- split_bip(dat, "active", 1, nCurrM1, nCurrM2, nArrivals, nArrivalsM2)
                     dat <- split_bip(dat, "infTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "entrTime", at, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "exitTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                 }
                 newNodesInf <- intersect(newNodes, which(dat$attr$status == "i"))
                 dat$attr$infTime[newNodesInf] <- at
                 if (length(unique(sapply(dat$attr, length))) != 1) {
                     stop("Attribute list of unequal length. Check arrivals.net module.")
                 }
             }
             if (at == 2) {
                 dat$epi$a.flow <- c(0, nArrivals)
                 if (modes == 2) {
                     dat$epi$a.flow.m2 <- c(0, nArrivalsM2)
                 }
             }
             else {
                 dat$epi$a.flow[at] <- nArrivals
                 if (modes == 2) {
                     dat$epi$a.flow.m2[at] <- nArrivalsM2
                 }
             }
             return(dat)
         }, recovery.FUN = function (dat, at) 
         {
             if (!(dat$control$type %in% c("SIR", "SIS"))) {
                 return(dat)
             }
             active <- dat$attr$active
             status <- dat$attr$status
             infTime <- dat$attr$infTime
             tea.status <- dat$control$tea.status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             recovState <- ifelse(type == "SIR", "r", "s")
             rec.rand <- dat$control$rec.rand
             rec.rate <- dat$param$rec.rate
             rec.rate.m2 <- dat$param$rec.rate.m2
             nRecov <- nRecovM2 <- 0
             idsElig <- which(active == 1 & status == "i")
             nElig <- length(idsElig)
             infDur <- at - infTime[active == 1 & status == "i"]
             infDur[infDur == 0] <- 1
             lrec.rate <- length(rec.rate)
             if (lrec.rate == 1) {
                 mElig <- mode[idsElig]
                 rates <- c(rec.rate, rec.rate.m2)
                 ratesElig <- rates[mElig]
             }
             else {
                 mElig <- mode[idsElig]
                 if (is.null(rec.rate.m2)) {
                     rates <- ifelse(infDur <= lrec.rate, rec.rate[infDur], rec.rate[lrec.rate])
                 }
                 else {
                     rates <- rep(NA, length(infDur))
                     rates[mElig == 1] <- ifelse(infDur[mElig == 1] <= lrec.rate, rec.rate[infDur[mElig == 
                       1]], rec.rate[lrec.rate])
                     rates[mElig == 2] <- ifelse(infDur[mElig == 2] <= length(rec.rate.m2), 
                       rec.rate.m2[infDur[mElig == 2]], rec.rate.m2[length(rec.rate.m2)])
                 }
                 ratesElig <- rates
             }
             if (nElig > 0) {
                 if (rec.rand == TRUE) {
                     vecRecov <- which(rbinom(nElig, 1, ratesElig) == 1)
                     if (length(vecRecov) > 0) {
                       idsRecov <- idsElig[vecRecov]
                       nRecov <- sum(mode[idsRecov] == 1)
                       nRecovM2 <- sum(mode[idsRecov] == 2)
                       status[idsRecov] <- recovState
                       if (tea.status == TRUE) {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = recovState, onset = at, terminus = Inf, v = idsRecov)
                       }
                     }
                 }
                 else {
                     idsRecov <- idsRecovM2 <- NULL
                     nRecov <- min(round(sum(ratesElig[mElig == 1])), sum(mElig == 1))
                     if (nRecov > 0) {
                       idsRecov <- ssample(idsElig[mElig == 1], nRecov)
                       status[idsRecov] <- recovState
                     }
                     if (modes == 2) {
                       nRecovM2 <- min(round(sum(ratesElig[mElig == 2])), sum(mElig == 
                         2))
                       if (nRecovM2 > 0) {
                         idsRecovM2 <- ssample(idsElig[mElig == 2], nRecovM2)
                         status[idsRecovM2] <- recovState
                       }
                     }
                     totRecov <- nRecov + nRecovM2
                     if (tea.status == TRUE & totRecov > 0) {
                       allids <- c(idsRecov, idsRecovM2)
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = recovState, onset = at, terminus = Inf, v = allids)
                     }
                 }
             }
             dat$attr$status <- status
             if ("status" %in% dat$temp$fterms) {
                 dat$nw <- set.vertex.attribute(dat$nw, "status", dat$attr$status)
             }
             outName <- ifelse(type == "SIR", "ir.flow", "is.flow")
             outName[2] <- paste0(outName, ".m2")
             if (at == 2) {
                 dat$epi[[outName[1]]] <- c(0, nRecov)
             }
             else {
                 dat$epi[[outName[1]]][at] <- nRecov
             }
             if (modes == 2) {
                 if (at == 2) {
                     dat$epi[[outName[2]]] <- c(0, nRecovM2)
                 }
                 else {
                     dat$epi[[outName[2]]][at] <- nRecovM2
                 }
             }
             return(dat)
         }, edges_correct.FUN = function (dat, at) 
         {
             if (dat$control$depend == TRUE) {
                 if (dat$param$modes == 1) {
                     old.num <- dat$epi$num[at - 1]
                     new.num <- sum(dat$attr$active == 1)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(old.num) - log(new.num)
                 }
                 if (dat$param$modes == 2) {
                     mode <- idmode(dat$nw)
                     old.num.m1 <- dat$epi$num[at - 1]
                     old.num.m2 <- dat$epi$num.m2[at - 1]
                     new.num.m1 <- sum(dat$attr$active == 1 & mode == 1)
                     new.num.m2 <- sum(dat$attr$active == 1 & mode == 2)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(2 * old.num.m1 * old.num.m2/(old.num.m1 + old.num.m2)) - log(2 * 
                       new.num.m1 * new.num.m2/(new.num.m1 + new.num.m2))
                 }
             }
             return(dat)
         }, resim_nets.FUN = function (dat, at) 
         {
             idsActive <- which(dat$attr$active == 1)
             anyActive <- ifelse(length(idsActive) > 0, TRUE, FALSE)
             if (dat$param$modes == 2) {
                 nActiveM1 <- length(intersect(modeids(dat$nw, mode = 1), idsActive))
                 nActiveM2 <- length(intersect(modeids(dat$nw, mode = 2), idsActive))
                 anyActive <- ifelse(nActiveM1 > 0 & nActiveM2 > 0, TRUE, FALSE)
             }
             nwparam <- get_nwparam(dat)
             statOnNw <- ("status" %in% dat$temp$fterms)
             status <- dat$attr$status
             if (statOnNw == TRUE && length(unique(status)) == 1) {
                 stop("Stopping simulation because status in formation formula and ", 
                     "no longer any discordant nodes", call. = TRUE)
             }
             if (dat$control$save.nwstats == TRUE) {
                 if (at == 2) {
                     nwstats <- attributes(dat$nw)$stats
                     dat$stats$nwstats <- as.data.frame(nwstats)
                 }
             }
             if (anyActive > 0 & dat$control$depend == TRUE) {
                 suppressWarnings(dat$nw <- simulate(dat$nw, formation = nwparam$formation, 
                     dissolution = nwparam$coef.diss$dissolution, coef.form = nwparam$coef.form, 
                     coef.diss = nwparam$coef.diss$coef.adj, constraints = nwparam$constraints, 
                     time.start = at, time.slices = 1, time.offset = 0, monitor = dat$control$nwstats.formula, 
                     control = dat$control$set.control.stergm))
                 if (dat$control$save.nwstats == TRUE) {
                     dat$stats$nwstats <- rbind(dat$stats$nwstats, tail(attributes(dat$nw)$stats, 
                       1))
                 }
                 if (dat$control$delete.nodes == TRUE) {
                     dat$nw <- network.extract(dat$nw, at = at)
                     inactive <- which(dat$attr$active == 0)
                     dat$attr <- deleteAttr(dat$attr, inactive)
                 }
             }
             return(dat)
         }, infection.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             status <- dat$attr$status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             inf.prob <- dat$param$inf.prob
             inf.prob.m2 <- dat$param$inf.prob.m2
             act.rate <- dat$param$act.rate
             nw <- dat$nw
             tea.status <- dat$control$tea.status
             idsInf <- which(active == 1 & status == "i")
             nActive <- sum(active == 1)
             nElig <- length(idsInf)
             nInf <- nInfM2 <- totInf <- 0
             if (nElig > 0 && nElig < nActive) {
                 del <- discord_edgelist(dat, at)
                 if (!(is.null(del))) {
                     del$infDur <- at - dat$attr$infTime[del$inf]
                     del$infDur[del$infDur == 0] <- 1
                     linf.prob <- length(inf.prob)
                     if (is.null(inf.prob.m2)) {
                       del$transProb <- ifelse(del$infDur <= linf.prob, inf.prob[del$infDur], 
                         inf.prob[linf.prob])
                     }
                     else {
                       del$transProb <- ifelse(del$sus <= nw %n% "bipartite", ifelse(del$infDur <= 
                         linf.prob, inf.prob[del$infDur], inf.prob[linf.prob]), ifelse(del$infDur <= 
                         linf.prob, inf.prob.m2[del$infDur], inf.prob.m2[linf.prob]))
                     }
                     if (!is.null(dat$param$inter.eff) && at >= dat$param$inter.start) {
                       del$transProb <- del$transProb * (1 - dat$param$inter.eff)
                     }
                     lact.rate <- length(act.rate)
                     del$actRate <- ifelse(del$infDur <= lact.rate, act.rate[del$infDur], 
                       act.rate[lact.rate])
                     del$finalProb <- 1 - (1 - del$transProb)^del$actRate
                     transmit <- rbinom(nrow(del), 1, del$finalProb)
                     del <- del[which(transmit == 1), ]
                     idsNewInf <- unique(del$sus)
                     nInf <- sum(mode[idsNewInf] == 1)
                     nInfM2 <- sum(mode[idsNewInf] == 2)
                     totInf <- nInf + nInfM2
                     if (totInf > 0) {
                       if (tea.status == TRUE) {
                         nw <- activate.vertex.attribute(nw, prefix = "testatus", value = "i", 
                           onset = at, terminus = Inf, v = idsNewInf)
                       }
                       dat$attr$status[idsNewInf] <- "i"
                       dat$attr$infTime[idsNewInf] <- at
                       if ("status" %in% dat$temp$fterms) {
                         nw <- set.vertex.attribute(nw, "status", dat$attr$status)
                       }
                     }
                     if (any(names(nw$gal) %in% "vertex.pid")) {
                       del$sus <- get.vertex.pid(nw, del$sus)
                       del$inf <- get.vertex.pid(nw, del$inf)
                     }
                 }
             }
             if (totInf > 0) {
                 del <- del[!duplicated(del$sus), ]
                 if (at == 2) {
                     dat$stats$transmat <- del
                 }
                 else {
                     dat$stats$transmat <- rbind(dat$stats$transmat, del)
                 }
             }
             if (at == 2) {
                 dat$epi$si.flow <- c(0, nInf)
                 if (modes == 2) {
                     dat$epi$si.flow.m2 <- c(0, nInfM2)
                 }
             }
             else {
                 dat$epi$si.flow[at] <- nInf
                 if (modes == 2) {
                     dat$epi$si.flow.m2[at] <- nInfM2
                 }
             }
             dat$nw <- nw
             return(dat)
         }, get_prev.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             modes <- dat$param$modes
             l <- lapply(1:length(dat$attr), function(x) dat$attr[[x]][active == 1])
             names(l) <- names(dat$attr)
             l$active <- l$infTime <- NULL
             status <- l$status
             if (modes == 2) {
                 mode <- idmode(dat$nw)[active == 1]
             }
             eb <- !is.null(dat$control$epi.by)
             if (eb == TRUE) {
                 ebn <- dat$control$epi.by
                 ebv <- dat$temp$epi.by.vals
                 ebun <- paste0(".", ebn, ebv)
                 assign(ebn, l[[ebn]])
             }
             if (modes == 1) {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]][at] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
             }
             else {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2 <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2 <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2 <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]] <- sum(status == "r" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2 <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2[at] <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2[at] <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2[at] <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]][at] <- sum(status == 
                             "r" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2[at] <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]][at] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
             }
             return(dat)
         }, verbose.FUN = function (x, type, s = 1, at = 2) 
         {
             if (type == "startup" && x$ncores == 1) {
                 if (x$verbose == TRUE) {
                     cat("\nStarting Network Simulation...")
                 }
             }
             if (type == "progress" && x$control$ncores == 1) {
                 if (x$control$verbose == TRUE) {
                     if (x$control$verbose.int == 0 && at == x$control$nsteps) {
                       cat("\nSim = ", s, "/", x$control$nsims, sep = "")
                     }
                     if (x$control$verbose.int > 0 && (at%%x$control$verbose.int == 0)) {
                       cat("\f")
                       cat("\nEpidemic Simulation")
                       cat("\n----------------------------")
                       cat("\nSimulation: ", s, "/", x$control$nsims, sep = "")
                       cat("\nTimestep: ", at, "/", x$control$nsteps, sep = "")
                       status <- x$attr$status
                       if (class(status) == "character") {
                         status <- ifelse(status == "i", 1, 0)
                       }
                       cat("\nPrevalence:", sum(status, na.rm = TRUE))
                       cat("\nPopulation Size:", sum(x$attr$active == 1))
                       cat("\n----------------------------")
                     }
                 }
             }
         }, module.order = NULL, save.nwstats = TRUE, nwstats.formula = "formation", delete.nodes = FALSE, 
         save.transmat = TRUE, save.network = TRUE, verbose = FALSE, verbose.int = 1, 
         skip.check = FALSE, bi.mods = c("initialize.FUN", "departures.FUN", "arrivals.FUN", 
         "recovery.FUN", "edges_correct.FUN", "resim_nets.FUN", "infection.FUN", "get_prev.FUN", 
         "verbose.FUN"), user.mods = character(0), attr.rules = list(), set.control.stergm = structure(list(
             MCMC.burnin.min = 1000, MCMC.burnin.max = 1e+05, MCMC.burnin.pval = 0.5, 
             MCMC.burnin.add = 1, MCMC.burnin = NULL, MCMC.burnin.mul = NULL, MCMC.prop.weights.form = "default", 
             MCMC.prop.args.form = NULL, MCMC.prop.weights.diss = "default", MCMC.prop.args.diss = NULL, 
             MCMC.init.maxedges = 20000, MCMC.packagenames = NULL, MCMC.init.maxchanges = 1e+06), class = c("control.simulate.network", 
         "control.list", "list")), set.control.ergm = structure(list(MCMC.burnin = 2e+05, 
             MCMC.interval = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, MCMC.init.maxedges = NULL, 
             MCMC.packagenames = NULL, MCMC.runtime.traceplot = FALSE, network.output = "network", 
             term.options = NULL, parallel = 0, parallel.type = NULL, parallel.version.check = TRUE), class = c("control.simulate.ergm", 
         "control.list", "list")), depend = FALSE), class = c("control.net", "list")), 
         1L)
  4: sim_nets(x, nw, nsteps = control$nsteps, control)
  5: suppressWarnings(sim <- simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm))
  6: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  7: simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, coef.form = x$coef.form, 
         coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, time.start = 1, time.offset = 0, 
         constraints = x$constraints, monitor = control$nwstats.formula, nsim = 1, control = control$set.control.stergm)
  8: simulate.network(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm)
  9: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  10: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  11: lapply(X = X, FUN = FUN, ...)
  12: FUN(X[[i]], ...)
  13: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  14: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 16. Error: PIDs for one-mode models (@test-netpids.R#19)  -------------------
  'Calloc' could not allocate memory (296619328 of 16 bytes)
  1: netsim(est, param, init, control) at testthat/test-netpids.R:19
  2: do.call(control[["initialize.FUN"]], list(x, param, init, control, s))
  3: (function (x, param, init, control, s) 
     {
         if (control$start == 1) {
             dat <- list()
             dat$param <- param
             dat$init <- init
             dat$control <- control
             dat$attr <- list()
             dat$stats <- list()
             dat$temp <- list()
             nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
             modes <- ifelse(nw %n% "bipartite", 2, 1)
             if (control$depend == TRUE) {
                 if (class(x$fit) == "stergm") {
                     nw <- network.collapse(nw, at = 1)
                 }
                 nw <- sim_nets(x, nw, nsteps = 1, control)
             }
             if (control$depend == FALSE) {
                 nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
             }
             nw <- activate.vertices(nw, onset = 1, terminus = Inf)
             dat$nw <- nw
             dat$nwparam <- list(x[-which(names(x) == "fit")])
             dat$param$modes <- modes
             if (control$use.pids == TRUE) {
                 dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
             }
             form <- get_nwparam(dat)$formation
             fterms <- get_formula_term_attr(form, nw)
             dat <- copy_toall_attr(dat, at = 1, fterms)
             dat$temp$fterms <- fterms
             dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
             dat <- init_status.net(dat)
             dat <- get_prev.net(dat, at = 1)
         }
         else {
             dat <- list()
             dat$nw <- x$network[[s]]
             dat$param <- x$param
             dat$control <- control
             dat$nwparam <- x$nwparam
             dat$epi <- sapply(x$epi, function(var) var[s])
             names(dat$epi) <- names(x$epi)
             dat$attr <- x$attr[[s]]
             dat$stats <- sapply(x$stats, function(var) var[[s]])
             dat$temp <- list()
         }
         return(dat)
     })(structure(list(fit = structure(list(coef = c(edges = -4.58496747858219), iterations = 7L, 
         MCMCtheta = c(edges = -4.58496747858219), gradient = NA, hessian = structure(-49.4956008703125, .Dim = c(1L, 
         1L)), covar = structure(0.0202038157415279, .Dim = c(1L, 1L)), failure = FALSE, 
         est.cov = structure(0, .Dim = c(1L, 1L)), glm = structure(list(coefficients = c(edges = -4.58496747858219), 
             residuals = c(`1` = -1.01020408163355, `2` = 98.9999999913385), fitted.values = c(`1` = 0.0101010101018938, 
             `2` = 0.0101010101018938), effects = c(edges = 32.2566721378818, 70.3557734423717
             ), R = structure(-7.03531100025525, .Dim = c(1L, 1L), .Dimnames = list("edges", 
                 "edges")), rank = 1L, qr = structure(list(qr = structure(c(-7.03531100025525, 
             0.100503781525921), .Dim = 2:1, .Dimnames = list(c("1", "2"), "edges")), 
                 rank = 1L, qraux = 1.99493667632618, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -4.58496747858219, `2` = -4.58496747858219
             ), deviance = 559.005225360835, aic = 561.005225360835, null.deviance = 6862.15708754346, 
             iter = 7L, weights = c(`1` = 48.9956453059659, `2` = 0.499955564346591), 
             prior.weights = c(`1` = 4900, `2` = 50), df.residual = 1L, df.null = 2L, 
             y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = 0:1, edges = c(1, 1), `offset(pl$foffset)` = c(0, 0), `(weights)` = c(4900, 
                 50)), terms = pl$zy ~ edges - 1 + offset(pl$foffset), row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ . - 1 + offset(pl$foffset), family = family, 
                 data = data.frame(pl$xmat), weights = pl$wend), formula = pl$zy ~ . - 
                 1 + offset(pl$foffset), terms = pl$zy ~ edges - 1 + offset(pl$foffset), 
             data = structure(list(edges = c(1, 1)), class = "data.frame", row.names = c(NA, 
             -2L)), offset = c(0, 0), control = list(epsilon = 1e-08, maxit = 25, trace = FALSE), 
             method = "glm.fit", contrasts = NULL, xlevels = structure(list(), .Names = character(0))), class = c("glm", 
         "lm")), glm.null = structure(list(coefficients = c(`(Intercept)` = -4.58496747858219), 
             residuals = c(`1` = -1.01020408163355, `2` = 98.9999999913385), fitted.values = c(`1` = 0.0101010101018938, 
             `2` = 0.0101010101018938), effects = c(`(Intercept)` = 32.2566721378818, 
             70.3557734423717), R = structure(-7.03531100025525, .Dim = c(1L, 1L), .Dimnames = list(
                 "(Intercept)", "(Intercept)")), rank = 1L, qr = structure(list(qr = structure(c(-7.03531100025525, 
             0.100503781525921), .Dim = 2:1, .Dimnames = list(c("1", "2"), "(Intercept)")), 
                 rank = 1L, qraux = 1.99493667632618, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -4.58496747858219, `2` = -4.58496747858219
             ), deviance = 559.005225360835, aic = 561.005225360835, null.deviance = 559.005225360834, 
             iter = 7L, weights = c(`1` = 48.9956453059659, `2` = 0.499955564346591), 
             prior.weights = c(`1` = 4900, `2` = 50), df.residual = 1L, df.null = 1L, 
             y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = 0:1, `(weights)` = c(4900, 50)), terms = pl$zy ~ 1, row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ 1, family = family, weights = pl$wend), formula = pl$zy ~ 
                 1, terms = pl$zy ~ 1, data = <environment>, offset = NULL, control = list(
                 epsilon = 1e-08, maxit = 25, trace = FALSE), method = "glm.fit", contrasts = NULL, 
             xlevels = NULL), class = c("glm", "lm")), theta1 = list(coef = c(edges = -4.58496747858219), 
             theta = c(edges = -4.58496747858219), independent = c(edges = TRUE)), MPLE_is_MLE = TRUE, 
         ergm_version = structure(list(c(3L, 10L, 1L)), class = c("package_version", "numeric_version"
         )), offset = FALSE, drop = 0, estimable = TRUE, network = structure(list(mel = list(
             list(inl = 79L, outl = 1L, atl = list(na = FALSE)), list(inl = 95L, outl = 1L, 
                 atl = list(na = FALSE)), list(inl = 13L, outl = 3L, atl = list(na = FALSE)), 
             list(inl = 47L, outl = 3L, atl = list(na = FALSE)), list(inl = 76L, outl = 3L, 
                 atl = list(na = FALSE)), list(inl = 60L, outl = 4L, atl = list(na = FALSE)), 
             list(inl = 98L, outl = 5L, atl = list(na = FALSE)), list(inl = 42L, outl = 6L, 
                 atl = list(na = FALSE)), list(inl = 96L, outl = 8L, atl = list(na = FALSE)), 
             list(inl = 40L, outl = 11L, atl = list(na = FALSE)), list(inl = 49L, outl = 11L, 
                 atl = list(na = FALSE)), list(inl = 43L, outl = 14L, atl = list(na = FALSE)), 
             list(inl = 82L, outl = 14L, atl = list(na = FALSE)), list(inl = 34L, outl = 15L, 
                 atl = list(na = FALSE)), list(inl = 100L, outl = 15L, atl = list(na = FALSE)), 
             list(inl = 20L, outl = 16L, atl = list(na = FALSE)), list(inl = 80L, outl = 16L, 
                 atl = list(na = FALSE)), list(inl = 19L, outl = 18L, atl = list(na = FALSE)), 
             list(inl = 66L, outl = 20L, atl = list(na = FALSE)), list(inl = 88L, outl = 21L, 
                 atl = list(na = FALSE)), list(inl = 81L, outl = 22L, atl = list(na = FALSE)), 
             list(inl = 29L, outl = 23L, atl = list(na = FALSE)), list(inl = 59L, outl = 24L, 
                 atl = list(na = FALSE)), list(inl = 77L, outl = 25L, atl = list(na = FALSE)), 
             list(inl = 85L, outl = 25L, atl = list(na = FALSE)), list(inl = 69L, outl = 26L, 
                 atl = list(na = FALSE)), list(inl = 45L, outl = 27L, atl = list(na = FALSE)), 
             list(inl = 91L, outl = 29L, atl = list(na = FALSE)), list(inl = 100L, outl = 30L, 
                 atl = list(na = FALSE)), list(inl = 61L, outl = 36L, atl = list(na = FALSE)), 
             list(inl = 89L, outl = 39L, atl = list(na = FALSE)), list(inl = 52L, outl = 40L, 
                 atl = list(na = FALSE)), list(inl = 51L, outl = 42L, atl = list(na = FALSE)), 
             list(inl = 82L, outl = 45L, atl = list(na = FALSE)), list(inl = 86L, outl = 46L, 
                 atl = list(na = FALSE)), list(inl = 91L, outl = 48L, atl = list(na = FALSE)), 
             list(inl = 98L, outl = 53L, atl = list(na = FALSE)), list(inl = 68L, outl = 55L, 
                 atl = list(na = FALSE)), list(inl = 61L, outl = 57L, atl = list(na = FALSE)), 
             list(inl = 92L, outl = 59L, atl = list(na = FALSE)), list(inl = 90L, outl = 60L, 
                 atl = list(na = FALSE)), list(inl = 70L, outl = 61L, atl = list(na = FALSE)), 
             list(inl = 86L, outl = 64L, atl = list(na = FALSE)), list(inl = 96L, outl = 75L, 
                 atl = list(na = FALSE)), list(inl = 89L, outl = 78L, atl = list(na = FALSE)), 
             list(inl = 99L, outl = 79L, atl = list(na = FALSE)), list(inl = 100L, outl = 91L, 
                 atl = list(na = FALSE)), list(inl = 94L, outl = 93L, atl = list(na = FALSE)), 
             list(inl = 98L, outl = 93L, atl = list(na = FALSE)), list(inl = 100L, outl = 93L, 
                 atl = list(na = FALSE))), gal = list(n = 100, mnext = 51L, directed = FALSE, 
             hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = FALSE), val = list(
             list(na = FALSE, vertex.names = 1L), list(na = FALSE, vertex.names = 2L), 
             list(na = FALSE, vertex.names = 3L), list(na = FALSE, vertex.names = 4L), 
             list(na = FALSE, vertex.names = 5L), list(na = FALSE, vertex.names = 6L), 
             list(na = FALSE, vertex.names = 7L), list(na = FALSE, vertex.names = 8L), 
             list(na = FALSE, vertex.names = 9L), list(na = FALSE, vertex.names = 10L), 
             list(na = FALSE, vertex.names = 11L), list(na = FALSE, vertex.names = 12L), 
             list(na = FALSE, vertex.names = 13L), list(na = FALSE, vertex.names = 14L), 
             list(na = FALSE, vertex.names = 15L), list(na = FALSE, vertex.names = 16L), 
             list(na = FALSE, vertex.names = 17L), list(na = FALSE, vertex.names = 18L), 
             list(na = FALSE, vertex.names = 19L), list(na = FALSE, vertex.names = 20L), 
             list(na = FALSE, vertex.names = 21L), list(na = FALSE, vertex.names = 22L), 
             list(na = FALSE, vertex.names = 23L), list(na = FALSE, vertex.names = 24L), 
             list(na = FALSE, vertex.names = 25L), list(na = FALSE, vertex.names = 26L), 
             list(na = FALSE, vertex.names = 27L), list(na = FALSE, vertex.names = 28L), 
             list(na = FALSE, vertex.names = 29L), list(na = FALSE, vertex.names = 30L), 
             list(na = FALSE, vertex.names = 31L), list(na = FALSE, vertex.names = 32L), 
             list(na = FALSE, vertex.names = 33L), list(na = FALSE, vertex.names = 34L), 
             list(na = FALSE, vertex.names = 35L), list(na = FALSE, vertex.names = 36L), 
             list(na = FALSE, vertex.names = 37L), list(na = FALSE, vertex.names = 38L), 
             list(na = FALSE, vertex.names = 39L), list(na = FALSE, vertex.names = 40L), 
             list(na = FALSE, vertex.names = 41L), list(na = FALSE, vertex.names = 42L), 
             list(na = FALSE, vertex.names = 43L), list(na = FALSE, vertex.names = 44L), 
             list(na = FALSE, vertex.names = 45L), list(na = FALSE, vertex.names = 46L), 
             list(na = FALSE, vertex.names = 47L), list(na = FALSE, vertex.names = 48L), 
             list(na = FALSE, vertex.names = 49L), list(na = FALSE, vertex.names = 50L), 
             list(na = FALSE, vertex.names = 51L), list(na = FALSE, vertex.names = 52L), 
             list(na = FALSE, vertex.names = 53L), list(na = FALSE, vertex.names = 54L), 
             list(na = FALSE, vertex.names = 55L), list(na = FALSE, vertex.names = 56L), 
             list(na = FALSE, vertex.names = 57L), list(na = FALSE, vertex.names = 58L), 
             list(na = FALSE, vertex.names = 59L), list(na = FALSE, vertex.names = 60L), 
             list(na = FALSE, vertex.names = 61L), list(na = FALSE, vertex.names = 62L), 
             list(na = FALSE, vertex.names = 63L), list(na = FALSE, vertex.names = 64L), 
             list(na = FALSE, vertex.names = 65L), list(na = FALSE, vertex.names = 66L), 
             list(na = FALSE, vertex.names = 67L), list(na = FALSE, vertex.names = 68L), 
             list(na = FALSE, vertex.names = 69L), list(na = FALSE, vertex.names = 70L), 
             list(na = FALSE, vertex.names = 71L), list(na = FALSE, vertex.names = 72L), 
             list(na = FALSE, vertex.names = 73L), list(na = FALSE, vertex.names = 74L), 
             list(na = FALSE, vertex.names = 75L), list(na = FALSE, vertex.names = 76L), 
             list(na = FALSE, vertex.names = 77L), list(na = FALSE, vertex.names = 78L), 
             list(na = FALSE, vertex.names = 79L), list(na = FALSE, vertex.names = 80L), 
             list(na = FALSE, vertex.names = 81L), list(na = FALSE, vertex.names = 82L), 
             list(na = FALSE, vertex.names = 83L), list(na = FALSE, vertex.names = 84L), 
             list(na = FALSE, vertex.names = 85L), list(na = FALSE, vertex.names = 86L), 
             list(na = FALSE, vertex.names = 87L), list(na = FALSE, vertex.names = 88L), 
             list(na = FALSE, vertex.names = 89L), list(na = FALSE, vertex.names = 90L), 
             list(na = FALSE, vertex.names = 91L), list(na = FALSE, vertex.names = 92L), 
             list(na = FALSE, vertex.names = 93L), list(na = FALSE, vertex.names = 94L), 
             list(na = FALSE, vertex.names = 95L), list(na = FALSE, vertex.names = 96L), 
             list(na = FALSE, vertex.names = 97L), list(na = FALSE, vertex.names = 98L), 
             list(na = FALSE, vertex.names = 99L), list(na = FALSE, vertex.names = 100L)), 
             iel = list(integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 3L, integer(0), integer(0), integer(0), integer(0), integer(0), 18L, 
                 16L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 22L, integer(0), integer(0), integer(0), integer(0), 
                 14L, integer(0), integer(0), integer(0), integer(0), integer(0), 10L, 
                 integer(0), 8L, 12L, integer(0), 27L, integer(0), 4L, integer(0), 11L, 
                 integer(0), 33L, 32L, integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 23L, 6L, c(30L, 39L), integer(0), integer(0), 
                 integer(0), integer(0), 19L, integer(0), 38L, 26L, 42L, integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 5L, 24L, integer(0), 1L, 17L, 21L, 
                 c(13L, 34L), integer(0), integer(0), 25L, c(35L, 43L), integer(0), 20L, 
                 c(31L, 45L), 41L, c(28L, 36L), 40L, integer(0), 48L, 2L, c(9L, 44L), 
                 integer(0), c(7L, 37L, 49L), 46L, c(15L, 29L, 47L, 50L)), oel = list(
                 2:1, integer(0), 5:3, 6L, 7L, 8L, integer(0), 9L, integer(0), integer(0), 
                 11:10, integer(0), integer(0), 13:12, 15:14, 17:16, integer(0), 18L, 
                 integer(0), 19L, 20L, 21L, 22L, 23L, 25:24, 26L, 27L, integer(0), 28L, 
                 29L, integer(0), integer(0), integer(0), integer(0), integer(0), 30L, 
                 integer(0), integer(0), 31L, 32L, integer(0), 33L, integer(0), integer(0), 
                 34L, 35L, integer(0), 36L, integer(0), integer(0), integer(0), integer(0), 
                 37L, integer(0), 38L, integer(0), 39L, integer(0), 40L, 41L, 42L, integer(0), 
                 integer(0), 43L, integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), 44L, integer(0), 
                 integer(0), 45L, 46L, integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), 47L, integer(0), 50:48, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0))), class = "network"), 
         reference = ~Bernoulli, newnetwork = structure(list(mel = list(list(inl = 79L, 
             outl = 1L, atl = list(na = FALSE)), list(inl = 95L, outl = 1L, atl = list(
             na = FALSE)), list(inl = 13L, outl = 3L, atl = list(na = FALSE)), list(inl = 47L, 
             outl = 3L, atl = list(na = FALSE)), list(inl = 76L, outl = 3L, atl = list(
             na = FALSE)), list(inl = 60L, outl = 4L, atl = list(na = FALSE)), list(inl = 98L, 
             outl = 5L, atl = list(na = FALSE)), list(inl = 42L, outl = 6L, atl = list(
             na = FALSE)), list(inl = 96L, outl = 8L, atl = list(na = FALSE)), list(inl = 40L, 
             outl = 11L, atl = list(na = FALSE)), list(inl = 49L, outl = 11L, atl = list(
             na = FALSE)), list(inl = 43L, outl = 14L, atl = list(na = FALSE)), list(inl = 82L, 
             outl = 14L, atl = list(na = FALSE)), list(inl = 34L, outl = 15L, atl = list(
             na = FALSE)), list(inl = 100L, outl = 15L, atl = list(na = FALSE)), list(
             inl = 20L, outl = 16L, atl = list(na = FALSE)), list(inl = 80L, outl = 16L, 
             atl = list(na = FALSE)), list(inl = 19L, outl = 18L, atl = list(na = FALSE)), 
             list(inl = 66L, outl = 20L, atl = list(na = FALSE)), list(inl = 88L, outl = 21L, 
                 atl = list(na = FALSE)), list(inl = 81L, outl = 22L, atl = list(na = FALSE)), 
             list(inl = 29L, outl = 23L, atl = list(na = FALSE)), list(inl = 59L, outl = 24L, 
                 atl = list(na = FALSE)), list(inl = 77L, outl = 25L, atl = list(na = FALSE)), 
             list(inl = 85L, outl = 25L, atl = list(na = FALSE)), list(inl = 69L, outl = 26L, 
                 atl = list(na = FALSE)), list(inl = 45L, outl = 27L, atl = list(na = FALSE)), 
             list(inl = 91L, outl = 29L, atl = list(na = FALSE)), list(inl = 100L, outl = 30L, 
                 atl = list(na = FALSE)), list(inl = 61L, outl = 36L, atl = list(na = FALSE)), 
             list(inl = 89L, outl = 39L, atl = list(na = FALSE)), list(inl = 52L, outl = 40L, 
                 atl = list(na = FALSE)), list(inl = 51L, outl = 42L, atl = list(na = FALSE)), 
             list(inl = 82L, outl = 45L, atl = list(na = FALSE)), list(inl = 86L, outl = 46L, 
                 atl = list(na = FALSE)), list(inl = 91L, outl = 48L, atl = list(na = FALSE)), 
             list(inl = 98L, outl = 53L, atl = list(na = FALSE)), list(inl = 68L, outl = 55L, 
                 atl = list(na = FALSE)), list(inl = 61L, outl = 57L, atl = list(na = FALSE)), 
             list(inl = 92L, outl = 59L, atl = list(na = FALSE)), list(inl = 90L, outl = 60L, 
                 atl = list(na = FALSE)), list(inl = 70L, outl = 61L, atl = list(na = FALSE)), 
             list(inl = 86L, outl = 64L, atl = list(na = FALSE)), list(inl = 96L, outl = 75L, 
                 atl = list(na = FALSE)), list(inl = 89L, outl = 78L, atl = list(na = FALSE)), 
             list(inl = 99L, outl = 79L, atl = list(na = FALSE)), list(inl = 100L, outl = 91L, 
                 atl = list(na = FALSE)), list(inl = 94L, outl = 93L, atl = list(na = FALSE)), 
             list(inl = 98L, outl = 93L, atl = list(na = FALSE)), list(inl = 100L, outl = 93L, 
                 atl = list(na = FALSE))), gal = list(n = 100, mnext = 51L, directed = FALSE, 
             hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = FALSE), val = list(
             list(na = FALSE, vertex.names = 1L), list(na = FALSE, vertex.names = 2L), 
             list(na = FALSE, vertex.names = 3L), list(na = FALSE, vertex.names = 4L), 
             list(na = FALSE, vertex.names = 5L), list(na = FALSE, vertex.names = 6L), 
             list(na = FALSE, vertex.names = 7L), list(na = FALSE, vertex.names = 8L), 
             list(na = FALSE, vertex.names = 9L), list(na = FALSE, vertex.names = 10L), 
             list(na = FALSE, vertex.names = 11L), list(na = FALSE, vertex.names = 12L), 
             list(na = FALSE, vertex.names = 13L), list(na = FALSE, vertex.names = 14L), 
             list(na = FALSE, vertex.names = 15L), list(na = FALSE, vertex.names = 16L), 
             list(na = FALSE, vertex.names = 17L), list(na = FALSE, vertex.names = 18L), 
             list(na = FALSE, vertex.names = 19L), list(na = FALSE, vertex.names = 20L), 
             list(na = FALSE, vertex.names = 21L), list(na = FALSE, vertex.names = 22L), 
             list(na = FALSE, vertex.names = 23L), list(na = FALSE, vertex.names = 24L), 
             list(na = FALSE, vertex.names = 25L), list(na = FALSE, vertex.names = 26L), 
             list(na = FALSE, vertex.names = 27L), list(na = FALSE, vertex.names = 28L), 
             list(na = FALSE, vertex.names = 29L), list(na = FALSE, vertex.names = 30L), 
             list(na = FALSE, vertex.names = 31L), list(na = FALSE, vertex.names = 32L), 
             list(na = FALSE, vertex.names = 33L), list(na = FALSE, vertex.names = 34L), 
             list(na = FALSE, vertex.names = 35L), list(na = FALSE, vertex.names = 36L), 
             list(na = FALSE, vertex.names = 37L), list(na = FALSE, vertex.names = 38L), 
             list(na = FALSE, vertex.names = 39L), list(na = FALSE, vertex.names = 40L), 
             list(na = FALSE, vertex.names = 41L), list(na = FALSE, vertex.names = 42L), 
             list(na = FALSE, vertex.names = 43L), list(na = FALSE, vertex.names = 44L), 
             list(na = FALSE, vertex.names = 45L), list(na = FALSE, vertex.names = 46L), 
             list(na = FALSE, vertex.names = 47L), list(na = FALSE, vertex.names = 48L), 
             list(na = FALSE, vertex.names = 49L), list(na = FALSE, vertex.names = 50L), 
             list(na = FALSE, vertex.names = 51L), list(na = FALSE, vertex.names = 52L), 
             list(na = FALSE, vertex.names = 53L), list(na = FALSE, vertex.names = 54L), 
             list(na = FALSE, vertex.names = 55L), list(na = FALSE, vertex.names = 56L), 
             list(na = FALSE, vertex.names = 57L), list(na = FALSE, vertex.names = 58L), 
             list(na = FALSE, vertex.names = 59L), list(na = FALSE, vertex.names = 60L), 
             list(na = FALSE, vertex.names = 61L), list(na = FALSE, vertex.names = 62L), 
             list(na = FALSE, vertex.names = 63L), list(na = FALSE, vertex.names = 64L), 
             list(na = FALSE, vertex.names = 65L), list(na = FALSE, vertex.names = 66L), 
             list(na = FALSE, vertex.names = 67L), list(na = FALSE, vertex.names = 68L), 
             list(na = FALSE, vertex.names = 69L), list(na = FALSE, vertex.names = 70L), 
             list(na = FALSE, vertex.names = 71L), list(na = FALSE, vertex.names = 72L), 
             list(na = FALSE, vertex.names = 73L), list(na = FALSE, vertex.names = 74L), 
             list(na = FALSE, vertex.names = 75L), list(na = FALSE, vertex.names = 76L), 
             list(na = FALSE, vertex.names = 77L), list(na = FALSE, vertex.names = 78L), 
             list(na = FALSE, vertex.names = 79L), list(na = FALSE, vertex.names = 80L), 
             list(na = FALSE, vertex.names = 81L), list(na = FALSE, vertex.names = 82L), 
             list(na = FALSE, vertex.names = 83L), list(na = FALSE, vertex.names = 84L), 
             list(na = FALSE, vertex.names = 85L), list(na = FALSE, vertex.names = 86L), 
             list(na = FALSE, vertex.names = 87L), list(na = FALSE, vertex.names = 88L), 
             list(na = FALSE, vertex.names = 89L), list(na = FALSE, vertex.names = 90L), 
             list(na = FALSE, vertex.names = 91L), list(na = FALSE, vertex.names = 92L), 
             list(na = FALSE, vertex.names = 93L), list(na = FALSE, vertex.names = 94L), 
             list(na = FALSE, vertex.names = 95L), list(na = FALSE, vertex.names = 96L), 
             list(na = FALSE, vertex.names = 97L), list(na = FALSE, vertex.names = 98L), 
             list(na = FALSE, vertex.names = 99L), list(na = FALSE, vertex.names = 100L)), 
             iel = list(integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 3L, integer(0), integer(0), integer(0), integer(0), integer(0), 18L, 
                 16L, integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 22L, integer(0), integer(0), integer(0), integer(0), 
                 14L, integer(0), integer(0), integer(0), integer(0), integer(0), 10L, 
                 integer(0), 8L, 12L, integer(0), 27L, integer(0), 4L, integer(0), 11L, 
                 integer(0), 33L, 32L, integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), 23L, 6L, c(30L, 39L), integer(0), integer(0), 
                 integer(0), integer(0), 19L, integer(0), 38L, 26L, 42L, integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 5L, 24L, integer(0), 1L, 17L, 21L, 
                 c(13L, 34L), integer(0), integer(0), 25L, c(35L, 43L), integer(0), 20L, 
                 c(31L, 45L), 41L, c(28L, 36L), 40L, integer(0), 48L, 2L, c(9L, 44L), 
                 integer(0), c(7L, 37L, 49L), 46L, c(15L, 29L, 47L, 50L)), oel = list(
                 2:1, integer(0), 5:3, 6L, 7L, 8L, integer(0), 9L, integer(0), integer(0), 
                 11:10, integer(0), integer(0), 13:12, 15:14, 17:16, integer(0), 18L, 
                 integer(0), 19L, 20L, 21L, 22L, 23L, 25:24, 26L, 27L, integer(0), 28L, 
                 29L, integer(0), integer(0), integer(0), integer(0), integer(0), 30L, 
                 integer(0), integer(0), 31L, 32L, integer(0), 33L, integer(0), integer(0), 
                 34L, 35L, integer(0), 36L, integer(0), integer(0), integer(0), integer(0), 
                 37L, integer(0), 38L, integer(0), 39L, integer(0), 40L, 41L, 42L, integer(0), 
                 integer(0), 43L, integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), 44L, integer(0), 
                 integer(0), 45L, 46L, integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), 47L, integer(0), 50:48, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0))), class = "network"), 
         formula = TARGET_STATS ~ edges, constraints = ~., target.stats = c(edges = 50), 
         etamap = list(canonical = 1L, offsetmap = FALSE, offset = FALSE, offsettheta = FALSE, 
             curved = list(), etalength = 1), target.esteq = structure(-50, .Dim = c(1L, 
         1L), .Dimnames = list(NULL, "edges")), estimate = "MLE", control = structure(list(
             drop = TRUE, init = NA_real_, init.method = "MPLE", main.method = "MCMLE", 
             force.main = FALSE, main.hessian = TRUE, checkpoint = NULL, resume = NULL, 
             MPLE.max.dyad.types = 1e+06, MPLE.samplesize = 50000, MPLE.type = "glm", 
             MCMC.prop.weights = "default", MCMC.prop.args = list(), MCMC.interval = 1024, 
             MCMC.burnin = 16384, MCMC.samplesize = 1024, MCMC.effectiveSize = NULL, MCMC.effectiveSize.damp = 10, 
             MCMC.effectiveSize.maxruns = 1000, MCMC.effectiveSize.base = 0.5, MCMC.effectiveSize.points = 5, 
             MCMC.effectiveSize.order = 1, MCMC.return.stats = TRUE, MCMC.runtime.traceplot = FALSE, 
             MCMC.init.maxedges = 20000, MCMC.max.maxedges = Inf, MCMC.addto.se = TRUE, 
             MCMC.compress = FALSE, MCMC.packagenames = NULL, SAN.maxit = 4, SAN.nsteps.times = 8, 
             SAN.control = structure(list(SAN.maxit = 4, SAN.tau = 1, SAN.invcov = NULL, 
                 SAN.invcov.diag = FALSE, SAN.nsteps.alloc = function (nsim) 
                 2^seq_len(nsim), SAN.nsteps = 131072, SAN.samplesize = 1024, SAN.init.maxedges = 20000, 
                 SAN.max.maxedges = Inf, SAN.prop.weights = "default", SAN.prop.args = list(), 
                 SAN.packagenames = NULL, term.options = NULL, seed = NULL, parallel = 0, 
                 parallel.type = NULL, parallel.version.check = TRUE), class = c("control.san", 
             "control.list", "list")), MCMLE.termination = "Hummel", MCMLE.maxit = 20, 
             MCMLE.conv.min.pval = 0.5, MCMLE.NR.maxit = 100, MCMLE.NR.reltol = 1.49011611938477e-08, 
             obs.MCMC.samplesize = 1024, obs.MCMC.interval = 1024, obs.MCMC.burnin = 16384, 
             obs.MCMC.burnin.min = 1638.4, obs.MCMC.prop.weights = "default", obs.MCMC.prop.args = list(), 
             obs.MCMC.impute.min_informative = function (nw) 
             network.size(nw)/4, obs.MCMC.impute.default_density = function (nw) 
             2/network.size(nw), MCMLE.check.degeneracy = FALSE, MCMLE.MCMC.precision = 0.005, 
             MCMLE.MCMC.max.ESS.frac = 0.1, MCMLE.metric = "lognormal", MCMLE.method = "BFGS", 
             MCMLE.trustregion = 20, MCMLE.dampening = FALSE, MCMLE.dampening.min.ess = 20, 
             MCMLE.dampening.level = 0.1, MCMLE.steplength.margin = 0.05, MCMLE.steplength = 1, 
             MCMLE.adaptive.trustregion = 3, MCMLE.sequential = TRUE, MCMLE.density.guard.min = 10000, 
             MCMLE.density.guard = 20.0855369231877, MCMLE.effectiveSize = NULL, MCMLE.last.boost = 4, 
             MCMLE.Hummel.esteq = TRUE, MCMLE.Hummel.miss.sample = 100, MCMLE.Hummel.maxit = 25, 
             MCMLE.steplength.min = 1e-04, MCMLE.effectiveSize.interval_drop = 2, MCMLE.save_intermediates = NULL, 
             SA.phase1_n = NULL, SA.initial_gain = NULL, SA.nsubphases = 4, SA.niterations = NULL, 
             SA.phase3_n = NULL, SA.trustregion = 0.5, RM.phase1n_base = 7, RM.phase2n_base = 100, 
             RM.phase2sub = 7, RM.init_gain = 0.5, RM.phase3n = 500, Step.MCMC.samplesize = 100, 
             Step.maxit = 50, Step.gridsize = 100, CD.nsteps = 8, CD.multiplicity = 1, 
             CD.nsteps.obs = 128, CD.multiplicity.obs = 1, CD.maxit = 60, CD.conv.min.pval = 0.5, 
             CD.NR.maxit = 100, CD.NR.reltol = 1.49011611938477e-08, CD.metric = "naive", 
             CD.method = "BFGS", CD.trustregion = 20, CD.dampening = FALSE, CD.dampening.min.ess = 20, 
             CD.dampening.level = 0.1, CD.steplength.margin = 0.5, CD.steplength = 1, 
             CD.adaptive.trustregion = 3, CD.adaptive.epsilon = 0.01, CD.Hummel.esteq = TRUE, 
             CD.Hummel.miss.sample = 100, CD.Hummel.maxit = 25, CD.steplength.min = 1e-04, 
             loglik.control = structure(list(nsteps = 20, MCMC.burnin = NULL, MCMC.interval = NULL, 
                 MCMC.samplesize = NULL, obs.MCMC.samplesize = NULL, obs.MCMC.interval = NULL, 
                 obs.MCMC.burnin = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 warn.dyads = NULL, MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, 
                 term.options = NULL, seed = NULL, parallel = NULL, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.logLik.ergm", "control.list", 
             "list")), term.options = NULL, seed = NULL, parallel = 0, parallel.type = NULL, 
             parallel.version.check = TRUE), class = c("control.ergm", "control.list", 
         "list"))), class = "ergm"), formation = ~edges, target.stats = 50, target.stats.names = "edges", 
         coef.form = c(edges = -8.47678777669281), coef.form.crude = c(edges = -4.58496747858219), 
         coef.diss = structure(list(dissolution = ~offset(edges), duration = 50, coef.crude = 3.89182029811063, 
             coef.adj = 9.19013766465877, d.rate = 0.01, model.type = "homog"), class = "disscoef"), 
         constraints = ~., edapprox = TRUE), class = "netest"), structure(list(inf.prob = 0.1, 
         rec.rate = 0.02, a.rate = 0.01, ds.rate = 0.01, di.rate = 0.01, act.rate = 1, 
         vital = TRUE), class = c("param.net", "list")), structure(list(i.num = 10), class = c("init.net", 
     "list")), structure(list(type = "SIS", nsteps = 10, start = 1, nsims = 1, ncores = 1, 
         rec.rand = TRUE, a.rand = TRUE, d.rand = TRUE, tea.status = TRUE, use.pids = TRUE, 
         initialize.FUN = function (x, param, init, control, s) 
         {
             if (control$start == 1) {
                 dat <- list()
                 dat$param <- param
                 dat$init <- init
                 dat$control <- control
                 dat$attr <- list()
                 dat$stats <- list()
                 dat$temp <- list()
                 nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
                 modes <- ifelse(nw %n% "bipartite", 2, 1)
                 if (control$depend == TRUE) {
                     if (class(x$fit) == "stergm") {
                       nw <- network.collapse(nw, at = 1)
                     }
                     nw <- sim_nets(x, nw, nsteps = 1, control)
                 }
                 if (control$depend == FALSE) {
                     nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
                 }
                 nw <- activate.vertices(nw, onset = 1, terminus = Inf)
                 dat$nw <- nw
                 dat$nwparam <- list(x[-which(names(x) == "fit")])
                 dat$param$modes <- modes
                 if (control$use.pids == TRUE) {
                     dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
                 }
                 form <- get_nwparam(dat)$formation
                 fterms <- get_formula_term_attr(form, nw)
                 dat <- copy_toall_attr(dat, at = 1, fterms)
                 dat$temp$fterms <- fterms
                 dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
                 dat <- init_status.net(dat)
                 dat <- get_prev.net(dat, at = 1)
             }
             else {
                 dat <- list()
                 dat$nw <- x$network[[s]]
                 dat$param <- x$param
                 dat$control <- control
                 dat$nwparam <- x$nwparam
                 dat$epi <- sapply(x$epi, function(var) var[s])
                 names(dat$epi) <- names(x$epi)
                 dat$attr <- x$attr[[s]]
                 dat$stats <- sapply(x$stats, function(var) var[[s]])
                 dat$temp <- list()
             }
             return(dat)
         }, departures.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             d.rand <- dat$control$d.rand
             nDepartures.sus <- nDeparturesM2.sus <- 0
             idsElig.sus <- which(dat$attr$active == 1 & dat$attr$status == "s")
             nElig.sus <- length(idsElig.sus)
             if (nElig.sus > 0) {
                 mElig.sus <- mode[idsElig.sus]
                 rates.sus <- c(dat$param$ds.rate, dat$param$ds.rate.m2)
                 ratesElig.sus <- rates.sus[mElig.sus]
                 if (d.rand == TRUE) {
                     vecDepartures.sus <- which(rbinom(nElig.sus, 1, ratesElig.sus) == 
                       1)
                     if (length(vecDepartures.sus) > 0) {
                       idsDpt.sus <- idsElig.sus[vecDepartures.sus]
                       nDepartures.sus <- sum(mode[idsDpt.sus] == 1)
                       nDeparturesM2.sus <- sum(mode[idsDpt.sus] == 2)
                       dat$attr$active[idsDpt.sus] <- 0
                       dat$attr$exitTime[idsDpt.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.sus, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.sus <- idsDptM2.sus <- NULL
                     nDepartures.sus <- min(round(sum(ratesElig.sus[mElig.sus == 1])), 
                       sum(mElig.sus == 1))
                     idsDpt.sus <- ssample(idsElig.sus[mElig.sus == 1], nDepartures.sus)
                     if (modes == 2) {
                       nDeparturesM2.sus <- min(round(sum(ratesElig.sus[mElig.sus == 2])), 
                         sum(mElig.sus == 2))
                       idsDptM2.sus <- ssample(idsElig.sus[mElig.sus == 2], nDeparturesM2.sus)
                     }
                     totDpt.sus <- nDepartures.sus + nDeparturesM2.sus
                     if (totDpt.sus > 0) {
                       idsDptAll.sus <- c(idsDpt.sus, idsDptM2.sus)
                       dat$attr$active[idsDptAll.sus] <- 0
                       dat$attr$exitTime[idsDptAll.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.sus, deactivate.edges = TRUE)
                     }
                 }
             }
             nDepartures.inf <- nDeparturesM2.inf <- 0
             idsElig.inf <- which(dat$attr$active == 1 & dat$attr$status == "i")
             nElig.inf <- length(idsElig.inf)
             if (nElig.inf > 0) {
                 mElig.inf <- mode[idsElig.inf]
                 rates.inf <- c(dat$param$di.rate, dat$param$di.rate.m2)
                 ratesElig.inf <- rates.inf[mElig.inf]
                 if (d.rand == TRUE) {
                     vecDepartures.inf <- which(rbinom(nElig.inf, 1, ratesElig.inf) == 
                       1)
                     if (length(vecDepartures.inf) > 0) {
                       idsDpt.inf <- idsElig.inf[vecDepartures.inf]
                       nDepartures.inf <- sum(mode[idsDpt.inf] == 1)
                       nDeparturesM2.inf <- sum(mode[idsDpt.inf] == 2)
                       dat$attr$active[idsDpt.inf] <- 0
                       dat$attr$exitTime[idsDpt.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.inf, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.inf <- idsDptM2.inf <- NULL
                     nDepartures.inf <- min(round(sum(ratesElig.inf[mElig.inf == 1])), 
                       sum(mElig.inf == 1))
                     idsDpt.inf <- ssample(idsElig.inf[mElig.inf == 1], nDepartures.inf)
                     if (modes == 2) {
                       nDeparturesM2.inf <- min(round(sum(ratesElig.inf[mElig.inf == 2])), 
                         sum(mElig.inf == 2))
                       idsDptM2.inf <- ssample(idsElig.inf[mElig.inf == 2], nDeparturesM2.inf)
                     }
                     totDpt.inf <- nDepartures.inf + nDeparturesM2.inf
                     if (totDpt.inf > 0) {
                       idsDptAll.inf <- c(idsDpt.inf, idsDptM2.inf)
                       dat$attr$active[idsDptAll.inf] <- 0
                       dat$attr$exitTime[idsDptAll.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.inf, deactivate.edges = TRUE)
                     }
                 }
             }
             if (type == "SIR") {
                 nDepartures.rec <- nDeparturesM2.rec <- 0
                 idsElig.rec <- which(dat$attr$active == 1 & dat$attr$status == "r")
                 nElig.rec <- length(idsElig.rec)
                 if (nElig.rec > 0) {
                     mElig.rec <- mode[idsElig.rec]
                     rates.rec <- c(dat$param$dr.rate, dat$param$dr.rate.m2)
                     ratesElig.rec <- rates.rec[mElig.rec]
                     if (d.rand == TRUE) {
                       vecDepartures.rec <- which(rbinom(nElig.rec, 1, ratesElig.rec) == 
                         1)
                       if (length(vecDepartures.rec) > 0) {
                         idsDpt.rec <- idsElig.rec[vecDepartures.rec]
                         nDepartures.rec <- sum(mode[idsDpt.rec] == 1)
                         nDeparturesM2.rec <- sum(mode[idsDpt.rec] == 2)
                         dat$attr$active[idsDpt.rec] <- 0
                         dat$attr$exitTime[idsDpt.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.rec, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.rec <- idsDptM2.rec <- NULL
                       nDepartures.rec <- min(round(sum(ratesElig.rec[mElig.rec == 1])), 
                         sum(mElig.rec == 1))
                       idsDpt.rec <- ssample(idsElig.rec[mElig.rec == 1], nDepartures.rec)
                       if (modes == 2) {
                         nDeparturesM2.rec <- min(round(sum(ratesElig.rec[mElig.rec == 
                           2])), sum(mElig.rec == 2))
                         idsDptM2.rec <- ssample(idsElig.rec[mElig.rec == 2], nDeparturesM2.rec)
                       }
                       totDpt.rec <- nDepartures.rec + nDeparturesM2.rec
                       if (totDpt.rec > 0) {
                         idsDptAll.rec <- c(idsDpt.rec, idsDptM2.rec)
                         dat$attr$active[idsDptAll.rec] <- 0
                         dat$attr$exitTime[idsDptAll.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.rec, deactivate.edges = TRUE)
                       }
                     }
                 }
             }
             if (at == 2) {
                 dat$epi$ds.flow <- c(0, nDepartures.sus)
                 dat$epi$di.flow <- c(0, nDepartures.inf)
                 if (type == "SIR") {
                     dat$epi$dr.flow <- c(0, nDepartures.rec)
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2 <- c(0, nDeparturesM2.sus)
                     dat$epi$di.flow.m2 <- c(0, nDeparturesM2.inf)
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2 <- c(0, nDeparturesM2.rec)
                     }
                 }
             }
             else {
                 dat$epi$ds.flow[at] <- nDepartures.sus
                 dat$epi$di.flow[at] <- nDepartures.inf
                 if (type == "SIR") {
                     dat$epi$dr.flow[at] <- nDepartures.rec
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2[at] <- nDeparturesM2.sus
                     dat$epi$di.flow.m2[at] <- nDeparturesM2.inf
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2[at] <- nDeparturesM2.rec
                     }
                 }
             }
             return(dat)
         }, arrivals.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             a.rate <- dat$param$a.rate
             a.rate.m2 <- dat$param$a.rate.m2
             modes <- dat$param$modes
             tea.status <- dat$control$tea.status
             nOld <- dat$epi$num[at - 1]
             nCurr <- network.size(dat$nw)
             a.rand <- dat$control$a.rand
             delete.nodes <- dat$control$delete.nodes
             nArrivals <- nArrivalsM2 <- 0
             newNodes <- newNodesM2 <- NULL
             if (modes == 1 && nOld > 0) {
                 if (a.rand == TRUE) {
                     nArrivals <- sum(rbinom(nOld, 1, a.rate))
                 }
                 if (a.rand == FALSE) {
                     nArrivals <- round(nOld * a.rate)
                 }
                 if (nArrivals > 0) {
                     dat$nw <- add.vertices(dat$nw, nv = nArrivals)
                     newNodes <- (nCurr + 1):(nCurr + nArrivals)
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (modes == 2 && nOld > 0) {
                 nOldM2 <- dat$epi$num.m2[at - 1]
                 if (a.rand == TRUE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOld, 1, a.rate))
                     }
                     else {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOldM2, 1, a.rate.m2))
                     }
                 }
                 if (a.rand == FALSE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOld * a.rate)
                     }
                     else {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOldM2 * a.rate.m2)
                     }
                 }
                 nCurrM1 <- length(modeids(dat$nw, 1))
                 nCurrM2 <- length(modeids(dat$nw, 2))
                 prefixes <- unique(substr(dat$nw %v% "vertex.names", 1, 1))
                 if (nArrivals > 0) {
                     newNodeIDs <- (nCurrM1 + 1):(nCurrM1 + nArrivals)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[1], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE)
                     }
                     newNodes <- newNodeIDs
                 }
                 if (nArrivalsM2 > 0) {
                     newNodeIDs <- (nCurrM2 + 1):(nCurrM2 + nArrivalsM2)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[2], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE)
                     }
                     newSize <- network.size(dat$nw)
                     newNodesM2 <- (newSize - nArrivalsM2 + 1):newSize
                 }
                 newNodes <- c(newNodes, newNodesM2)
                 if (!is.null(newNodes)) {
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (length(newNodes) > 0) {
                 fterms <- dat$temp$fterms
                 curr.tab <- get_attr_prop(dat$nw, fterms)
                 if (length(curr.tab) > 0) {
                     dat$nw <- update_nwattr(dat$nw, newNodes, dat$control$attr.rules, 
                       curr.tab, dat$temp$t1.tab)
                 }
                 dat <- copy_toall_attr(dat, at, fterms)
                 if (tea.status == TRUE) {
                     if ("status" %in% fterms) {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = dat$attr$status[newNodes], onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                     else {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = "s", onset = at, terminus = Inf, v = newNodes)
                     }
                 }
                 if (modes == 1) {
                     if (!("status" %in% fterms)) {
                       dat$attr$status <- c(dat$attr$status, rep("s", length(newNodes)))
                     }
                     dat$attr$active <- c(dat$attr$active, rep(1, length(newNodes)))
                     dat$attr$infTime <- c(dat$attr$infTime, rep(NA, length(newNodes)))
                     dat$attr$entrTime <- c(dat$attr$entrTime, rep(at, length(newNodes)))
                     dat$attr$exitTime <- c(dat$attr$exitTime, rep(NA, length(newNodes)))
                 }
                 if (modes == 2) {
                     if (!("status" %in% fterms)) {
                       dat <- split_bip(dat, "status", "s", nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                     }
                     dat <- split_bip(dat, "active", 1, nCurrM1, nCurrM2, nArrivals, nArrivalsM2)
                     dat <- split_bip(dat, "infTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "entrTime", at, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "exitTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                 }
                 newNodesInf <- intersect(newNodes, which(dat$attr$status == "i"))
                 dat$attr$infTime[newNodesInf] <- at
                 if (length(unique(sapply(dat$attr, length))) != 1) {
                     stop("Attribute list of unequal length. Check arrivals.net module.")
                 }
             }
             if (at == 2) {
                 dat$epi$a.flow <- c(0, nArrivals)
                 if (modes == 2) {
                     dat$epi$a.flow.m2 <- c(0, nArrivalsM2)
                 }
             }
             else {
                 dat$epi$a.flow[at] <- nArrivals
                 if (modes == 2) {
                     dat$epi$a.flow.m2[at] <- nArrivalsM2
                 }
             }
             return(dat)
         }, recovery.FUN = function (dat, at) 
         {
             if (!(dat$control$type %in% c("SIR", "SIS"))) {
                 return(dat)
             }
             active <- dat$attr$active
             status <- dat$attr$status
             infTime <- dat$attr$infTime
             tea.status <- dat$control$tea.status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             recovState <- ifelse(type == "SIR", "r", "s")
             rec.rand <- dat$control$rec.rand
             rec.rate <- dat$param$rec.rate
             rec.rate.m2 <- dat$param$rec.rate.m2
             nRecov <- nRecovM2 <- 0
             idsElig <- which(active == 1 & status == "i")
             nElig <- length(idsElig)
             infDur <- at - infTime[active == 1 & status == "i"]
             infDur[infDur == 0] <- 1
             lrec.rate <- length(rec.rate)
             if (lrec.rate == 1) {
                 mElig <- mode[idsElig]
                 rates <- c(rec.rate, rec.rate.m2)
                 ratesElig <- rates[mElig]
             }
             else {
                 mElig <- mode[idsElig]
                 if (is.null(rec.rate.m2)) {
                     rates <- ifelse(infDur <= lrec.rate, rec.rate[infDur], rec.rate[lrec.rate])
                 }
                 else {
                     rates <- rep(NA, length(infDur))
                     rates[mElig == 1] <- ifelse(infDur[mElig == 1] <= lrec.rate, rec.rate[infDur[mElig == 
                       1]], rec.rate[lrec.rate])
                     rates[mElig == 2] <- ifelse(infDur[mElig == 2] <= length(rec.rate.m2), 
                       rec.rate.m2[infDur[mElig == 2]], rec.rate.m2[length(rec.rate.m2)])
                 }
                 ratesElig <- rates
             }
             if (nElig > 0) {
                 if (rec.rand == TRUE) {
                     vecRecov <- which(rbinom(nElig, 1, ratesElig) == 1)
                     if (length(vecRecov) > 0) {
                       idsRecov <- idsElig[vecRecov]
                       nRecov <- sum(mode[idsRecov] == 1)
                       nRecovM2 <- sum(mode[idsRecov] == 2)
                       status[idsRecov] <- recovState
                       if (tea.status == TRUE) {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = recovState, onset = at, terminus = Inf, v = idsRecov)
                       }
                     }
                 }
                 else {
                     idsRecov <- idsRecovM2 <- NULL
                     nRecov <- min(round(sum(ratesElig[mElig == 1])), sum(mElig == 1))
                     if (nRecov > 0) {
                       idsRecov <- ssample(idsElig[mElig == 1], nRecov)
                       status[idsRecov] <- recovState
                     }
                     if (modes == 2) {
                       nRecovM2 <- min(round(sum(ratesElig[mElig == 2])), sum(mElig == 
                         2))
                       if (nRecovM2 > 0) {
                         idsRecovM2 <- ssample(idsElig[mElig == 2], nRecovM2)
                         status[idsRecovM2] <- recovState
                       }
                     }
                     totRecov <- nRecov + nRecovM2
                     if (tea.status == TRUE & totRecov > 0) {
                       allids <- c(idsRecov, idsRecovM2)
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = recovState, onset = at, terminus = Inf, v = allids)
                     }
                 }
             }
             dat$attr$status <- status
             if ("status" %in% dat$temp$fterms) {
                 dat$nw <- set.vertex.attribute(dat$nw, "status", dat$attr$status)
             }
             outName <- ifelse(type == "SIR", "ir.flow", "is.flow")
             outName[2] <- paste0(outName, ".m2")
             if (at == 2) {
                 dat$epi[[outName[1]]] <- c(0, nRecov)
             }
             else {
                 dat$epi[[outName[1]]][at] <- nRecov
             }
             if (modes == 2) {
                 if (at == 2) {
                     dat$epi[[outName[2]]] <- c(0, nRecovM2)
                 }
                 else {
                     dat$epi[[outName[2]]][at] <- nRecovM2
                 }
             }
             return(dat)
         }, edges_correct.FUN = function (dat, at) 
         {
             if (dat$control$depend == TRUE) {
                 if (dat$param$modes == 1) {
                     old.num <- dat$epi$num[at - 1]
                     new.num <- sum(dat$attr$active == 1)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(old.num) - log(new.num)
                 }
                 if (dat$param$modes == 2) {
                     mode <- idmode(dat$nw)
                     old.num.m1 <- dat$epi$num[at - 1]
                     old.num.m2 <- dat$epi$num.m2[at - 1]
                     new.num.m1 <- sum(dat$attr$active == 1 & mode == 1)
                     new.num.m2 <- sum(dat$attr$active == 1 & mode == 2)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(2 * old.num.m1 * old.num.m2/(old.num.m1 + old.num.m2)) - log(2 * 
                       new.num.m1 * new.num.m2/(new.num.m1 + new.num.m2))
                 }
             }
             return(dat)
         }, resim_nets.FUN = function (dat, at) 
         {
             idsActive <- which(dat$attr$active == 1)
             anyActive <- ifelse(length(idsActive) > 0, TRUE, FALSE)
             if (dat$param$modes == 2) {
                 nActiveM1 <- length(intersect(modeids(dat$nw, mode = 1), idsActive))
                 nActiveM2 <- length(intersect(modeids(dat$nw, mode = 2), idsActive))
                 anyActive <- ifelse(nActiveM1 > 0 & nActiveM2 > 0, TRUE, FALSE)
             }
             nwparam <- get_nwparam(dat)
             statOnNw <- ("status" %in% dat$temp$fterms)
             status <- dat$attr$status
             if (statOnNw == TRUE && length(unique(status)) == 1) {
                 stop("Stopping simulation because status in formation formula and ", 
                     "no longer any discordant nodes", call. = TRUE)
             }
             if (dat$control$save.nwstats == TRUE) {
                 if (at == 2) {
                     nwstats <- attributes(dat$nw)$stats
                     dat$stats$nwstats <- as.data.frame(nwstats)
                 }
             }
             if (anyActive > 0 & dat$control$depend == TRUE) {
                 suppressWarnings(dat$nw <- simulate(dat$nw, formation = nwparam$formation, 
                     dissolution = nwparam$coef.diss$dissolution, coef.form = nwparam$coef.form, 
                     coef.diss = nwparam$coef.diss$coef.adj, constraints = nwparam$constraints, 
                     time.start = at, time.slices = 1, time.offset = 0, monitor = dat$control$nwstats.formula, 
                     control = dat$control$set.control.stergm))
                 if (dat$control$save.nwstats == TRUE) {
                     dat$stats$nwstats <- rbind(dat$stats$nwstats, tail(attributes(dat$nw)$stats, 
                       1))
                 }
                 if (dat$control$delete.nodes == TRUE) {
                     dat$nw <- network.extract(dat$nw, at = at)
                     inactive <- which(dat$attr$active == 0)
                     dat$attr <- deleteAttr(dat$attr, inactive)
                 }
             }
             return(dat)
         }, infection.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             status <- dat$attr$status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             inf.prob <- dat$param$inf.prob
             inf.prob.m2 <- dat$param$inf.prob.m2
             act.rate <- dat$param$act.rate
             nw <- dat$nw
             tea.status <- dat$control$tea.status
             idsInf <- which(active == 1 & status == "i")
             nActive <- sum(active == 1)
             nElig <- length(idsInf)
             nInf <- nInfM2 <- totInf <- 0
             if (nElig > 0 && nElig < nActive) {
                 del <- discord_edgelist(dat, at)
                 if (!(is.null(del))) {
                     del$infDur <- at - dat$attr$infTime[del$inf]
                     del$infDur[del$infDur == 0] <- 1
                     linf.prob <- length(inf.prob)
                     if (is.null(inf.prob.m2)) {
                       del$transProb <- ifelse(del$infDur <= linf.prob, inf.prob[del$infDur], 
                         inf.prob[linf.prob])
                     }
                     else {
                       del$transProb <- ifelse(del$sus <= nw %n% "bipartite", ifelse(del$infDur <= 
                         linf.prob, inf.prob[del$infDur], inf.prob[linf.prob]), ifelse(del$infDur <= 
                         linf.prob, inf.prob.m2[del$infDur], inf.prob.m2[linf.prob]))
                     }
                     if (!is.null(dat$param$inter.eff) && at >= dat$param$inter.start) {
                       del$transProb <- del$transProb * (1 - dat$param$inter.eff)
                     }
                     lact.rate <- length(act.rate)
                     del$actRate <- ifelse(del$infDur <= lact.rate, act.rate[del$infDur], 
                       act.rate[lact.rate])
                     del$finalProb <- 1 - (1 - del$transProb)^del$actRate
                     transmit <- rbinom(nrow(del), 1, del$finalProb)
                     del <- del[which(transmit == 1), ]
                     idsNewInf <- unique(del$sus)
                     nInf <- sum(mode[idsNewInf] == 1)
                     nInfM2 <- sum(mode[idsNewInf] == 2)
                     totInf <- nInf + nInfM2
                     if (totInf > 0) {
                       if (tea.status == TRUE) {
                         nw <- activate.vertex.attribute(nw, prefix = "testatus", value = "i", 
                           onset = at, terminus = Inf, v = idsNewInf)
                       }
                       dat$attr$status[idsNewInf] <- "i"
                       dat$attr$infTime[idsNewInf] <- at
                       if ("status" %in% dat$temp$fterms) {
                         nw <- set.vertex.attribute(nw, "status", dat$attr$status)
                       }
                     }
                     if (any(names(nw$gal) %in% "vertex.pid")) {
                       del$sus <- get.vertex.pid(nw, del$sus)
                       del$inf <- get.vertex.pid(nw, del$inf)
                     }
                 }
             }
             if (totInf > 0) {
                 del <- del[!duplicated(del$sus), ]
                 if (at == 2) {
                     dat$stats$transmat <- del
                 }
                 else {
                     dat$stats$transmat <- rbind(dat$stats$transmat, del)
                 }
             }
             if (at == 2) {
                 dat$epi$si.flow <- c(0, nInf)
                 if (modes == 2) {
                     dat$epi$si.flow.m2 <- c(0, nInfM2)
                 }
             }
             else {
                 dat$epi$si.flow[at] <- nInf
                 if (modes == 2) {
                     dat$epi$si.flow.m2[at] <- nInfM2
                 }
             }
             dat$nw <- nw
             return(dat)
         }, get_prev.FUN = function (dat, at) 
         {
             active <- dat$attr$active
             modes <- dat$param$modes
             l <- lapply(1:length(dat$attr), function(x) dat$attr[[x]][active == 1])
             names(l) <- names(dat$attr)
             l$active <- l$infTime <- NULL
             status <- l$status
             if (modes == 2) {
                 mode <- idmode(dat$nw)[active == 1]
             }
             eb <- !is.null(dat$control$epi.by)
             if (eb == TRUE) {
                 ebn <- dat$control$epi.by
                 ebv <- dat$temp$epi.by.vals
                 ebun <- paste0(".", ebn, ebv)
                 assign(ebn, l[[ebn]])
             }
             if (modes == 1) {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & get(ebn) == 
                           ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i")
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r")
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num", ebun[i])]][at] <- sum(status == "r" & 
                             get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- length(status)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(get(ebn) == ebv[i])
                       }
                     }
                 }
             }
             else {
                 if (at == 1) {
                     dat$epi <- list()
                     dat$epi$s.num <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "s" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]] <- sum(status == "i" & mode == 
                           1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2 <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2 <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2 <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]] <- sum(status == "r" & 
                             mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2 <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
                 else {
                     dat$epi$s.num[at] <- sum(status == "s" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num[at] <- sum(status == "i" & mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 1 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num[at] <- sum(status == "r" & mode == 1)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("s.num", ebun[i])]][at] <- sum(status == "r" & 
                             mode == 1 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num[at] <- sum(mode == 1)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num", ebun[i])]][at] <- sum(mode == 1 & get(ebn) == 
                           ebv[i])
                       }
                     }
                     dat$epi$s.num.m2[at] <- sum(status == "s" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("s.num.m2", ebun[i])]][at] <- sum(status == "s" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     dat$epi$i.num.m2[at] <- sum(status == "i" & mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("i.num.m2", ebun[i])]][at] <- sum(status == "i" & 
                           mode == 2 & get(ebn) == ebv[i])
                       }
                     }
                     if (dat$control$type == "SIR") {
                       dat$epi$r.num.m2[at] <- sum(status == "r" & mode == 2)
                       if (eb == TRUE) {
                         for (i in 1:length(ebun)) {
                           dat$epi[[paste0("r.num.m2", ebun[i])]][at] <- sum(status == 
                             "r" & mode == 2 & get(ebn) == ebv[i])
                         }
                       }
                     }
                     dat$epi$num.m2[at] <- sum(mode == 2)
                     if (eb == TRUE) {
                       for (i in 1:length(ebun)) {
                         dat$epi[[paste0("num.m2", ebun[i])]][at] <- sum(mode == 2 & get(ebn) == 
                           ebv[i])
                       }
                     }
                 }
             }
             return(dat)
         }, verbose.FUN = function (x, type, s = 1, at = 2) 
         {
             if (type == "startup" && x$ncores == 1) {
                 if (x$verbose == TRUE) {
                     cat("\nStarting Network Simulation...")
                 }
             }
             if (type == "progress" && x$control$ncores == 1) {
                 if (x$control$verbose == TRUE) {
                     if (x$control$verbose.int == 0 && at == x$control$nsteps) {
                       cat("\nSim = ", s, "/", x$control$nsims, sep = "")
                     }
                     if (x$control$verbose.int > 0 && (at%%x$control$verbose.int == 0)) {
                       cat("\f")
                       cat("\nEpidemic Simulation")
                       cat("\n----------------------------")
                       cat("\nSimulation: ", s, "/", x$control$nsims, sep = "")
                       cat("\nTimestep: ", at, "/", x$control$nsteps, sep = "")
                       status <- x$attr$status
                       if (class(status) == "character") {
                         status <- ifelse(status == "i", 1, 0)
                       }
                       cat("\nPrevalence:", sum(status, na.rm = TRUE))
                       cat("\nPopulation Size:", sum(x$attr$active == 1))
                       cat("\n----------------------------")
                     }
                 }
             }
         }, module.order = NULL, save.nwstats = TRUE, nwstats.formula = "formation", delete.nodes = FALSE, 
         save.transmat = TRUE, save.network = TRUE, verbose = FALSE, verbose.int = 1, 
         skip.check = FALSE, bi.mods = c("initialize.FUN", "departures.FUN", "arrivals.FUN", 
         "recovery.FUN", "edges_correct.FUN", "resim_nets.FUN", "infection.FUN", "get_prev.FUN", 
         "verbose.FUN"), user.mods = character(0), attr.rules = list(), set.control.stergm = structure(list(
             MCMC.burnin.min = 1000, MCMC.burnin.max = 1e+05, MCMC.burnin.pval = 0.5, 
             MCMC.burnin.add = 1, MCMC.burnin = NULL, MCMC.burnin.mul = NULL, MCMC.prop.weights.form = "default", 
             MCMC.prop.args.form = NULL, MCMC.prop.weights.diss = "default", MCMC.prop.args.diss = NULL, 
             MCMC.init.maxedges = 20000, MCMC.packagenames = NULL, MCMC.init.maxchanges = 1e+06), class = c("control.simulate.network", 
         "control.list", "list")), set.control.ergm = structure(list(MCMC.burnin = 2e+05, 
             MCMC.interval = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, MCMC.init.maxedges = NULL, 
             MCMC.packagenames = NULL, MCMC.runtime.traceplot = FALSE, network.output = "network", 
             term.options = NULL, parallel = 0, parallel.type = NULL, parallel.version.check = TRUE), class = c("control.simulate.ergm", 
         "control.list", "list")), depend = TRUE), class = c("control.net", "list")), 
         1L)
  4: sim_nets(x, nw, nsteps = 1, control)
  5: suppressWarnings(sim <- simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm))
  6: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  7: simulate(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, coef.form = x$coef.form, 
         coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, time.start = 1, time.offset = 0, 
         constraints = x$constraints, monitor = control$nwstats.formula, nsim = 1, control = control$set.control.stergm)
  8: simulate.network(nw, formation = x$formation, dissolution = x$coef.diss$dissolution, 
         coef.form = x$coef.form, coef.diss = x$coef.diss$coef.crude, time.slices = nsteps, 
         time.start = 1, time.offset = 0, constraints = x$constraints, monitor = control$nwstats.formula, 
         nsim = 1, control = control$set.control.stergm)
  9: replicate(nsim, {
         nw <- .set.default.net.obs.period(nw, time.start)
         nw %n% "time" <- start <- .get.last.obs.time(nw, time.start)
         z <- stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, 
             proposal.diss, eta.form = eta.form, eta.diss = eta.diss, control = control, 
             verbose = verbose)
         stats.form <- if (control$collect.form) 
             mcmc(sweep(z$statsmatrix.form, 2, summary(formation), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats.diss <- if (control$collect.diss) 
             mcmc(sweep(z$statsmatrix.diss, 2, summary(dissolution), "+"), start = time.burnin + 
                 1, thin = time.interval)
         stats <- if (!is.null(model.mon)) 
             mcmc(sweep(z$statsmatrix.mon, 2, summary(monitor), "+"), start = time.burnin + 
                 1, thin = time.interval)
         out <- switch(output, networkDynamic = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             nwd <- to.networkDynamic.lasttoggle(nw)
             nwd <- networkDynamic.apply.changes(nwd, changes)
             attributes(nwd) <- c(attributes(nwd), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 changes = changes))
             nwd <- .add.net.obs.period.spell(nwd, start - 1 + time.offset, time.slices)
             nwd
         }, changes = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             attributes(changes) <- c(attributes(changes), list(formation = formation, 
                 dissolution = dissolution, stats.form = stats.form, stats.diss = stats.diss, 
                 monitor = monitor, constraints = constraints, stats = stats, coef.form = coef.form, 
                 coef.diss = coef.diss, start = nw %n% "time" + 0, end = nw %n% "time" + 
                     time.slices))
             changes
         }, stats = {
             list(stats.form = stats.form, stats.diss = stats.diss, stats = stats)
         }, final = {
             changes <- z$changed
             changes[, 1] <- changes[, 1] - 1 + time.offset
             newnw <- z$newnetwork
             attributes(newnw) <- c(attributes(newnw), list(formation = formation, dissolution = dissolution, 
                 stats.form = stats.form, stats.diss = stats.diss, monitor = monitor, 
                 stats = stats, coef.form = coef.form, coef.diss = coef.diss, constraints = constraints, 
                 start = nw %n% "time" + 0, end = nw %n% "time" + time.slices, changes = changes))
             newnw
         })
     }, simplify = FALSE)
  10: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify)
  11: lapply(X = X, FUN = FUN, ...)
  12: FUN(X[[i]], ...)
  13: stergm_MCMC_sample(nw, model.form, model.diss, model.mon, proposal.form, proposal.diss, 
         eta.form = eta.form, eta.diss = eta.diss, control = control, verbose = verbose)
  14: stergm_MCMC_slave(Clist.form, Clist.diss, Clist.mon, proposal.form, proposal.diss, 
         eta.form, eta.diss, control, verbose)
  
  -- 17. Error: PIDs for bipartite models (@test-netpids.R#48)  ------------------
  'Calloc' could not allocate memory (269430441 of 16 bytes)
  1: netsim(est, param, init, control) at testthat/test-netpids.R:48
  2: do.call(control[["initialize.FUN"]], list(x, param, init, control, s))
  3: (function (x, param, init, control, s) 
     {
         if (control$start == 1) {
             dat <- list()
             dat$param <- param
             dat$init <- init
             dat$control <- control
             dat$attr <- list()
             dat$stats <- list()
             dat$temp <- list()
             nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
             modes <- ifelse(nw %n% "bipartite", 2, 1)
             if (control$depend == TRUE) {
                 if (class(x$fit) == "stergm") {
                     nw <- network.collapse(nw, at = 1)
                 }
                 nw <- sim_nets(x, nw, nsteps = 1, control)
             }
             if (control$depend == FALSE) {
                 nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
             }
             nw <- activate.vertices(nw, onset = 1, terminus = Inf)
             dat$nw <- nw
             dat$nwparam <- list(x[-which(names(x) == "fit")])
             dat$param$modes <- modes
             if (control$use.pids == TRUE) {
                 dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
             }
             form <- get_nwparam(dat)$formation
             fterms <- get_formula_term_attr(form, nw)
             dat <- copy_toall_attr(dat, at = 1, fterms)
             dat$temp$fterms <- fterms
             dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
             dat <- init_status.net(dat)
             dat <- get_prev.net(dat, at = 1)
         }
         else {
             dat <- list()
             dat$nw <- x$network[[s]]
             dat$param <- x$param
             dat$control <- control
             dat$nwparam <- x$nwparam
             dat$epi <- sapply(x$epi, function(var) var[s])
             names(dat$epi) <- names(x$epi)
             dat$attr <- x$attr[[s]]
             dat$stats <- sapply(x$stats, function(var) var[[s]])
             dat$temp <- list()
         }
         return(dat)
     })(structure(list(fit = structure(list(coef = c(edges = -3.8918202981106), iterations = 7L, 
         MCMCtheta = c(edges = -3.8918202981106), gradient = NA, hessian = structure(-49.0000108501759, .Dim = c(1L, 
         1L)), covar = structure(0.0204081587462834, .Dim = c(1L, 1L)), failure = FALSE, 
         est.cov = structure(0, .Dim = c(1L, 1L)), glm = structure(list(coefficients = c(edges = -3.8918202981106), 
             residuals = c(`1` = -1.02040816326531, `2` = 49.9999999999988), fitted.values = c(`1` = 0.0200000000000005, 
             `2` = 0.0200000000000005), effects = c(edges = 27.2427451029837, 49.9999944641969
             ), R = structure(-7.00000077501252, .Dim = c(1L, 1L), .Dimnames = list("edges", 
                 "edges")), rank = 1L, qr = structure(list(qr = structure(c(-7.00000077501252, 
             0.14142135623731), .Dim = 2:1, .Dimnames = list(c("1", "2"), "edges")), rank = 1L, 
                 qraux = 1.98994949366117, pivot = 1L, tol = 1e-11), class = "qr"), family = structure(list(
                 family = "binomial", link = "logit", linkfun = function (mu) 
                 .Call(C_logit_link, mu), linkinv = function (eta) 
                 .Call(C_logit_linkinv, eta), variance = function (mu) 
                 mu * (1 - mu), dev.resids = function (y, mu, wt) 
                 .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, 
                     dev) 
                 {
                     m <- if (any(n > 1)) 
                       n
                     else wt
                     -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), 
                       mu, log = TRUE))
                 }, mu.eta = function (eta) 
                 .Call(C_logit_mu_eta, eta), initialize = {
                     if (NCOL(y) == 1) {
                       if (is.factor(y)) 
                         y <- y != levels(y)[1L]
                       n <- rep.int(1, nobs)
                       y[weights == 0] <- 0
                       if (any(y < 0 | y > 1)) 
                         stop("y values must be 0 <= y <= 1")
                       mustart <- (weights * y + 0.5)/(weights + 1)
                       m <- weights * y
                       if (any(abs(m - round(m)) > 0.001)) 
                         warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                           domain = NA)
                     }
                     else if (NCOL(y) == 2) {
                       if (any(abs(y - round(y)) > 0.001)) 
                         warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                           domain = NA)
                       n <- (y1 <- y[, 1L]) + y[, 2L]
                       y <- y1/n
                       if (any(n0 <- n == 0)) 
                         y[n0] <- 0
                       weights <- weights * n
                       mustart <- (n * y + 0.5)/(n + 1)
                     }
                     else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                       "binomial"), domain = NA)
                 }, validmu = function (mu) 
                 all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
                 TRUE, simulate = function (object, nsim) 
                 {
                     ftd <- fitted(object)
                     n <- length(ftd)
                     ntot <- n * nsim
                     wts <- object$prior.weights
                     if (any(wts%%1 != 0)) 
                       stop("cannot simulate from non-integer prior.weights")
                     if (!is.null(m <- object$model)) {
                       y <- model.response(m)
                       if (is.factor(y)) {
                         yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                         split(yy, rep(seq_len(nsim), each = n))
                       }
                       else if (is.matrix(y) && ncol(y) == 2) {
                         yy <- vector("list", nsim)
                         for (i in seq_len(nsim)) {
                           Y <- rbinom(n, size = wts, prob = ftd)
                           YY <- cbind(Y, wts - Y)
                           colnames(YY) <- colnames(y)
                           yy[[i]] <- YY
                         }
                         yy
                       }
                       else rbinom(ntot, size = wts, prob = ftd)/wts
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }), class = "family"), linear.predictors = c(`1` = -3.8918202981106, 
             `2` = -3.8918202981106), deviance = 490.19556639866, aic = 492.19556639866, 
             null.deviance = 3465.73590279973, iter = 7L, weights = c(`1` = 48.0200106331724, 
             `2` = 0.980000217003518), prior.weights = c(`1` = 2450, `2` = 50), df.residual = 1L, 
             df.null = 2L, y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, 
             model = structure(list(`pl$zy` = 0:1, edges = c(1, 1), `offset(pl$foffset)` = c(0, 
             0), `(weights)` = c(2450, 50)), terms = pl$zy ~ edges - 1 + offset(pl$foffset), row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ . - 1 + offset(pl$foffset), family = family, 
                 data = data.frame(pl$xmat), weights = pl$wend), formula = pl$zy ~ . - 
                 1 + offset(pl$foffset), terms = pl$zy ~ edges - 1 + offset(pl$foffset), 
             data = structure(list(edges = c(1, 1)), class = "data.frame", row.names = c(NA, 
             -2L)), offset = c(0, 0), control = list(epsilon = 1e-08, maxit = 25, trace = FALSE), 
             method = "glm.fit", contrasts = NULL, xlevels = structure(list(), .Names = character(0))), class = c("glm", 
         "lm")), glm.null = structure(list(coefficients = c(`(Intercept)` = -3.8918202981106), 
             residuals = c(`1` = -1.02040816326531, `2` = 49.9999999999988), fitted.values = c(`1` = 0.0200000000000005, 
             `2` = 0.0200000000000005), effects = c(`(Intercept)` = 27.2427451029837, 
             49.9999944641969), R = structure(-7.00000077501252, .Dim = c(1L, 1L), .Dimnames = list(
                 "(Intercept)", "(Intercept)")), rank = 1L, qr = structure(list(qr = structure(c(-7.00000077501252, 
             0.14142135623731), .Dim = 2:1, .Dimnames = list(c("1", "2"), "(Intercept)")), 
                 rank = 1L, qraux = 1.98994949366117, pivot = 1L, tol = 1e-11), class = "qr"), 
             family = structure(list(family = "binomial", link = "logit", linkfun = function (mu) 
             .Call(C_logit_link, mu), linkinv = function (eta) 
             .Call(C_logit_linkinv, eta), variance = function (mu) 
             mu * (1 - mu), dev.resids = function (y, mu, wt) 
             .Call(C_binomial_dev_resids, y, mu, wt), aic = function (y, n, mu, wt, dev) 
             {
                 m <- if (any(n > 1)) 
                     n
                 else wt
                 -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), round(m), mu, 
                     log = TRUE))
             }, mu.eta = function (eta) 
             .Call(C_logit_mu_eta, eta), initialize = {
                 if (NCOL(y) == 1) {
                     if (is.factor(y)) 
                       y <- y != levels(y)[1L]
                     n <- rep.int(1, nobs)
                     y[weights == 0] <- 0
                     if (any(y < 0 | y > 1)) 
                       stop("y values must be 0 <= y <= 1")
                     mustart <- (weights * y + 0.5)/(weights + 1)
                     m <- weights * y
                     if (any(abs(m - round(m)) > 0.001)) 
                       warning(gettextf("non-integer #successes in a %s glm!", "binomial"), 
                         domain = NA)
                 }
                 else if (NCOL(y) == 2) {
                     if (any(abs(y - round(y)) > 0.001)) 
                       warning(gettextf("non-integer counts in a %s glm!", "binomial"), 
                         domain = NA)
                     n <- (y1 <- y[, 1L]) + y[, 2L]
                     y <- y1/n
                     if (any(n0 <- n == 0)) 
                       y[n0] <- 0
                     weights <- weights * n
                     mustart <- (n * y + 0.5)/(n + 1)
                 }
                 else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures", 
                     "binomial"), domain = NA)
             }, validmu = function (mu) 
             all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta) 
             TRUE, simulate = function (object, nsim) 
             {
                 ftd <- fitted(object)
                 n <- length(ftd)
                 ntot <- n * nsim
                 wts <- object$prior.weights
                 if (any(wts%%1 != 0)) 
                     stop("cannot simulate from non-integer prior.weights")
                 if (!is.null(m <- object$model)) {
                     y <- model.response(m)
                     if (is.factor(y)) {
                       yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd), labels = levels(y))
                       split(yy, rep(seq_len(nsim), each = n))
                     }
                     else if (is.matrix(y) && ncol(y) == 2) {
                       yy <- vector("list", nsim)
                       for (i in seq_len(nsim)) {
                         Y <- rbinom(n, size = wts, prob = ftd)
                         YY <- cbind(Y, wts - Y)
                         colnames(YY) <- colnames(y)
                         yy[[i]] <- YY
                       }
                       yy
                     }
                     else rbinom(ntot, size = wts, prob = ftd)/wts
                 }
                 else rbinom(ntot, size = wts, prob = ftd)/wts
             }), class = "family"), linear.predictors = c(`1` = -3.8918202981106, `2` = -3.8918202981106
             ), deviance = 490.19556639866, aic = 492.19556639866, null.deviance = 490.19556639866, 
             iter = 7L, weights = c(`1` = 48.0200106331724, `2` = 0.980000217003518), 
             prior.weights = c(`1` = 2450, `2` = 50), df.residual = 1L, df.null = 1L, 
             y = c(`1` = 0, `2` = 1), converged = TRUE, boundary = FALSE, model = structure(list(
                 `pl$zy` = 0:1, `(weights)` = c(2450, 50)), terms = pl$zy ~ 1, row.names = 1:2, class = "data.frame"), 
             call = glm(formula = pl$zy ~ 1, family = family, weights = pl$wend), formula = pl$zy ~ 
                 1, terms = pl$zy ~ 1, data = <environment>, offset = NULL, control = list(
                 epsilon = 1e-08, maxit = 25, trace = FALSE), method = "glm.fit", contrasts = NULL, 
             xlevels = NULL), class = c("glm", "lm")), theta1 = list(coef = c(edges = -3.8918202981106), 
             theta = c(edges = -3.8918202981106), independent = c(edges = TRUE)), MPLE_is_MLE = TRUE, 
         ergm_version = structure(list(c(3L, 10L, 1L)), class = c("package_version", "numeric_version"
         )), offset = FALSE, drop = 0, estimable = TRUE, network = structure(list(mel = list(
             list(inl = 80L, outl = 1L, atl = list(na = FALSE)), list(inl = 91L, outl = 1L, 
                 atl = list(na = FALSE)), list(inl = 63L, outl = 2L, atl = list(na = FALSE)), 
             list(inl = 72L, outl = 4L, atl = list(na = FALSE)), list(inl = 74L, outl = 4L, 
                 atl = list(na = FALSE)), list(inl = 100L, outl = 4L, atl = list(na = FALSE)), 
             list(inl = 72L, outl = 7L, atl = list(na = FALSE)), list(inl = 73L, outl = 7L, 
                 atl = list(na = FALSE)), list(inl = 92L, outl = 7L, atl = list(na = FALSE)), 
             list(inl = 94L, outl = 7L, atl = list(na = FALSE)), list(inl = 84L, outl = 9L, 
                 atl = list(na = FALSE)), list(inl = 99L, outl = 9L, atl = list(na = FALSE)), 
             list(inl = 76L, outl = 11L, atl = list(na = FALSE)), list(inl = 66L, outl = 14L, 
                 atl = list(na = FALSE)), list(inl = 77L, outl = 14L, atl = list(na = FALSE)), 
             list(inl = 89L, outl = 14L, atl = list(na = FALSE)), list(inl = 79L, outl = 17L, 
                 atl = list(na = FALSE)), list(inl = 92L, outl = 18L, atl = list(na = FALSE)), 
             list(inl = 86L, outl = 19L, atl = list(na = FALSE)), list(inl = 58L, outl = 20L, 
                 atl = list(na = FALSE)), list(inl = 53L, outl = 21L, atl = list(na = FALSE)), 
             list(inl = 66L, outl = 21L, atl = list(na = FALSE)), list(inl = 71L, outl = 22L, 
                 atl = list(na = FALSE)), list(inl = 83L, outl = 22L, atl = list(na = FALSE)), 
             list(inl = 91L, outl = 22L, atl = list(na = FALSE)), list(inl = 70L, outl = 23L, 
                 atl = list(na = FALSE)), list(inl = 73L, outl = 24L, atl = list(na = FALSE)), 
             list(inl = 91L, outl = 24L, atl = list(na = FALSE)), list(inl = 97L, outl = 26L, 
                 atl = list(na = FALSE)), list(inl = 84L, outl = 27L, atl = list(na = FALSE)), 
             list(inl = 78L, outl = 28L, atl = list(na = FALSE)), list(inl = 93L, outl = 29L, 
                 atl = list(na = FALSE)), list(inl = 52L, outl = 30L, atl = list(na = FALSE)), 
             list(inl = 64L, outl = 30L, atl = list(na = FALSE)), list(inl = 74L, outl = 30L, 
                 atl = list(na = FALSE)), list(inl = 80L, outl = 31L, atl = list(na = FALSE)), 
             list(inl = 68L, outl = 32L, atl = list(na = FALSE)), list(inl = 87L, outl = 32L, 
                 atl = list(na = FALSE)), list(inl = 71L, outl = 33L, atl = list(na = FALSE)), 
             list(inl = 92L, outl = 36L, atl = list(na = FALSE)), list(inl = 86L, outl = 39L, 
                 atl = list(na = FALSE)), list(inl = 98L, outl = 41L, atl = list(na = FALSE)), 
             list(inl = 78L, outl = 43L, atl = list(na = FALSE)), list(inl = 85L, outl = 43L, 
                 atl = list(na = FALSE)), list(inl = 72L, outl = 44L, atl = list(na = FALSE)), 
             list(inl = 56L, outl = 46L, atl = list(na = FALSE)), list(inl = 59L, outl = 49L, 
                 atl = list(na = FALSE)), list(inl = 68L, outl = 49L, atl = list(na = FALSE)), 
             list(inl = 79L, outl = 49L, atl = list(na = FALSE)), list(inl = 87L, outl = 50L, 
                 atl = list(na = FALSE))), gal = list(n = 100, mnext = 51L, directed = FALSE, 
             hyper = FALSE, loops = FALSE, multiple = FALSE, bipartite = 50), val = list(
             list(na = FALSE, vertex.names = 1L), list(na = FALSE, vertex.names = 2L), 
             list(na = FALSE, vertex.names = 3L), list(na = FALSE, vertex.names = 4L), 
             list(na = FALSE, vertex.names = 5L), list(na = FALSE, vertex.names = 6L), 
             list(na = FALSE, vertex.names = 7L), list(na = FALSE, vertex.names = 8L), 
             list(na = FALSE, vertex.names = 9L), list(na = FALSE, vertex.names = 10L), 
             list(na = FALSE, vertex.names = 11L), list(na = FALSE, vertex.names = 12L), 
             list(na = FALSE, vertex.names = 13L), list(na = FALSE, vertex.names = 14L), 
             list(na = FALSE, vertex.names = 15L), list(na = FALSE, vertex.names = 16L), 
             list(na = FALSE, vertex.names = 17L), list(na = FALSE, vertex.names = 18L), 
             list(na = FALSE, vertex.names = 19L), list(na = FALSE, vertex.names = 20L), 
             list(na = FALSE, vertex.names = 21L), list(na = FALSE, vertex.names = 22L), 
             list(na = FALSE, vertex.names = 23L), list(na = FALSE, vertex.names = 24L), 
             list(na = FALSE, vertex.names = 25L), list(na = FALSE, vertex.names = 26L), 
             list(na = FALSE, vertex.names = 27L), list(na = FALSE, vertex.names = 28L), 
             list(na = FALSE, vertex.names = 29L), list(na = FALSE, vertex.names = 30L), 
             list(na = FALSE, vertex.names = 31L), list(na = FALSE, vertex.names = 32L), 
             list(na = FALSE, vertex.names = 33L), list(na = FALSE, vertex.names = 34L), 
             list(na = FALSE, vertex.names = 35L), list(na = FALSE, vertex.names = 36L), 
             list(na = FALSE, vertex.names = 37L), list(na = FALSE, vertex.names = 38L), 
             list(na = FALSE, vertex.names = 39L), list(na = FALSE, vertex.names = 40L), 
             list(na = FALSE, vertex.names = 41L), list(na = FALSE, vertex.names = 42L), 
             list(na = FALSE, vertex.names = 43L), list(na = FALSE, vertex.names = 44L), 
             list(na = FALSE, vertex.names = 45L), list(na = FALSE, vertex.names = 46L), 
             list(na = FALSE, vertex.names = 47L), list(na = FALSE, vertex.names = 48L), 
             list(na = FALSE, vertex.names = 49L), list(na = FALSE, vertex.names = 50L), 
             list(na = FALSE, vertex.names = 51L), list(na = FALSE, vertex.names = 52L), 
             list(na = FALSE, vertex.names = 53L), list(na = FALSE, vertex.names = 54L), 
             list(na = FALSE, vertex.names = 55L), list(na = FALSE, vertex.names = 56L), 
             list(na = FALSE, vertex.names = 57L), list(na = FALSE, vertex.names = 58L), 
             list(na = FALSE, vertex.names = 59L), list(na = FALSE, vertex.names = 60L), 
             list(na = FALSE, vertex.names = 61L), list(na = FALSE, vertex.names = 62L), 
             list(na = FALSE, vertex.names = 63L), list(na = FALSE, vertex.names = 64L), 
             list(na = FALSE, vertex.names = 65L), list(na = FALSE, vertex.names = 66L), 
             list(na = FALSE, vertex.names = 67L), list(na = FALSE, vertex.names = 68L), 
             list(na = FALSE, vertex.names = 69L), list(na = FALSE, vertex.names = 70L), 
             list(na = FALSE, vertex.names = 71L), list(na = FALSE, vertex.names = 72L), 
             list(na = FALSE, vertex.names = 73L), list(na = FALSE, vertex.names = 74L), 
             list(na = FALSE, vertex.names = 75L), list(na = FALSE, vertex.names = 76L), 
             list(na = FALSE, vertex.names = 77L), list(na = FALSE, vertex.names = 78L), 
             list(na = FALSE, vertex.names = 79L), list(na = FALSE, vertex.names = 80L), 
             list(na = FALSE, vertex.names = 81L), list(na = FALSE, vertex.names = 82L), 
             list(na = FALSE, vertex.names = 83L), list(na = FALSE, vertex.names = 84L), 
             list(na = FALSE, vertex.names = 85L), list(na = FALSE, vertex.names = 86L), 
             list(na = FALSE, vertex.names = 87L), list(na = FALSE, vertex.names = 88L), 
             list(na = FALSE, vertex.names = 89L), list(na = FALSE, vertex.names = 90L), 
             list(na = FALSE, vertex.names = 91L), list(na = FALSE, vertex.names = 92L), 
             list(na = FALSE, vertex.names = 93L), list(na = FALSE, vertex.names = 94L), 
             list(na = FALSE, vertex.names = 95L), list(na = FALSE, vertex.names = 96L), 
             list(na = FALSE, vertex.names = 97L), list(na = FALSE, vertex.names = 98L), 
             list(na = FALSE, vertex.names = 99L), list(na = FALSE, vertex.names = 100L)), 
             iel = list(integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), 33L, 21L, integer(0), integer(0), 
                 46L, integer(0), 20L, 47L, integer(0), integer(0), integer(0), 3L, 34L, 
                 integer(0), c(14L, 22L), integer(0), c(37L, 48L), integer(0), 26L, c(23L, 
                 39L), c(4L, 7L, 45L), c(8L, 27L), c(5L, 35L), integer(0), 13L, 15L, c(31L, 
                 43L), c(17L, 49L), c(1L, 36L), integer(0), integer(0), 24L, c(11L, 30L
                 ), 44L, c(19L, 41L), c(38L, 50L), integer(0), 16L, integer(0), c(2L, 
                 25L, 28L), c(9L, 18L, 40L), 32L, 10L, integer(0), integer(0), 29L, 42L, 
                 12L, 6L), oel = list(2:1, 3L, integer(0), 6:4, integer(0), integer(0), 
                 10:7, integer(0), 12:11, integer(0), 13L, integer(0), integer(0), 16:14, 
                 integer(0), integer(0), 17L, 18L, 19L, 20L, 22:21, 25:23, 26L, 28:27, 
                 integer(0), 29L, 30L, 31L, 32L, 35:33, 36L, 38:37, 39L, integer(0), integer(0), 
                 40L, integer(0), integer(0), 41L, integer(0), 42L, integer(0), 44:43, 
                 45L, integer(0), 46L, integer(0), integer(0), 49:47, 50L, integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0))), class = "network"), reference = ~Bernoulli, newnetwork = structure(list(
             mel = list(list(inl = 80L, outl = 1L, atl = list(na = FALSE)), list(inl = 91L, 
                 outl = 1L, atl = list(na = FALSE)), list(inl = 63L, outl = 2L, atl = list(
                 na = FALSE)), list(inl = 72L, outl = 4L, atl = list(na = FALSE)), list(
                 inl = 74L, outl = 4L, atl = list(na = FALSE)), list(inl = 100L, outl = 4L, 
                 atl = list(na = FALSE)), list(inl = 72L, outl = 7L, atl = list(na = FALSE)), 
                 list(inl = 73L, outl = 7L, atl = list(na = FALSE)), list(inl = 92L, outl = 7L, 
                     atl = list(na = FALSE)), list(inl = 94L, outl = 7L, atl = list(na = FALSE)), 
                 list(inl = 84L, outl = 9L, atl = list(na = FALSE)), list(inl = 99L, outl = 9L, 
                     atl = list(na = FALSE)), list(inl = 76L, outl = 11L, atl = list(na = FALSE)), 
                 list(inl = 66L, outl = 14L, atl = list(na = FALSE)), list(inl = 77L, 
                     outl = 14L, atl = list(na = FALSE)), list(inl = 89L, outl = 14L, 
                     atl = list(na = FALSE)), list(inl = 79L, outl = 17L, atl = list(na = FALSE)), 
                 list(inl = 92L, outl = 18L, atl = list(na = FALSE)), list(inl = 86L, 
                     outl = 19L, atl = list(na = FALSE)), list(inl = 58L, outl = 20L, 
                     atl = list(na = FALSE)), list(inl = 53L, outl = 21L, atl = list(na = FALSE)), 
                 list(inl = 66L, outl = 21L, atl = list(na = FALSE)), list(inl = 71L, 
                     outl = 22L, atl = list(na = FALSE)), list(inl = 83L, outl = 22L, 
                     atl = list(na = FALSE)), list(inl = 91L, outl = 22L, atl = list(na = FALSE)), 
                 list(inl = 70L, outl = 23L, atl = list(na = FALSE)), list(inl = 73L, 
                     outl = 24L, atl = list(na = FALSE)), list(inl = 91L, outl = 24L, 
                     atl = list(na = FALSE)), list(inl = 97L, outl = 26L, atl = list(na = FALSE)), 
                 list(inl = 84L, outl = 27L, atl = list(na = FALSE)), list(inl = 78L, 
                     outl = 28L, atl = list(na = FALSE)), list(inl = 93L, outl = 29L, 
                     atl = list(na = FALSE)), list(inl = 52L, outl = 30L, atl = list(na = FALSE)), 
                 list(inl = 64L, outl = 30L, atl = list(na = FALSE)), list(inl = 74L, 
                     outl = 30L, atl = list(na = FALSE)), list(inl = 80L, outl = 31L, 
                     atl = list(na = FALSE)), list(inl = 68L, outl = 32L, atl = list(na = FALSE)), 
                 list(inl = 87L, outl = 32L, atl = list(na = FALSE)), list(inl = 71L, 
                     outl = 33L, atl = list(na = FALSE)), list(inl = 92L, outl = 36L, 
                     atl = list(na = FALSE)), list(inl = 86L, outl = 39L, atl = list(na = FALSE)), 
                 list(inl = 98L, outl = 41L, atl = list(na = FALSE)), list(inl = 78L, 
                     outl = 43L, atl = list(na = FALSE)), list(inl = 85L, outl = 43L, 
                     atl = list(na = FALSE)), list(inl = 72L, outl = 44L, atl = list(na = FALSE)), 
                 list(inl = 56L, outl = 46L, atl = list(na = FALSE)), list(inl = 59L, 
                     outl = 49L, atl = list(na = FALSE)), list(inl = 68L, outl = 49L, 
                     atl = list(na = FALSE)), list(inl = 79L, outl = 49L, atl = list(na = FALSE)), 
                 list(inl = 87L, outl = 50L, atl = list(na = FALSE))), gal = list(n = 100, 
                 mnext = 51L, directed = FALSE, hyper = FALSE, loops = FALSE, multiple = FALSE, 
                 bipartite = 50), val = list(list(na = FALSE, vertex.names = 1L), list(
                 na = FALSE, vertex.names = 2L), list(na = FALSE, vertex.names = 3L), 
                 list(na = FALSE, vertex.names = 4L), list(na = FALSE, vertex.names = 5L), 
                 list(na = FALSE, vertex.names = 6L), list(na = FALSE, vertex.names = 7L), 
                 list(na = FALSE, vertex.names = 8L), list(na = FALSE, vertex.names = 9L), 
                 list(na = FALSE, vertex.names = 10L), list(na = FALSE, vertex.names = 11L), 
                 list(na = FALSE, vertex.names = 12L), list(na = FALSE, vertex.names = 13L), 
                 list(na = FALSE, vertex.names = 14L), list(na = FALSE, vertex.names = 15L), 
                 list(na = FALSE, vertex.names = 16L), list(na = FALSE, vertex.names = 17L), 
                 list(na = FALSE, vertex.names = 18L), list(na = FALSE, vertex.names = 19L), 
                 list(na = FALSE, vertex.names = 20L), list(na = FALSE, vertex.names = 21L), 
                 list(na = FALSE, vertex.names = 22L), list(na = FALSE, vertex.names = 23L), 
                 list(na = FALSE, vertex.names = 24L), list(na = FALSE, vertex.names = 25L), 
                 list(na = FALSE, vertex.names = 26L), list(na = FALSE, vertex.names = 27L), 
                 list(na = FALSE, vertex.names = 28L), list(na = FALSE, vertex.names = 29L), 
                 list(na = FALSE, vertex.names = 30L), list(na = FALSE, vertex.names = 31L), 
                 list(na = FALSE, vertex.names = 32L), list(na = FALSE, vertex.names = 33L), 
                 list(na = FALSE, vertex.names = 34L), list(na = FALSE, vertex.names = 35L), 
                 list(na = FALSE, vertex.names = 36L), list(na = FALSE, vertex.names = 37L), 
                 list(na = FALSE, vertex.names = 38L), list(na = FALSE, vertex.names = 39L), 
                 list(na = FALSE, vertex.names = 40L), list(na = FALSE, vertex.names = 41L), 
                 list(na = FALSE, vertex.names = 42L), list(na = FALSE, vertex.names = 43L), 
                 list(na = FALSE, vertex.names = 44L), list(na = FALSE, vertex.names = 45L), 
                 list(na = FALSE, vertex.names = 46L), list(na = FALSE, vertex.names = 47L), 
                 list(na = FALSE, vertex.names = 48L), list(na = FALSE, vertex.names = 49L), 
                 list(na = FALSE, vertex.names = 50L), list(na = FALSE, vertex.names = 51L), 
                 list(na = FALSE, vertex.names = 52L), list(na = FALSE, vertex.names = 53L), 
                 list(na = FALSE, vertex.names = 54L), list(na = FALSE, vertex.names = 55L), 
                 list(na = FALSE, vertex.names = 56L), list(na = FALSE, vertex.names = 57L), 
                 list(na = FALSE, vertex.names = 58L), list(na = FALSE, vertex.names = 59L), 
                 list(na = FALSE, vertex.names = 60L), list(na = FALSE, vertex.names = 61L), 
                 list(na = FALSE, vertex.names = 62L), list(na = FALSE, vertex.names = 63L), 
                 list(na = FALSE, vertex.names = 64L), list(na = FALSE, vertex.names = 65L), 
                 list(na = FALSE, vertex.names = 66L), list(na = FALSE, vertex.names = 67L), 
                 list(na = FALSE, vertex.names = 68L), list(na = FALSE, vertex.names = 69L), 
                 list(na = FALSE, vertex.names = 70L), list(na = FALSE, vertex.names = 71L), 
                 list(na = FALSE, vertex.names = 72L), list(na = FALSE, vertex.names = 73L), 
                 list(na = FALSE, vertex.names = 74L), list(na = FALSE, vertex.names = 75L), 
                 list(na = FALSE, vertex.names = 76L), list(na = FALSE, vertex.names = 77L), 
                 list(na = FALSE, vertex.names = 78L), list(na = FALSE, vertex.names = 79L), 
                 list(na = FALSE, vertex.names = 80L), list(na = FALSE, vertex.names = 81L), 
                 list(na = FALSE, vertex.names = 82L), list(na = FALSE, vertex.names = 83L), 
                 list(na = FALSE, vertex.names = 84L), list(na = FALSE, vertex.names = 85L), 
                 list(na = FALSE, vertex.names = 86L), list(na = FALSE, vertex.names = 87L), 
                 list(na = FALSE, vertex.names = 88L), list(na = FALSE, vertex.names = 89L), 
                 list(na = FALSE, vertex.names = 90L), list(na = FALSE, vertex.names = 91L), 
                 list(na = FALSE, vertex.names = 92L), list(na = FALSE, vertex.names = 93L), 
                 list(na = FALSE, vertex.names = 94L), list(na = FALSE, vertex.names = 95L), 
                 list(na = FALSE, vertex.names = 96L), list(na = FALSE, vertex.names = 97L), 
                 list(na = FALSE, vertex.names = 98L), list(na = FALSE, vertex.names = 99L), 
                 list(na = FALSE, vertex.names = 100L)), iel = list(integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), 33L, 21L, integer(0), integer(0), 46L, integer(0), 20L, 47L, 
                 integer(0), integer(0), integer(0), 3L, 34L, integer(0), c(14L, 22L), 
                 integer(0), c(37L, 48L), integer(0), 26L, c(23L, 39L), c(4L, 7L, 45L), 
                 c(8L, 27L), c(5L, 35L), integer(0), 13L, 15L, c(31L, 43L), c(17L, 49L
                 ), c(1L, 36L), integer(0), integer(0), 24L, c(11L, 30L), 44L, c(19L, 
                 41L), c(38L, 50L), integer(0), 16L, integer(0), c(2L, 25L, 28L), c(9L, 
                 18L, 40L), 32L, 10L, integer(0), integer(0), 29L, 42L, 12L, 6L), oel = list(
                 2:1, 3L, integer(0), 6:4, integer(0), integer(0), 10:7, integer(0), 12:11, 
                 integer(0), 13L, integer(0), integer(0), 16:14, integer(0), integer(0), 
                 17L, 18L, 19L, 20L, 22:21, 25:23, 26L, 28:27, integer(0), 29L, 30L, 31L, 
                 32L, 35:33, 36L, 38:37, 39L, integer(0), integer(0), 40L, integer(0), 
                 integer(0), 41L, integer(0), 42L, integer(0), 44:43, 45L, integer(0), 
                 46L, integer(0), integer(0), 49:47, 50L, integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0), integer(0), 
                 integer(0), integer(0), integer(0), integer(0), integer(0))), class = "network"), 
         formula = TARGET_STATS ~ edges, constraints = ~., target.stats = c(edges = 50), 
         etamap = list(canonical = 1L, offsetmap = FALSE, offset = FALSE, offsettheta = FALSE, 
             curved = list(), etalength = 1), target.esteq = structure(-50, .Dim = c(1L, 
         1L), .Dimnames = list(NULL, "edges")), estimate = "MLE", control = structure(list(
             drop = TRUE, init = NA_real_, init.method = "MPLE", main.method = "MCMLE", 
             force.main = FALSE, main.hessian = TRUE, checkpoint = NULL, resume = NULL, 
             MPLE.max.dyad.types = 1e+06, MPLE.samplesize = 50000, MPLE.type = "glm", 
             MCMC.prop.weights = "default", MCMC.prop.args = list(), MCMC.interval = 1024, 
             MCMC.burnin = 16384, MCMC.samplesize = 1024, MCMC.effectiveSize = NULL, MCMC.effectiveSize.damp = 10, 
             MCMC.effectiveSize.maxruns = 1000, MCMC.effectiveSize.base = 0.5, MCMC.effectiveSize.points = 5, 
             MCMC.effectiveSize.order = 1, MCMC.return.stats = TRUE, MCMC.runtime.traceplot = FALSE, 
             MCMC.init.maxedges = 20000, MCMC.max.maxedges = Inf, MCMC.addto.se = TRUE, 
             MCMC.compress = FALSE, MCMC.packagenames = NULL, SAN.maxit = 4, SAN.nsteps.times = 8, 
             SAN.control = structure(list(SAN.maxit = 4, SAN.tau = 1, SAN.invcov = NULL, 
                 SAN.invcov.diag = FALSE, SAN.nsteps.alloc = function (nsim) 
                 2^seq_len(nsim), SAN.nsteps = 131072, SAN.samplesize = 1024, SAN.init.maxedges = 20000, 
                 SAN.max.maxedges = Inf, SAN.prop.weights = "default", SAN.prop.args = list(), 
                 SAN.packagenames = NULL, term.options = NULL, seed = NULL, parallel = 0, 
                 parallel.type = NULL, parallel.version.check = TRUE), class = c("control.san", 
             "control.list", "list")), MCMLE.termination = "Hummel", MCMLE.maxit = 20, 
             MCMLE.conv.min.pval = 0.5, MCMLE.NR.maxit = 100, MCMLE.NR.reltol = 1.49011611938477e-08, 
             obs.MCMC.samplesize = 1024, obs.MCMC.interval = 1024, obs.MCMC.burnin = 16384, 
             obs.MCMC.burnin.min = 1638.4, obs.MCMC.prop.weights = "default", obs.MCMC.prop.args = list(), 
             obs.MCMC.impute.min_informative = function (nw) 
             network.size(nw)/4, obs.MCMC.impute.default_density = function (nw) 
             2/network.size(nw), MCMLE.check.degeneracy = FALSE, MCMLE.MCMC.precision = 0.005, 
             MCMLE.MCMC.max.ESS.frac = 0.1, MCMLE.metric = "lognormal", MCMLE.method = "BFGS", 
             MCMLE.trustregion = 20, MCMLE.dampening = FALSE, MCMLE.dampening.min.ess = 20, 
             MCMLE.dampening.level = 0.1, MCMLE.steplength.margin = 0.05, MCMLE.steplength = 1, 
             MCMLE.adaptive.trustregion = 3, MCMLE.sequential = TRUE, MCMLE.density.guard.min = 10000, 
             MCMLE.density.guard = 20.0855369231877, MCMLE.effectiveSize = NULL, MCMLE.last.boost = 4, 
             MCMLE.Hummel.esteq = TRUE, MCMLE.Hummel.miss.sample = 100, MCMLE.Hummel.maxit = 25, 
             MCMLE.steplength.min = 1e-04, MCMLE.effectiveSize.interval_drop = 2, MCMLE.save_intermediates = NULL, 
             SA.phase1_n = NULL, SA.initial_gain = NULL, SA.nsubphases = 4, SA.niterations = NULL, 
             SA.phase3_n = NULL, SA.trustregion = 0.5, RM.phase1n_base = 7, RM.phase2n_base = 100, 
             RM.phase2sub = 7, RM.init_gain = 0.5, RM.phase3n = 500, Step.MCMC.samplesize = 100, 
             Step.maxit = 50, Step.gridsize = 100, CD.nsteps = 8, CD.multiplicity = 1, 
             CD.nsteps.obs = 128, CD.multiplicity.obs = 1, CD.maxit = 60, CD.conv.min.pval = 0.5, 
             CD.NR.maxit = 100, CD.NR.reltol = 1.49011611938477e-08, CD.metric = "naive", 
             CD.method = "BFGS", CD.trustregion = 20, CD.dampening = FALSE, CD.dampening.min.ess = 20, 
             CD.dampening.level = 0.1, CD.steplength.margin = 0.5, CD.steplength = 1, 
             CD.adaptive.trustregion = 3, CD.adaptive.epsilon = 0.01, CD.Hummel.esteq = TRUE, 
             CD.Hummel.miss.sample = 100, CD.Hummel.maxit = 25, CD.steplength.min = 1e-04, 
             loglik.control = structure(list(nsteps = 20, MCMC.burnin = NULL, MCMC.interval = NULL, 
                 MCMC.samplesize = NULL, obs.MCMC.samplesize = NULL, obs.MCMC.interval = NULL, 
                 obs.MCMC.burnin = NULL, MCMC.prop.weights = NULL, MCMC.prop.args = NULL, 
                 warn.dyads = NULL, MCMC.init.maxedges = NULL, MCMC.packagenames = NULL, 
                 term.options = NULL, seed = NULL, parallel = NULL, parallel.type = NULL, 
                 parallel.version.check = TRUE), class = c("control.logLik.ergm", "control.list", 
             "list")), term.options = NULL, seed = NULL, parallel = 0, parallel.type = NULL, 
             parallel.version.check = TRUE), class = c("control.ergm", "control.list", 
         "list"))), class = "ergm"), formation = ~edges, target.stats = 50, target.stats.names = "edges", 
         coef.form = c(edges = -7.78364059622123), coef.form.crude = c(edges = -3.8918202981106), 
         coef.diss = structure(list(dissolution = ~offset(edges), duration = 50, coef.crude = 3.89182029811063, 
             coef.adj = 9.19013766465877, d.rate = 0.01, model.type = "homog"), class = "disscoef"), 
         constraints = ~., edapprox = TRUE), class = "netest"), structure(list(inf.prob = 0.1, 
         a.rate = 0.01, ds.rate = 0.01, di.rate = 0.01, inf.prob.m2 = 0.1, a.rate.m2 = 0.01, 
         ds.rate.m2 = 0.01, di.rate.m2 = 0.01, act.rate = 1, vital = TRUE), class = c("param.net", 
     "list")), structure(list(i.num = 10, i.num.m2 = 10), class = c("init.net", "list"
     )), structure(list(type = "SI", nsteps = 10, start = 1, nsims = 1, ncores = 1, rec.rand = TRUE, 
         a.rand = TRUE, d.rand = TRUE, tea.status = TRUE, use.pids = TRUE, initialize.FUN = function (x, 
             param, init, control, s) 
         {
             if (control$start == 1) {
                 dat <- list()
                 dat$param <- param
                 dat$init <- init
                 dat$control <- control
                 dat$attr <- list()
                 dat$stats <- list()
                 dat$temp <- list()
                 nw <- simulate(x$fit, basis = x$fit$newnetwork, control = control$set.control.ergm)
                 modes <- ifelse(nw %n% "bipartite", 2, 1)
                 if (control$depend == TRUE) {
                     if (class(x$fit) == "stergm") {
                       nw <- network.collapse(nw, at = 1)
                     }
                     nw <- sim_nets(x, nw, nsteps = 1, control)
                 }
                 if (control$depend == FALSE) {
                     nw <- sim_nets(x, nw, nsteps = control$nsteps, control)
                 }
                 nw <- activate.vertices(nw, onset = 1, terminus = Inf)
                 dat$nw <- nw
                 dat$nwparam <- list(x[-which(names(x) == "fit")])
                 dat$param$modes <- modes
                 if (control$use.pids == TRUE) {
                     dat$nw <- init_pids(dat$nw, dat$control$pid.prefix)
                 }
                 form <- get_nwparam(dat)$formation
                 fterms <- get_formula_term_attr(form, nw)
                 dat <- copy_toall_attr(dat, at = 1, fterms)
                 dat$temp$fterms <- fterms
                 dat$temp$t1.tab <- get_attr_prop(dat$nw, fterms)
                 dat <- init_status.net(dat)
                 dat <- get_prev.net(dat, at = 1)
             }
             else {
                 dat <- list()
                 dat$nw <- x$network[[s]]
                 dat$param <- x$param
                 dat$control <- control
                 dat$nwparam <- x$nwparam
                 dat$epi <- sapply(x$epi, function(var) var[s])
                 names(dat$epi) <- names(x$epi)
                 dat$attr <- x$attr[[s]]
                 dat$stats <- sapply(x$stats, function(var) var[[s]])
                 dat$temp <- list()
             }
             return(dat)
         }, departures.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             d.rand <- dat$control$d.rand
             nDepartures.sus <- nDeparturesM2.sus <- 0
             idsElig.sus <- which(dat$attr$active == 1 & dat$attr$status == "s")
             nElig.sus <- length(idsElig.sus)
             if (nElig.sus > 0) {
                 mElig.sus <- mode[idsElig.sus]
                 rates.sus <- c(dat$param$ds.rate, dat$param$ds.rate.m2)
                 ratesElig.sus <- rates.sus[mElig.sus]
                 if (d.rand == TRUE) {
                     vecDepartures.sus <- which(rbinom(nElig.sus, 1, ratesElig.sus) == 
                       1)
                     if (length(vecDepartures.sus) > 0) {
                       idsDpt.sus <- idsElig.sus[vecDepartures.sus]
                       nDepartures.sus <- sum(mode[idsDpt.sus] == 1)
                       nDeparturesM2.sus <- sum(mode[idsDpt.sus] == 2)
                       dat$attr$active[idsDpt.sus] <- 0
                       dat$attr$exitTime[idsDpt.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.sus, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.sus <- idsDptM2.sus <- NULL
                     nDepartures.sus <- min(round(sum(ratesElig.sus[mElig.sus == 1])), 
                       sum(mElig.sus == 1))
                     idsDpt.sus <- ssample(idsElig.sus[mElig.sus == 1], nDepartures.sus)
                     if (modes == 2) {
                       nDeparturesM2.sus <- min(round(sum(ratesElig.sus[mElig.sus == 2])), 
                         sum(mElig.sus == 2))
                       idsDptM2.sus <- ssample(idsElig.sus[mElig.sus == 2], nDeparturesM2.sus)
                     }
                     totDpt.sus <- nDepartures.sus + nDeparturesM2.sus
                     if (totDpt.sus > 0) {
                       idsDptAll.sus <- c(idsDpt.sus, idsDptM2.sus)
                       dat$attr$active[idsDptAll.sus] <- 0
                       dat$attr$exitTime[idsDptAll.sus] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.sus, deactivate.edges = TRUE)
                     }
                 }
             }
             nDepartures.inf <- nDeparturesM2.inf <- 0
             idsElig.inf <- which(dat$attr$active == 1 & dat$attr$status == "i")
             nElig.inf <- length(idsElig.inf)
             if (nElig.inf > 0) {
                 mElig.inf <- mode[idsElig.inf]
                 rates.inf <- c(dat$param$di.rate, dat$param$di.rate.m2)
                 ratesElig.inf <- rates.inf[mElig.inf]
                 if (d.rand == TRUE) {
                     vecDepartures.inf <- which(rbinom(nElig.inf, 1, ratesElig.inf) == 
                       1)
                     if (length(vecDepartures.inf) > 0) {
                       idsDpt.inf <- idsElig.inf[vecDepartures.inf]
                       nDepartures.inf <- sum(mode[idsDpt.inf] == 1)
                       nDeparturesM2.inf <- sum(mode[idsDpt.inf] == 2)
                       dat$attr$active[idsDpt.inf] <- 0
                       dat$attr$exitTime[idsDpt.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDpt.inf, deactivate.edges = TRUE)
                     }
                 }
                 if (d.rand == FALSE) {
                     idsDpt.inf <- idsDptM2.inf <- NULL
                     nDepartures.inf <- min(round(sum(ratesElig.inf[mElig.inf == 1])), 
                       sum(mElig.inf == 1))
                     idsDpt.inf <- ssample(idsElig.inf[mElig.inf == 1], nDepartures.inf)
                     if (modes == 2) {
                       nDeparturesM2.inf <- min(round(sum(ratesElig.inf[mElig.inf == 2])), 
                         sum(mElig.inf == 2))
                       idsDptM2.inf <- ssample(idsElig.inf[mElig.inf == 2], nDeparturesM2.inf)
                     }
                     totDpt.inf <- nDepartures.inf + nDeparturesM2.inf
                     if (totDpt.inf > 0) {
                       idsDptAll.inf <- c(idsDpt.inf, idsDptM2.inf)
                       dat$attr$active[idsDptAll.inf] <- 0
                       dat$attr$exitTime[idsDptAll.inf] <- at
                       dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                         v = idsDptAll.inf, deactivate.edges = TRUE)
                     }
                 }
             }
             if (type == "SIR") {
                 nDepartures.rec <- nDeparturesM2.rec <- 0
                 idsElig.rec <- which(dat$attr$active == 1 & dat$attr$status == "r")
                 nElig.rec <- length(idsElig.rec)
                 if (nElig.rec > 0) {
                     mElig.rec <- mode[idsElig.rec]
                     rates.rec <- c(dat$param$dr.rate, dat$param$dr.rate.m2)
                     ratesElig.rec <- rates.rec[mElig.rec]
                     if (d.rand == TRUE) {
                       vecDepartures.rec <- which(rbinom(nElig.rec, 1, ratesElig.rec) == 
                         1)
                       if (length(vecDepartures.rec) > 0) {
                         idsDpt.rec <- idsElig.rec[vecDepartures.rec]
                         nDepartures.rec <- sum(mode[idsDpt.rec] == 1)
                         nDeparturesM2.rec <- sum(mode[idsDpt.rec] == 2)
                         dat$attr$active[idsDpt.rec] <- 0
                         dat$attr$exitTime[idsDpt.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDpt.rec, deactivate.edges = TRUE)
                       }
                     }
                     if (d.rand == FALSE) {
                       idsDpt.rec <- idsDptM2.rec <- NULL
                       nDepartures.rec <- min(round(sum(ratesElig.rec[mElig.rec == 1])), 
                         sum(mElig.rec == 1))
                       idsDpt.rec <- ssample(idsElig.rec[mElig.rec == 1], nDepartures.rec)
                       if (modes == 2) {
                         nDeparturesM2.rec <- min(round(sum(ratesElig.rec[mElig.rec == 
                           2])), sum(mElig.rec == 2))
                         idsDptM2.rec <- ssample(idsElig.rec[mElig.rec == 2], nDeparturesM2.rec)
                       }
                       totDpt.rec <- nDepartures.rec + nDeparturesM2.rec
                       if (totDpt.rec > 0) {
                         idsDptAll.rec <- c(idsDpt.rec, idsDptM2.rec)
                         dat$attr$active[idsDptAll.rec] <- 0
                         dat$attr$exitTime[idsDptAll.rec] <- at
                         dat$nw <- deactivate.vertices(dat$nw, onset = at, terminus = Inf, 
                           v = idsDptAll.rec, deactivate.edges = TRUE)
                       }
                     }
                 }
             }
             if (at == 2) {
                 dat$epi$ds.flow <- c(0, nDepartures.sus)
                 dat$epi$di.flow <- c(0, nDepartures.inf)
                 if (type == "SIR") {
                     dat$epi$dr.flow <- c(0, nDepartures.rec)
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2 <- c(0, nDeparturesM2.sus)
                     dat$epi$di.flow.m2 <- c(0, nDeparturesM2.inf)
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2 <- c(0, nDeparturesM2.rec)
                     }
                 }
             }
             else {
                 dat$epi$ds.flow[at] <- nDepartures.sus
                 dat$epi$di.flow[at] <- nDepartures.inf
                 if (type == "SIR") {
                     dat$epi$dr.flow[at] <- nDepartures.rec
                 }
                 if (modes == 2) {
                     dat$epi$ds.flow.m2[at] <- nDeparturesM2.sus
                     dat$epi$di.flow.m2[at] <- nDeparturesM2.inf
                     if (type == "SIR") {
                       dat$epi$dr.flow.m2[at] <- nDeparturesM2.rec
                     }
                 }
             }
             return(dat)
         }, arrivals.FUN = function (dat, at) 
         {
             if (dat$param$vital == FALSE) {
                 return(dat)
             }
             a.rate <- dat$param$a.rate
             a.rate.m2 <- dat$param$a.rate.m2
             modes <- dat$param$modes
             tea.status <- dat$control$tea.status
             nOld <- dat$epi$num[at - 1]
             nCurr <- network.size(dat$nw)
             a.rand <- dat$control$a.rand
             delete.nodes <- dat$control$delete.nodes
             nArrivals <- nArrivalsM2 <- 0
             newNodes <- newNodesM2 <- NULL
             if (modes == 1 && nOld > 0) {
                 if (a.rand == TRUE) {
                     nArrivals <- sum(rbinom(nOld, 1, a.rate))
                 }
                 if (a.rand == FALSE) {
                     nArrivals <- round(nOld * a.rate)
                 }
                 if (nArrivals > 0) {
                     dat$nw <- add.vertices(dat$nw, nv = nArrivals)
                     newNodes <- (nCurr + 1):(nCurr + nArrivals)
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (modes == 2 && nOld > 0) {
                 nOldM2 <- dat$epi$num.m2[at - 1]
                 if (a.rand == TRUE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOld, 1, a.rate))
                     }
                     else {
                       nArrivals <- sum(rbinom(nOld, 1, a.rate))
                       nArrivalsM2 <- sum(rbinom(nOldM2, 1, a.rate.m2))
                     }
                 }
                 if (a.rand == FALSE) {
                     if (is.na(a.rate.m2)) {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOld * a.rate)
                     }
                     else {
                       nArrivals <- round(nOld * a.rate)
                       nArrivalsM2 <- round(nOldM2 * a.rate.m2)
                     }
                 }
                 nCurrM1 <- length(modeids(dat$nw, 1))
                 nCurrM2 <- length(modeids(dat$nw, 2))
                 prefixes <- unique(substr(dat$nw %v% "vertex.names", 1, 1))
                 if (nArrivals > 0) {
                     newNodeIDs <- (nCurrM1 + 1):(nCurrM1 + nArrivals)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[1], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivals, last.mode = FALSE)
                     }
                     newNodes <- newNodeIDs
                 }
                 if (nArrivalsM2 > 0) {
                     newNodeIDs <- (nCurrM2 + 1):(nCurrM2 + nArrivalsM2)
                     if (delete.nodes == FALSE) {
                       newPids <- paste0(prefixes[2], newNodeIDs)
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE, 
                         vertex.pid = newPids)
                     }
                     else {
                       dat$nw <- add.vertices(dat$nw, nv = nArrivalsM2, last.mode = TRUE)
                     }
                     newSize <- network.size(dat$nw)
                     newNodesM2 <- (newSize - nArrivalsM2 + 1):newSize
                 }
                 newNodes <- c(newNodes, newNodesM2)
                 if (!is.null(newNodes)) {
                     dat$nw <- activate.vertices(dat$nw, onset = at, terminus = Inf, v = newNodes)
                 }
             }
             if (length(newNodes) > 0) {
                 fterms <- dat$temp$fterms
                 curr.tab <- get_attr_prop(dat$nw, fterms)
                 if (length(curr.tab) > 0) {
                     dat$nw <- update_nwattr(dat$nw, newNodes, dat$control$attr.rules, 
                       curr.tab, dat$temp$t1.tab)
                 }
                 dat <- copy_toall_attr(dat, at, fterms)
                 if (tea.status == TRUE) {
                     if ("status" %in% fterms) {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = dat$attr$status[newNodes], onset = at, terminus = Inf, 
                         v = newNodes)
                     }
                     else {
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = "s", onset = at, terminus = Inf, v = newNodes)
                     }
                 }
                 if (modes == 1) {
                     if (!("status" %in% fterms)) {
                       dat$attr$status <- c(dat$attr$status, rep("s", length(newNodes)))
                     }
                     dat$attr$active <- c(dat$attr$active, rep(1, length(newNodes)))
                     dat$attr$infTime <- c(dat$attr$infTime, rep(NA, length(newNodes)))
                     dat$attr$entrTime <- c(dat$attr$entrTime, rep(at, length(newNodes)))
                     dat$attr$exitTime <- c(dat$attr$exitTime, rep(NA, length(newNodes)))
                 }
                 if (modes == 2) {
                     if (!("status" %in% fterms)) {
                       dat <- split_bip(dat, "status", "s", nCurrM1, nCurrM2, nArrivals, 
                         nArrivalsM2)
                     }
                     dat <- split_bip(dat, "active", 1, nCurrM1, nCurrM2, nArrivals, nArrivalsM2)
                     dat <- split_bip(dat, "infTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "entrTime", at, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                     dat <- split_bip(dat, "exitTime", NA, nCurrM1, nCurrM2, nArrivals, 
                       nArrivalsM2)
                 }
                 newNodesInf <- intersect(newNodes, which(dat$attr$status == "i"))
                 dat$attr$infTime[newNodesInf] <- at
                 if (length(unique(sapply(dat$attr, length))) != 1) {
                     stop("Attribute list of unequal length. Check arrivals.net module.")
                 }
             }
             if (at == 2) {
                 dat$epi$a.flow <- c(0, nArrivals)
                 if (modes == 2) {
                     dat$epi$a.flow.m2 <- c(0, nArrivalsM2)
                 }
             }
             else {
                 dat$epi$a.flow[at] <- nArrivals
                 if (modes == 2) {
                     dat$epi$a.flow.m2[at] <- nArrivalsM2
                 }
             }
             return(dat)
         }, recovery.FUN = function (dat, at) 
         {
             if (!(dat$control$type %in% c("SIR", "SIS"))) {
                 return(dat)
             }
             active <- dat$attr$active
             status <- dat$attr$status
             infTime <- dat$attr$infTime
             tea.status <- dat$control$tea.status
             modes <- dat$param$modes
             mode <- idmode(dat$nw)
             type <- dat$control$type
             recovState <- ifelse(type == "SIR", "r", "s")
             rec.rand <- dat$control$rec.rand
             rec.rate <- dat$param$rec.rate
             rec.rate.m2 <- dat$param$rec.rate.m2
             nRecov <- nRecovM2 <- 0
             idsElig <- which(active == 1 & status == "i")
             nElig <- length(idsElig)
             infDur <- at - infTime[active == 1 & status == "i"]
             infDur[infDur == 0] <- 1
             lrec.rate <- length(rec.rate)
             if (lrec.rate == 1) {
                 mElig <- mode[idsElig]
                 rates <- c(rec.rate, rec.rate.m2)
                 ratesElig <- rates[mElig]
             }
             else {
                 mElig <- mode[idsElig]
                 if (is.null(rec.rate.m2)) {
                     rates <- ifelse(infDur <= lrec.rate, rec.rate[infDur], rec.rate[lrec.rate])
                 }
                 else {
                     rates <- rep(NA, length(infDur))
                     rates[mElig == 1] <- ifelse(infDur[mElig == 1] <= lrec.rate, rec.rate[infDur[mElig == 
                       1]], rec.rate[lrec.rate])
                     rates[mElig == 2] <- ifelse(infDur[mElig == 2] <= length(rec.rate.m2), 
                       rec.rate.m2[infDur[mElig == 2]], rec.rate.m2[length(rec.rate.m2)])
                 }
                 ratesElig <- rates
             }
             if (nElig > 0) {
                 if (rec.rand == TRUE) {
                     vecRecov <- which(rbinom(nElig, 1, ratesElig) == 1)
                     if (length(vecRecov) > 0) {
                       idsRecov <- idsElig[vecRecov]
                       nRecov <- sum(mode[idsRecov] == 1)
                       nRecovM2 <- sum(mode[idsRecov] == 2)
                       status[idsRecov] <- recovState
                       if (tea.status == TRUE) {
                         dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                           value = recovState, onset = at, terminus = Inf, v = idsRecov)
                       }
                     }
                 }
                 else {
                     idsRecov <- idsRecovM2 <- NULL
                     nRecov <- min(round(sum(ratesElig[mElig == 1])), sum(mElig == 1))
                     if (nRecov > 0) {
                       idsRecov <- ssample(idsElig[mElig == 1], nRecov)
                       status[idsRecov] <- recovState
                     }
                     if (modes == 2) {
                       nRecovM2 <- min(round(sum(ratesElig[mElig == 2])), sum(mElig == 
                         2))
                       if (nRecovM2 > 0) {
                         idsRecovM2 <- ssample(idsElig[mElig == 2], nRecovM2)
                         status[idsRecovM2] <- recovState
                       }
                     }
                     totRecov <- nRecov + nRecovM2
                     if (tea.status == TRUE & totRecov > 0) {
                       allids <- c(idsRecov, idsRecovM2)
                       dat$nw <- activate.vertex.attribute(dat$nw, prefix = "testatus", 
                         value = recovState, onset = at, terminus = Inf, v = allids)
                     }
                 }
             }
             dat$attr$status <- status
             if ("status" %in% dat$temp$fterms) {
                 dat$nw <- set.vertex.attribute(dat$nw, "status", dat$attr$status)
             }
             outName <- ifelse(type == "SIR", "ir.flow", "is.flow")
             outName[2] <- paste0(outName, ".m2")
             if (at == 2) {
                 dat$epi[[outName[1]]] <- c(0, nRecov)
             }
             else {
                 dat$epi[[outName[1]]][at] <- nRecov
             }
             if (modes == 2) {
                 if (at == 2) {
                     dat$epi[[outName[2]]] <- c(0, nRecovM2)
                 }
                 else {
                     dat$epi[[outName[2]]][at] <- nRecovM2
                 }
             }
             return(dat)
         }, edges_correct.FUN = function (dat, at) 
         {
             if (dat$control$depend == TRUE) {
                 if (dat$param$modes == 1) {
                     old.num <- dat$epi$num[at - 1]
                     new.num <- sum(dat$attr$active == 1)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(old.num) - log(new.num)
                 }
                 if (dat$param$modes == 2) {
                     mode <- idmode(dat$nw)
                     old.num.m1 <- dat$epi$num[at - 1]
                     old.num.m2 <- dat$epi$num.m2[at - 1]
                     new.num.m1 <- sum(dat$attr$active == 1 & mode == 1)
                     new.num.m2 <- sum(dat$attr$active == 1 & mode == 2)
                     dat$nwparam[[1]]$coef.form[1] <- dat$nwparam[[1]]$coef.form[1] + 
                       log(2 * old.num.m1 * old.num.m2/(old.num.m1 + old.num.m2)) - log(2 *