The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Conversions for tergm version 4.0

Introduction

Version 4.0 of the tergm package introduces new user interfaces for specifying tergm models. While an effort has been made to maintain a high degree of backwards compatibility, there are some points of backwards incompatibility, and some users may wish to convert their code to use the new interfaces anyway, so this document describes how to go about doing that. The examples given here are somewhat artificial so as to better illustrate the range of possible changes needed; they may not be typical or even plausible in every detail, but are intended to exhibit the types of updates that users may need to make.

Estimation

Estimation calls in tergm 3.x might look something like

data(samplk)
samp <- list(samplk1, samplk2, samplk3)
samp.fit <- stergm(samp,
                   formation = ~edges+mutual+cyclicalties+transitiveties,
                   dissolution = ~edges+mutual+cyclicalties+transitiveties,
                   estimate = "CMLE",
                   times = 1:3,
                   control = control.stergm(CMLE.control.form = control.ergm(init = c(-3.5,2,0,NA)),
                                            CMLE.control.diss = control.ergm(init = c(0,1,0,1/2))))

for CMLE, and

data(florentine)
stergm.fit.1 <- stergm(flobusiness,
                       formation = ~edges+gwesp(0,fixed=T),
                       dissolution = ~offset(edges),
                       targets = "formation",
                       offset.coef.diss = log(9),
                       estimate = "EGMME",
                       control = control.stergm(SA.plot.progress=TRUE))

for EGMME.

To convert these to the new 4.0 user interface, we make the following changes.

Overall, this produces the new-style calls

data(samplk)
samp <- list(samplk1, samplk2, samplk3)
samp.fit <- tergm(samp ~ Form(~edges+mutual+cyclicalties+transitiveties) + 
                         Persist(~edges+mutual+cyclicalties+transitiveties),
                  estimate = "CMLE",
                  times = 1:3,
                  control = snctrl(init = c(-3.5,2,0,NA,0,1,0,1/2)))

for CMLE, and

data(florentine)
tergm.fit.1 <- tergm(flobusiness ~ Form(~edges+gwesp(0,fixed=T)) + 
                                   Persist(~offset(edges)),
                     targets = "formation",
                     offset.coef = log(9),
                     estimate = "EGMME",
                     control = control.tergm(SA.plot.progress=TRUE))

for EGMME.

Simulation

From a fitted tergm object

A call in tergm 3.x for simulating from a fitted stergm might look something like

stergm.sim.1 <- simulate(stergm.fit.1, 
                         stats.form = TRUE,
                         nsim = 1,
                         time.slices = 1000,
                         control = control.simulate.stergm(MCMC.init.maxchanges = 10000))

There is no simulate.stergm function in tergm 4.0, only a simulate.tergm function, so the changes described in this section are generally mandatory, with the exception of the control list class, which can be left as control.simulate.stergm if desired (although this is not recommended). Even if one calls the old stergm() function to estimate the model, calling simulate on the returned object will dispatch to the simulate.tergm function described here.

To convert from simulating a fitted stergm in tergm 3.x to simulating a fitted tergm in tergm 4.0, we make the following changes.

Thus, dropping the s from the object names for consistency, we obtain the 4.0 style call

tergm.sim.1 <- simulate(tergm.fit.1, 
                        stats = TRUE,
                        nsim = 1,
                        time.slices = 1000,
                        control = snctrl(MCMC.maxchanges = 10000))

From a network (or networkDynamic)

A call in tergm 3.x for simulating based on a starting network (or networkDynamic), along with specified formation and dissolution formulas and coefficients, might look something like

stergm.sim.2 <- simulate(flobusiness, 
                         formation = ~edges+gwesp(0,fixed=T),
                         dissolution = ~edges, 
                         monitor = "formation",
                         coef.form = c(-7.981749, 1.575780), 
                         coef.diss = log(99),
                         time.slices = 50000)

To convert from simulating based on a starting network in tergm 3.x to simulating based on a starting network in tergm 4.0, we make the following changes.

Thus, we obtain the 4.0 simulation call

tergm.sim.2 <- simulate(flobusiness ~ Form(~edges+gwesp(0,fixed=T)) +
                                      Persist(~edges),
                        monitor = "formation",
                        coef = c(-7.981749, 1.575780, log(99)), 
                        time.slices = 50000,
                        dynamic = TRUE)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.