AFSC Case Study Gulf of Alaska Walleye Pollock

The setup

Code
# Names of required packages
packages <- c("dplyr", "tidyr", "ggplot2", "TMB", "reshape2", "here", "remotes", "lubridate")

# Install packages not yet installed
installed_packages <- packages %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) {
  install.packages(packages[!installed_packages], repos = "http://cran.us.r-project.org")
}

The downloaded binary packages are in
    /var/folders/2s/h6hvv9ps03xgz_krkkstvq_r0000gn/T//RtmpOd90kw/downloaded_packages
Code
# Install FIMS: main branch version if on main, dev version on any other branch

branch_name <- system("git branch --show-current")
use_fims_main <- grepl("main", branch_name)

if (use_fims_main) {
  remotes::install_github("NOAA-FIMS/FIMS")
} else {
  remotes::install_github("NOAA-FIMS/FIMS", ref = "dev")
}
* checking for file ‘/private/var/folders/2s/h6hvv9ps03xgz_krkkstvq_r0000gn/T/RtmpOd90kw/remotes175646e10833/NOAA-FIMS-FIMS-92746fe/DESCRIPTION’ ... OK
* preparing ‘FIMS’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘FIMS_0.3.0.1.tar.gz’
Code
remotes::install_github("r4ss/r4ss")
systemfonts (NA -> 1.2.1   ) [CRAN]
sys         (NA -> 3.4.3   ) [CRAN]
askpass     (NA -> 1.2.1   ) [CRAN]
openssl     (NA -> 2.3.2   ) [CRAN]
curl        (NA -> 6.2.1   ) [CRAN]
parallelly  (NA -> 1.42.0  ) [CRAN]
listenv     (NA -> 0.9.1   ) [CRAN]
globals     (NA -> 0.16.3  ) [CRAN]
gridExtra   (NA -> 2.3     ) [CRAN]
svglite     (NA -> 2.1.3   ) [CRAN]
rstudioapi  (NA -> 0.17.1  ) [CRAN]
xml2        (NA -> 1.3.6   ) [CRAN]
ini         (NA -> 0.3.1   ) [CRAN]
httr2       (NA -> 1.1.0   ) [CRAN]
gitcreds    (NA -> 0.1.2   ) [CRAN]
future      (NA -> 1.34.0  ) [CRAN]
viridis     (NA -> 0.6.5   ) [CRAN]
kableExtra  (NA -> 1.4.0   ) [CRAN]
gh          (NA -> 1.4.1   ) [CRAN]
furrr       (NA -> 0.3.1   ) [CRAN]
forcats     (NA -> 1.0.0   ) [CRAN]
corpcor     (NA -> 1.6.10  ) [CRAN]
coda        (NA -> 0.19-4.1) [CRAN]

The downloaded binary packages are in
    /var/folders/2s/h6hvv9ps03xgz_krkkstvq_r0000gn/T//RtmpOd90kw/downloaded_packages
* checking for file ‘/private/var/folders/2s/h6hvv9ps03xgz_krkkstvq_r0000gn/T/RtmpOd90kw/remotes17566910f673/r4ss-r4ss-b2b4418/DESCRIPTION’ ... OK
* preparing ‘r4ss’:
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘r4ss_1.51.0.tar.gz’
Code
# Load packages
invisible(lapply(packages, library, character.only = TRUE))

library(FIMS)

R_version <- version$version.string
TMB_version <- packageDescription("TMB")$Version
FIMS_commit <- substr(packageDescription("FIMS")$GithubSHA1, 1, 7)

source(file.path("R", "utils.R"))
Code
ggplot2::theme_set(theme_bw())
  • R version: R version 4.4.2 (2024-10-31)
  • TMB version: 1.9.16
  • FIMS commit: 92746fe
  • Stock name: Gulf of Alaska (GOA) Walleye Pollock
  • Region: AFSC
  • Analyst: Cole Monnahan

Simplifications to the original assessment

The model presented in this case study was changed substantially from the operational version and should not be considered reflective of the pollock stock. This is intended as a demonstration and nothing more.

To get the opertional model to more closely match FIMS I:

  • Droped surveys 1, 4, and 5
  • Removed ageing error
  • Removed length compositions
  • Removed bias correction in log-normal index likelihoods
  • Simplified catchability of survey 3 to be constant in time (removed random walk)
  • Updated maturity to be parametric rather than empirical
  • Used constant weight at age for all sources: spawning, fishery, surveys, and biomass calculations. The same matrix was used throughout.
  • Changee timing to be Jan 1 for spawning and all surveys
  • Removed prior on catchability for survey 2
  • Removed time-varying fisheries selectivity (constant double logistic)
  • Took off normalization of selectivity
  • Removed age accumulation for fishery age compositions

Script to prepare data for building FIMS object

Code
## define the dimensions and global variables
years <- 1970:2023
nyears <- length(years)
nseasons <- 1
nages <- 10
ages <- 1:nages
## This will fit the models bridging to FIMS (simplifying)
## source("fit_bridge_models.R")
## compare changes to model
pkfitfinal <- readRDS("data_files/pkfitfinal.RDS")
pkfit0 <- readRDS("data_files/pkfit0.RDS")
parfinal <- pkfitfinal$obj$env$parList()
pkinput0 <- readRDS('data_files/pkinput0.RDS')
fimsdat <- pkdat0 <- pkinput0$dat
pkinput <- readRDS('data_files/pkinput.RDS')

Run FIMS model without using wrapper functions

Code
## set up FIMS data objects
FIMS::clear()
estimate_fish_selex <- TRUE
estimate_survey_selex <- TRUE
estimate_q2 <- TRUE
estimate_q3 <- TRUE
estimate_q6 <- TRUE
estimate_F <- TRUE
estimate_recdevs <- TRUE

# Set up a FIMS model without wrapper functions
source("R/pk_prepare_FIMS_inputs.R")

## make FIMS model
success <- CreateTMBModel()
parameters <- list(p = get_fixed())
obj <- TMB::MakeADFun(data = list(), parameters, DLL = "FIMS", silent = TRUE)
## report values for the two models
rep0 <- pkfitfinal$rep
rep1 <- obj$report() # FIMS initial values
## try fitting the model
# use nlminb() to match FIMS::fit_fims()
# opt <- TMBhelper::fit_tmb(obj, getsd=FALSE, newtonsteps=0, control=list(trace=100))
opt <- with(obj, nlminb(
  start = par,
  objective = fn,
  gradient = gr,
  control = list(
    eval.max = 10000,
    iter.max = 10000,
    trace = 0
  )
))
max(abs(obj$gr())) # from Cole, can use TMBhelper::fit_tmb to get val to <1e-10
rep2 <- obj$report(obj$env$last.par.best) ## FIMS after estimation

