## Example 1 - Growth under constant conditions -----------------------------
## Valid model keys can be retrieved calling primary_model_data()
primary_model_data()
my_model <- "modGompertz" # we will use the modified-Gompertz
## The keys of the model parameters can also be obtained from primary_model_data()
primary_model_data(my_model)$pars
## We define the primary model as a list
my_model <- list(model = "modGompertz", logN0 = 0, C = 6, mu = .2, lambda = 20)
## We can now make the predictions
my_time <- seq(0, 100, length = 1000) # Vector of time points for the calculations
my_prediction <- predict_growth(my_time, my_model, environment = "constant")
## The instance of IsothermalGrowth includes several S3 methods
print(my_prediction)
plot(my_prediction)
coef(my_prediction)
## Example 2 - Growth under dynamic conditions ------------------------------
## We will consider the effect of two factors: temperature and pH
my_conditions <- data.frame(time = c(0, 5, 40),
temperature = c(20, 30, 35),
pH = c(7, 6.5, 5)
)
## The primary model is defined as a named list
my_primary <- list(mu = 2, Nmax = 1e7, N0 = 1, Q0 = 1e-3)
## The secondary model is defined independently for each factor
sec_temperature <- list(model = "Zwietering",
xmin = 25, xopt = 35, n = 1)
sec_pH = list(model = "CPM",
xmin = 5.5, xopt = 6.5,
xmax = 7.5, n = 2)
## Then, they are assigned to each factor using a named list
my_secondary <- list(
temperature = sec_temperature,
pH = sec_pH
)
## We can call the function now
my_times <- seq(0, 50, length = 1000) # Where the output is calculated
dynamic_prediction <- predict_growth(environment = "dynamic",
my_times, my_primary, my_secondary,
my_conditions
)
## The instance of DynamicGrowth includes several useful S3 methods
print(dynamic_prediction)
plot(dynamic_prediction)
plot(dynamic_prediction, add_factor = "pH")
coef(dynamic_prediction)
## The time_to_size function can predict the time to reach a population size
time_to_size(my_prediction, 3)
Run the code above in your browser using DataLab