Last data update: 2014.03.03

R: Prevalence
prevalenceR Documentation

Prevalence

Description

Calculate the proportion infected individuals

Usage

prevalence(model, ...)

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

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

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

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

Arguments

model

The model to calculated the prevalence from

...

Additional arguments affecting the measure

wnp

Determine within-node prevalence. Default is FALSE.

i

Indices specifying the nodes to include in the calculation of the prevalence. If wnp = TRUE, then specifying which nodes to extract prevalence for. 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 prevalence at every time point.

age

For models with age categories, the age category to include in the calculation. Default is that all age categories are included.

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 prevalence of infected nodes after each time
## step in the simulation
prevalence(result)

## Extract the prevalence of infected nodes after each time
## step in the simulation when including only the first,
## second and third node in the population at risk.
prevalence(result, i = 1:3)

## Extract the prevalence of infected nodes after every other
## time step in the simulation when including only the first,
## second and third node in the population at risk.
prevalence(result, i = 1:3, by = 2)

## Extract the within-node prevalence of infected individuals
## in each node after each time step in the simulation
prevalence(result, wnp = TRUE)

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

## Extract the within-node prevalence of infected individuals
## in the first and third node after every other time step in
## the simulation
prevalence(result, wnp = TRUE, 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 prevalence of infected nodes after each time
## step in the simulation
prevalence(result)

## Extract the within-node prevalence of infected
## individuals in the third age category after each
## time step in the simulation
prevalence(result, wnp = TRUE, age = 3)

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/prevalence-methods.Rd_%03d_medium.png", width=480, height=480)
> ### Name: prevalence
> ### Title: Prevalence
> ### Aliases: prevalence prevalence,SISe-method prevalence,SISe3-method
> ###   prevalence,SISe3_sp-method prevalence,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 prevalence of infected nodes after each time
> ## step in the simulation
> prevalence(result)
 [1] 0.024 0.024 0.030 0.038 0.044 0.040 0.046 0.050 0.056 0.062
> 
> ## Extract the prevalence of infected nodes after each time
> ## step in the simulation when including only the first,
> ## second and third node in the population at risk.
> prevalence(result, i = 1:3)
 [1] 0.03000000 0.03000000 0.03000000 0.03666667 0.04000000 0.03333333
 [7] 0.04666667 0.05666667 0.06666667 0.06666667
> 
> ## Extract the prevalence of infected nodes after every other
> ## time step in the simulation when including only the first,
> ## second and third node in the population at risk.
> prevalence(result, i = 1:3, by = 2)
[1] 0.03000000 0.03000000 0.04000000 0.04666667 0.06666667
> 
> ## Extract the within-node prevalence of infected individuals
> ## in each node after each time step in the simulation
> prevalence(result, wnp = TRUE)
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 0.02 0.03 0.03 0.03 0.04 0.05 0.07 0.08 0.08  0.08
[2,] 0.02 0.01 0.02 0.02 0.01 0.01 0.02 0.04 0.04  0.04
[3,] 0.05 0.05 0.04 0.06 0.07 0.04 0.05 0.05 0.08  0.08
[4,] 0.02 0.02 0.05 0.07 0.07 0.07 0.06 0.06 0.06  0.07
[5,] 0.01 0.01 0.01 0.01 0.03 0.03 0.03 0.02 0.02  0.04
> 
> ## Extract the within-node prevalence of infected individuals
> ## in the first and third node after each time step in the
> ## simulation
> prevalence(result, wnp = TRUE, i = c(1, 3))
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 0.02 0.03 0.03 0.03 0.04 0.05 0.07 0.08 0.08  0.08
[2,] 0.05 0.05 0.04 0.06 0.07 0.04 0.05 0.05 0.08  0.08
> 
> ## Extract the within-node prevalence of infected individuals
> ## in the first and third node after every other time step in
> ## the simulation
> prevalence(result, wnp = TRUE, i = c(1, 3), by = 2)
     [,1] [,2] [,3] [,4] [,5]
[1,] 0.02 0.03 0.04 0.07 0.08
[2,] 0.05 0.04 0.07 0.05 0.08
> 
> ## 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 prevalence of infected nodes after each time
> ## step in the simulation
> prevalence(result)
 [1] 0.012 0.016 0.022 0.024 0.030 0.030 0.038 0.044 0.038 0.036
> 
> ## Extract the within-node prevalence of infected
> ## individuals in the third age category after each
> ## time step in the simulation
> prevalence(result, wnp = TRUE, age = 3)
     [,1]       [,2]       [,3]       [,4]       [,5]       [,6]       [,7]
[1,]    0 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[2,]    0 0.01428571 0.02857143 0.02857143 0.01428571 0.01428571 0.02857143
[3,]    0 0.01428571 0.02857143 0.01428571 0.01428571 0.01428571 0.01428571
[4,]    0 0.00000000 0.01428571 0.01428571 0.04285714 0.04285714 0.04285714
[5,]    0 0.00000000 0.00000000 0.00000000 0.00000000 0.01428571 0.02857143
           [,8]       [,9]      [,10]
[1,] 0.00000000 0.00000000 0.00000000
[2,] 0.02857143 0.02857143 0.02857143
[3,] 0.01428571 0.02857143 0.02857143
[4,] 0.05714286 0.05714286 0.05714286
[5,] 0.02857143 0.02857143 0.01428571
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>