Output plotting

Code
## Output plotting
out1 <- get_long_outputs(rep1, rep0) %>%
  mutate(platform=ifelse(platform=='FIMS', 'FIMS init', 'TMB'))
out2 <- get_long_outputs(rep2, rep0) %>% filter(platform=='FIMS') %>%
  mutate(platform='FIMS opt')
out <- rbind(out1,out2)
g <- ggplot(out, aes(year, value, color=platform)) + geom_line() +
  facet_wrap('name', scales='free') + ylim(0,NA) +
  labs(x=NULL, y=NULL)
ggsave('figures/AFSC_PK_ts_comparison.png', g, width=9, height=5, units='in')
g <- ggplot(filter(out, platform!='TMB'), aes(year, relerror, color=platform)) + geom_line() +
  facet_wrap('name', scales='free') +
  labs(x=NULL, y='Relative difference') + coord_cartesian(ylim=c(-.5,.5))
ggsave('figures/AFSC_PK_ts_comparison_relerror.png', g, width=9, height=5, units='in')

## Quick check on age comp fits
p1 <- get_acomp_fits(rep0, rep1, rep2, fleet=1, years=pkdat0$fshyrs)
g <- ggplot(p1, aes(age, paa, color=platform)) + facet_wrap('year') + geom_line()
ggsave('figures/AFSC_PK_age_comp_fits_1.png', g, width=9, height=8, units='in')
p2 <- get_acomp_fits(rep0, rep1, rep2, fleet=2, years=pkdat0$srv_acyrs2)
g <- ggplot(p2, aes(age, paa, color=platform)) + facet_wrap('year') + geom_line()
ggsave('figures/AFSC_PK_age_comp_fits_2.png', g, width=9, height=8, units='in')
## p3 <- get_acomp_fits(rep0, rep1, rep2, fleet=3, years=pkdat0$srv_acyrs3)
## g <- ggplot(p3, aes(age, paa, color=platform)) + facet_wrap('year') + geom_line()
## p6 <- get_acomp_fits(rep0, rep1, rep2, fleet=4, years=pkdat0$srv_acyrs6)
## g <- ggplot(p6, aes(age, paa, color=platform)) + facet_wrap('year') + geom_line()

## index fits
addsegs <- function(yrs, obs, CV){
  getlwr <- function(obs, CV) qlnorm(p=.025, meanlog=log(obs), sdlog=sqrt(log(1+CV^2)))
  getupr <- function(obs, CV) qlnorm(p=.975, meanlog=log(obs), sdlog=sqrt(log(1+CV^2)))
  segments(yrs, y0=getlwr(obs,CV), y1=getupr(obs,CV))
  points(yrs, obs, pch=22, bg='white')
}
png('figures/AFSC_PK_index_fits.png', res=300, width=6, height=7, units='in')
par(mfrow=c(3,1), mar=c(3,3,.5,.5), mgp=c(1.5,.5,0), tck=-0.02)
plot(years, rep0$Eindxsurv2, type='l',
     ylim=c(0,2), lwd=5.5,
      xlab=NA, ylab='Biomass (million t)')
x1 <- out1 %>% filter(name=='Index2' & platform=='FIMS init')
x2 <- out2 %>% filter(name=='Index2' & platform=='FIMS opt')
lines(years,x1$value, col=2, lwd=1.5)
lines(years,x2$value, col=3, lwd=1.5)
addsegs(yrs=pkdat0$srvyrs2, obs=pkdat0$indxsurv2, CV=pkdat0$indxsurv_log_sd2)
legend('topright', legend=c('TMB', 'FIMS init', 'FIMS opt'), lty=1, col=1:3)
mtext('Survey 2', line=-1.5)
plot(years, rep0$Eindxsurv3, type='l',
     ylim=c(0,.6), lwd=5.5,
      xlab=NA, ylab='Biomass (million t)')
x1 <- out1 %>% filter(name=='Index3' & platform=='FIMS init')
x2 <- out2 %>% filter(name=='Index3' & platform=='FIMS opt')
lines(years,x1$value, col=2, lwd=1.5)
lines(years,x2$value, col=3, lwd=1.5)
addsegs(yrs=pkdat0$srvyrs3, obs=pkdat0$indxsurv3, CV=pkdat0$indxsurv_log_sd3)
mtext('Survey 3', line=-1.5)
legend('topright', legend=c('TMB', 'FIMS init', 'FIMS opt'), lty=1, col=1:3)
plot(years, rep0$Eindxsurv6, type='l',
     ylim=c(0,2.6), lwd=5.5,
      xlab=NA, ylab='Biomass (million t)')
x1 <- out1 %>% filter(name=='Index6' & platform=='FIMS init')
x2 <- out2 %>% filter(name=='Index6' & platform=='FIMS opt')
lines(years,x1$value, col=2, lwd=1.5)
lines(years,x2$value, col=3, lwd=1.5)
addsegs(yrs=pkdat0$srvyrs6, obs=pkdat0$indxsurv6, CV=pkdat0$indxsurv_log_sd6)
mtext('Survey 6', line=-1.5)
legend('topright', legend=c('TMB', 'FIMS init', 'FIMS opt'), lty=1, col=1:3)
dev.off()
quartz_off_screen 
                2 

Comparison figures for basic model

Time Series Time Series (relative error) Indices Fishery Age Composition Fits Survey 2 Age Composition Fits

Extra analyses

Two extra analyses are demonstrated. First is a likelihood profile over lnR0, showing component contributions and testing for data conflict (a Piner plot). The second is to run the model through the ‘Stan’ software using the ‘tmbstan’ R package. This samples from the posterior, which are put back into the model to get the posterior distribution for spawning stock biomass. Given its long run time the results are saved to a file and read in for post-hoc plotting.

Code
## Try a likelihood profile
i <- 68 # this will break if model is changed at all
map <- parameters
map$p[i] <- NA # map off R0 specified below
map$p <- as.factor(map$p)
xseq <- as.numeric(c(opt$par[i],  seq(22,24, len=30)))
res <- list()
for(j in 1:length(xseq)){
  print(j)
  parameters$p[i] <- xseq[j]
  obj2 <- MakeADFun(data = list(), parameters, DLL = "FIMS", silent = TRUE, map=map)
  opt2 <- with(obj2, nlminb(par,fn,gr))
  out <- obj2$report(obj2$env$last.par.best)
  nll_components <- out$nll_components
  index_nll <- sum(nll_components[seq(2, length(nll_components), by = 2)])
  age_comp_nll <- sum(nll_components[seq(3, length(nll_components), by = 2)])
  res[[j]] <- data.frame(
    j = j, lnR0 = xseq[j], total = out$jnll, index = index_nll,
    age = age_comp_nll, recruit = out$nll_components[1], maxgrad = max(abs(obj$gr()))
  )
}
res <- bind_rows(res) %>%
  pivot_longer( cols=c(total, index, age, recruit)) %>%
  group_by(name) %>% mutate(deltaNLL=value-min(value))
