From 440e1593b55c43b8384434b092313d7d3a53f098 Mon Sep 17 00:00:00 2001 From: Cole-Monnahan-NOAA Date: Wed, 4 Sep 2024 13:13:18 -0700 Subject: [PATCH] Add test file for fimsfit using pollock --- content/test_fimsfit.R | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 content/test_fimsfit.R diff --git a/content/test_fimsfit.R b/content/test_fimsfit.R new file mode 100644 index 0000000..4741813 --- /dev/null +++ b/content/test_fimsfit.R @@ -0,0 +1,38 @@ +# Load packages and input data ------------------------------------------- +# Load required packages +packages <- c("dplyr", "tidyr", "ggplot2", "TMB", "reshape2", "here", "remotes", "lubridate") +invisible(lapply(packages, library, character.only = TRUE)) + +# Install the FIMS package from specific repositories +# install.packages("FIMS", repos = c("https://noaa-fims.r-universe.dev", "https://cloud.r-project.org")) + +# detach("package:FIMS", unload = TRUE) +library(FIMS) + +# Define the years and ages for the assessment +years <- 1970:2023 +nyears <- length(years) +nseasons <- 1 +nages <- 10 +ages <- 1:nages + +# Source the script to prepare input data +source(file.path("content", "R", "pk_prepare_dat.R")) + +# Run FIMS without helper functions --------------------------------------- +clear() +clear_logs() + +# Source the script to prepare FIMS inputs without using helper functions +source(file.path(getwd(), "content", "R", "pk_prepare_FIMS_inputs.R")) + +# Create the TMB model and generate the report +success <- CreateTMBModel() +parameters <- list(p = get_fixed()) +parameters$p[1] = 3.5 +input <- list(data=age_frame, parameters=parameters, version='GOA pollock') + +## devtools::load_all('C:/Users/cole.monnahan/FIMS') + +fit <- fit_fims(input, verbose=FALSE) +fit <- fit_fims(input)