Learn R Programming

SimInf (version 5.0.0)

U: Extract the number of individuals in each compartment

Description

The result matrix with the number of individuals in each compartment in every node after running a trajectory with run. U[, j] contains the number of individuals in each compartment at tspan[j]. U[1:Nc, j] contains the number of individuals in node 1 at tspan[j]. U[(Nc + 1):(2 * Nc), j] contains the number of individuals in node 2 at tspan[j] etc, where Nc is the number of compartments in the model. The dimension of the matrix is \(N_n N_c \times\) length(tspan) where \(N_n\) is the number of nodes.

Usage

U(model)

# S4 method for SimInf_model U(model)

Arguments

model

The model to extract the result matrix from.

Value

The number of individuals in each compartment

Examples

Run this code
# NOT RUN {
## Create an 'SIR' model with 6 nodes and initialize
## it to run over 10 days.
u0 <- data.frame(S = 100:105, I = 1:6, R = rep(0, 6))
model <- SIR(u0 = u0, tspan = 1:10, beta = 0.16, gamma = 0.077)

## Run the model
result <- run(model, threads = 1, seed = 22)

## Extract the number of individuals in each compartment at the
## time-points in tspan.
U(result)
# }

Run the code above in your browser using DataLab