g <- ggplot(res, aes(lnR0, deltaNLL, color=name)) + geom_line()
g <- g+ geom_point(data=filter(res, deltaNLL==0), size=2) +
  labs(y='Delta NLL', color='NLL component')
ggsave('figures/AFSC_PK_like_profile_R0.png', g, width=7, height=3.5)



## ## Try Bayesian
## library(tmbstan)
## library(shinystan)
## ## Some paraemters wandering off to Inf so fix those (need
## ## priors). Needs a ton of work but is proof of concept. Major
## ## problem is parallel fails.
## map <- parameters
## ## parameters$p[65:66]
## map$p[65:66] <- NA # map off R0 specified below
## map$p <- as.factor(map$p)
## obj3 <- MakeADFun(data = list(), parameters, DLL = "FIMS", silent=TRUE, map=map)
## opt3 <- TMBhelper::fit_tmb(obj3, getsd=FALSE, newtonsteps=0, control=list(trace=0))
## ## Fails when trying to do this in parallel unfortunately
## fit <- tmbstan(obj3, chains=1, cores=1, open_progress=FALSE,
##                init='last.par.best', control=list(max_treedepth=10))
## launch_shinystan(fit)
## df <- as.data.frame(fit)
## df <- df[,-ncol(df)] # drop lp__
## ## for each posterior draw, report to get SSB
## postreps <- list()
## for(ii in 1:nrow(df)){
##   if(ii %% 10==0) print(ii)
##   postreps[[ii]] <- obj3$rep(df[ii,])
## }
## ssbpost <- lapply(postreps, function(x) data.frame(year=years, ssb=x$ssb[[1]][-55]))%>%
##   bind_rows %>% mutate(rep=rep(1:nrow(df), each=54))
## saveRDS(ssbpost, file='pk_SSB_posteriors.RDS')
ssbpost <- readRDS('data_files/pk_pollock_SSB_posteriors.RDS')
g <- ggplot(ssbpost, aes(year, ssb/1e9, group=rep)) + geom_line(alpha=.1) +
  ylim(0,NA) + labs(x=NULL, y='SSB (M t)', title='Posterior demo (unconverged!)')
ggsave('figures/AFSC_PK_ssb_posterior.png', g, width=7, height=4, units='in')

Plots for extra analyses

Likelihood Profile SSB Posterior

Run FIMS model using wrapper functions

Code
FIMS::clear()
# set up selectivities for fleets and survey
fleet1 <- survey2 <- survey6 <- list(
  selectivity = list(form = "DoubleLogisticSelectivity"),
  data_distribution = c(
    Index = "DlnormDistribution",
    AgeComp = "DmultinomDistribution"
  )
)

survey3 <- list(
  selectivity = list(form = "LogisticSelectivity"),
  data_distribution = c(
    Index = "DlnormDistribution",
    AgeComp = "DmultinomDistribution"
  )
)

fleets <- list(
  fleet1 = fleet1,
  survey2 = survey2,
  survey3 = survey3,
  survey6 = survey6
)

# Create parameters list and update default values for parameters
parameters_with_wrappers <- data_4_model |>
  create_default_parameters(fleets = fleets) |>
  update_parameters(
    modified_parameters = list(
      fleet1 = list(
        DoubleLogisticSelectivity.inflection_point_asc.value = parfinal$inf1_fsh_mean,
        DoubleLogisticSelectivity.slope_asc.value = exp(parfinal$log_slp1_fsh_mean),
        DoubleLogisticSelectivity.inflection_point_desc.value = parfinal$inf2_fsh_mean,
        DoubleLogisticSelectivity.slope_desc.value = exp(parfinal$log_slp2_fsh_mean),
        Fleet.log_Fmort.value = log(pkfitfinal$rep$F)
      )
    )
  ) |>
  update_parameters(
    modified_parameters = list(
      survey2 = list(
        DoubleLogisticSelectivity.inflection_point_asc.value = parfinal$inf1_srv2,
        DoubleLogisticSelectivity.slope_asc.value = exp(parfinal$log_slp1_srv2),
        DoubleLogisticSelectivity.inflection_point_desc.value = parfinal$inf2_srv2,
        DoubleLogisticSelectivity.inflection_point_desc.estimated = FALSE,
        DoubleLogisticSelectivity.slope_desc.value = exp(parfinal$log_slp2_srv2),
        DoubleLogisticSelectivity.slope_desc.estimated = FALSE,
        Fleet.log_q.value = parfinal$log_q2_mean
      )
    )
  ) |>
  update_parameters(
    modified_parameters = list(
      survey3 = list(
        LogisticSelectivity.inflection_point.value = parfinal$inf1_srv3,
        LogisticSelectivity.slope.value = exp(parfinal$log_slp1_srv3),
        Fleet.log_q.value = parfinal$log_q3_mean
      )
    )
  ) |>
  update_parameters(
    modified_parameters = list(
      survey6 = list(
        DoubleLogisticSelectivity.inflection_point_asc.value = parfinal$inf1_srv6,
        DoubleLogisticSelectivity.inflection_point_asc.estimated = FALSE,
        DoubleLogisticSelectivity.slope_asc.value = exp(parfinal$log_slp1_srv6),
        DoubleLogisticSelectivity.slope_asc.estimated = FALSE,
        DoubleLogisticSelectivity.inflection_point_desc.value = parfinal$inf2_srv6,
        DoubleLogisticSelectivity.slope_desc.value = exp(parfinal$log_slp2_srv6),
        Fleet.log_q.value = parfinal$log_q6
      )
    )
  ) |>
  update_parameters(
    modified_parameters = list(
      recruitment = list(
        BevertonHoltRecruitment.log_rzero.value = parfinal$mean_log_recruit + log(1e9),
        BevertonHoltRecruitment.logit_steep.value = -log(1.0 - .99999) + log(.99999 - 0.2),
        BevertonHoltRecruitment.log_devs.value = parfinal$dev_log_recruit[-1],
        DnormDistribution.log_sd.value = parfinal$sigmaR
      )
    )
  ) |>
  update_parameters(
    modified_parameters = list(
      maturity = list(
        LogisticMaturity.inflection_point.value = 4.5,
        LogisticMaturity.inflection_point.estimated = FALSE,
        LogisticMaturity.slope.value = 1.5,
        LogisticMaturity.slope.estimated = FALSE
      )
    )
  ) |>
  update_parameters(
    modified_parameters = list(
      population = list(
        Population.log_M.value = log(as.numeric(t(matrix(
          rep(pkfitfinal$rep$M, each = data_4_model@n_years),
          nrow = data_4_model@n_years
        )))),
        Population.log_init_naa.value = c(log(pkfitfinal$rep$recruit[1]), log(pkfitfinal$rep$initN)) + log(1e9),
        Population.log_init_naa.estimated = FALSE
      )
    )
  )

