| 71 | |

| 72 | === Constraints and -Inf offsets === |

| 73 | |

| 74 | Constraints may be specified via the constraint formula or a -Inf offset (which prevents ties matching that term from forming). Unless there is real network data, the initial network should be created with {{{san()}} to match the constraints. In the example below, the fitted TERGM model has no male-to-male ties, and the maximum degree is 3. |

| 75 | |

| 76 | {{{ |

| 77 | library(tergm) |

| 78 | nw <- network.initialize(100, directed = FALSE) |

| 79 | nw %v% "male" <- rbinom(100, 1, 0.5) |

| 80 | nw2 <- san(nw ~ edges + nodematch('male'), target.stats=c(80,0),constraints = ~bd(maxout=3) ) |

| 81 | |

| 82 | fit <- stergm(nw2, |

| 83 | formation = ~edges + offset(nodematch("male")), |

| 84 | dissolution = ~offset(edges), |

| 85 | constraints = ~bd(maxout=3), |

| 86 | target.stats = c(80), |

| 87 | offset.coef.form = -Inf, |

| 88 | offset.coef.diss = log(1.5), |

| 89 | targets = ~edges, |

| 90 | estimate = "EGMME") |

| 91 | |

| 92 | summary(fit$network ~ nodematch("male")) |

| 93 | fit |

| 94 | |

| 95 | sim <- simulate.stergm(fit, nsim = 1, time.slices = 100, output = "stats", monitor = ~nodematch("male")) |

| 96 | |

| 97 | as.vector(sim) |

| 98 | }}} |