# sa.R - Status and trend estimators and indicators.
# mse/R/sa.R
# Copyright European Union, 2018-2021
# Author: Iago Mosqueira (EC JRC) <iago.mosqueira@ec.europa.eu>
#
# Distributed under the terms of the European Union Public Licence (EUPL) V.1.1.
# perfect.sa {{{
#' A perfect 'estimate' of abundances, catches and harvest.
#'
#' The *FLStock* generated by the call to *oem* is simply passed on in this
#' function. The estimates of abundance, catches and exploitation will thus be
#' as precise as the OEM observation.
#'
#' @param stk The stock observation generated by *oem*. Class *FLStock*.
#' @param idx An observation of chnages in abundance, not used. Class *FLIndices*.
#' @param args MSE arguments, class *list*.
#' @param tracking Structure for tracking modules outputs.
#'
#' @return A *list* with elements *stk* and *tracking*.
#'
#' @examples
#' data(sol274)
#' perfect.sa(stock(om), FLIndices(), args=list(ay=2018, dy=2017),
#' tracking=FLQuants(FLQuant(dimnames=list(metric="conv.est", year=2018))))
perfect.sa <- function(stk, idx, args, tracking, ...) {
dy <- args$dy
ay <- args$ay
stk <- window(stk, end=dy)
if(all(is.na(harvest(stk))))
harvest(stk) <- harvest(stock.n(stk), catch.n(stk), m(stk))
track(tracking, "conv.est", ac(ay)) <- 1
list(stk=stk, tracking=tracking)
}
# }}}
# shortcut.sa {{{
shortcut.sa <- function(stk, idx, SSBdevs=ssb(stk) %=% 1, args, tracking, ...) {
# DIMS
y0 <- args$y0
dy <- args$dy
ay <- args$ay
it <- args$it
# SUBSET oem stock
stk <- window(stk, end=dy)
ind <- FLQuants(
# SSB + devs
ssb=ssb(stk) * window(SSBdevs, start=y0, end=dy))
track(tracking, "conv.est", ac(ay)) <- 1
list(stk=stk, ind=ind, tracking=tracking)
}
# }}}
# shortcut_devs {{{
# GET new Fphi, Fcv values.
shortcut_devs <- function(om, Fcv=0.212, Fphi=0.423, SSBcv=0, SSBphi=0) {
devs <- FLQuants(
F=ar1rlnorm(Fphi, dimnames(om)$year, dims(om)$iter, 0, Fcv),
SSB=ar1rlnorm(0, dimnames(om)$year, dims(om)$iter, 0, SSBcv)
)
return(devs)
}
# }}}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.