Last data update: 2014.03.03

R: Infected
infectedR Documentation

Infected

Description

Extracts the number of infected

Usage

infected(model, ...)

## S4 method for signature 'SISe'
infected(model, i = NULL, by = 1, ...)

## S4 method for signature 'SISe3'
infected(model, age = 1:3, i = NULL, by = 1, ...)

## S4 method for signature 'SISe3_sp'
infected(model, age = 1:3, i = NULL, by = 1, ...)

## S4 method for signature 'SISe_sp'
infected(model, i = NULL, by = 1, ...)

Arguments

model

The model to extract the infected from

...

Additional arguments affecting the measure

i

Indices specifying the nodes to include when extracting the number of infected. Default is NULL, which includes all nodes.

by

The number to increment the sequence of time points starting from 1. Default is 1, which gives the number of infected at every time point.

age

For models with age categories, the age category to extract.

Examples

## Create a 'SISe' demo model with 5 nodes and initialize
## it to run over 10 days.
model <- demo_model(nodes = 5, days = 10, model = "SISe")

## Run the model and save the result
result <- run(model)

## Extract the number of infected individuals in each
## node after each time step in the simulation
infected(result)

## Extract the number of infected individuals in the
## first node after each time step in the simulation
infected(result, i = 1)

## Extract the number of infected individuals in the
## first and third node after each time step in the simulation
infected(result, i = c(1, 3))

## Extract the number of infected individuals in the first
## and third node after every other time step in the simulation
infected(result, i = c(1, 3), by = 2)

## Create a 'SISe3' demo model with 5 nodes and initialize
## it to run over 10 days.
model <- demo_model(nodes = 5, days = 10, model = "SISe3")

## Run the model and save the result
result <- run(model)

## Extract the sum all of infected individuals in all age
## categories in each node after each time step in the simulation
infected(result)

## Extract the number of infected individuals in the first age
## category in each node after each time step in the simulation
infected(result, age = 1)

## Extract the sum of infected individuals in the first and
## second age category in each node after each time step in
## the simulation
infected(result, age = c(1, 2))

## Extract the number of infected individuals in the first age
## category in the first and third node after each time step in
## the simulation
infected(result, i = c(1, 3), age = 1)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(SimInf)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SimInf/infected-methods.Rd_%03d_medium.png", width=480, height=480)
> ### Name: infected
> ### Title: Infected
> ### Aliases: infected infected,SISe-method infected,SISe3-method
> ###   infected,SISe3_sp-method infected,SISe_sp-method
> ### Keywords: methods
> 
> ### ** Examples
> 
> ## Create a 'SISe' demo model with 5 nodes and initialize
> ## it to run over 10 days.
> model <- demo_model(nodes = 5, days = 10, model = "SISe")
> 
> ## Run the model and save the result
> result <- run(model)
> 
> ## Extract the number of infected individuals in each
> ## node after each time step in the simulation
> infected(result)
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]    5    6    7    9    9    9    8   10   10     8
[2,]    5    5    6    6    5    4    6    5    5     5
[3,]    3    3    7    5    5    6    6    7    9     8
[4,]    2    6    6    7    7    9   10   10    7     7
[5,]    1    1    2    3    5    6    5    5    7     7
> 
> ## Extract the number of infected individuals in the
> ## first node after each time step in the simulation
> infected(result, i = 1)
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]    5    6    7    9    9    9    8   10   10     8
> 
> ## Extract the number of infected individuals in the
> ## first and third node after each time step in the simulation
> infected(result, i = c(1, 3))
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]    5    6    7    9    9    9    8   10   10     8
[2,]    3    3    7    5    5    6    6    7    9     8
> 
> ## Extract the number of infected individuals in the first
> ## and third node after every other time step in the simulation
> infected(result, i = c(1, 3), by = 2)
     [,1] [,2] [,3] [,4] [,5]
[1,]    5    7    9    8   10
[2,]    3    7    5    6    9
> 
> ## Create a 'SISe3' demo model with 5 nodes and initialize
> ## it to run over 10 days.
> model <- demo_model(nodes = 5, days = 10, model = "SISe3")
> 
> ## Run the model and save the result
> result <- run(model)
> 
> ## Extract the sum all of infected individuals in all age
> ## categories in each node after each time step in the simulation
> infected(result)
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]    4    5    5    6    6    6    6    8    9     9
[2,]    6    6    7    7    7    7    7    7    9     9
[3,]    2    2    4    5    7    9    9    9   10     9
[4,]    1    2    3    3    4    4    4    5    6     7
[5,]    0    0    0    1    0    1    0    1    2     2
> 
> ## Extract the number of infected individuals in the first age
> ## category in each node after each time step in the simulation
> infected(result, age = 1)
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]    2    2    2    3    3    4    4    4    4     3
[2,]    1    1    1    1    1    1    1    1    2     2
[3,]    0    0    2    2    2    3    3    2    2     2
[4,]    0    0    0    0    1    1    1    1    3     3
[5,]    0    0    0    1    0    0    0    0    0     0
> 
> ## Extract the sum of infected individuals in the first and
> ## second age category in each node after each time step in
> ## the simulation
> infected(result, age = c(1, 2))
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]    3    3    3    4    4    5    5    5    6     6
[2,]    4    4    4    4    4    4    4    4    4     4
[3,]    1    2    4    4    4    6    6    6    7     6
[4,]    1    2    3    3    4    4    4    5    6     7
[5,]    0    0    0    1    0    1    0    1    2     2
> 
> ## Extract the number of infected individuals in the first age
> ## category in the first and third node after each time step in
> ## the simulation
> infected(result, i = c(1, 3), age = 1)
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]    2    2    2    3    3    4    4    4    4     3
[2,]    0    0    2    2    2    3    3    2    2     2
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>