l2a: Method to convert length-based data to age-based

l2aR Documentation

Method to convert length-based data to age-based

Description

Method to convert length-based data to age-based

Usage

l2a(object, model, ...)

## S4 method for signature 'FLQuant,a4aGr'
l2a(
  object,
  model,
  halfwidth = c(diff(as.numeric(dimnames(object)[[1]])),
    tail(diff(as.numeric(dimnames(object)[[1]])), 1))/2,
  stat = "sum",
  max_age = NA
)

## S4 method for signature 'FLStockLen,a4aGr'
l2a(object, model, plusgroup = NA, ...)

## S4 method for signature 'FLIndex,a4aGr'
l2a(object, model, ...)

Arguments

object

an FLQuant, or FLStockLen object.

model

an a4aGr object

...

additional argument list that might never be used

halfwidth

the halfwidths of the length classes; a single numeric or vector the size of the number of length classes; not used if object is an FLStockLen

stat

the aggregation statistic, which must be mean or sum; only used if object is an FLQuant.

max_age

the maximum age in the returned FLQuant; all ages above this are set to max_age; only used if object is an FLQuant

plusgroup

the plusgroup of the stock; only used if the object is an FLStockLen.

Details

A deterministic slicing method converts the length-based data to age-based data, using the supplied growth model (the a4aGr object). Each length-based observation is allocated to a corresponding age, based on the growth model, and aggregated accordingly (either the sum or the mean). There should be 1 or n iterations in both the object being sliced and the growth model. This means that although the slicing method is deterministic, the length-based data is sliced by each iteration of the growth parameters, thereby propagating the uncertainty in the biological growth parameters (representing process uncertainty) through to the age-based data.

Value

an age based FLQuant, FLStock

Examples

# Southern hake
# Variance-covariance matrix for parameters
mm <- matrix(NA, ncol=3, nrow=3)
diag(mm) <- c(2310, 0.13, 0.84)
mm[upper.tri(mm)] <- mm[lower.tri(mm)] <- c(-7.22,-6.28,0.08)
# Make the von Bertalanffy growth model
md <- ~linf*(1-exp(-k*(t-t0)))
imd <- ~t0-1/k*log(1-len/linf)
prs <- FLPar(linf=130, k=0.164, t0=-0.092, units=c("cm","yr-1","yr"))
vbObj <- a4aGr(grMod=md, grInvMod=imd, params=prs, vcov=mm, distr="norm")
# Make a triangle copula for simulating process error
linf <- list(a=104.5, b=155.5, c=130) 
k <- list(a=0.132, b=0.196, c=0.164)
t0 <- list(a=-0.184, b=0, c=-0.092)
tri_pars <- list(linf = linf, k = k, t0 = t0)
# Simulate 10 iterations from it
vbObj_tri <- mvrtriangle(10, vbObj, paramMargins=tri_pars)
data(southernHakeLen)
# Extract the catch numbers at length from stock object
cth <- catch.n(shake_len) 
# Slice the data using the unsimulated growth object 
# so the stock and the growth object have 1 iteration
cthA1 <- l2a(cth, vbObj)
# Slice with 1 iteration in stock and multiple in growth object
cthA2 <- l2a(cth, vbObj_tri)
# Result is age based catch with multiple iterations
# mod: iter=1, data: iter=n
cthA3 <- l2a(propagate(cth,10), vbObj)
# both with iter=n
cthA4 <- l2a(propagate(cth,10), vbObj_tri)
# converting a stock object
shake_age <- l2a(shake_len, vbObj)
shake_age <- l2a(shake_len, vbObj_tri)
shake_age <- l2a(propagate(shake_len, 10), vbObj)
shake_age <- l2a(propagate(shake_len, 10), vbObj_tri)
# converting a index object
index_pt_age <- l2a(index_pt_len, vbObj)
index_pt_age <- l2a(index_pt_len, mvrnorm(10, vbObj))
index_pt_age <- l2a(propagate(index_pt_len, 10), vbObj)

flr/FLa4a documentation built on Dec. 21, 2024, 9:28 p.m.