This function runs a simulation of a compartment model using a set of ordinary differential equations. The model describes a simple viral infection system.

simulate_basicvirus_fit(
  U = 1e+06,
  I = 0,
  V = 1,
  n = 0,
  dU = 0,
  dI = 2,
  g = 0,
  p = 0.001,
  plow = 1e-04,
  phigh = 100,
  psim = 0.001,
  b = 0.1,
  blow = 0.001,
  bhigh = 10,
  bsim = 0.1,
  dV = 1,
  dVlow = 0.01,
  dVhigh = 100,
  dVsim = 1,
  noise = 0,
  iter = 1,
  solvertype = 1,
  usesimdata = 0
)

Arguments

U

: initial number of uninfected target cells : numeric

I

: initial number of infected target cells : numeric

V

: initial number of infectious virions : numeric

n

: rate of uninfected cell production : numeric

dU

: rate at which uninfected cells die : numeric

dI

: rate at which infected cells die : numeric

g

: unit conversion factor : numeric

p

: rate at which infected cells produce virus : numeric

plow

: lower bound for p : numeric

phigh

: upper bound for p : numeric

psim

: rate at which infected cells produce virus for simulated data : numeric

b

: rate at which virus infects cells : numeric

blow

: lower bound for infection rate : numeric

bhigh

: upper bound for infection rate : numeric

bsim

: rate at which virus infects cells for simulated data : numeric

dV

: rate at which infectious virus is cleared : numeric

dVlow

: lower bound for virus clearance rate : numeric

dVhigh

: upper bound for virus clearance rate : numeric

dVsim

: rate at which infectious virus is cleared for simulated data : numeric

noise

: noise to be added to simulated data : numeric

iter

: max number of steps to be taken by optimizer : numeric

solvertype

: the type of solver/optimizer to use (1-3) : numeric

usesimdata

: set to 1 if simulated data should be fitted, 0 otherwise : numeric

Value

The function returns a list containing as elements the best fit time series data frame, the best fit parameters, the data and the final SSR

Details

A simple compartmental ODE model mimicking acute viral infection is fitted to data. Data can either be real or created by running the model with known parameters and using the simulated data to determine if the model parameters can be identified. The fitting is done using solvers/optimizers from the nloptr package (which is a wrapper for the nlopt library). The package provides access to a large number of solvers. Here, we only implement 3 solvers, namely 1 = NLOPT_LN_COBYLA, 2 = NLOPT_LN_NELDERMEAD, 3 = NLOPT_LN_SBPLX For details on what those optimizers are and how they work, see the nlopt/nloptr documentation.

Warning

This function does not perform any error checking. So if you try to do something nonsensical (e.g. specify negative parameter or starting values, the code will likely abort with an error message.

See also

See the Shiny app documentation corresponding to this function for more details on this model.

Author

Andreas Handel

Examples

# To run the code with default parameters just call the function:
if (FALSE) result <- simulate_basicvirus_fit()
# To apply different settings, provide them to the simulator function, like such:
result <- simulate_basicvirus_fit(iter = 5)