From 4c4769f85a97da00b3fc94048652439a8cc2171c Mon Sep 17 00:00:00 2001 From: kellijohnson-NOAA Date: Tue, 17 Sep 2024 13:34:02 -0700 Subject: [PATCH] fix: Removes log_sigma_recruit from BH interface because it is now a part of the distribution associated with log_devs --- inst/include/interface/rcpp/rcpp_interface.hpp | 2 -- .../rcpp/rcpp_objects/rcpp_recruitment.hpp | 15 --------------- .../recruitment/functors/recruitment_base.hpp | 2 -- tests/concurrent/fims_concurrent_mpi.R | 3 --- tests/concurrent/fims_concurrent_processR.R | 3 --- tests/concurrent/fims_concurrent_snowfall.R | 3 --- tests/integration/integration_class.hpp | 16 ---------------- tests/testthat/test-rcpp-recruitment-interface.R | 1 - vignettes/fims-demo.Rmd | 2 +- 9 files changed, 1 insertion(+), 46 deletions(-) diff --git a/inst/include/interface/rcpp/rcpp_interface.hpp b/inst/include/interface/rcpp/rcpp_interface.hpp index 25b19e23..e8480524 100644 --- a/inst/include/interface/rcpp/rcpp_interface.hpp +++ b/inst/include/interface/rcpp/rcpp_interface.hpp @@ -395,8 +395,6 @@ RCPP_MODULE(fims) { .field("estimate_log_devs", &BevertonHoltRecruitmentInterface::estimate_log_devs) .method("get_id", &BevertonHoltRecruitmentInterface::get_id) - .field("log_sigma_recruit", - &BevertonHoltRecruitmentInterface::log_sigma_recruit) .method("evaluate", &BevertonHoltRecruitmentInterface::evaluate); Rcpp::class_("Fleet") diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp index 733f8a74..37506b4d 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp @@ -66,8 +66,6 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase { public: Parameter logit_steep; /**< steepness or the productivity of the stock*/ Parameter log_rzero; /**< recruitment at unfished biomass */ - Parameter - log_sigma_recruit; /**< the log of the stock recruit standard deviation */ ParameterVector log_devs; /**< log recruitment deviations*/ bool estimate_log_devs = false; /**< boolean describing whether to estimate */ @@ -131,19 +129,6 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase { } info->variable_map[this->log_rzero.id_m] = &(recruitment)->log_rzero; - //set log_sigma_recruit - recruitment->log_sigma_recruit.resize(1); - recruitment->log_sigma_recruit[0] = this->log_sigma_recruit.value_m; - if (this->log_sigma_recruit.estimated_m) { - info->RegisterParameterName("log_sigma_recruit"); - if (this->log_sigma_recruit.is_random_effect_m) { - info->RegisterRandomEffect(recruitment->log_sigma_recruit[0]); - } else { - info->RegisterParameter(recruitment->log_sigma_recruit[0]); - } - } - info->variable_map[this->log_sigma_recruit.id_m] = &(recruitment)->log_sigma_recruit; - //set log_recruit_devs recruitment->log_recruit_devs.resize(this->log_devs.size()); for (size_t i = 0; i < recruitment->log_recruit_devs.size(); i++) { diff --git a/inst/include/population_dynamics/recruitment/functors/recruitment_base.hpp b/inst/include/population_dynamics/recruitment/functors/recruitment_base.hpp index 9ea8a4bc..0bbc1bd2 100644 --- a/inst/include/population_dynamics/recruitment/functors/recruitment_base.hpp +++ b/inst/include/population_dynamics/recruitment/functors/recruitment_base.hpp @@ -37,8 +37,6 @@ struct RecruitmentBase : public fims_model_object::FIMSObject { bool constrain_deviations = false; /*!< A flag to indicate if recruitment deviations are summing to zero or not */ - fims::Vector log_sigma_recruit; /**< Log standard deviation of log recruitment - deviations */ fims::Vector log_rzero; /**< Log of unexploited recruitment.*/ bool estimate_log_recruit_devs = true; /*!< A flag to indicate if recruitment diff --git a/tests/concurrent/fims_concurrent_mpi.R b/tests/concurrent/fims_concurrent_mpi.R index 8be30cb8..f11bba1e 100644 --- a/tests/concurrent/fims_concurrent_mpi.R +++ b/tests/concurrent/fims_concurrent_mpi.R @@ -55,9 +55,6 @@ init_fims <- function(i) { # Recruitment recruitment <- new(fims$BevertonHoltRecruitment) - # logR_sd is NOT logged. It needs to enter the model logged b/c the exp() is taken - # before the likelihood calculation - recruitment$log_sigma_recruit$value <- log(om_input$logR_sd) recruitment$log_rzero$value <- log(om_input$R0 + runif(1, min = 0, max = 1000)) recruitment$log_rzero$is_random_effect <- FALSE recruitment$log_rzero$estimated <- FALSE diff --git a/tests/concurrent/fims_concurrent_processR.R b/tests/concurrent/fims_concurrent_processR.R index b76710a9..b48ab1f8 100644 --- a/tests/concurrent/fims_concurrent_processR.R +++ b/tests/concurrent/fims_concurrent_processR.R @@ -42,9 +42,6 @@ init_fims <- function(i) { # Recruitment recruitment <- new(fims$BevertonHoltRecruitment) - # logR_sd is NOT logged. It needs to enter the model logged b/c the exp() is taken - # before the likelihood calculation - recruitment$log_sigma_recruit$value <- log(om_input$logR_sd) recruitment$log_rzero$value <- log(om_input$R0 + runif(1, min = 0, max = 1000)) recruitment$log_rzero$is_random_effect <- FALSE recruitment$log_rzero$estimated <- FALSE diff --git a/tests/concurrent/fims_concurrent_snowfall.R b/tests/concurrent/fims_concurrent_snowfall.R index 8472bbcf..c1c2a2d9 100644 --- a/tests/concurrent/fims_concurrent_snowfall.R +++ b/tests/concurrent/fims_concurrent_snowfall.R @@ -37,9 +37,6 @@ init_fims <- function(i) { # Recruitment recruitment <- new(fims$BevertonHoltRecruitment) - # logR_sd is NOT logged. It needs to enter the model logged b/c the exp() is taken - # before the likelihood calculation - recruitment$log_sigma_recruit$value <- log(om_input$logR_sd) recruitment$log_rzero$value <- log(om_input$R0) # + runif(1,min=0, max=1000)) recruitment$log_rzero$is_random_effect <- FALSE recruitment$log_rzero$estimated <- TRUE diff --git a/tests/integration/integration_class.hpp b/tests/integration/integration_class.hpp index fa79f8a3..e17092bf 100644 --- a/tests/integration/integration_class.hpp +++ b/tests/integration/integration_class.hpp @@ -547,22 +547,6 @@ class IntegrationTest { } } - it = obj.find("logR_sd"); - if (it != obj.end()) { - if ((*it).second.GetType() == JsonValueType::Array) { - rec->log_sigma_recruit.resize(1); - rec->log_sigma_recruit[0] = (*it).second.GetArray()[0].GetDouble(); - if (print_statements) { - std::cout << "'SD' " << rec->log_sigma_recruit[0] << " \n"; - } - } - } else { - if (print_statements) { - std::cout << "'logR_sd' not found.\n"; - } - } - - it = obj.find("logR.resid"); /*the log_recruit_dev vector does not include a value for year == 0 and is of length nyears - 1 where the first position of the vector diff --git a/tests/testthat/test-rcpp-recruitment-interface.R b/tests/testthat/test-rcpp-recruitment-interface.R index 3d8242db..5c3903dc 100644 --- a/tests/testthat/test-rcpp-recruitment-interface.R +++ b/tests/testthat/test-rcpp-recruitment-interface.R @@ -13,7 +13,6 @@ test_that("Recruitment input settings work as expected", { recruitment$logit_steep$is_random_effect <- TRUE recruitment$logit_steep$estimated <- TRUE recruitment$log_rzero$value <- log(r0) - recruitment$log_sigma_recruit$value <- log(0.7) expect_equal(recruitment$get_id(), 1) expect_equal(recruitment$logit_steep$value, 0.78845736) diff --git a/vignettes/fims-demo.Rmd b/vignettes/fims-demo.Rmd index 4919a6a8..334d11a1 100644 --- a/vignettes/fims-demo.Rmd +++ b/vignettes/fims-demo.Rmd @@ -254,7 +254,7 @@ We'll use a Beverton Holt recruitment module. We first instantiate a module usin recruitment <- methods::new(BevertonHoltRecruitment) methods::show(BevertonHoltRecruitment) ``` -There are three parameters we need to set-up: *log_sigma_recruit*, *log_rzero*, and *logit_steep*. +Set up the following parameters: *log_rzero* and *logit_steep*. ```{r set-up-recruitment} recruitment$log_rzero$value <- log(1e+06) # unit: log(number)