# Put it all together, creating the FIMS model and making the TMB fcn
# Run the model without optimization to help ensure a viable model
test_fit <- parameters_with_wrappers  |>
  initialize_fims(data = data_4_model) |>
  fit_fims(optimize = FALSE)
get_obj(test_fit)$report()$nll_components |> length()
[1] 9
Code
get_data(data_4_model) |> dplyr::filter(name == "fleet1", type == "age") |> print(n = 300)
# A tibble: 540 × 9
    type  name     age datestart  dateend         value unit  uncertainty  year
    <chr> <chr>  <int> <date>     <date>          <dbl> <chr>       <dbl> <dbl>
  1 age   fleet1     1 1970-01-01 1970-12-31 -999       ""          1      1970
  2 age   fleet1     2 1970-01-01 1970-12-31 -999       ""          1      1970
  3 age   fleet1     3 1970-01-01 1970-12-31 -999       ""          1      1970
  4 age   fleet1     4 1970-01-01 1970-12-31 -999       ""          1      1970
  5 age   fleet1     5 1970-01-01 1970-12-31 -999       ""          1      1970
  6 age   fleet1     6 1970-01-01 1970-12-31 -999       ""          1      1970
  7 age   fleet1     7 1970-01-01 1970-12-31 -999       ""          1      1970
  8 age   fleet1     8 1970-01-01 1970-12-31 -999       ""          1      1970
  9 age   fleet1     9 1970-01-01 1970-12-31 -999       ""          1      1970
 10 age   fleet1    10 1970-01-01 1970-12-31 -999       ""          1      1970
 11 age   fleet1     1 1971-01-01 1971-12-31 -999       ""          1      1971
 12 age   fleet1     2 1971-01-01 1971-12-31 -999       ""          1      1971
 13 age   fleet1     3 1971-01-01 1971-12-31 -999       ""          1      1971
 14 age   fleet1     4 1971-01-01 1971-12-31 -999       ""          1      1971
 15 age   fleet1     5 1971-01-01 1971-12-31 -999       ""          1      1971
 16 age   fleet1     6 1971-01-01 1971-12-31 -999       ""          1      1971
 17 age   fleet1     7 1971-01-01 1971-12-31 -999       ""          1      1971
 18 age   fleet1     8 1971-01-01 1971-12-31 -999       ""          1      1971
 19 age   fleet1     9 1971-01-01 1971-12-31 -999       ""          1      1971
 20 age   fleet1    10 1971-01-01 1971-12-31 -999       ""          1      1971
 21 age   fleet1     1 1972-01-01 1972-12-31 -999       ""          1      1972
 22 age   fleet1     2 1972-01-01 1972-12-31 -999       ""          1      1972
 23 age   fleet1     3 1972-01-01 1972-12-31 -999       ""          1      1972
 24 age   fleet1     4 1972-01-01 1972-12-31 -999       ""          1      1972
 25 age   fleet1     5 1972-01-01 1972-12-31 -999       ""          1      1972
 26 age   fleet1     6 1972-01-01 1972-12-31 -999       ""          1      1972
 27 age   fleet1     7 1972-01-01 1972-12-31 -999       ""          1      1972
 28 age   fleet1     8 1972-01-01 1972-12-31 -999       ""          1      1972
 29 age   fleet1     9 1972-01-01 1972-12-31 -999       ""          1      1972
 30 age   fleet1    10 1972-01-01 1972-12-31 -999       ""          1      1972
 31 age   fleet1     1 1973-01-01 1973-12-31 -999       ""          1      1973
 32 age   fleet1     2 1973-01-01 1973-12-31 -999       ""          1      1973
 33 age   fleet1     3 1973-01-01 1973-12-31 -999       ""          1      1973
 34 age   fleet1     4 1973-01-01 1973-12-31 -999       ""          1      1973
 35 age   fleet1     5 1973-01-01 1973-12-31 -999       ""          1      1973
 36 age   fleet1     6 1973-01-01 1973-12-31 -999       ""          1      1973
 37 age   fleet1     7 1973-01-01 1973-12-31 -999       ""          1      1973
 38 age   fleet1     8 1973-01-01 1973-12-31 -999       ""          1      1973
 39 age   fleet1     9 1973-01-01 1973-12-31 -999       ""          1      1973
 40 age   fleet1    10 1973-01-01 1973-12-31 -999       ""          1      1973
 41 age   fleet1     1 1974-01-01 1974-12-31 -999       ""          1      1974
 42 age   fleet1     2 1974-01-01 1974-12-31 -999       ""          1      1974
 43 age   fleet1     3 1974-01-01 1974-12-31 -999       ""          1      1974
 44 age   fleet1     4 1974-01-01 1974-12-31 -999       ""          1      1974
 45 age   fleet1     5 1974-01-01 1974-12-31 -999       ""          1      1974
 46 age   fleet1     6 1974-01-01 1974-12-31 -999       ""          1      1974
 47 age   fleet1     7 1974-01-01 1974-12-31 -999       ""          1      1974
 48 age   fleet1     8 1974-01-01 1974-12-31 -999       ""          1      1974
 49 age   fleet1     9 1974-01-01 1974-12-31 -999       ""          1      1974
 50 age   fleet1    10 1974-01-01 1974-12-31 -999       ""          1      1974
 51 age   fleet1     1 1975-01-01 1975-12-31    0       ""          0.369  1975
 52 age   fleet1     2 1975-01-01 1975-12-31    0.0236  ""          0.369  1975
 53 age   fleet1     3 1975-01-01 1975-12-31    0.544   ""          0.369  1975
 54 age   fleet1     4 1975-01-01 1975-12-31    0.169   ""          0.369  1975
 55 age   fleet1     5 1975-01-01 1975-12-31    0.142   ""          0.369  1975
 56 age   fleet1     6 1975-01-01 1975-12-31    0.0668  ""          0.369  1975
 57 age   fleet1     7 1975-01-01 1975-12-31    0.0277  ""          0.369  1975
 58 age   fleet1     8 1975-01-01 1975-12-31    0.0270  ""          0.369  1975
 59 age   fleet1     9 1975-01-01 1975-12-31    0       ""          0.369  1975
 60 age   fleet1    10 1975-01-01 1975-12-31    0       ""          0.369  1975
 61 age   fleet1     1 1976-01-01 1976-12-31    0       ""          8.11   1976
 62 age   fleet1     2 1976-01-01 1976-12-31    0.00887 ""          8.11   1976
 63 age   fleet1     3 1976-01-01 1976-12-31    0.108   ""          8.11   1976
 64 age   fleet1     4 1976-01-01 1976-12-31    0.577   ""          8.11   1976
 65 age   fleet1     5 1976-01-01 1976-12-31    0.187   ""          8.11   1976
 66 age   fleet1     6 1976-01-01 1976-12-31    0.0780  ""          8.11   1976
 67 age   fleet1     7 1976-01-01 1976-12-31    0.0172  ""          8.11   1976
 68 age   fleet1     8 1976-01-01 1976-12-31    0.0134  ""          8.11   1976
 69 age   fleet1     9 1976-01-01 1976-12-31    0.00918 ""          8.11   1976
 70 age   fleet1    10 1976-01-01 1976-12-31    0.00111 ""          8.11   1976
 71 age   fleet1     1 1977-01-01 1977-12-31    0.00023 ""         70.8    1977
 72 age   fleet1     2 1977-01-01 1977-12-31    0.0357  ""         70.8    1977
 73 age   fleet1     3 1977-01-01 1977-12-31    0.0601  ""         70.8    1977
 74 age   fleet1     4 1977-01-01 1977-12-31    0.138   ""         70.8    1977
 75 age   fleet1     5 1977-01-01 1977-12-31    0.522   ""         70.8    1977
 76 age   fleet1     6 1977-01-01 1977-12-31    0.151   ""         70.8    1977
 77 age   fleet1     7 1977-01-01 1977-12-31    0.0566  ""         70.8    1977
 78 age   fleet1     8 1977-01-01 1977-12-31    0.0147  ""         70.8    1977
 79 age   fleet1     9 1977-01-01 1977-12-31    0.0130  ""         70.8    1977
 80 age   fleet1    10 1977-01-01 1977-12-31    0.00921 ""         70.8    1977
 81 age   fleet1     1 1978-01-01 1978-12-31    0.00186 ""         73.7    1978
 82 age   fleet1     2 1978-01-01 1978-12-31    0.0659  ""         73.7    1978
 83 age   fleet1     3 1978-01-01 1978-12-31    0.210   ""         73.7    1978
 84 age   fleet1     4 1978-01-01 1978-12-31    0.148   ""         73.7    1978
 85 age   fleet1     5 1978-01-01 1978-12-31    0.147   ""         73.7    1978
 86 age   fleet1     6 1978-01-01 1978-12-31    0.285   ""         73.7    1978
 87 age   fleet1     7 1978-01-01 1978-12-31    0.0823  ""         73.7    1978
 88 age   fleet1     8 1978-01-01 1978-12-31    0.0350  ""         73.7    1978
 89 age   fleet1     9 1978-01-01 1978-12-31    0.0130  ""         73.7    1978
 90 age   fleet1    10 1978-01-01 1978-12-31    0.0120  ""         73.7    1978
 91 age   fleet1     1 1979-01-01 1979-12-31    0.00049 ""         73.7    1979
 92 age   fleet1     2 1979-01-01 1979-12-31    0.0179  ""         73.7    1979
 93 age   fleet1     3 1979-01-01 1979-12-31    0.282   ""         73.7    1979
 94 age   fleet1     4 1979-01-01 1979-12-31    0.462   ""         73.7    1979
 95 age   fleet1     5 1979-01-01 1979-12-31    0.0736  ""         73.7    1979
 96 age   fleet1     6 1979-01-01 1979-12-31    0.0490  ""         73.7    1979
 97 age   fleet1     7 1979-01-01 1979-12-31    0.0670  ""         73.7    1979
 98 age   fleet1     8 1979-01-01 1979-12-31    0.0308  ""         73.7    1979
 99 age   fleet1     9 1979-01-01 1979-12-31    0.0120  ""         73.7    1979
