get.growth.rate: Extract exponential growth rate from a time series of...

Description Usage Arguments Value Examples

View source: R/tools.R

Description

This meta-function takes a time series of abundance, and attempts to extract an estimate of exponential growth rate, using one or more of a suite of possible methods. These methods allow for the possibility that exponential growth may lag or saturate, or both, over the course of the time series. All selected methods are used to fit models to the time series. Subsequently, model comparison (based on AIC) is used to determine which model best fits the focal data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
get.growth.rate(
  x,
  y,
  id,
  plot.best.Q = F,
  fpath = NA,
  methods = c("linear", "lag", "sat", "flr", "lagsat"),
  model.selection = c("AICc"),
  min.exp.obs = 3,
  internal.r2.cutoff = 0,
  verbose = FALSE,
  zero.time = TRUE
)

Arguments

x

Time steps

y

ln(abundance)

id

Label corresponding to the population/strain/species of interest; used to determine the title and file name of saved plot, if any.

plot.best.Q

logical; should the best fitting model be plotted?

fpath

character; if best model is to be plotted, provide the file path for saving the plot

methods

Must be a character vector containing one or more of 'linear', 'lag', 'sat', 'flr', or 'lagsat'

model.selection

control parameter to specify which IC metric to use in model selection; default is AICc, which corrects for small sample sizes and converges asymptotically on AIC.

min.exp.obs

control parameter specifying the minimum number of observations that must fall within the estimated exponential phase in order to consider lag, sat, lagsat, and flr models; defaults to 3.

internal.r2.cutoff

control parameter specifying the R2 criteria that may be applied to drop fits where the number of observations in the exponential portion is equal to 3. The default value of zero permits all fits of 3 obs to be considered.

verbose

logical; display or suppress diagnostics

zero.time

if TRUE, shift time axis so that each time series starts at time = 0

Value

A data frame containing the identity of the best model, the content of the best model, the estimated slopes of the increasing linear portion of the regressions (ie, exponential growth rate), the standard errors associated with these slopes, the IC table used to determine the best model, and the full list of all models fit. See vignette for details.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
sdat<-data.frame(trt=c(rep('A',10),rep('B',10),rep('C',10),rep('D',10)),
                dtime=rep(seq(1,10),4),
                ln.fluor=c(c(1,1.1,0.9,1,2,3,4,5,5.2,4.7),
                           c(1.1,0.9,1,2,3,4,4.1,4.2,3.7,4)+0.3,
                           c(3.5,3.4,3.6,3.5,3.2,2.2,1.2,0.5,0.4,0.1),
                           c(5.5,4.5,3.5,2.5,1.5,0,0.2,-0.1,0,-0.1)))
                           
# for single replicate                            
sdat2<-sdat[sdat$trt=='A',]

# calculate growth rate using all available methods:
res<-get.growth.rate(sdat2$dtime,sdat2$ln.fluor,plot.best.Q = TRUE,id = 'Population A')
res$best.model
res$best.slope

ctkremer/growthTools documentation built on July 27, 2021, 4:19 p.m.