Skip to contents

Introduction

This vignette provides the minimal steps needed to run a Fisheries Integrated Modeling System (FIMS) model.

Setup

Load the FIMS package and clear memory:

library(FIMS)

# clear memory
clear()

Data and parameters

First, load the available data and create a FIMS data frame to create a model with. Then create a set of default parameters.

# Load sample data
data("data1")
# Prepare data for FIMS model
data_4_model <- FIMSFrame(data1)

# Define fleet specifications
fleet1 <- list(
  selectivity = list(form = "LogisticSelectivity"),
  data_distribution = c(
    Landings = "DlnormDistribution",
    AgeComp = "DmultinomDistribution",
    LengthComp = "DmultinomDistribution"
  )
)
survey1 <- list(
  selectivity = list(form = "LogisticSelectivity"),
  data_distribution = c(
    Index = "DlnormDistribution",
    AgeComp = "DmultinomDistribution",
    LengthComp = "DmultinomDistribution"
  )
)

# Create parameters
parameters <- data_4_model |>
  create_default_parameters(
    fleets = list(fleet1 = fleet1, survey1 = survey1)
  )

Initialize and Fit

Initialize the FIMS modules and fit the model.

# Run the  model with optimization
fit <- parameters |>
  initialize_fims(data = data_4_model) |>
  fit_fims(optimize = TRUE)
##  Starting optimization ...
##  Restarting optimizer 3 times to improve gradient.
##  Maximum gradient went from 0.00539 to 0.00136 after 3 steps.
##  Finished optimization
##  Finished sdreport
##  FIMS model version: 0.4.0
##  Total run time was 5.56943 seconds
##  Number of parameters: total=79, fixed_effects=79, and random_effects=0
##  Maximum gradient= 0.00136
##  Negative log likelihood (NLL):
##  Marginal NLL= 3230.08373
##  Total NLL= 3230.08373
##  Terminal SB=
# Clear memory post-run
clear()