predict_growth_uncertainty: Isothermal growth with parameter uncertainty

View source: R/predict_stochastic_growth.R

predict_growth_uncertaintyR Documentation

Isothermal growth with parameter uncertainty

Description

[Stable]

Simulation of microbial growth considering uncertianty in the model parameters. Calculations are based on Monte Carlo simulations, considering the parameters follow a multivariate normal distribution.

Usage

predict_growth_uncertainty(
  model_name,
  times,
  n_sims,
  pars,
  corr_matrix = diag(nrow(pars)),
  check = TRUE,
  logbase_mu = logbase_logN,
  logbase_logN = 10
)

Arguments

model_name

Character describing the primary growth model.

times

Numeric vector of storage times for the simulations.

n_sims

Number of simulations.

pars

A tibble describing the parameter uncertainty (see details).

corr_matrix

Correlation matrix of the model parameters. Defined in the same order as in pars. An identity matrix by default (uncorrelated parameters).

check

Whether to do some tests. FALSE by default.

logbase_mu

Base of the logarithm the growth rate is referred to. By default, the same as logbase_logN. See vignette about units for details.

logbase_logN

Base of the logarithm for the population size. By default, 10 (i.e. log10). See vignette about units for details.

Details

The distributions of the model parameters are defined in the pars argument using a tibble with 4 columns:

  • par: identifier of the model parameter (according to primary_model_data()),

  • mean: mean value of the model parameter.,

  • sd: standard deviation of the model parameter.,

  • scale: scale at which the model parameter is defined. Valid values are 'original' (no transformation), 'sqrt' square root or 'log' log-scale. The parameter sample is generated considering the parameter follows a marginal normal distribution at this scale, and is later converted to the original scale for calculations.

Value

An instance of GrowthUncertainty().

Examples


## Definition of the simulation settings

my_model <- "Baranyi"
my_times <- seq(0, 30, length = 100)
n_sims <- 3000

library(tibble)

pars <- tribble(
    ~par, ~mean, ~sd, ~scale,
    "logN0", 0, .2, "original",
    "mu", 2, .3, "sqrt",
    "lambda", 4, .4, "sqrt",
    "logNmax", 6, .5, "original"
)

## Calling the function

stoc_growth <- predict_growth_uncertainty(my_model, my_times, n_sims, pars)

## We can plot the results

plot(stoc_growth)

## Adding parameter correlation

my_cor <- matrix(c(1,   0,   0, 0,
    0,   1, 0.7, 0,
    0, 0.7,   1, 0,
    0,   0,   0, 1),
    nrow = 4)

stoc_growth2 <- predict_growth_uncertainty(my_model, my_times, n_sims, pars, my_cor)

plot(stoc_growth2)

## The time_to_size function can calculate the median growth curve to reach a size

time_to_size(stoc_growth, 4)

## Or the distribution of times

dist <- time_to_size(stoc_growth, 4, type = "distribution")
plot(dist)





biogrowth documentation built on May 29, 2024, 4:17 a.m.