# Derived-output definitions and reproducible interpretation

These notes refer to the frozen `source/jjm2.tpl` for the h1_1.06 single-stock base model. Source and prepared files are read-only to this postprocessing workflow.

- `write_mceval` (lines 1975–2049) writes six fields: draw, type, unit, year, age, value. The unit is a stock number for stock outputs, fleet number for fishery outputs and index number for survey outputs. Its header (lines 4325–4326) omits that unit field and has only five headings; `summarize-derived.R` deliberately skips it and supplies all six names.
- SSB is `Sp_Biom(k,i)` (line 1992), calculated as numbers at age times survival to spawning times population weight times maturity (line 2638; weight and maturity combined at lines 1124–1130). Values are retained in **thousand tonnes (kt)**. Recruitment is `recruits(k,i)` (line 1994), assigned from the first population age (line 2773), which is **age 1** (`source/1.06.dat`, lines 4–6). Values are **million fish**. The canonical current report code explicitly labels these native quantities as SSB in `'000 t` and age-1 recruitment in millions: `/Users/jim/_mymods/sprfmo/jjm/doc/annex/constructor_input_tables.R`, lines 85–91; matching captions are in `doc/annex/annex_plots.qmd`, line 283. The weight captions in the same file, lines 75 and 82, use kg. Thus million fish times kg yields thousand tonnes. `write_mceval` retains the native model units.
- `Depletion` is **terminal total biomass divided by initial-year total biomass**, specifically 2026/1970 (template line 2787). `Dynamic_Depletion` is **terminal total biomass divided by terminal dynamic no-fishing total biomass** (line 2788). The no-fishing trajectory starts from the fitted initial numbers; subsequent recruitment is multiplied by the stock-recruit function ratio for no-fishing versus fished SSB (lines 2768–2783). Both outputs describe total-biomass ratios; Kobe coordinates use the separately defined SSB and MSY reference quantities.
- The emitted `Fbar` is `mfexp(fmort(k,i))` (line 1993), while the actual stock `Fbar` variable is an abundance-weighted ages-2–5 mean of summed fleet F (line 2833). For this one-stock model the emitted field uses the first fleet parameter. It is excluded from stock-F interpretation and plots.
- The file also emits MSY, SBMSY, FMSY, R0, B0, annual SBMSYy, stock numbers at age, fishery selectivity, catch numbers at age, F at age, a fishery F index, survey catchability, predicted indices and survey selectivity. The inventory records each native output type. `SBMSYy` is recalculated via `get_msy_robust(i)` inside the draw's annual loop (lines 1997–1999); the Kobe methods document the verified recent-average biomass reference and annual FMSY convention.

## Original fitted mode and uncertainty

Use `prepared/For_R_1.rep` for the mode trajectory; the preparation reran the same saved parameter vector without estimation, and the script checks that source and prepared objective values agree within 1e-6. The file's `$SSB` block contains 2026 SSB **6108.87 kt**, and `$R` contains 2026 recruitment **5559.86 million fish**. The plain `source/h1_1.06.rep` stock-recruit table reports SSB from **year minus recruitment age** (template lines 4564–4570), so its row labelled 2026 is 2025 SSB and is unsuitable as the terminal SSB comparator.

The prepared report provides SD and limits obtained by multiplying/dividing the mode by `exp(2 * sqrt(log(1 + CV^2)))` (template lines 6115–6126). Those limits use two standard errors in a lognormal approximation; they are kept explicitly labelled `mode_lower_2se`/`mode_upper_2se`, separate from empirical MCMC 2.5th–97.5th percentile intervals.

## Draw ordering and diagnostics

The expected complete pooled PSV contains 1000 post-warmup draws from chain 1, then 1000 from chain 2, then 1000 from chain 3. The postprocessor requires all draw IDs 1–3000, unique selected quantity/draw rows, all 1970–2026 SSB and recruitment years, age-1 recruitment and finite values. It reconstructs three chains from this known order and computes rank-normalized R-hat, bulk ESS, tail ESS and Monte Carlo SE of the mean using `posterior`. A derived-quantity screen flags R-hat above 1.01 or either ESS below 400. Full-model convergence assessment combines the derived screens with parameter, divergence, tree-depth and energy diagnostics.

All plots label retained-sample intervals. When the full run needs further convergence checks, these intervals are **diagnostic sample quantiles**. Further sampling and validation are needed to support reliable posterior uncertainty for management inference. This script summarizes historical SSB and recruitment; the supplemental Kobe workflow provides historical reference-point ratios.

## One-draw execution benchmark

`mceval-benchmark/` contains a single first saved row copied from chain 1 while sampling was still in warmup. It exists solely to verify output parsing and execution time, and is excluded from inference. The PSV contains a four-byte integer header (1593 parameters) followed by 1593 doubles.

The command `./jjm2 -nox -ind h1_1.06.ctl -mceval -nohess -fut_sel 3` completed with exit 0 in 0.11 s wall time (0.07 s user time), producing 13,768 data records, 20 types and 376,875 bytes. A 3000-draw output is approximately 1.14 GB; multiplying the one-draw wall time gives about 5.5 minutes, an approximate conservative estimate because startup is included. The script's parser verified all types, finite values, 57 SSB years, 57 recruitment years and age-1 recruitment. Synthetic IID and separated-chain inputs also verified the rank-R-hat/ESS screen behaves in the expected direction.

Without `-nohess`, the same complete draw was written but the executable then exited with `Attempting to take the derivative of sqrt(prevariable x) at x=0` in final reporting. The template always calls `Profile_F` in `FINAL_SECTION`, then calls `Write_R` only when `do_hess == 0` (lines 4941–4949). The `-nohess` switch sets `do_hess = 1` (lines 78–80), suppressing that final SD-based report. The mceval draw calculations remain unchanged. Use `-nohess` during pooled posterior evaluation, and retain the successful original prepared `For_R_1.rep` for mode comparison.
