##################################################################### # (20190918) EJ # Can we build a index of abundance based in genetics ? # Demostration of impact of new index in stock assessment ##################################################################### library(FLa4a) library(ggplotFL) data(ple4) data(ple4.index) it <- 250 #==================================================================== # Default model, no index of recruitment #==================================================================== fit0 <- sca(ple4, FLIndices(a=ple4.index)) stk0 <- ple4+simulate(fit0, it) #==================================================================== # (flat) index of recruitment #==================================================================== flq <- stock.n(ple4)[1] flq[] <- rnorm(61, 5) fit1 <- sca(ple4, FLIndices(a=ple4.index, b=FLIndex(index=flq, range=c(startf=0, endf=0)))) plot(FLStocks(Default=stk0, FlatIndex=ple4+simulate(fit1, it))) #==================================================================== # (contrasted) index of recruitment #==================================================================== set.seed(111) ts.sim <- arima.sim(list(order = c(1,1,0), ar = 0.7), n = 61)[-1] flq[] <- exp(scale(ts.sim)) flqv <- flq flqv[] <- 0.3 fit2 <- sca(ple4, FLIndices(a=ple4.index, b=FLIndex(index=flq, index.var=flqv, range=c(startf=0, endf=0)))) plot(FLStocks(Default=stk0, FlatIndex=ple4+simulate(fit1, it) ,ContrastedIndex=ple4+simulate(fit2, it)))