recdevs <- rep$parameters |>
dplyr::filter(stringr::str_detect(Label, "RecrDev")) |>
dplyr::select(Label, Value)
init_naa <- (exp(opaka_ctl$SR_parms["SR_LN(R0)", "INIT"]) * 1000) * exp(-(ages - 1) * 0.135)
init_naa[n_ages] <- init_naa[n_ages] / 0.135
# Create default parameters
default_parameters <- FIMS::create_default_configurations(
data = data_4_model
) |>
FIMS::create_default_parameters(
data = data_4_model
) |>
tidyr::unnest(cols = data) |>
dplyr::rows_update(
tibble::tibble(
module_name = "Maturity",
label = c("inflection_point", "slope"),
value = c(7, 0.5)
),
by = c("module_name", "label")
) |>
dplyr::rows_update(
tibble::tibble(
module_name = "Selectivity",
fleet_name = "fleet1",
label = c("slope", "inflection_point"),
# Used age selectivity values
value = c(4.5, 1.81),
estimation_type = "constant"
),
by = c("module_name", "fleet_name", "label")
) |>
dplyr::rows_update(
tibble::tibble(
module_name = "Selectivity",
fleet_name = "fleet2",
label = c("slope", "inflection_point"),
value = c(3, 1),
estimation_type = "constant"
),
by = c("module_name", "fleet_name", "label")
) |>
dplyr::rows_update(
tibble::tibble(
module_name = "Selectivity",
fleet_name = "fleet3",
label = c("slope", "inflection_point"),
value = c(4.5, 1.97),
estimation_type = "constant"
),
by = c("module_name", "fleet_name", "label")
) |>
dplyr::rows_update(
tibble::tibble(
module_name = "Selectivity",
fleet_name = "fleet4",
label = c("slope", "inflection_point"),
value = c(4.5, 1.81),
estimation_type = "constant"
),
by = c("module_name", "fleet_name", "label")
) |>
dplyr::rows_update(
tibble::tibble(
module_name = "Population",
label = c("log_M"),
value = log(0.135)
),
by = c("module_name", "label")
) |>
dplyr::rows_update(
tibble::tibble(
module_name = "Population",
label = "log_init_naa",
age = ages,
value = log(init_naa),
estimation_type = "constant"
),
by = c("module_name", "label", "age")
) |>
# dplyr::rows_update(
# tibble::tibble(
# module_name = "Recruitment",
# # Transformed 0.999 to logit where a previous version just used 0.999
# # Wondering if we should use logit(0.75) as noted previously for scamp
# # as the null recruitment model?
# label = c("log_rzero", "logit_steep", "log_sd"),
# value = c(opaka_ctl$SR_parms["SR_LN(R0)", "INIT"], -log(1.0 - 0.76) + log(0.76 - 0.2), sca$parm.cons$rec_sigma[8])
# ),
# by = c("module_name", "label")
# ) |>
dplyr::rows_update(
tibble::tibble(
module_name = "Recruitment",
label = "log_devs",
time = years[-1],
# The last value of the initial numbers at age is the first
# recruitment deviation
value = recdevs$Value,
),
by = c("module_name", "label", "time")
) |>
dplyr::rows_update(
tibble::tibble(
module_name = "Fleet",
fleet_name = "fleet1",
time = years,
label = "log_Fmort",
value = log(rep$exploitation$FRS)
),
by = c("module_name", "fleet_name", "label", "time")
) |>
dplyr::rows_update(
tibble::tibble(
module_name = "Fleet",
fleet_name = "fleet2",
label = "log_q",
value = -4.12772
),
by = c("module_name", "fleet_name", "label")
) |>
dplyr::rows_update(
tibble::tibble(
module_name = "Fleet",
fleet_name = "fleet3",
label = "log_Fmort",
time = years,
value = log(rep$exploitation$Non_comm)
),
by = c("module_name", "fleet_name", "label", "time")
) |>
dplyr::rows_update(
tibble::tibble(
module_name = "Fleet",
fleet_name = "fleet4",
label = "log_q",
value = -3.90281 #value from SS
),
by = c("module_name", "fleet_name", "label")
)
# Run the model with optimization
fit <- default_parameters |>
FIMS::initialize_fims(data = data_4_model) |>
# Model is too big to run on GitHub action if you estimate uncertainty
FIMS::fit_fims(optimize = TRUE, get_sd = FALSE)