Learn R Programming

EpiModel (version 2.0.5)

generate_random_params: Generate Values for Random Parameters

Description

This function uses the generative functions in the random.params list to create values for the parameters.

Usage

generate_random_params(param, verbose = FALSE)

Arguments

param

The param argument received by the netsim functions.

verbose

Should the function output the generated values (default = FALSE)?

Value

A fully instantiated param list.

<code>random_params</code>

The random_params argument to the param.net function must be a named list of functions that return a values that can be used as the argument with the same name. In the example below, param_random is a function factory provided by EpiModel for act.rate and tx.halt.part.prob we provide bespoke functions.

Generator Functions

The function used inside random_params must be 0 argument functions returning a valid value for the parameter with the same name.

Examples

Run this code
# NOT RUN {
# Define random parameter list
my_randoms <- list(
  act.rate = param_random(c(0.25, 0.5, 0.75)),
  tx.prob = function() rbeta(1, 1, 2),
  stratified.test.rate = function() c(
    rnorm(1, 0.05, 0.01),
    rnorm(1, 0.15, 0.03),
    rnorm(1, 0.25, 0.05)
  )
)

# Parameter model with deterministic and random parameters
param <- param.net(inf.prob = 0.3, random.params = my_randoms)

# Parameters are drawn automatically in netsim by calling the function
# within netsim_loop. Demonstrating draws here but this is not used by
# end user.
paramDraw <- generate_random_params(param, verbose = TRUE)
paramDraw

# }

Run the code above in your browser using DataLab