R/simulate_bacteria_fit.R
simulate_bacteria_fit.Rd
This function runs a simulation of a compartment model using a set of ordinary differential equations. The model describes a simple bacteria infection system.
simulate_bacteria_fit(
B = 1,
I = 1,
g = 0.1,
glow = 1e-04,
ghigh = 100,
Bmax = 1e+08,
Bmaxlow = 10000,
Bmaxhigh = 1e+10,
dB = 0.01,
dBlow = 1e-04,
dBhigh = 100,
kI = 0.001,
kIlow = 1e-04,
kIhigh = 100,
rI = 0.1,
rIlow = 1e-04,
rIhigh = 100,
Imax = 10000,
Imaxlow = 1,
Imaxhigh = 1e+10,
dI = 0.1,
dIlow = 0.001,
dIhigh = 100,
iter = 10,
solvertype = 1
)
: initial number of bacteria : numeric
: initial number of neutrophils (immune response) : numeric
: maximum rate of bacteria growth : numeric
: lower bound for g : numeric
: upper bound for g : numeric
: bacteria carrying capacity : numeric
: lower bound for Bmax : numeric
: upper bound for Bmax : numeric
: bacteria death rate : numeric
: lower bound for dB : numeric
: upper bound for dB : numeric
: rate of bacteria killing by immune response : numeric
: lower bound for k : numeric
: upper bound for k : numeric
: immune response growth rate : numeric
: lower bound for r : numeric
: upper bound for r : numeric
: immune response carrying capacity : numeric
: lower bound for Imax : numeric
: upper bound for Imax : numeric
: immune response decay rate : numeric
: lower bound for dI : numeric
: upper bound for dI : numeric
: max number of steps to be taken by optimizer : numeric
: the type of solver/optimizer to use (1-3) : numeric
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
A simple compartmental ODE model for a bacterial infection is fitted to data. 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.
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 the Shiny app documentation corresponding to this function for more details on this model.
# To run the code with default parameters just call the function:
if (FALSE) result <- simulate_bacteria_fit()
# To apply different settings, provide them to the simulator function, like such:
result <- simulate_bacteria_fit(iter = 5)