Growth2OM: Generate bootstrapped estimates of von Bertalanffy growth...

Description Usage Arguments Details Value Examples

View source: R/data2OMfunctions.r

Description

The von Bertalanffy model is fitted to length-at-age data and bootstrapped to provide either OM@nsim or nsim estimates of Linf, K, and t0 parameters. LenCV is also estimated from mean growth curve and the observed length-at-age data.

Usage

1
2
3
4
5
6
7
8
Growth2OM(
  data = NULL,
  OM = NULL,
  nsim = 48,
  seed = 101,
  plot = TRUE,
  msg = TRUE
)

Arguments

data

A data.frame with columns names 'Age' and 'Length'

OM

Optional. Object of class OM. Function will return OM with cpars slot populated if an OM is provided, otherwise it returns a data.frame

nsim

Optional numeric. If an OM is not provided, nsim is used.

seed

Optional numierc. If an OM is not provided, seed is used in set.seed.

plot

Logical. Plot the data and model fits?

msg

Logical. Display messages?

Details

The function either returns an OM with the cpars slot updated with estimated values, or a data.frame with the estimated values.

Value

An OM with cpars slot populated with Linf, K, t0 and LenCV values, or a data.frame.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Simple model to generate length-at-age data
OM <- DLMtool::testOM 
OM@nsim <- 2
Hist <- runMSE(OM, Hist=TRUE)
N <- Hist@AtAge$Nage[1,,1] * Hist@AtAge$Select[1,,1]
meanL <- Hist@AtAge$Length[1,,1]
sdL <- Hist@AtAge$Length[1,,1] * 0.1
nsamp <- ceiling(N/sum(N) * 1000)
Length <- unlist(sapply(1:length(meanL), function(i) rnorm(nsamp[i], meanL[i], sdL[i])))
Ages <- rep(1:length(N), nsamp)
data <- data.frame(Age=Ages, Length=Length)

# Return an OM with cpars populated
OM@nsim <- 48
newOM <- Growth2OM(data, OM)

# Return a data.frame
estPars <- Growth2OM(data)

DLMtool/DLMtool documentation built on June 20, 2021, 5:20 p.m.