trim_netest {EpiModel}R Documentation

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,
  keep = character(0)
)

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.

keep

Character vector of object names to keep in formula environments. By default, all objects are removed.

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.

The function always trims the environments of object$constraints and object$coef.diss$dissolution.

When both edapprox = TRUE and nested.edapprox = TRUE in the netest call, also trims the environments of object$formula and object$formation.

When both edapprox = TRUE and nested.edapprox = FALSE in the netest call, also trims the environments of object$formula, environment(object$formation)$formation, and environment(object$formation)$dissolution.

When edapprox = FALSE in the netest call, also trims the environments of object$formation, environment(object$formula)$formation and environment(object$formula)$dissolution.

By default all objects are removed from these trimmed environments. Specific objects may be retained by passing their names as the keep argument. For the output of trim_netest to be usable in netsim simulation, any objects referenced in the formulas should be included in the keep argument.

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

Value

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

Examples

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")


[Package EpiModel version 2.4.0 Index]