From 7f72769dddb64f7d10833aa9b2d0750c768fdc24 Mon Sep 17 00:00:00 2001 From: msupernaw Date: Mon, 25 Nov 2024 10:47:12 -0800 Subject: [PATCH] refactor(D*Distribution): Removes TMB from names Removes TMB from Distribution names and files to clean up the code and allow the downstream R interface to also remove these names. This is part of ensuring that the code is portable. If we change from TMB in the future we do not want to have to rename these things when a distribution is just a distribution, it does not have to come from TMB. Thank you @msupernaw for these changes. --- NAMESPACE | 6 ++-- R/FIMS-package.R | 6 ++-- R/create_default_parameters.R | 30 +++++++++---------- R/distribution_formulas.R | 10 +++---- .../include/interface/rcpp/rcpp_interface.hpp | 10 +++---- ...distribution.hpp => rcpp_distribution.hpp} | 10 +++---- man/create_default_parameters.Rd | 8 ++--- .../testthat/helper-integration-tests-setup.R | 22 +++++++------- .../testthat/test-create_default_parameters.R | 8 ++--- tests/testthat/test-fims-wrappers.R | 10 +++---- tests/testthat/test-initialize_modules.R | 4 +-- ...ntegration-fims-estimation-with-wrappers.R | 12 ++++---- ...tributions.R => test-rcpp-distributions.R} | 18 +++++------ tests/testthat/test-update_parameters.R | 4 +-- vignettes/fims-demo.Rmd | 6 ++-- 15 files changed, 82 insertions(+), 82 deletions(-) rename inst/include/interface/rcpp/rcpp_objects/{rcpp_tmb_distribution.hpp => rcpp_distribution.hpp} (98%) rename tests/testthat/{test-rcpp-tmb-distributions.R => test-rcpp-distributions.R} (90%) diff --git a/NAMESPACE b/NAMESPACE index b58292af..af7dad6e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,9 @@ export(AgeComp) export(BevertonHoltRecruitment) export(CreateTMBModel) +export(DlnormDistribution) +export(DmultinomDistribution) +export(DnormDistribution) export(DoubleLogisticSelectivity) export(EWAAgrowth) export(FIMSFrame) @@ -15,9 +18,6 @@ export(Parameter) export(ParameterVector) export(Population) export(SetFIMSFunctions) -export(TMBDlnormDistribution) -export(TMBDmultinomDistribution) -export(TMBDnormDistribution) export(ToJSON) export(clear) export(clear_logs) diff --git a/R/FIMS-package.R b/R/FIMS-package.R index a30628a0..8f1da4e1 100644 --- a/R/FIMS-package.R +++ b/R/FIMS-package.R @@ -21,12 +21,12 @@ #' @export Index #' @export Population #' @export ParameterVector -#' @export TMBDnormDistribution +#' @export DnormDistribution #' @export LogisticMaturity #' @export LogisticSelectivity #' @export DoubleLogisticSelectivity #' @export EWAAgrowth -#' @export TMBDlnormDistribution -#' @export TMBDmultinomDistribution +#' @export DlnormDistribution +#' @export DmultinomDistribution ## usethis namespace: end NULL diff --git a/R/create_default_parameters.R b/R/create_default_parameters.R index e33ba789..f0164917 100644 --- a/R/create_default_parameters.R +++ b/R/create_default_parameters.R @@ -26,8 +26,8 @@ #' fleet1 <- survey1 <- list( #' selectivity = list(form = "LogisticSelectivity"), #' data_distribution = c( -#' Index = "TMBDlnormDistribution", -#' AgeComp = "TMBDmultinomDistribution" +#' Index = "DlnormDistribution", +#' AgeComp = "DmultinomDistribution" #' ) #' ) #' default_parameters <- fims_frame |> @@ -35,7 +35,7 @@ #' fleets = list(fleet1 = fleet1, survey1 = survey1), #' recruitment = list( #' form = "BevertonHoltRecruitment", -#' process_distribution = c(log_devs = "TMBDnormDistribution") +#' process_distribution = c(log_devs = "DnormDistribution") #' ), #' growth = list(form = "EWAAgrowth"), #' maturity = list(form = "LogisticMaturity") @@ -46,7 +46,7 @@ create_default_parameters <- function( fleets, recruitment = list( form = "BevertonHoltRecruitment", - process_distribution = c(log_devs = "TMBDnormDistribution") + process_distribution = c(log_devs = "DnormDistribution") ), growth = list(form = "EWAAgrowth"), maturity = list(form = "LogisticMaturity")) { @@ -296,10 +296,10 @@ create_default_fleet <- function(fleets, (\(x) x$uncertainty)() index_distribution_default <- switch(index_distribution, - "TMBDnormDistribution" = create_default_TMBDnormDistribution( + "DnormDistribution" = create_default_DnormDistribution( value = index_uncertainty, input_type = "data", data = data ), - "TMBDlnormDistribution" = create_default_TMBDlnormDistribution( + "DlnormDistribution" = create_default_DlnormDistribution( value = index_uncertainty, input_type = "data", data = data ) ) @@ -358,16 +358,16 @@ create_default_BevertonHoltRecruitment <- function(data) { return(default) } -#' Create Default TMBDnormDistribution Parameters +#' Create Default DnormDistribution Parameters #' #' @description -#' Create default parameters for TMBDnormDistribution. +#' Create default parameters for DnormDistribution. #' @param value Default value for `log_sd`. #' @param data An S4 object. FIMS input data. #' @param input_type A character. Specifies if input is data or process. -#' @return A list of default parameters for TMBDnormDistribution. +#' @return A list of default parameters for DnormDistribution. #' @noRd -create_default_TMBDnormDistribution <- function(value = log(0.4), data, input_type = "data") { +create_default_DnormDistribution <- function(value = log(0.4), data, input_type = "data") { # Check if input_type is valid valid_input_types <- c("data", "process") check_valid_input(input = input_type, valid_options = valid_input_types, arg_name = "input_type") @@ -396,16 +396,16 @@ create_default_TMBDnormDistribution <- function(value = log(0.4), data, input_ty return(default) } -#' Create Default TMBDlnormDistribution Parameters +#' Create Default DlnormDistribution Parameters #' #' @description -#' Create default parameters for TMBDlnormDistribution. +#' Create default parameters for DlnormDistribution. #' @param value Default value for `log_sd`. #' @param data An S4 object. FIMS input data. #' @param input_type A character. Specifies if input is data or process. -#' @return A list of default parameters for TMBDlnormDistribution. +#' @return A list of default parameters for DlnormDistribution. #' @noRd -create_default_TMBDlnormDistribution <- function(value = 0.1, data, input_type = "data") { +create_default_DlnormDistribution <- function(value = 0.1, data, input_type = "data") { # Validate input value if (!is.numeric(value) || any(value <= 0, na.rm = TRUE)) { cli::cli_abort("The {.var value} argument must be positive numeric values.") @@ -469,7 +469,7 @@ create_default_recruitment <- function(recruitment, data) { distribution_default <- NULL if (!is.null(distribution_input)) { distribution_default <- switch(distribution_input, - "TMBDnormDistribution" = create_default_TMBDnormDistribution( + "DnormDistribution" = create_default_DnormDistribution( value = 0.1, data = data, input_type = "process" diff --git a/R/distribution_formulas.R b/R/distribution_formulas.R index b3eb28b2..18a0f2d5 100644 --- a/R/distribution_formulas.R +++ b/R/distribution_formulas.R @@ -166,7 +166,7 @@ initialize_data_distribution <- function( # Set up distribution based on `family` argument` if (family[["family"]] == "lognormal") { # create new Rcpp module - new_module <- new(TMBDlnormDistribution) + new_module <- new(DlnormDistribution) # populate logged standard deviation parameter with log of input new_module$log_sd <- new( @@ -186,7 +186,7 @@ initialize_data_distribution <- function( if (family[["family"]] == "gaussian") { # create new Rcpp module - new_module <- new(TMBDnormDistribution) + new_module <- new(DnormDistribution) # populate logged standard deviation parameter with log of input new_module$log_sd$resize(length(sd$value)) @@ -206,7 +206,7 @@ initialize_data_distribution <- function( if (family[["family"]] == "multinomial") { #create new Rcpp module - new_module <- new(TMBDmultinomDistribution) + new_module <- new(DmultinomDistribution) } # setup link to observed data @@ -267,7 +267,7 @@ initialize_process_distribution <- function(module, # Set up distribution based on `family` argument` if (family[["family"]] == "lognormal") { # create new Rcpp module - new_module <- new(TMBDlnormDistribution) + new_module <- new(DlnormDistribution) # populate logged standard deviation parameter with log of input new_module$log_sd <- new( @@ -287,7 +287,7 @@ initialize_process_distribution <- function(module, if (family[["family"]] == "gaussian") { # create new Rcpp module - new_module <- new(TMBDnormDistribution) + new_module <- new(DnormDistribution) # populate logged standard deviation parameter with log of input new_module$log_sd$resize(length(sd$value)) diff --git a/inst/include/interface/rcpp/rcpp_interface.hpp b/inst/include/interface/rcpp/rcpp_interface.hpp index df215249..eabd3848 100644 --- a/inst/include/interface/rcpp/rcpp_interface.hpp +++ b/inst/include/interface/rcpp/rcpp_interface.hpp @@ -20,7 +20,7 @@ #include "rcpp_objects/rcpp_population.hpp" #include "rcpp_objects/rcpp_recruitment.hpp" #include "rcpp_objects/rcpp_selectivity.hpp" -#include "rcpp_objects/rcpp_tmb_distribution.hpp" +#include "rcpp_objects/rcpp_distribution.hpp" SEXP FIMS_objective_function; @@ -429,7 +429,7 @@ void clear() { DoubleLogisticSelectivityInterface::id_g = 1; DoubleLogisticSelectivityInterface::live_objects.clear(); - // rcpp_tmb_distribution.hpp + // rcpp_distribution.hpp DistributionsInterfaceBase::id_g = 1; DistributionsInterfaceBase::live_objects.clear(); @@ -724,7 +724,7 @@ RCPP_MODULE(fims) { .method("get_id", &EWAAGrowthInterface::get_id) .method("evaluate", &EWAAGrowthInterface::evaluate); - Rcpp::class_("TMBDnormDistribution") + Rcpp::class_("DnormDistribution") .constructor() .method("get_id", &DnormDistributionsInterface::get_id, "Returns a unique ID for the Dnorm distribution class.") .method("evaluate", &DnormDistributionsInterface::evaluate, "Evaluates the normal distribution given input data and parameter values.") @@ -734,7 +734,7 @@ RCPP_MODULE(fims) { .field("expected_values", &DnormDistributionsInterface::expected_values, "Mean of the distribution.") .field("log_sd", &DnormDistributionsInterface::log_sd, "The natural log of the standard deviation."); - Rcpp::class_("TMBDlnormDistribution") + Rcpp::class_("DlnormDistribution") .constructor() .method("get_id", &DlnormDistributionsInterface::get_id, "Returns a unique ID for the Dnorm distribution class.") .method("evaluate", &DlnormDistributionsInterface::evaluate, "Evaluates the normal distribution given input data and parameter values.") @@ -744,7 +744,7 @@ RCPP_MODULE(fims) { .field("expected_values", &DlnormDistributionsInterface::expected_values, "Mean of the distribution on the log scale.") .field("log_sd", &DlnormDistributionsInterface::log_sd, "The natural log of the standard deviation of the distribution on the log scale."); - Rcpp::class_("TMBDmultinomDistribution") + Rcpp::class_("DmultinomDistribution") .constructor() .method("get_id", &DmultinomDistributionsInterface::get_id, "Returns a unique ID for the Dnorm distribution class.") .method("evaluate", &DmultinomDistributionsInterface::evaluate, "Evaluates the normal distribution given input data and parameter values.") diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_tmb_distribution.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_distribution.hpp similarity index 98% rename from inst/include/interface/rcpp/rcpp_objects/rcpp_tmb_distribution.hpp rename to inst/include/interface/rcpp/rcpp_objects/rcpp_distribution.hpp index cf5af08e..0fcb4faa 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_tmb_distribution.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_distribution.hpp @@ -6,8 +6,8 @@ * source folder for reuse information. * */ -#ifndef FIMS_INTERFACE_RCPP_RCPP_OBJECTS_RCPP_TMB_DISTRIBUTION_HPP -#define FIMS_INTERFACE_RCPP_RCPP_OBJECTS_RCPP_TMB_DISTRIBUTION_HPP +#ifndef FIMS_INTERFACE_RCPP_RCPP_OBJECTS_RCPP_DISTRIBUTION_HPP +#define FIMS_INTERFACE_RCPP_RCPP_OBJECTS_RCPP_DISTRIBUTION_HPP #include "../../../distributions/distributions.hpp" #include "../../interface.hpp" @@ -83,7 +83,7 @@ std::map diff --git a/man/create_default_parameters.Rd b/man/create_default_parameters.Rd index fe6e9d95..dfaab6ac 100644 --- a/man/create_default_parameters.Rd +++ b/man/create_default_parameters.Rd @@ -9,7 +9,7 @@ create_default_parameters( data, fleets, recruitment = list(form = "BevertonHoltRecruitment", process_distribution = c(log_devs - = "TMBDnormDistribution")), + = "DnormDistribution")), growth = list(form = "EWAAgrowth"), maturity = list(form = "LogisticMaturity") ) @@ -66,8 +66,8 @@ fims_frame <- FIMSFrame(data_mile1) fleet1 <- survey1 <- list( selectivity = list(form = "LogisticSelectivity"), data_distribution = c( - Index = "TMBDlnormDistribution", - AgeComp = "TMBDmultinomDistribution" + Index = "DlnormDistribution", + AgeComp = "DmultinomDistribution" ) ) default_parameters <- fims_frame |> @@ -75,7 +75,7 @@ default_parameters <- fims_frame |> fleets = list(fleet1 = fleet1, survey1 = survey1), recruitment = list( form = "BevertonHoltRecruitment", - process_distribution = c(log_devs = "TMBDnormDistribution") + process_distribution = c(log_devs = "DnormDistribution") ), growth = list(form = "EWAAgrowth"), maturity = list(form = "LogisticMaturity") diff --git a/tests/testthat/helper-integration-tests-setup.R b/tests/testthat/helper-integration-tests-setup.R index 2d8e2331..614f8541 100644 --- a/tests/testthat/helper-integration-tests-setup.R +++ b/tests/testthat/helper-integration-tests-setup.R @@ -94,7 +94,7 @@ setup_and_run_FIMS_without_wrappers <- function(iter_id, fishing_fleet$SetObservedAgeCompData(fishing_fleet_age_comp$get_id()) # Set up fishery index data using the lognormal - fishing_fleet_index_distribution <- methods::new(TMBDlnormDistribution) + fishing_fleet_index_distribution <- methods::new(DlnormDistribution) # lognormal observation error transformed on the log scale fishing_fleet_index_distribution$log_sd$resize(om_input$nyr) for (y in 1:om_input$nyr) { @@ -106,7 +106,7 @@ setup_and_run_FIMS_without_wrappers <- function(iter_id, fishing_fleet_index_distribution$set_distribution_links("data", fishing_fleet$log_expected_index$get_id()) # Set up fishery age composition data using the multinomial - fishing_fleet_agecomp_distribution <- methods::new(TMBDmultinomDistribution) + fishing_fleet_agecomp_distribution <- methods::new(DmultinomDistribution) fishing_fleet_agecomp_distribution$set_observed_data(fishing_fleet$GetObservedAgeCompDataID()) fishing_fleet_agecomp_distribution$set_distribution_links("data", fishing_fleet$proportion_catch_numbers_at_age$get_id()) @@ -141,7 +141,7 @@ setup_and_run_FIMS_without_wrappers <- function(iter_id, survey_fleet$SetObservedAgeCompData(survey_fleet_age_comp$get_id()) # Set up survey index data using the lognormal - survey_fleet_index_distribution <- methods::new(TMBDlnormDistribution) + survey_fleet_index_distribution <- methods::new(DlnormDistribution) # lognormal observation error transformed on the log scale # sd = sqrt(log(cv^2 + 1)), sd is log transformed survey_fleet_index_distribution$log_sd$resize(om_input$nyr) @@ -155,7 +155,7 @@ setup_and_run_FIMS_without_wrappers <- function(iter_id, # Age composition data - survey_fleet_agecomp_distribution <- methods::new(TMBDmultinomDistribution) + survey_fleet_agecomp_distribution <- methods::new(DmultinomDistribution) survey_fleet_agecomp_distribution$set_observed_data(survey_fleet$GetObservedAgeCompDataID()) survey_fleet_agecomp_distribution$set_distribution_links("data", survey_fleet$proportion_catch_numbers_at_age$get_id()) @@ -186,7 +186,7 @@ setup_and_run_FIMS_without_wrappers <- function(iter_id, for (y in 1:(om_input$nyr - 1)) { recruitment$log_devs[y]$value <- om_input$logR.resid[y + 1] } - recruitment_distribution <- new(TMBDnormDistribution) + recruitment_distribution <- new(DnormDistribution) # set up logR_sd using the normal log_sd parameter # logR_sd is NOT logged. It needs to enter the model logged b/c the exp() is # taken before the likelihood calculation @@ -449,15 +449,15 @@ setup_and_run_FIMS_with_wrappers <- function(iter_id, fleet1 = list( selectivity = list(form = "LogisticSelectivity"), data_distribution = c( - Index = "TMBDlnormDistribution", - AgeComp = "TMBDmultinomDistribution" + Index = "DlnormDistribution", + AgeComp = "DmultinomDistribution" ) ), survey1 = list( selectivity = list(form = "LogisticSelectivity"), data_distribution = c( - Index = "TMBDlnormDistribution", - AgeComp = "TMBDmultinomDistribution" + Index = "DlnormDistribution", + AgeComp = "DmultinomDistribution" ) ) ) @@ -467,7 +467,7 @@ setup_and_run_FIMS_with_wrappers <- function(iter_id, fleets = fleets, recruitment = list( form = "BevertonHoltRecruitment", - process_distribution = c(log_devs = "TMBDnormDistribution") + process_distribution = c(log_devs = "DnormDistribution") ), growth = list(form = "EWAAgrowth"), maturity = list(form = "LogisticMaturity") @@ -489,7 +489,7 @@ setup_and_run_FIMS_with_wrappers <- function(iter_id, BevertonHoltRecruitment.log_rzero.value = log(om_input$R0), BevertonHoltRecruitment.log_devs.value = om_input$logR.resid[-1], BevertonHoltRecruitment.log_devs.estimated = FALSE, - TMBDnormDistribution.log_sd.value = om_input$logR_sd + DnormDistribution.log_sd.value = om_input$logR_sd ), maturity = list( LogisticMaturity.inflection_point.value = om_input$A50.mat, diff --git a/tests/testthat/test-create_default_parameters.R b/tests/testthat/test-create_default_parameters.R index 948979a1..a3c2fc03 100644 --- a/tests/testthat/test-create_default_parameters.R +++ b/tests/testthat/test-create_default_parameters.R @@ -4,8 +4,8 @@ data <- FIMSFrame(data_mile1) fleet1 <- survey1 <- list( selectivity = list(form = "LogisticSelectivity"), data_distribution = c( - Index = "TMBDlnormDistribution", - AgeComp = "TMBDmultinomDistribution" + Index = "DlnormDistribution", + AgeComp = "DmultinomDistribution" ) ) @@ -31,8 +31,8 @@ test_that("create_default_parameters detects missing fleet names", { invalid_fleet <- list( selectivity = list(form = "LogisticSelectivity"), data_distribution = c( - Index = "TMBDlnormDistribution", - AgeComp = "TMBDmultinomDistribution" + Index = "DlnormDistribution", + AgeComp = "DmultinomDistribution" ) ) diff --git a/tests/testthat/test-fims-wrappers.R b/tests/testthat/test-fims-wrappers.R index 7c1fa658..ea77483c 100644 --- a/tests/testthat/test-fims-wrappers.R +++ b/tests/testthat/test-fims-wrappers.R @@ -3,15 +3,15 @@ # fleet1 = list( # selectivity = list(form = "LogisticSelectivity"), # data_distribution = c( -# Index = "TMBDlnormDistribution", -# AgeComp = "TMBDmultinomDistribution" +# Index = "DlnormDistribution", +# AgeComp = "DmultinomDistribution" # ) # ), # survey1 = list( # selectivity = list(form = "LogisticSelectivity"), # data_distribution = c( -# Index = "TMBDlnormDistribution", -# AgeComp = "TMBDmultinomDistribution" +# Index = "DlnormDistribution", +# AgeComp = "DmultinomDistribution" # ) # ) # ) @@ -24,7 +24,7 @@ # fleets = fleets, # recruitment = list( # form = "BevertonHoltRecruitment", -# process_distribution = c(log_devs = "TMBDnormDistribution") +# process_distribution = c(log_devs = "DnormDistribution") # ), # growth = list(form = "EWAAgrowth"), # maturity = list(form = "LogisticMaturity") diff --git a/tests/testthat/test-initialize_modules.R b/tests/testthat/test-initialize_modules.R index bbd1be6f..a25a704d 100644 --- a/tests/testthat/test-initialize_modules.R +++ b/tests/testthat/test-initialize_modules.R @@ -4,8 +4,8 @@ data <- FIMSFrame(data_mile1) fleet1 <- survey1 <- list( selectivity = list(form = "LogisticSelectivity"), data_distribution = c( - Index = "TMBDlnormDistribution", - AgeComp = "TMBDmultinomDistribution" + Index = "DlnormDistribution", + AgeComp = "DmultinomDistribution" ) ) diff --git a/tests/testthat/test-integration-fims-estimation-with-wrappers.R b/tests/testthat/test-integration-fims-estimation-with-wrappers.R index a46f9cbd..a33b59f5 100644 --- a/tests/testthat/test-integration-fims-estimation-with-wrappers.R +++ b/tests/testthat/test-integration-fims-estimation-with-wrappers.R @@ -4,15 +4,15 @@ fleets <- list( fleet1 = list( selectivity = list(form = "LogisticSelectivity"), data_distribution = c( - Index = "TMBDlnormDistribution", - AgeComp = "TMBDmultinomDistribution" + Index = "DlnormDistribution", + AgeComp = "DmultinomDistribution" ) ), survey1 = list( selectivity = list(form = "LogisticSelectivity"), data_distribution = c( - Index = "TMBDlnormDistribution", - AgeComp = "TMBDmultinomDistribution" + Index = "DlnormDistribution", + AgeComp = "DmultinomDistribution" ) ) ) @@ -25,7 +25,7 @@ default_parameters <- data_mile1 |> fleets = fleets, recruitment = list( form = "BevertonHoltRecruitment", - process_distribution = c(log_devs = "TMBDnormDistribution") + process_distribution = c(log_devs = "DnormDistribution") ), growth = list(form = "EWAAgrowth"), maturity = list(form = "LogisticMaturity") @@ -44,7 +44,7 @@ modified_parameters <- list( BevertonHoltRecruitment.log_rzero.value = log(om_input_list[[1]]$R0), BevertonHoltRecruitment.log_devs.value = om_input_list[[1]]$logR.resid[-1], BevertonHoltRecruitment.log_devs.estimated = FALSE, - TMBDnormDistribution.log_sd.value = om_input_list[[1]]$logR_sd + DnormDistribution.log_sd.value = om_input_list[[1]]$logR_sd ), maturity = list( LogisticMaturity.inflection_point.value = om_input_list[[1]]$A50.mat, diff --git a/tests/testthat/test-rcpp-tmb-distributions.R b/tests/testthat/test-rcpp-distributions.R similarity index 90% rename from tests/testthat/test-rcpp-tmb-distributions.R rename to tests/testthat/test-rcpp-distributions.R index 3b7758fe..8e501520 100644 --- a/tests/testthat/test-rcpp-tmb-distributions.R +++ b/tests/testthat/test-rcpp-distributions.R @@ -10,7 +10,7 @@ test_that("normal_lpdf", { y <- stats::rnorm(1) # create a fims Rcpp object # initialize the Dnorm module - dnorm_ <- new(TMBDnormDistribution) + dnorm_ <- new(DnormDistribution) # populate class members dnorm_$x <- new(ParameterVector, y, 1) dnorm_$expected_values <- new(ParameterVector, 0, 1) @@ -25,7 +25,7 @@ test_that("normal_lpdf", { y <- stats::rnorm(10) # create a fims Rcpp object # initialize the Dnorm module - dnorm_ <- new(TMBDnormDistribution) + dnorm_ <- new(DnormDistribution) # populate class members dnorm_$x <- new(ParameterVector, y, 10) dnorm_$expected_values <- new(ParameterVector, 0, 1) @@ -40,7 +40,7 @@ test_that("normal_lpdf", { y <- stats::rnorm(10) # create a fims Rcpp object # initialize the Dnorm module - dnorm_ <- new(TMBDnormDistribution) + dnorm_ <- new(DnormDistribution) # populate class members dnorm_$x <- new(ParameterVector, y, 10) dnorm_$expected_values <- new(ParameterVector, rep(0, 10), 10) @@ -54,7 +54,7 @@ test_that("normal_lpdf", { # y <- stats::rnorm(10) # # create a fims Rcpp object # # initialize the Dnorm module - # dnorm_ <- new(TMBDnormDistribution) + # dnorm_ <- new(DnormDistribution) # # populate class members # dnorm_$x <- new(FIMS:::ParameterVector, y, 10) # dnorm_$expected_values <- new(FIMS:::ParameterVector, 0, 11) @@ -74,7 +74,7 @@ test_that("lognormal_lpdf", { # create a fims Rcpp object # initialize the Dlnorm module - dlnorm_ <- new(TMBDlnormDistribution) + dlnorm_ <- new(DlnormDistribution) # populate class members dlnorm_$x <- new(ParameterVector, y, 1) dlnorm_$expected_values <- new(ParameterVector, 0, 1) @@ -89,7 +89,7 @@ test_that("lognormal_lpdf", { # create a fims Rcpp object # initialize the Dlnorm module - dlnorm_ <- new(TMBDlnormDistribution) + dlnorm_ <- new(DlnormDistribution) # populate class members dlnorm_$x <- new(ParameterVector, y, 10) dlnorm_$expected_values <- new(ParameterVector, 0, 1) @@ -105,7 +105,7 @@ test_that("lognormal_lpdf", { # create a fims Rcpp object # initialize the Dlnorm module - dlnorm_ <- new(TMBDlnormDistribution) + dlnorm_ <- new(DlnormDistribution) # populate class members dlnorm_$x <- new(ParameterVector, y, 10) dlnorm_$expected_values <- new(ParameterVector, rep(0, 10), 10) @@ -120,7 +120,7 @@ test_that("lognormal_lpdf", { # # # create a fims Rcpp object # # initialize the Dlnorm module - # dlnorm_ <- new(TMBDlnormDistribution) + # dlnorm_ <- new(DlnormDistribution) # # populate class members # dlnorm_$x <- new(ParameterVector, y, 10) # dlnorm_$expected_values <- new(ParameterVector, 0, 11) @@ -135,7 +135,7 @@ test_that("multinomial_lpdf", { x <- t(stats::rmultinom(1, 100, p)) # create a fims Rcpp object # initialize the Dmultinom module - dmultinom_ <- new(TMBDmultinomDistribution) + dmultinom_ <- new(DmultinomDistribution) # populate class members dmultinom_$expected_values <- new(ParameterVector, p, 10) dmultinom_$dims <- c(1, 10) diff --git a/tests/testthat/test-update_parameters.R b/tests/testthat/test-update_parameters.R index 060ef5ed..9e04b34a 100644 --- a/tests/testthat/test-update_parameters.R +++ b/tests/testthat/test-update_parameters.R @@ -4,8 +4,8 @@ data <- FIMSFrame(data_mile1) fleet1 <- survey1 <- list( selectivity = list(form = "LogisticSelectivity"), data_distribution = c( - Index = "TMBDlnormDistribution", - AgeComp = "TMBDmultinomDistribution" + Index = "DlnormDistribution", + AgeComp = "DmultinomDistribution" ) ) diff --git a/vignettes/fims-demo.Rmd b/vignettes/fims-demo.Rmd index e2097e70..5dae4b4b 100644 --- a/vignettes/fims-demo.Rmd +++ b/vignettes/fims-demo.Rmd @@ -62,8 +62,8 @@ Here, we define specifications for fleets, recruitment, growth, and maturity mod fleet1 <- survey1 <- list( selectivity = list(form = "LogisticSelectivity"), data_distribution = c( - Index = "TMBDlnormDistribution", - AgeComp = "TMBDmultinomDistribution" + Index = "DlnormDistribution", + AgeComp = "DmultinomDistribution" ) ) @@ -73,7 +73,7 @@ default_parameters <- fims_frame |> fleets = list(fleet1 = fleet1, survey1 = survey1), recruitment = list( form = "BevertonHoltRecruitment", - process_distribution = c(log_devs = "TMBDnormDistribution") + process_distribution = c(log_devs = "DnormDistribution") ), growth = list(form = "EWAAgrowth"), maturity = list(form = "LogisticMaturity")