100 age   fleet1    10 1979-01-01 1979-12-31    0.00445 ""         73.7    1979
101 age   fleet1     1 1980-01-01 1980-12-31    0.00271 ""         73.7    1980
102 age   fleet1     2 1980-01-01 1980-12-31    0.0545  ""         73.7    1980
103 age   fleet1     3 1980-01-01 1980-12-31    0.154   ""         73.7    1980
104 age   fleet1     4 1980-01-01 1980-12-31    0.324   ""         73.7    1980
105 age   fleet1     5 1980-01-01 1980-12-31    0.234   ""         73.7    1980
106 age   fleet1     6 1980-01-01 1980-12-31    0.0771  ""         73.7    1980
107 age   fleet1     7 1980-01-01 1980-12-31    0.0596  ""         73.7    1980
108 age   fleet1     8 1980-01-01 1980-12-31    0.0542  ""         73.7    1980
109 age   fleet1     9 1980-01-01 1980-12-31    0.0274  ""         73.7    1980
110 age   fleet1    10 1980-01-01 1980-12-31    0.0131  ""         73.7    1980
111 age   fleet1     1 1981-01-01 1981-12-31    0.00106 ""         73.7    1981
112 age   fleet1     2 1981-01-01 1981-12-31    0.0226  ""         73.7    1981
113 age   fleet1     3 1981-01-01 1981-12-31    0.166   ""         73.7    1981
114 age   fleet1     4 1981-01-01 1981-12-31    0.343   ""         73.7    1981
115 age   fleet1     5 1981-01-01 1981-12-31    0.276   ""         73.7    1981
116 age   fleet1     6 1981-01-01 1981-12-31    0.110   ""         73.7    1981
117 age   fleet1     7 1981-01-01 1981-12-31    0.0316  ""         73.7    1981
118 age   fleet1     8 1981-01-01 1981-12-31    0.0274  ""         73.7    1981
119 age   fleet1     9 1981-01-01 1981-12-31    0.0195  ""         73.7    1981
120 age   fleet1    10 1981-01-01 1981-12-31    0.00319 ""         73.7    1981
121 age   fleet1     1 1982-01-01 1982-12-31    0.00015 ""         73.7    1982
122 age   fleet1     2 1982-01-01 1982-12-31    0.0348  ""         73.7    1982
123 age   fleet1     3 1982-01-01 1982-12-31    0.152   ""         73.7    1982
124 age   fleet1     4 1982-01-01 1982-12-31    0.338   ""         73.7    1982
125 age   fleet1     5 1982-01-01 1982-12-31    0.265   ""         73.7    1982
126 age   fleet1     6 1982-01-01 1982-12-31    0.157   ""         73.7    1982
127 age   fleet1     7 1982-01-01 1982-12-31    0.0400  ""         73.7    1982
128 age   fleet1     8 1982-01-01 1982-12-31    0.00625 ""         73.7    1982
129 age   fleet1     9 1982-01-01 1982-12-31    0.00401 ""         73.7    1982
130 age   fleet1    10 1982-01-01 1982-12-31    0.00295 ""         73.7    1982
131 age   fleet1     1 1983-01-01 1983-12-31    0       ""         73.7    1983
132 age   fleet1     2 1983-01-01 1983-12-31    0.0195  ""         73.7    1983
133 age   fleet1     3 1983-01-01 1983-12-31    0.119   ""         73.7    1983
134 age   fleet1     4 1983-01-01 1983-12-31    0.229   ""         73.7    1983
135 age   fleet1     5 1983-01-01 1983-12-31    0.342   ""         73.7    1983
136 age   fleet1     6 1983-01-01 1983-12-31    0.167   ""         73.7    1983
137 age   fleet1     7 1983-01-01 1983-12-31    0.0930  ""         73.7    1983
138 age   fleet1     8 1983-01-01 1983-12-31    0.0245  ""         73.7    1983
139 age   fleet1     9 1983-01-01 1983-12-31    0.00478 ""         73.7    1983
140 age   fleet1    10 1983-01-01 1983-12-31    0.002   ""         73.7    1983
141 age   fleet1     1 1984-01-01 1984-12-31    0.00176 ""         73.7    1984
142 age   fleet1     2 1984-01-01 1984-12-31    0.0131  ""         73.7    1984
143 age   fleet1     3 1984-01-01 1984-12-31    0.155   ""         73.7    1984
144 age   fleet1     4 1984-01-01 1984-12-31    0.166   ""         73.7    1984
145 age   fleet1     5 1984-01-01 1984-12-31    0.203   ""         73.7    1984
146 age   fleet1     6 1984-01-01 1984-12-31    0.302   ""         73.7    1984
147 age   fleet1     7 1984-01-01 1984-12-31    0.109   ""         73.7    1984
148 age   fleet1     8 1984-01-01 1984-12-31    0.0370  ""         73.7    1984
149 age   fleet1     9 1984-01-01 1984-12-31    0.0123  ""         73.7    1984
150 age   fleet1    10 1984-01-01 1984-12-31    0.00176 ""         73.7    1984
151 age   fleet1     1 1985-01-01 1985-12-31    0.00061 ""         73.7    1985
152 age   fleet1     2 1985-01-01 1985-12-31    0.0348  ""         73.7    1985
153 age   fleet1     3 1985-01-01 1985-12-31    0.0223  ""         73.7    1985
154 age   fleet1     4 1985-01-01 1985-12-31    0.109   ""         73.7    1985
155 age   fleet1     5 1985-01-01 1985-12-31    0.118   ""         73.7    1985
156 age   fleet1     6 1985-01-01 1985-12-31    0.212   ""         73.7    1985
157 age   fleet1     7 1985-01-01 1985-12-31    0.352   ""         73.7    1985
158 age   fleet1     8 1985-01-01 1985-12-31    0.110   ""         73.7    1985
159 age   fleet1     9 1985-01-01 1985-12-31    0.0309  ""         73.7    1985
160 age   fleet1    10 1985-01-01 1985-12-31    0.0105  ""         73.7    1985
161 age   fleet1     1 1986-01-01 1986-12-31    0.0120  ""         32.1    1986
162 age   fleet1     2 1986-01-01 1986-12-31    0.0727  ""         32.1    1986
163 age   fleet1     3 1986-01-01 1986-12-31    0.176   ""         32.1    1986
164 age   fleet1     4 1986-01-01 1986-12-31    0.106   ""         32.1    1986
165 age   fleet1     5 1986-01-01 1986-12-31    0.234   ""         32.1    1986
166 age   fleet1     6 1986-01-01 1986-12-31    0.0994  ""         32.1    1986
167 age   fleet1     7 1986-01-01 1986-12-31    0.108   ""         32.1    1986
168 age   fleet1     8 1986-01-01 1986-12-31    0.131   ""         32.1    1986
169 age   fleet1     9 1986-01-01 1986-12-31    0.0523  ""         32.1    1986
170 age   fleet1    10 1986-01-01 1986-12-31    0.0089  ""         32.1    1986
171 age   fleet1     1 1987-01-01 1987-12-31    0       ""         10.3    1987
172 age   fleet1     2 1987-01-01 1987-12-31    0.0593  ""         10.3    1987
173 age   fleet1     3 1987-01-01 1987-12-31    0.0897  ""         10.3    1987
174 age   fleet1     4 1987-01-01 1987-12-31    0.0799  ""         10.3    1987
175 age   fleet1     5 1987-01-01 1987-12-31    0.0929  ""         10.3    1987
176 age   fleet1     6 1987-01-01 1987-12-31    0.175   ""         10.3    1987
177 age   fleet1     7 1987-01-01 1987-12-31    0.150   ""         10.3    1987
178 age   fleet1     8 1987-01-01 1987-12-31    0.0985  ""         10.3    1987
179 age   fleet1     9 1987-01-01 1987-12-31    0.218   ""         10.3    1987
180 age   fleet1    10 1987-01-01 1987-12-31    0.0369  ""         10.3    1987
181 age   fleet1     1 1988-01-01 1988-12-31    0.0102  ""         12.2    1988
182 age   fleet1     2 1988-01-01 1988-12-31    0.106   ""         12.2    1988
183 age   fleet1     3 1988-01-01 1988-12-31    0.151   ""         12.2    1988
184 age   fleet1     4 1988-01-01 1988-12-31    0.229   ""         12.2    1988
185 age   fleet1     5 1988-01-01 1988-12-31    0.192   ""         12.2    1988
186 age   fleet1     6 1988-01-01 1988-12-31    0.127   ""         12.2    1988
187 age   fleet1     7 1988-01-01 1988-12-31    0.0706  ""         12.2    1988
188 age   fleet1     8 1988-01-01 1988-12-31    0.0324  ""         12.2    1988
189 age   fleet1     9 1988-01-01 1988-12-31    0.00479 ""         12.2    1988
190 age   fleet1    10 1988-01-01 1988-12-31    0.0773  ""         12.2    1988
191 age   fleet1     1 1989-01-01 1989-12-31    0.0275  ""         27.3    1989
192 age   fleet1     2 1989-01-01 1989-12-31    0.0124  ""         27.3    1989
193 age   fleet1     3 1989-01-01 1989-12-31    0.0338  ""         27.3    1989
194 age   fleet1     4 1989-01-01 1989-12-31    0.322   ""         27.3    1989
195 age   fleet1     5 1989-01-01 1989-12-31    0.367   ""         27.3    1989
196 age   fleet1     6 1989-01-01 1989-12-31    0.127   ""         27.3    1989
197 age   fleet1     7 1989-01-01 1989-12-31    0.0487  ""         27.3    1989
198 age   fleet1     8 1989-01-01 1989-12-31    0.0248  ""         27.3    1989
199 age   fleet1     9 1989-01-01 1989-12-31    0.0101  ""         27.3    1989
200 age   fleet1    10 1989-01-01 1989-12-31    0.0264  ""         27.3    1989
201 age   fleet1     1 1990-01-01 1990-12-31    0       ""         40.6    1990
202 age   fleet1     2 1990-01-01 1990-12-31    0.0138  ""         40.6    1990
203 age   fleet1     3 1990-01-01 1990-12-31    0.0174  ""         40.6    1990
204 age   fleet1     4 1990-01-01 1990-12-31    0.0256  ""         40.6    1990
205 age   fleet1     5 1990-01-01 1990-12-31    0.149   ""         40.6    1990
206 age   fleet1     6 1990-01-01 1990-12-31    0.470   ""         40.6    1990
207 age   fleet1     7 1990-01-01 1990-12-31    0.168   ""         40.6    1990
208 age   fleet1     8 1990-01-01 1990-12-31    0.0951  ""         40.6    1990
209 age   fleet1     9 1990-01-01 1990-12-31    0.0230  ""         40.6    1990
210 age   fleet1    10 1990-01-01 1990-12-31    0.0385  ""         40.6    1990
211 age   fleet1     1 1991-01-01 1991-12-31    0       ""         60.8    1991
212 age   fleet1     2 1991-01-01 1991-12-31    0.0123  ""         60.8    1991
213 age   fleet1     3 1991-01-01 1991-12-31    0.0878  ""         60.8    1991
214 age   fleet1     4 1991-01-01 1991-12-31    0.0470  ""         60.8    1991
215 age   fleet1     5 1991-01-01 1991-12-31    0.0415  ""         60.8    1991
216 age   fleet1     6 1991-01-01 1991-12-31    0.0800  ""         60.8    1991
217 age   fleet1     7 1991-01-01 1991-12-31    0.368   ""         60.8    1991
218 age   fleet1     8 1991-01-01 1991-12-31    0.0406  ""         60.8    1991
219 age   fleet1     9 1991-01-01 1991-12-31    0.207   ""         60.8    1991
220 age   fleet1    10 1991-01-01 1991-12-31    0.116   ""         60.8    1991
221 age   fleet1     1 1992-01-01 1992-12-31    0.00104 ""         51.2    1992
222 age   fleet1     2 1992-01-01 1992-12-31    0.0151  ""         51.2    1992
223 age   fleet1     3 1992-01-01 1992-12-31    0.0322  ""         51.2    1992
224 age   fleet1     4 1992-01-01 1992-12-31    0.205   ""         51.2    1992
225 age   fleet1     5 1992-01-01 1992-12-31    0.218   ""         51.2    1992
226 age   fleet1     6 1992-01-01 1992-12-31    0.115   ""         51.2    1992
227 age   fleet1     7 1992-01-01 1992-12-31    0.0833  ""         51.2    1992
228 age   fleet1     8 1992-01-01 1992-12-31    0.173   ""         51.2    1992
229 age   fleet1     9 1992-01-01 1992-12-31    0.0529  ""         51.2    1992
230 age   fleet1    10 1992-01-01 1992-12-31    0.104   ""         51.2    1992
231 age   fleet1     1 1993-01-01 1993-12-31    0.00032 ""         53.5    1993
232 age   fleet1     2 1993-01-01 1993-12-31    0.0196  ""         53.5    1993
233 age   fleet1     3 1993-01-01 1993-12-31    0.0672  ""         53.5    1993
234 age   fleet1     4 1993-01-01 1993-12-31    0.159   ""         53.5    1993
235 age   fleet1     5 1993-01-01 1993-12-31    0.380   ""         53.5    1993
236 age   fleet1     6 1993-01-01 1993-12-31    0.133   ""         53.5    1993
237 age   fleet1     7 1993-01-01 1993-12-31    0.0573  ""         53.5    1993
238 age   fleet1     8 1993-01-01 1993-12-31    0.0545  ""         53.5    1993
239 age   fleet1     9 1993-01-01 1993-12-31    0.0774  ""         53.5    1993
240 age   fleet1    10 1993-01-01 1993-12-31    0.0523  ""         53.5    1993
241 age   fleet1     1 1994-01-01 1994-12-31    0.00059 ""         57.1    1994
242 age   fleet1     2 1994-01-01 1994-12-31    0.00826 ""         57.1    1994
243 age   fleet1     3 1994-01-01 1994-12-31    0.0390  ""         57.1    1994
244 age   fleet1     4 1994-01-01 1994-12-31    0.0711  ""         57.1    1994
245 age   fleet1     5 1994-01-01 1994-12-31    0.312   ""         57.1    1994
246 age   fleet1     6 1994-01-01 1994-12-31    0.279   ""         57.1    1994
247 age   fleet1     7 1994-01-01 1994-12-31    0.112   ""         57.1    1994
248 age   fleet1     8 1994-01-01 1994-12-31    0.0494  ""         57.1    1994
249 age   fleet1     9 1994-01-01 1994-12-31    0.0442  ""         57.1    1994
250 age   fleet1    10 1994-01-01 1994-12-31    0.0836  ""         57.1    1994
251 age   fleet1     1 1995-01-01 1995-12-31    0       ""         36.5    1995
252 age   fleet1     2 1995-01-01 1995-12-31    0.00365 ""         36.5    1995
253 age   fleet1     3 1995-01-01 1995-12-31    0.0271  ""         36.5    1995
254 age   fleet1     4 1995-01-01 1995-12-31    0.0757  ""         36.5    1995
255 age   fleet1     5 1995-01-01 1995-12-31    0.149   ""         36.5    1995
256 age   fleet1     6 1995-01-01 1995-12-31    0.345   ""         36.5    1995
257 age   fleet1     7 1995-01-01 1995-12-31    0.214   ""         36.5    1995
258 age   fleet1     8 1995-01-01 1995-12-31    0.0676  ""         36.5    1995
259 age   fleet1     9 1995-01-01 1995-12-31    0.0323  ""         36.5    1995
260 age   fleet1    10 1995-01-01 1995-12-31    0.0860  ""         36.5    1995
261 age   fleet1     1 1996-01-01 1996-12-31    0       ""         23.6    1996
262 age   fleet1     2 1996-01-01 1996-12-31    0.0175  ""         23.6    1996
263 age   fleet1     3 1996-01-01 1996-12-31    0.0425  ""         23.6    1996
264 age   fleet1     4 1996-01-01 1996-12-31    0.0314  ""         23.6    1996
265 age   fleet1     5 1996-01-01 1996-12-31    0.0893  ""         23.6    1996
266 age   fleet1     6 1996-01-01 1996-12-31    0.123   ""         23.6    1996
267 age   fleet1     7 1996-01-01 1996-12-31    0.238   ""         23.6    1996
268 age   fleet1     8 1996-01-01 1996-12-31    0.255   ""         23.6    1996
269 age   fleet1     9 1996-01-01 1996-12-31    0.0835  ""         23.6    1996
270 age   fleet1    10 1996-01-01 1996-12-31    0.120   ""         23.6    1996
271 age   fleet1     1 1997-01-01 1997-12-31    0       ""         50.9    1997
272 age   fleet1     2 1997-01-01 1997-12-31    0.0208  ""         50.9    1997
273 age   fleet1     3 1997-01-01 1997-12-31    0.0905  ""         50.9    1997
274 age   fleet1     4 1997-01-01 1997-12-31    0.0513  ""         50.9    1997
275 age   fleet1     5 1997-01-01 1997-12-31    0.0539  ""         50.9    1997
276 age   fleet1     6 1997-01-01 1997-12-31    0.104   ""         50.9    1997
277 age   fleet1     7 1997-01-01 1997-12-31    0.155   ""         50.9    1997
278 age   fleet1     8 1997-01-01 1997-12-31    0.236   ""         50.9    1997
279 age   fleet1     9 1997-01-01 1997-12-31    0.173   ""         50.9    1997
280 age   fleet1    10 1997-01-01 1997-12-31    0.116   ""         50.9    1997
281 age   fleet1     1 1998-01-01 1998-12-31    0.00421 ""         51.6    1998
282 age   fleet1     2 1998-01-01 1998-12-31    0.00146 ""         51.6    1998
283 age   fleet1     3 1998-01-01 1998-12-31    0.147   ""         51.6    1998
284 age   fleet1     4 1998-01-01 1998-12-31    0.251   ""         51.6    1998
285 age   fleet1     5 1998-01-01 1998-12-31    0.110   ""         51.6    1998
286 age   fleet1     6 1998-01-01 1998-12-31    0.0650  ""         51.6    1998
287 age   fleet1     7 1998-01-01 1998-12-31    0.0738  ""         51.6    1998
288 age   fleet1     8 1998-01-01 1998-12-31    0.0860  ""         51.6    1998
289 age   fleet1     9 1998-01-01 1998-12-31    0.125   ""         51.6    1998
290 age   fleet1    10 1998-01-01 1998-12-31    0.137   ""         51.6    1998
291 age   fleet1     1 1999-01-01 1999-12-31    0       ""         73.7    1999
292 age   fleet1     2 1999-01-01 1999-12-31    0.00724 ""         73.7    1999
293 age   fleet1     3 1999-01-01 1999-12-31    0.0253  ""         73.7    1999
294 age   fleet1     4 1999-01-01 1999-12-31    0.222   ""         73.7    1999
295 age   fleet1     5 1999-01-01 1999-12-31    0.333   ""         73.7    1999
296 age   fleet1     6 1999-01-01 1999-12-31    0.0975  ""         73.7    1999
297 age   fleet1     7 1999-01-01 1999-12-31    0.0728  ""         73.7    1999
298 age   fleet1     8 1999-01-01 1999-12-31    0.0387  ""         73.7    1999
299 age   fleet1     9 1999-01-01 1999-12-31    0.0600  ""         73.7    1999
300 age   fleet1    10 1999-01-01 1999-12-31    0.143   ""         73.7    1999
# ℹ 240 more rows
Code
# Run the  model with optimization
fit <- parameters_with_wrappers  |>
  initialize_fims(data = data_4_model) |>
  fit_fims(optimize = TRUE)
