Equilibrium: An R6 class to calculate the equilibrium of a model

EquilibriumR Documentation

An R6 class to calculate the equilibrium of a model

Description

An R6 class to calculate the equilibrium of a model

An R6 class to calculate the equilibrium of a model

Details

Calculate the equilibrium of the model with a given initial condition

Super classes

REpiSim::Simulator -> REpiSim::ODE -> Equilibrium

Methods

Public methods


Method new()

constructor

Usage
Equilibrium$new(
  model,
  vary = NULL,
  range = NULL,
  max.iter = 100,
  error = 1e-06
)
Arguments
model

the model to simulate. It must be an object of a subclass of 'Model'.

vary

the name of a parameter to value, a character

range

the range of the varying parameter, a numerical vector

max.iter

the maximum iterations to search for the equilibrium

error

a numeric value giving the 2-norm of the tolerance


Method simulate()

simulate the model

Usage
Equilibrium$simulate(t, y0, parms = NULL, vars = names(y0), ...)
Arguments
t

a numeric vector of times.

y0

a numeric vector of initial conditions.

parms

a numeric vector of parameter values.

vars

a character vector specifying the variable names to be returned. A variable can be either a compartment or a substitution

...

extra arguments to be passed to the 'ode' method substitutions that depend on the compartments are calculated and returned

Returns

a data frame which rows correspond to each time in 't', and columns correspond to the variables specified in vars.


Method clone()

The objects of this class are cloneable with this method.

Usage
Equilibrium$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

## an SIR model
SIR = Model$new(title="SIR")
SIR$compartment(S ~ -beta*S*I/N)$
  compartment(I ~ beta*S*I/N - gamma*I)$
  compartment(R ~ gamma*I)$
  where(N = S + I + R)
eq = Equilibrium$new(SIR, vary="beta", range=seq(0, 0.4, by=0.01))
ode$simulate(
  time=0:40, 
  y0=c(S=10000, I=1, R=0), 
  parms=c(beta=0.4, gamma=0.2), 
  alias = FALSE) # N is not returned.

junlingm/REpiSim documentation built on Nov. 28, 2023, 2:35 a.m.