View source: R/fit_coupled_growth.R
fit_coupled_growth | R Documentation |
This function implements the methodology suggested by Garre et al. (2025; doi: 10.1016/j.ijfoodmicro.2025.111078) for the Baranyi-Ratkowsky model. Rather than fitting independent models for mu and lambda, this approach considers a link between both secondary models, reducing the number of unknown parameters from 3 to 4.
The function implements too modes of fitting: two-steps and one-step. Please see the respective sections for further information.
fit_coupled_growth(
fit_data,
start,
known = c(),
mode = "two_steps",
weight = "sd",
...,
logbase_mu = exp(1),
logbase_logN = 10
)
fit_data |
a tibble (or data.frame) with the data for the fit. The content must be different depending on the fitting mode (see relevant sections within the help page). |
start |
a numeric vector of initial guesses for the parameter estimates |
known |
a numeric vector of known mode parameters. An empty vector by default (no knonw parameter) |
mode |
the type of model fitting approach. Either |
weight |
weights to apply for the |
... |
ignored |
logbase_mu |
Base for the definition of mu. By default, |
logbase_logN |
Base for the definition of logN. By default, 10 (decimal logarithm). |
In this mode, it is assumed that primary models have been already fitted to each experiment. Therefore,
the data is available as a table of values of mu and lambda estimated at each temperature. Hence,
fit_data
must be a tibble (or data.frame) with three columns: temp
(storage temperature),
mu
(specific growth rate) and lambda
(lag phase duration). By default, mu
must be
defined in the scale of natural logarithm, although this can be modified using the logbase_mu
argument.
The package includes the dataset example_coupled_twosteps
as an illustration of the type of data.
In this mode, secondary models are directly fitted to the observed (log) microbial counts. Hence,
fit_data
must be a tibble (or data.frame) with three columns: temp
(storage temperature),
time
(the elapsed time) and logN
(the log-microbial concentration). By default, logN
must be
defined in the scale of decimal logarithm, although this can be modified using the logbase_logN
argument.
The package includes the dataset example_coupled_onestep
as an illustration of the type of data.
## Example 1: Two-steps fitting-------------------------------------------------
## We can use the example dataset
data(example_coupled_twosteps)
## We need to define initial guesses for every parameter
guess <- c(logC0 = -1, b = .1, Tmin = 5)
## We can now call the fitting function
my_fit <- fit_coupled_growth(example_coupled_twosteps,
start = guess,
mode = "two_steps")
## Common S3 methods are included
print(my_fit)
coef(my_fit)
summary(my_fit)
plot(my_fit)
## Any model parameter can be fixed using the known argument
known <- c(b = .01)
## Please note that the guess must be updated, as now parameter can appear both as a guess and known
guess <- c(logC0 = -1, Tmin = 0)
fixed_fit <- fit_coupled_growth(example_coupled_twosteps,
start = guess,
known = known,
mode = "two_steps")
print(fixed_fit)
coef(fixed_fit)
summary(fixed_fit)
plot(fixed_fit)
## Example 2: One-step fitting--------------------------------------------------
## We can use an example dataset with the right format
data("example_coupled_onestep")
## The function requires initial guesses for every model parameter
guess <- c(logN0 = 2, logNmax = 8, b = 0.04, logC0 = -4, Tmin = 5)
## We can now call the fitting function
my_fit <- fit_coupled_growth(example_coupled_onestep,
start = guess,
mode = "one_step")
## The package includes common S3 methods
print(my_fit)
coef(my_fit)
summary(my_fit)
plot(my_fit)
## Any model parameter can be fixed before fitting
known <- c(logNmax = 7)
## Guesses must be updated, so no parameter appears twice
guess <- c(logN0 = 2, b = 0.04, logC0 = -4, Tmin = 5)
## We can now call the fitting function
my_fit <- fit_coupled_growth(example_coupled_onestep,
start = guess,
known = known,
mode = "one_step")
## The package includes common S3 methods
print(my_fit)
coef(my_fit)
summary(my_fit)
plot(my_fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.