Skip to content

Commit

Permalink
Corrected SRR residuals
Browse files Browse the repository at this point in the history
  • Loading branch information
iagomosqueira committed Mar 19, 2024
1 parent f4355f5 commit 9e9dd26
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ss3om
Title: Tools for Conditioning Fisheries Operating Models Using Stock Synthesis 3
Version: 0.5.2.9011
Version: 0.5.2.9015
Authors@R: person("Iago", "Mosqueira", email = "[email protected]",
role = c("aut", "cre"))
Description: Tools for loading Stock Synthesis (SS3) models into FLR. Used in
Expand All @@ -20,7 +20,7 @@ Imports:
FLFishery,
mse,
mvtnorm
Additional_repositories: http://flr.r-universe.dev
Additional_repositories: https://flr.r-universe.dev
Remotes: https://r4ss.r-universe.dev
BugReports: https://github.com/flr/ss3om/issues
Suggests:
Expand Down
15 changes: 10 additions & 5 deletions R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ buildFLSRss3 <- function(out, ...) {
"sigma_R_in", "sigma_R_info")]

# EXTRACT elements
recruit <- data.table(out$recruit)[era %in% c("Fixed", "Main"),]
recruit <- data.table(out$recruit)[era %in% c("Early","Fixed","Main","Fore"),]
parameters <- data.table(out$parameters)
dquants <- data.table(out$derived_quants)
lkhds <- out$likelihoods_used
Expand Down Expand Up @@ -213,16 +213,21 @@ buildFLSRss3 <- function(out, ...) {

# rec
rec <- FLQuant(recruit$pred_rec, dimnames=c(age=0, dms), units="1000")

# ssb
ssb <- FLQuant(recruit$SpawnBio, dimnames=c(age="all", dms), units="t")

# fitted
fitted <- FLQuant(recruit$bias_adjusted, dimnames=c(age=0, dms),
units="1000")
# residuals with bias-correction
residuals <- FLQuant(exp(recruit$dev -0.5 * out$sigma_R_in^2),
dimnames=c(age=0, dms), units="")
if(out$nsexes == 2)

# residuals with bias-correction
residuals <- FLQuant(exp(recruit$dev - recruit$biasadjuster * 0.5 *
out$sigma_R_info[1, 8] ^ 2), dimnames=c(age=0, dms), units="")

if(out$nsexes == 2) {
residuals <- expand(residuals, unit=c("F", "M"))
}

# SETUP for multiple recruit seasons
if(out$nseasons > 1) {
Expand Down

0 comments on commit 9e9dd26

Please sign in to comment.