This vignette fits an operating model and a Tier 3 estimation model,
runs a management strategy evaluation with run_mse(), then
compares alternative reference points, survey frequencies, assessment
schedules and a climate-linked operating model.
Fitting the operating model
A management strategy evaluation (MSE; Punt et al. 2016) runs a management strategy in closed loop: an operating model (OM) represents the “true” stock and generates data, an estimation model (EM) is fitted to that data and applies a harvest control rule (HCR), and the resulting catch feeds back into the OM. This example uses the Gulf of Alaska northern rockfish assessment as the OM.
library(Rceattle)
data("NorthernRockfish2022")
nrdata <- NorthernRockfish2022
nrdata$fleet_control$Proj_F_proportion <- 1
om <- Rceattle::fit_mod(
data_list = nrdata,
estimateMode = 0, # Estimate
initMode = 1, # Assume unfished equilibrium
M1Fun = build_M1(
M1_model = "sex_age_invariant",
linkages = list(
M1 = linkage_spec(
formula = ~ 1,
priors = list(
"(Intercept)" = lognormal(log(0.06), 0.05)
)
)
)
),
fit_control = fit_control(phase = TRUE)
)Fitting the estimation model (Tier 3 HCR)
fit_mod(HCR = build_hcr()) sets the harvest control rule
and its reference points. Here the EM uses the NPFMC Tier 3 rule:
fishing at F40%, the maxFABC rate, with an F35% overfishing limit (FOFL,
the Amendment-56 SPR proxy for FMSY). Below the B40% target, F ramps
down linearly, reaching zero when SSB falls to Alpha = 0.05
of that target. Plimit = 0.2 is a separate shutoff: fishing
stops when the stock is assessed below 20% of unfished SSB. See
?build_hcr for the available rules and reference
points.
em <- Rceattle::fit_mod(
data_list = nrdata,
estimateMode = 0, # Estimate
initMode = 1, # Assume unfished equilibrium
M1Fun = build_M1(
M1_model = "sex_age_invariant",
linkages = list(
M1 = linkage_spec(
formula = ~ 1,
priors = list(
"(Intercept)" = lognormal(log(0.06), 0.05)
)
)
)
),
HCR = build_hcr(HCR = "NPFMC", # Tier3 HCR
Ftarget = 0.4, # F40%
Flimit = 0.35, # F35%
Plimit = 0.2, # No fishing when SB<SB20
Alpha = 0.05),
fit_control = fit_control(verbose = 1, phase = TRUE)
)Running the MSE
run_mse() projects the OM, samples data every
sampling_period years, re-fits the EM every
assessment_period years, and applies the EM’s HCR to the
OM. nsim sets the number of stochastic trajectories.
Parameters you fixed in the EM’s map that Rceattle would otherwise
estimate stay fixed at each re-fit, and run_mse() reports
how many; see ?run_mse for years after the EM’s
endyr and what does not carry forward.
Check endyr before you start
The OM and the EM must share a terminal year and a projection horizon; mismatched years are refused.
Every year after endyr is a projection year whose catch
the control rule sets, so catch recorded past endyr is
blanked to NA at setup and run_mse() warns and
names the years. That warning almost always means endyr has
fallen behind the data, which the likelihood scores only for
Year <= endyr. To condition the assessment on those
years, move endyr up and refit both models; leave it, and
the MSE simulates those years instead.
Reproducibility
-
seed(default 666) sets the draws inside each simulated trajectory (recruitment, observation error, composition resampling): simulationsimcallsset.seed(seed + sim), so simulation1uses seed667. The same call with the sameseedreproduces the trajectories bit-for-bit, with noset.seed()needed beforehand. -
regenerate_seed(defaults toseed) sets the one observation-error draw in the optionalregenerate_past = TRUEstep, shared by every simulation; undersimulate_data = FALSEthat step uses the OM’s expected values.
Reproducibility holds within a package version, not across one:
-
5.9.0 and 5.18.0 move the
random-number stream for every seeded
run_mse(simulate_data = TRUE), so a seeded run from before either does not reproduce after it; 5.9.0 also moves a seededself_test(). -
5.13.0 is a boundary only for a run using a scalar
cap, or one whose control rule reads reference points from an estimated stock-recruit curve. -
5.70.4 changes a seeded
run_mse(regenerate_past = TRUE, simulate_data = TRUE).
simulate_data = FALSE is unaffected by 5.9.0 and 5.18.0.
The stream position is data-dependent, so changing an unrelated
covariance or composition sample size moves everything drawn after it.
sim_mod() redraws stomach contents only where suitability
is estimated; run_mse() always keeps the observed ones.
For management-facing runs, save
packageVersion("Rceattle") and the seed with
the .rds.
Evaluating the MSE with plots
The OM’s SSB depletion across simulations shows the range of stock trajectories the strategy produces.
plot_ssb_depletion(lapply(mse1, function(x) x$OM))
plot_ssb_depletion(
c(mse1$Sim_1$EM, # EMs
list(mse1$Sim_1$OM, # OM
mse1$Sim_1$OM_no_F # OM with no fishing after the original OM's endyr
)),
line_col = c(
paste0("grey", round(seq(80, 50, length.out = 15))),
1, 3
)
)Summary statistics
mse_summary() reduces the trajectories to performance
statistics. It returns a list: $species (one row per
species), $fleet (one row per fishery fleet),
$total (a named vector across the whole system), and
$meta (the number of simulations, species and fishery
fleets, and the harvest control rule).
mse_summ <- mse_summary(mse1)
names(mse_summ)
knitr::kable(mse_summ$species, digits = 2)
knitr::kable(mse_summ$fleet, digits = 2)In the metric columns (avg_catch,
catch_iav, om_p_overfishing,
em_p_overfished, …), om_ is what the operating
model did and em_ what the estimation model believed;
p_overfishing_false_pos and its siblings are where the two
disagree.
Alternative scenarios
The runs below vary the reference points, the survey frequency, the
assessment interval with sampling effort, and the environment
(mse5 is mse4 with a climate-linked OM), for
comparison against mse1.
Different reference points
Here the EM uses a more aggressive rule: an F30% target, an F10%
limit, and Plimit = 0, so there is no SB0-based shutoff; F
still reaches zero below Alpha = 0.1 of B30%.
em2 <- Rceattle::fit_mod(
data_list = nrdata,
estimateMode = 0, # Estimate
initMode = 1, # Assume unfished equilibrium
M1Fun = build_M1(
M1_model = "sex_age_invariant",
linkages = list(
M1 = linkage_spec(
formula = ~ 1,
priors = list(
"(Intercept)" = lognormal(log(0.06), 0.05)
)
)
)
),
HCR = build_hcr(HCR = "NPFMC", # Tier3 HCR
Ftarget = 0.30,# F30%
Flimit = 0.10, # F10%
Plimit = 0, # No limit
Alpha = 0.1),
fit_control = fit_control(verbose = 1, phase = TRUE)
)
mse2 <- run_mse(
om = om, em = em2,
nsim = 10,
assessment_period = 2,
sampling_period = c(2, 1) # BTS = fleet 1, Fishery = fleet 2
)Triennial bottom-trawl survey
sampling_period = c(3, 1) samples the bottom-trawl
survey (BTS, fleet 1) only every third year and the fishery (fleet 2)
every year.
mse3 <- run_mse(
om = om, em = em,
nsim = 10,
assessment_period = 2,
sampling_period = c(3, 1) # BTS = fleet 1, Fishery = fleet 2
)4-year assessment cycle and reduced survey coverage
The EM is re-fitted only every fourth year
(assessment_period = 4), and fut_sample = 0.5
halves future sampling effort on both data streams: composition sample
sizes are halved and the index log-SD is doubled
(Log_sd * 1 / fut_sample).
mse4 <- run_mse(
om = om, em = em,
nsim = 10,
fut_sample = 0.5,
assessment_period = 4,
sampling_period = c(2, 1) # BTS = fleet 1, Fishery = fleet 2
)A missed assessment, and a buffer while advice is stale
The scenarios above set a period. For one skipped assessment
in an otherwise regular cycle, assessment_period also takes
the schedule itself, as a vector of the years an assessment is
completed. A period is a permanent policy whose cost compounds; one
missed assessment is a single episode of stale advice, whose cost
depends on the stock’s state when the gap opens.
biennial <- seq(om$data_list$endyr + 2, om$data_list$projyr, by = 2)
miss_yr <- biennial[ceiling(length(biennial) / 3)]
mse6 <- run_mse(
om = om, em = em,
nsim = 10,
assessment_period = setdiff(biennial, miss_yr), # every year but miss_yr
sampling_period = c(2, 1)
)To pair the gap with a precautionary reduction, give
catch_mult a data.frame of Year,
Species (the species number) and mult; any
pair the table omits is multiplied by 1.
The assessment in year Y sets catch for Y+1
onward, so a missed assessment leaves the two years after
it on the previous assessment’s advice, not the missed year
itself, which the previous assessment sets in the baseline too.
schedule <- setdiff(biennial, miss_yr)
# The years the missed assessment would have set: from the year after it,
# through the next assessment that was completed.
gap_yrs <- (miss_yr + 1):min(schedule[schedule > miss_yr])
# 10% reduction, held for exactly those years.
buffer <- expand.grid(Year = gap_yrs, Species = seq_len(om$data_list$nspp))
buffer$mult <- 0.90
mse7 <- run_mse(
om = om, em = em,
nsim = 10,
assessment_period = schedule,
sampling_period = c(2, 1),
catch_mult = buffer
)Compare these with a baseline that differs only in the
schedule (same om, em and seed),
as paired within-replicate differences. Schedules on the same
seed share their recruitment deviations, and each
assessment’s observation draws are seeded on that assessment’s own year,
so an assessment in year Y starts from the same place in
every schedule that assesses Y.
Common random numbers are not complete, though. One
sim_mod() call draws every year in the assessment interval
under that assessment’s seed, so two schedules that differ in which
years they assess realize different observation error in the years
between, even where the stock is in the same state. The paired
difference is therefore mostly, but not entirely, the schedule; size the
replicate count accordingly. Once two schedules genuinely diverge
(different catch taken, different years surveyed), their draws diverge
too, which is a real difference between the runs, not noise.
Make the last assessment year reach the projection horizon. Catch is
filled only up to the last assessment year, so a schedule that stops
short leaves the trailing years at NA, and
mse_summary() summarises over the whole projection, so it
understates average catch, catch IAV and P(Closed);
run_mse() warns when this happens. A biennial cycle over an
odd number of projection years always does this:
seq(2027, 2050, by = 2) ends at 2049 against a 2050
horizon.
catch_mult multiplies catch, not ABC. A real ABC
reduction changes removals only to the extent the fishery attains ABC,
so either scale the multiplier by recent attainment,
1 - (1 - mult) * attainment, or report the unscaled result
as an upper bound on the effect of the reduction.
Climate-linked MSE
Here OM recruitment (via R0) tracks a steadily rising
environmental covariate, so the OM’s productivity shifts over time while
the EM keeps assuming stationary recruitment.
Climate-linked OM
# Generate random env data
projyrs <- nrdata$styr:nrdata$projyr
projnyrs <- length(projyrs)
# Env data
# Build the table over styr:projyr so the trend runs into the projection;
# years past the last row would take a zero offset.
nrdata$env_data <- data.frame(Year = projyrs,
EnvIndex = seq(0, 1, length.out = projnyrs))
# Fit OM
om2 <- Rceattle::fit_mod(
data_list = nrdata,
estimateMode = 0, # Estimate
initMode = 1, # Assume unfished equilibrium
M1Fun = build_M1(
M1_model = "sex_age_invariant",
linkages = list(
M1 = linkage_spec(
formula = ~ 1,
priors = list(
"(Intercept)" = lognormal(log(0.06), 0.05)
)
)
)
),
recFun = build_srr(
srr_fun = "mean", # Mean R with covariates
proj_mean_rec = FALSE,
linkages = list(
R0 = linkage_spec(formula = ~ EnvIndex)
)),
fit_control = fit_control(phase = TRUE)
)
plot_biomass(om2, incl_proj = TRUE)Overall summary
To put the strategies side by side, label one entity of each summary
(here $species) and stack those, not the whole list.
stack_species <- function(x, label) {
out <- x$species
out$MSE <- label
out
}
knitr::kable(
rbind(stack_species(mse_summary(mse1), 1),
stack_species(mse_summary(mse2), 2)) |>
dplyr::relocate(MSE),
digits = 2)