Learn R Programming

SimInf (version 5.0.0)

run_outer: Run SimInf_model on scaled parameters

Description

Run SimInf_model on scaled parameters

Usage

run_outer(x, y, model, formula = NULL, FUN = NULL, ...)

# S4 method for numeric,numeric,SimInf_model run_outer(x, y, model, formula = NULL, FUN = NULL, ...)

Arguments

x

Scale the model gdata parameter values on the right hand side of the formula with x before calling FUN with the scaled model as argument.

y

Scale the model gdata parameter values on the left hand side of the formula with y before calling FUN with the scaled model as argument.

model

The siminf model to scale parameters on and run.

formula

The parameters in the gdata vector matching the left hand side of the formula a + b ~ c will be scaled by y. The parameters in the gdata vector matching the right hand side of the formula a + b ~ c will be scaled by x.

FUN

A function to use on the scaled model 'gdata' parameters.

...

Optional arguments to be passed to FUN.

Value

Array with dimension c(dim(x), dim(y)).

Examples

Run this code
# NOT RUN {
## Create an SIR-model with 500 nodes of 99 susceptible individuals
## and one infected individuals.
u0 <- data.frame(S = rep(99, 500), I = rep(1, 500), R = rep(0, 500))
model <- SIR(u0, 1:75, beta = 0.16, gamma = 0.077)

## Define scaling parameters
x <- seq(from = 0.2, to = 1.8, by = 0.05)
y <- seq(from = 0.2, to = 1.1, by = 0.05)

## Run the model and determine the population prevalence
pop <- run_outer(x, y, model, gamma ~ beta,
                 function(model) {prevalence(run(model), "pop")[75]})

## Plot result
contour(x * model@gdata["beta"], y * model@gdata["gamma"],
        pop, method = "edge", bty = "l")

## Run the model and determine the between-node prevalence
bnp <- run_outer(x, y, model, gamma ~ beta,
                 function(model) {prevalence(run(model), "bnp")[75]})

## Plot result
contour(x * model@gdata["beta"], y * model@gdata["gamma"],
        bnp, method = "edge", bty = "l")
# }

Run the code above in your browser using DataLab