MicrobialGrowth: MicrobialGrowth regression function

View source: R/base.R

MicrobialGrowthR Documentation

MicrobialGrowth regression function

Description

Regression function to different microbial growth models.

Usage

MicrobialGrowth(
  x,
  y,
  model = "gompertz",
  clip = c(-Inf, Inf),
  start = list(),
  lower = list(),
  upper = list(),
  nls.args = list(),
  callbackError = NULL,
  ...
)

Arguments

x

index series or time series.

y

values or list of values to regress (should not be logged).

model

wanted growth model : "baranyi", "gompertz" or "rosso".

clip

a pair of values indicating in which interval to clip the data y. When clip is missing, default values are used.

start

a named list of starting estimates. When start is missing, default values are used.

lower

a named list of lower bounds. When lower is missing, default values are used.

upper

a named list of upper bounds. When upper is missing, default values are used.

nls.args

additional parameters to use when calling nls.

callbackError

function to call on error during regression.

...

further arguments passed to or from other methods.

Details

Use listAvailableModels() function to see all values accepted by model parameter.

The default values for clip, start, lower and upper are calculated based on the given data. These default values can be known through the call member of the returned value.

The nls.args argument is a list that can contain any nls function argument except formula, algorithm, start, lower and upper which are already fixed (via a homonymous or hard-coded argument).

For the callbackError argument, prefer the stop function to block or warning to not be blocking.

Value

a MicrobialGrowth-object composed of

call

the matched call with several components.

coefficients

coefficients obtained by regression.

data

data used for regression, once the y values are clipped

f

a list of functions such as formula to retrieve the function of the model with the coefficients obtained by regression, confint to retrieve the confidence intervals, etc.

isValid

a boolean indicating whether the regression was successful or not.

message

contains the error message if the regression fails, NULL otherwise.

reg

the nls object returned by the nls function.

Examples

# Using the embedded data example_data
# Simple example
g <- MicrobialGrowth(example_data$time, example_data$y1, model="gompertz")

# Multiple regression example
G <- MicrobialGrowth(example_data$time, example_data[2:ncol(example_data)], model="gompertz")

# Example of multiple parameter changes
g <- MicrobialGrowth(example_data$time, example_data$y1, model="gompertz",
                           clip = c(0.15, Inf), start = list(N0=0.1, Nmax=2,
                           mu=0.05, lambda=40), lower = list(lambda = 40))

# Example of using `nls.args` to apply weight to some data
g <- MicrobialGrowth(example_data$time, example_data$y1, model="gompertz",
nls.args = list(weights = (function(x){(x >= 50 & x <= 70)*9 + 1})(example_data$time)))

# Example of callbackError (remaining non-blocking)
g <- MicrobialGrowth(example_data$time, example_data$y15, model="gompertz",
                           callbackError = warning)

# Example of callbackError (becoming blocking)
try(
  g <- MicrobialGrowth(c(1,2,3,4,5),c(1,1,1,1,1), model="gompertz", callbackError = stop)
)

MicrobialGrowth documentation built on April 12, 2025, 1:34 a.m.