fit_multiple_growth_MCMC: Fitting growth models to multiple dynamic experiments using...

View source: R/fit_multi_dynamic.R

fit_multiple_growth_MCMCR Documentation

Fitting growth models to multiple dynamic experiments using MCMC

Description

[Superseded]

The function fit_multiple_growth_MCMC() has been superseded by the top-level function fit_growth(), which provides a unified approach for growth modelling.

However, this functions can still be used to fit a growth model using a dataset comprised of several experiments with potentially different dynamic experimental conditions.

Usage

fit_multiple_growth_MCMC(
  starting_point,
  experiment_data,
  known_pars,
  sec_model_names,
  niter,
  ...,
  check = TRUE,
  formula = logN ~ time,
  logbase_mu = logbase_logN,
  logbase_logN = 10
)

Arguments

starting_point

a named vector of starting values for the model parameters.

experiment_data

a nested list with the experimental data. Each entry describes one experiment as a list with two elements: data and conditions. data is a tibble with a column giving the elapsed time (named "time" by default) and another one with the decimal logarithm of the population size (named "logN" by default). conditions is a tibble with one column giving the elapsed time (using the same name as data) and as many additional columns as environmental factors. The default column names can be changed with the formula argument.

known_pars

named vector of known model parameters

sec_model_names

named character vector with names of the environmental conditions and values of the secondary model (see secondary_model_data).

niter

number of samples of the MCMC algorithm.

...

additional arguments for modMCMC (e.g. upper and lower bounds).

check

Whether to check the validity of the models. TRUE by default.

formula

an object of class "formula" describing the x and y variables. logN ~ time as a 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.

Value

An instance of FitMultipleGrowthMCMC().

Examples


## We will use the multiple_experiments data set

data("multiple_experiments")

## For each environmental factor, we need to defined a model

sec_names <- c(temperature = "CPM", pH = "CPM")

## Any model parameter can be fixed

known <- list(Nmax = 1e8, N0 = 1e0, Q0 = 1e-3,
    temperature_n = 2, temperature_xmin = 20, temperature_xmax = 35,
    pH_n = 2, pH_xmin = 5.5, pH_xmax = 7.5, pH_xopt = 6.5)

## The rest require starting values for model fitting

start <- list(mu_opt = .8, temperature_xopt = 30)

## We can now call the fitting function

set.seed(12412)
global_MCMC <- fit_multiple_growth_MCMC(start, multiple_experiments, known, sec_names, niter = 1000,
   lower = c(.2, 29),  # lower limits of the model parameters
   upper = c(.8, 34))  # upper limits of the model parameters

## Parameter estimates can be retrieved with summary

summary(global_MCMC)

## We can compare fitted model against observations

plot(global_MCMC)

## Any single environmental factor can be added to the plot using add_factor

plot(global_MCMC, add_factor = "temperature")



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