ergmx.simulate_dynamic#

ergmx.simulate_dynamic(network, formula, coef, time_slices=1, *, nsim=1, constraints=None, bipartite=None, seed=None, monitor=None, triadic_weight=None, min_steps=1000, max_steps=100000, pval=0.5, add=1.0)[source]#

Simulate a network forward in time from a temporal ERGM, as R’s tergm does with simulate(..., dynamic=TRUE).

At each of time_slices time steps, the next network is drawn from the model conditional on the current one: the model of each transition of ergmx.tergm(), with Form(), Persist(), Diss(), Cross() and Change() (terms outside them describe the current network, as Cross()). Each time step’s Markov chain starts from the current network and runs, as in tergm, until the number of dyads that differ from it stops growing: after at least min_steps proposals, once a z-test no longer finds the (exponentially weighted) average change in that number positive, with p-value above pval, the chain runs add times as many proposals again; at most max_steps in all.

Parameters:
  • network (igraph.Graph or networkx.Graph) – The network at time 0.

  • formula (str or terms) – A model with tergm’s operators, for example "Form(~edges + gwesp(0.5, fixed=TRUE)) + Persist(~edges)".

  • coef (array-like or dict) – Coefficients, in the order of the formula’s parameters or by name ("Form(1)~edges"…), as ergmx.tergm() estimates them.

  • time_slices (int) – Number of time steps.

  • nsim (int) – Number of independent simulations, run in parallel.

  • monitor (str or terms, optional) – A formula whose statistics are computed on each network, such as "edges + mutual", and of the ages of its ties (mean.age…; the ties of the starting network count as formed at time 0).

  • constraints – As in ergmx.simulate().

  • bipartite – As in ergmx.simulate().

  • seed – As in ergmx.simulate().

  • triadic_weight – As in ergmx.simulate().

  • min_steps – The length of each time step’s chain, as tergm’s MCMC.burnin.min, MCMC.burnin.max, MCMC.burnin.pval and MCMC.burnin.add. Set min_steps and max_steps equal for a fixed number.

  • max_steps – The length of each time step’s chain, as tergm’s MCMC.burnin.min, MCMC.burnin.max, MCMC.burnin.pval and MCMC.burnin.add. Set min_steps and max_steps equal for a fixed number.

  • pval – The length of each time step’s chain, as tergm’s MCMC.burnin.min, MCMC.burnin.max, MCMC.burnin.pval and MCMC.burnin.add. Set min_steps and max_steps equal for a fixed number.

  • add – The length of each time step’s chain, as tergm’s MCMC.burnin.min, MCMC.burnin.max, MCMC.burnin.pval and MCMC.burnin.add. Set min_steps and max_steps equal for a fixed number.

Returns:

DynamicSimulation, or a list of nsim of them