Learn R Programming

EpiModel (version 2.3.1)

trim_netest: Function to Reduce the Size of a netest Object

Description

Trims formula environments from the netest object. Optionally converts the newnetwork element of the netest object to a networkLite class, and removes the fit element (if present) from the netest object.

Usage

trim_netest(object, as.networkLite = TRUE, keep.fit = FALSE)

Value

A netest object with formula environments removed, optionally with the newnetwork element converted to a networkLite and the fit element removed.

Arguments

object

A netest class object.

as.networkLite

If TRUE, converts object$newnetwork to a networkLite.

keep.fit

If FALSE, removes the object$fit (if present) on the netest object.

Details

With larger, more complex network structures with epidemic models, it is generally useful to reduce the memory footprint of the fitted TERGM model object (estimated with netest). This utility function removes all but the bare essentials needed for simulating a network model with netsim.

Specifically, the function removes:

  • environment(object$constraints)

  • environment(object$coef.diss$dissolution)

  • environment(object$formation)

When edapprox = TRUE in the netest call, also removes environment(object$formula).

When edapprox = FALSE, also removes all but formation and dissolution from environment(object$formula), as well as environment(environment(object$formula)$formation) and environment(environment(object$formula)$dissolution).

If as.networkLite = TRUE, converts object$newnetwork to a networkLite object. If keep.fit = FALSE, removes fit (if present) from object.

For the output to be usable in netsim simulation, there should not be substitutions in the formulas, other than formation and dissolution in object$formula when edapprox = FALSE.

Examples

Run this code
nw <- network_initialize(n = 100)
formation <- ~edges + concurrent
target.stats <- c(50, 25)
coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 10)
est <- netest(nw, formation, target.stats, coef.diss,
              set.control.ergm = control.ergm(MCMC.burnin = 1e5,
                                              MCMC.interval = 1000))
print(object.size(est), units = "KB")

est.small <- trim_netest(est)
print(object.size(est.small), units = "KB")

Run the code above in your browser using DataLab