Description
Fitting Predictive Microbiology Models.
Description
Provides predictive microbiology model functions and convenience wrappers for fitting primary growth, microbial inactivation, dynamic, omnibus, and cardinal parameter models to experimental data using nonlinear least squares and related mixed-effects or time-varying workflows. Includes helper functions for extracting fitted values, calculating model diagnostics, and comparing fitted models. Implemented model families include those described by: Zwietering et al. (1990) <doi:10.1128/AEM.56.6.1875-1881.1990>, Baranyi and Roberts (1994) <doi:10.1016/0168-1605(94)90157-0>, Baranyi and Roberts (1995) <doi:10.1016/0168-1605(94)00121-L>, Buchanan et al. (1997) <doi:10.1006/fmic.1997.0125>, Richards (1959) <doi:10.1093/jxb/10.2.290>, Fang et al. (2012) <doi:10.1111/j.1750-3841.2012.02873.x>, Fang et al. (2013) <doi:10.1016/j.fm.2012.12.005>, Huang (2008) <doi:10.1111/j.1750-3841.2008.00785.x>, Huang (2009) <doi:10.1016/j.jfoodeng.2008.07.011>, Huang (2013) <doi:10.1016/j.foodcont.2012.11.019>, Geeraerd et al. (2005) <doi:10.1016/j.ijfoodmicro.2004.11.038>, van Boekel (2002) <doi:10.1016/S0168-1605(01)00742-5>, Peleg (1999) <doi:10.1016/S0963-9969(99)00081-2>, Mafart et al. (2002) <doi:10.1016/S0168-1605(01)00624-9>, Albert and Mafart (2005) <doi:10.1016/j.ijfoodmicro.2004.10.016>, Rosso et al. (1993) <doi:10.1006/jtbi.1993.1099>, Rosso et al. (1995) <doi:10.1128/AEM.61.2.610-616.1995>, and Rosso et al. (1996) <doi:10.4315/0362-028X-59.9.944>.
README.md
predmicror
predmicror provides predictive microbiology model functions and convenience wrappers for fitting primary growth, microbial inactivation, and cardinal parameter models to experimental data. It also supports omnibus (nonlinear mixed-effects) and dynamic (ODE-based time-varying) modelling.
The package can be used in two complementary ways:
- call the exported model equations directly inside
gslnls::gsl_nls(); - use the higher-level
fit_*()wrappers for routine fitting, diagnostics, and model comparison.
Installation
install.packages("devtools")
devtools::install_github("fsqanalytics/predmicror")
Model catalogue
List all supported models with:
library(predmicror)
predmicror_models()
predmicror_models("growth")
predmicror_models("inactivation")
predmicror_models("cardinal")
| Workflow | Wrapper | Response scale | Examples |
|---|---|---|---|
| Primary growth | fit_growth() | natural log (lnN) | HuangFM, BaranyiFM, RossoFM |
| Microbial inactivation | fit_inactivation() | base-10 log (logN) | WeibullM, GeeraerdST, WeibullPH |
| Cardinal parameters | fit_cardinal() | sqrt growth rate (sqrtGR) | CMTI, CMPH, CMAW, CMInh |
| Dynamic (time-varying) | fit_dynamic_growth/inactivation() | natural log (lnN) | Huang ODE, Weibull-Peleg ODE |
| Omnibus (mixed-effects) | fit_omnibus_growth/inactivation() | per primary model | any primary + secondary covariates |
Quick start: growth
library(predmicror)
data(growthfull)
fit <- fit_growth(
data = growthfull,
model = "HuangFM",
time = "Time",
response = "lnN",
start = list(Y0 = 0, Ymax = 22, MUmax = 1.7, lag = 5)
)
summary(fit)
coef(fit)
plot(fit)
Inactivation
data(bixina)
fit <- fit_inactivation(
data = bixina,
model = "WeibullM",
time = "Time",
response = "lnN",
start = list(Y0 = 5.6, sigma = 12, alpha = 1)
)
fit_metrics(fit)
plot(fit)
Cardinal parameter model
data(salmonella)
fit <- fit_cardinal(
data = salmonella,
model = "CMTI",
x = Temp,
response = sqrtGR,
start = list(Tmax = 42, Tmin = 1, MUopt = 1, Topt = 37)
)
coef(fit)
Model comparison
huang <- fit_growth(growthfull, model = "HuangFM", time = "Time",
response = "lnN", start = list(Y0 = 0, Ymax = 22, MUmax = 1.7, lag = 5))
baranyi <- fit_growth(growthfull, model = "BaranyiFM", time = "Time",
response = "lnN", start = list(Y0 = 0, Ymax = 22, MUmax = 1.7, lag = 5))
compare_models(HuangFM = huang, BaranyiFM = baranyi, sort_by = "AIC")
Dynamic (time-varying environment)
profile <- dynamic_profile(
time = c(0, 5, 10),
temperature = c(12, 20, 25)
)
pred <- predict_dynamic_growth(
profile = profile,
start = list(logN0 = 2, logNmax = 8, a = 0.08, Tmin = 5, lag = 1),
times = seq(0, 10, length.out = 50)
)
plot(pred$time, pred$logN, type = "l")
Omnibus (mixed-effects)
# Each group (Condition) has its own curve
dat <- data.frame(
Condition = rep(1:3, each = 7),
Time = rep(seq(0, 6), 3),
lnN = HuangNLM(rep(seq(0, 6), 3), Y0 = 2, Ymax = 8, MUmax = 0.6)
)
fit <- fit_omnibus_growth(
data = dat,
primary = "HuangNLM",
time = "Time",
response = "lnN",
group = "Condition",
random = Y0 ~ 1,
start = c(Y0 = 2, Ymax = 8, MUmax = 0.6)
)
Response scale conventions
The fitting wrappers do not transform the response automatically:
- Growth models: natural logarithm of concentration (
lnN) - Inactivation models: base-10 logarithm (
logN) - Cardinal models: square root of growth rate (
sqrtGR) - Dynamic models: natural logarithm (
lnN)
Documentation
Full reference and vignettes:
https://fsqanalytics.github.io/predmicror/
Citation
citation("predmicror")