Skip to contents

This function fits a specified growth model to a bipod object. Depending on the input, it can fit an exponential or logistic growth model, or perform model selection to choose the best fit.

Usage

fit(
  x,
  growth_type = "exponential",
  infer_t0 = TRUE,
  variational = FALSE,
  factor_size = 1,
  model_selection_algo = "bayes_factor",
  chains = 4,
  iter = 5000,
  cores = 4
)

Arguments

x

A bipod object to which the growth model will be fitted.

growth_type

A character string specifying the type of growth model to fit. Options are 'exponential', 'logistic', or 'both'. If 'both' is selected, model selection will be performed to choose the best fit. (default is 'exponential')

infer_t0

A logical value indicating whether to infer the time of population origin (t0). If TRUE, the function will estimate this value during model fitting. (default is TRUE)

variational

A logical value indicating whether to use variational inference instead of Markov Chain Monte Carlo (MCMC) sampling. If TRUE, variational inference is used; otherwise, MCMC sampling is used. (default is FALSE)

factor_size

A numeric value representing the factor by which to divide counts in the bipod object. Must be a positive number and less than or equal to the minimum count in the bipod object. (default is 1)

model_selection_algo

A character string specifying the algorithm to use for model selection when growth_type = "both". Options are 'bayes_factor' or 'mixture_model'. (default is "bayes_factor")

chains

An integer specifying the number of chains to run in the MCMC algorithm. Ignored if variational = TRUE. (default is 4)

iter

An integer specifying the number of iterations to run in the MCMC algorithm. Ignored if variational = TRUE. (default is 5000)

cores

An integer specifying the number of cores to use for parallel processing during model fitting. (default is 4)

Value

The input bipod object with added slots:

  • 'fit': Contains the fitted model.

  • 'fit_info': Contains information about the fitting process, including metadata such as sampling type, factor size, growth type, and model selection details.