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

View source: R/merge.R

merge.icmR Documentation

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 class 'icm'
merge(x, 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.

Value

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

Examples

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)


EpiModel documentation built on Oct. 12, 2024, 1:06 a.m.