Skip to content

Add SAM assessement (via FLSAM) in MP - #25

Open
iambaim wants to merge 4 commits into
flr:masterfrom
REDUS-IMR:withsam
Open

Add SAM assessement (via FLSAM) in MP#25
iambaim wants to merge 4 commits into
flr:masterfrom
REDUS-IMR:withsam

Conversation

@iambaim

@iambaim iambaim commented Dec 12, 2018

Copy link
Copy Markdown

Add SAM (https://github.com/fishfollower/SAM) as one of the assessment methods.
Example:

devtools::install_github("flr/FLSAM")

library(FLBEIA)
library(FLSAM)

rm(list=ls())
data(one)

oneAssC.sam <- oneAssC
oneAssC.sam[["stk1"]]$assess.model <- "sam2flbeia"
oneAssC.sam[["stk1"]]$harvest.units <- "f"
oneAssC.sam[["stk1"]]$control$indices.type <- "number" # This can be number, biomass or con


s1 <- FLBEIA( biols       = oneBio,    # FLBiols: FLBiol for stk1.
              SRs         = oneSR,     # List: FLSRSim for stk1.
              BDs         = NULL,        # Not population with biomass dynamics.
              fleets      = oneFl,     # FLFleets: one fleet.
              covars      = oneCv,     # List: covars related to economy.
              indices     = oneIndAge, # Age-structured index.
              advice      = oneAdv,    # List: 'TAC' and 'quota.share'
              main.ctrl   = oneMainC,  # List: info on start and end of the simulation.
              biols.ctrl  = oneBioC,   # List: model to simulate the stock dynamics.
              fleets.ctrl = oneFlC,    # List: fleet dynamics models select. and other params.
              covars.ctrl = oneCvC,    # List: covariates dynamics ("fixedCovar").
              obs.ctrl    = oneObsCIndAge, # List: type of stock and index observation
                                           #       ("age2ageDat","ageInd").
              assess.ctrl = oneAssC.sam,   # List: assessment model used ("sca2flbeia").
              advice.ctrl = oneAdvC)  # List: rule for TAC advice ("IcesHCR").


stk1.mp1 <- s1$stocks[['stk1']]
stk1.om1 <- FLBEIA:::perfectObs(s1$biols[['stk1']], s1$fleets, year = dim(s1$biols[['stk1']]@n)[2])
adf <- as.data.frame
s1_pop <- rbind( data.frame( population='obs', indicator='SSB', as.data.frame(ssb(stk1.mp1))), 
                 data.frame( population='obs', indicator='Harvest', as.data.frame(fbar(stk1.mp1))), 
                 data.frame( population='obs', indicator='Catch', as.data.frame(catch(stk1.mp1))),
                 data.frame( population='obs', indicator='Recruitment', as.data.frame(rec(stk1.mp1))),
                 data.frame( population='real', indicator='SSB', as.data.frame(ssb(stk1.om1))), 
                 data.frame( population='real', indicator='Harvest', as.data.frame(fbar(stk1.om1))), 
                 data.frame( population='real', indicator='Catch', as.data.frame(catch(stk1.om1))),
                 data.frame( population='real', indicator='Recruitment', as.data.frame(rec(stk1.om1))))
p <- ggplot( data=s1_pop, aes(x=year, y=data, color=population)) + 
  geom_line() +
  facet_grid(indicator ~ ., scales="free") + 
  geom_vline(xintercept = oneMainC$sim.years[['initial']]-1, linetype = "longdash")+
  theme_bw()+
  theme(text=element_text(size=15),
        title=element_text(size=15,face="bold"),
        strip.text=element_text(size=15), 
        legend.position="top")+
  ylab("")
print(p)

Thanks!

-Ibrahim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant