| createInits | R Documentation | 
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.
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)
object | 
 An   | 
indicesB | 
 Abundance indices in total biomass (element of class:   | 
indicesP | 
 Percentage of recruits in biomass (element of class:   | 
findicesB | 
 A   | 
findicesP | 
 A   | 
g | 
 A   | 
An object of class FLPar.
Methods exist for various calculations based on the output class (FLPar). For details: ?FLPar.
Leire Ibaibarriaga & Sonia Sanchez.
bbm, FLQuant, FLQuants, FLIndices, FLPar, bbmFLPar
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.