✔ Starting optimization ...
ℹ Restarting optimizer 3 times to improve gradient.
ℹ Maximum gradient went from 0.00794 to 0.00021 after 3 steps.
✔ Finished optimization
✔ Finished sdreport
ℹ FIMS model version: 0.3.0.1
ℹ Total run time was 2.59903 seconds
ℹ Number of parameters: total=121, fixed_effects=121, and random_effects=0
ℹ Maximum gradient= 0.00021
ℹ Negative log likelihood (NLL):
• Marginal NLL= 3248.81864
• Total NLL= 3248.81864
ℹ Terminal SB=
Code
## report values for models
rep1_with_wrappers <- test_fit@report # FIMS initial values
fit@max_gradient # from Cole, can use TMBhelper::fit_tmb to get val to <1e-10
[1] 0.0002109227
Code
rep2_with_wrappers <- fit@report

# slight differences due to different optimizer settings
# cbind(rep2$ssb[[1]], rep2_with_wrappers$ssb[[1]])
# cbind(rep2$nll_components, rep2_with_wrappers$nll_components)

Comparison table

The likelihood components from the TMB model do not include constants and thus are not directly comparable. To be fixed later. Relative differences between the modified TMB model and FIMS implementation are given in the figure above.

What was your experience using FIMS? What could we do to improve usability?

To do

List any issues that you ran into or found

  • Output more derived quantities like selectivity, maturity, etc.
  • NLL components are not separated by fleet and need to be. So age comp NLL for fleets 1 and 2 need to be separate to make, e.g., the likelihood profile plot above.
  • Need more ADREPORTed values like SSB

What features are most important to add based on this case study?

  • More sophisticated control over selectivity so that ages 1 and 2 can be zeroed out for a double-logistic form, overriding the selectivity curve.
Code
# Clear C++ objects from memory
FIMS::clear()