Learn R Programming

EpiModel (version 0.95)

as.data.frame.epiICM: Extract Model Run for Stochastic Models

Description

This function extracts model simulations for objects of classes epiICM and epiNet.simTrans into a data frame using the generic as.data.frame function.

Usage

## S3 method for class 'epiICM':
as.data.frame(x, row.names = NULL, optional = FALSE, sim,
  out = "mean", ...)

## S3 method for class 'epiNet.simTrans': as.data.frame(x, row.names = NULL, optional = FALSE, sim, out = "mean", ...)

Arguments

x
an EpiModel object of class epiICM or epiNet.simTrans.
sim
simulation number from model, used only if out="vals".
out
type of output to data frame: use "mean" for mean across simulations, "sd" for standard deviations across all simulations, and "vals" for values from one simulation (with simulation set with sim)
row.names

Details

These generics work from both epiICM and epiNet.simTrans class objects, and output data frames containing the time-specific means, standard deviations, or model values (compartment and flow sizes from individual simulations) from these stochastic model classes. For summary output types, row mean or standard deviations are calculated across all simulations. Total population size for one and two-group models are also calculated and appended.

Examples

Run this code
# Individual contact SIS model with 2 simulations
mod <- epiICM(type="SIS", s.num=500, i.num=1,
              trans.rate=0.8, act.rate=2, rec.rate=0.1,
              nsteps=20, nsims=2)

# Default output is mean across simulations
as.data.frame(mod)

# Standard deviations of simulations
as.data.frame(mod, out="sd")

# Individual simulation runs, with default sim=1
as.data.frame(mod, out="vals")
as.data.frame(mod, out="vals", sim=2)

Run the code above in your browser using DataLab