createInits: Method createInits

createInitsR Documentation

Method createInits

Description

Function for generating intial values for the parameters of the bbm function, given information on catches, survey indices and instantaneous rate of biomass decrease, g.

Usage

createInits(object, indicesB, indicesP, ...)

## S4 method for signature 'FLQuant,FLQuants,FLQuants'
createInits(object, indicesB, indicesP, findicesB, findicesP, g)

## S4 method for signature 'FLStock,ANY,ANY'
createInits(object, indicesB, indicesP, findicesB = NULL, findicesP = NULL, g)

## S4 method for signature 'FLQuant,FLIndices,FLIndices'
createInits(object, indicesB, indicesP, findicesB = NULL, findicesP = NULL, g)

## S4 method for signature 'FLQuant,FLQuant,FLQuant'
createInits(object, indicesB, indicesP, findicesB, findicesP, g)

Arguments

object

An FLQuant with catch information (for recruits and adults) or an FLStock.

indicesB

Abundance indices in total biomass (element of class: FLQuants, FLQuant or FLIndices) from surveys. Please assign a survey name to each index.

indicesP

Percentage of recruits in biomass (element of class: FLQuants, FLQuant or FLIndices) from surveys. Please assign a survey name to each proportion.

findicesB

A vector with fraction of the year corresponding to each of the indicesB.

findicesP

A vector with fraction of the year corresponding to each of the indicesP.

g

A vector with information on instantaneous rate of biomass decrease, g = M - G, for recruits (rec) and adults (adult).

Value

An object of class FLPar.

Methods

Methods exist for various calculations based on the output class (FLPar). For details: ?FLPar.

Author(s)

Leire Ibaibarriaga & Sonia Sanchez.

See Also

bbm, FLQuant, FLQuants, FLIndices, FLPar, bbmFLPar

Examples


# Load data
data(ane)


# Case: object='FLQuant'; indicesB=indicesP='FLQuants'
inits1 <- createInits( catch.ane,
                       indicesB=lapply( indicesB.ane, function(x) x@index), 
                       indicesP=lapply( indicesP.ane, function(x) x@index), 
                       findicesB=unlist(lapply( indicesB.ane, function(x) mean(range(x)[c('startf','endf')]))),
                       findicesP=unlist(lapply( indicesP.ane, function(x) mean(range(x)[c('startf','endf')]))), 
                       g=control.ane@g )
class(inits1)

# Case: object='FLQuant'; indicesB=indicesP='ANY'

stock <- FLStock(catch.n=catch.ane, catch.wt=catch.ane*0+1)
units(stock@catch.wt) <- ''
stock@catch <- quantSums(stock@catch.n*stock@catch.wt)

inits2 <- createInits( stock, indicesB=indicesB.ane, indicesP=indicesP.ane, 
                       g=control.ane@g )
class(inits2)

# Case: object='FLQuant'; indicesB=indicesP='FLIndices'

inits3 <- createInits( catch.ane,
                       indicesB=indicesB.ane, indicesP=indicesP.ane, 
                       g=control.ane@g )
class(inits3)

# Case: object='FLQuant'; indicesB=indicesP='FLQuant'
inits4 <- createInits( catch.ane,
                       indicesB=indicesB.ane[[1]]@index, indicesP=indicesP.ane[[1]]@index, 
                       findicesB=c( depm=(indicesB.ane[[1]]@range[['startf']]+indicesB.ane[[1]]@range[['endf']])/2),
                       findicesP=c( depm=(indicesP.ane[[1]]@range[['startf']]+indicesP.ane[[1]]@range[['endf']])/2), 
                       g=control.ane@g )
class(inits4)

# Run assessment (with the different initial values)
run0 <- bbm(catch.ane, indicesB=indicesB.ane, indicesP=indicesP.ane, control=control.ane, inits=inits.ane)
run1 <- bbm(catch.ane, indicesB=indicesB.ane, indicesP=indicesP.ane, control=control.ane, inits=inits1)
run2 <- bbm(catch.ane, indicesB=indicesB.ane, indicesP=indicesP.ane, control=control.ane, inits=inits2)
run3 <- bbm(catch.ane, indicesB=indicesB.ane, indicesP=indicesP.ane, control=control.ane, inits=inits3)
namdel <- c("q_acoustic","psi_acoustic","xi_acoustic") # we will take only one of the indices --> need to delete the parameters related to other indices
control <- control.ane
control@param.fix <- control@param.fix[dimnames(control@param.fix)$params[!dimnames(control@param.fix)$params %in% namdel],]
run4 <- bbm(catch.ane, indicesB=indicesB.ane[[1]]@index, indicesP=indicesP.ane[[1]]@index, 
            findicesB=c( depm=(indicesB.ane[[1]]@range[['startf']]+indicesB.ane[[1]]@range[['endf']])/2),
            findicesP=c( depm=(indicesP.ane[[1]]@range[['startf']]+indicesP.ane[[1]]@range[['endf']])/2), 
            control=control, inits=inits4)

# Plot assessed populations
biomass <- FLQuants()
runs <- paste("run",0:4,sep="")
names(runs) <- c('bc','run1','run2','run3','only_depm')
for (i in 1:length(runs)) biomass[[i]] <- quantSums(stock.bio(get(runs[i])))
names(biomass) <- names(runs)
plot( biomass)


flr/bbm documentation built on Sept. 6, 2022, 8:56 p.m.