if (FALSE) {
# Create the param.updater.list
param.updater.list <- list(
# this is one updater
list(
at = 10,
param = list(
hiv.test.rate = rep(0.0128, 3),
trans.scale = c(1.61, 0.836, 0.622)
)
),
# this is another updater
list(
at = 12,
verbose = TRUE,
param = list(
hiv.test.rate = function(x) x * 3,
trans.scale = function(x) x^2 / 3
)
)
)
# Add it to params
param <- param.net(
inf.prob = 0.3,
act.rate = 0.5,
hiv.test.rate = rep(0.256, 3),
trans.scale = c(1, 2, 3),
param.updater.list = param.updater.list
)
# Create the control.updater.list
# these updaters will toggle on and off the verbosity of the model
control.updater.list <- list(
list(
at = 50,
verbose = TRUE,
control = list(
verbose = TRUE
)
),
# this is another updater
list(
at = 75,
verbose = TRUE,
control = list(
verbose = FALSE
)
)
)
# Enable the module in control, and add `control.updater.list` to it
control <- control.net(
type = NULL, # must be NULL as we use a custom module
nsims = 1,
nsteps = 20,
verbose = FALSE,
updater.FUN = updater.net,
infection.FUN = infection.net,
control.updater.list = control.updater.list
)
nw <- network_initialize(n = 50)
nw <- set_vertex_attribute(nw, "race", rbinom(50, 1, 0.5))
est <- netest(
nw,
formation = ~edges,
target.stats = 25,
coef.diss = dissolution_coefs(~offset(edges), 10, 0),
verbose = FALSE
)
init <- init.net(i.num = 10)
mod <- netsim(est, param, init, control)
}
Run the code above in your browser using DataLab