Learn R Programming

EpiModel (version 2.5.0)

merge.icm: Merge Data across Stochastic Individual Contact Model Simulations

Description

Merges epidemiological data from two independent simulations of stochastic individual contact models from icm.

Usage

# S3 method for icm
merge(x, y, ...)

Value

An EpiModel object of class icm containing the data from both x and y.

Arguments

x

An EpiModel object of class icm.

y

Another EpiModel object of class icm, with the identical model parameterization as x.

...

Additional merge arguments (not used).

Details

This merge function combines the results of two independent simulations of icm class models, simulated under separate function calls. The model parameterization between the two calls must be exactly the same, except for the number of simulations in each call. This allows for manual parallelization of model simulations.

This merge function does not work the same as the default merge, which allows for a combined object where the structure differs between the input elements. Instead, the function checks that objects are identical in model parameterization in every respect (except number of simulations) and binds the results.

Examples

Run this code
param <- param.icm(inf.prob = 0.2, act.rate = 0.8)
init <- init.icm(s.num = 1000, i.num = 100)
control <- control.icm(type = "SI", nsteps = 10,
                       nsims = 3, verbose = FALSE)
x <- icm(param, init, control)

control <- control.icm(type = "SI", nsteps = 10,
                       nsims = 1, verbose = FALSE)
y <- icm(param, init, control)

z <- merge(x, y)

# Examine separate and merged data
as.data.frame(x)
as.data.frame(y)
as.data.frame(z)

Run the code above in your browser using DataLab