Skip to content

Commit

Permalink
Feature: Extend main rec dev phase in em
Browse files Browse the repository at this point in the history
Update EM functions to increment the end year of the main rec dev phase so that
  • Loading branch information
nathanvaughan-NOAA committed Jun 14, 2024
1 parent c4e1ce9 commit 5c549b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions R/MS_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ EM <- function(EM_out_dir = NULL, init_loop = TRUE, OM_dat, verbose = FALSE,
new_datfile_name = new_datfile_name,
verbose = verbose
)

#Increment main recruitment phase end year by number of assessment years
#So the model can continue to estimate rec devs
ctl <- SS_readctl(file.path(EM_out_dir, start[["ctlfile"]]),
datlist = new_EM_dat
)
ctl$MainRdevYrLast <- ctl$MainRdevYrLast + nyrs_assess
r4ss::SS_writectl(ctl, file.path(EM_out_dir, start[["ctlfile"]]),
overwrite = TRUE
)
}
# Update SS random seed
start <- SS_readstarter(file.path(EM_out_dir, "starter.ss"),
Expand Down
11 changes: 10 additions & 1 deletion R/RatioBiasEM.R
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ get_RatioEM_catch_df<-function(EM_dir, dat, dat_yrs,
#' init_loop is TRUE.
#' @template OM_out_dir
#' @template sample_struct
#' @template seed
#' @template seed
#' @param ... Any additional parameters

#For example, if EM has a positive bias (e.g., EM catch = 1 when true OM catch = 0.5), the EM2OM multiplier should be less than 1 (EM2OM = 0.5)
Expand Down Expand Up @@ -662,6 +662,15 @@ BiasEM <- function(EM_out_dir = NULL, init_loop = TRUE, OM_dat, verbose = FALSE,
verbose = verbose
)

#Increment main recruitment phase end year by number of assessment years
#So the model can continue to estimate rec devs
ctl <- SS_readctl(file.path(EM_out_dir, start[["ctlfile"]]),
datlist = new_EM_dat
)
ctl$MainRdevYrLast <- ctl$MainRdevYrLast + nyrs_assess
r4ss::SS_writectl(ctl, file.path(EM_out_dir, start[["ctlfile"]]),
overwrite = TRUE
)
} # end else not first iteration

# Update SS random seed
Expand Down

0 comments on commit 5c549b4

Please sign in to comment.