This repository contains:
- a script to go from raw data (MCMC samples usually; stored locally) to cleaned and processed data (
data-raw-process/process-raw-data.R
) - the processed data sets themselves as
.rds
files (data-generated
) - the model in Stan
analysis/rw-ss.stan
- a simulation test of the model (
analysis
) - code to fit the model and make figures (
analysis
) - text for the preprint (
preprint
)
- Use the
data-raw/process-raw-dat.R
file to clean any newly added/updated assessment data (raw data can be placed indata-raw/model-output
). This script saves outputs as:data-raw/species-region-mcmc.rds
, where species name is often abbreviated- Contact people for the latest MCMCs of the biomass trend and Bmsy (or other LRP and USR MCMC's). LRP and USR are generally 0.4 * Bmsy and 0.8 * Bmsy (e.g., see: A fishery decision-making framework incorporating the precautionary approach) or some fraction of B_0 or historical biomass. Double check the stock assessment document to confirm.
- For example: Bmsy is not used for Arrowtooth Flounder e.g., see pg 5, Pacific Cod e.g., see pg 4, and Walleye Pollock e.g., see pg 3
If the LRP and USR are based on fractions of Bmsy, process new data to get dataframe of the format:
year | b | bmsy | run | lrp | usr | species | region | iter |
---|---|---|---|---|---|---|---|---|
2018 | 1370 | 523 | 1 | 209 | 418 | pacific-ocean-perch | 3CD | 1 |
2019 | 1400 | 523 | 1 | 209 | 418 | pacific-ocean-perch | 3CD | 1 |
2020 | 1530 | 523 | 1 | 209 | 418 | pacific-ocean-perch | 3CD | 1 |
If the LRP and USR are not based on fractions of Bmsy, the dataframe will look like this:
year | blrp | busr | iter | species | region | run |
---|---|---|---|---|---|---|
1918 | 7.26 | 3.63 | 1 | quillback | 4B | 1 |
1918 | 9.00 | 4.50 | 2 | quillback | 4B | 1 |
1918 | 8.34 | 4.17 | 3 | quillback | 4B | 1 |
- If there is no
run
column, you will need to add a placeholder, e.g.,mutate(run = 1)
-
Add any new stocks (if any) to the
analysis/stock_df.R
anddata-raw/species-regions-tofit.csv
(see Section C) -
Update the
data-raw/last-assess-years.csv
, grab the info from the latest stock assessments/stock assessment drafts in review.
The scripts contained in analysis
summarise the assessment data. The following scripts should be run in order (as numbered) and should not need to be modified year to year. With the exception of updating end_year
in analysis/01-stitch-data.R
L.5 and analysis/stock_df.R
.
-
analysis/01-stitch-data.R
can be run once the mcmc data files have been updated, collates the processed assessment data. UPDATE THEend_year
on L5. This script also outputs a figure that you can use to check that all the B status ratios loaded properly and were updated properly before you fit the Stan model. -
analysis/02-fit-models.R
compiles and fits the Stan model. -
analysis/03-plot-models.R
plots model fits of the assessment time-series. -
analysis/04-ridges.R
plots posterior distributions of estimated biomass over limit reference points -
analysis/05-combine-plots
--> archive -
analysis/06-values.R
--> archive
The scripts contained in analysis-survey
summarise the survey data. The following scripts should be run in order (as numbered) and should not need to be modified year to year.
If new species or assessment regions are added, you will need to update:
data-raw/species-regions-tofit.csv
and analysis-survey/get-all-spp.R
.
-
analysis-survey/00-get-all-spp.R
is run to get the latest data on all the species of interest. This list may or may not need to be updated. Note this queries GFBio and will need to access to the DFO network. -
analysis-survey/02-render-indices.R
analysis-survey/01-index-new-deltas.Rmd
is not manually run. It generates html files for each species and fits the delta-gamma model. If the delta-gamma fails to converge, the Tweedie is then fit. In 2023 all delta-gamma models converged.analysis-survey/00-make-grids.R
is also sourced by02-render-indices.R
. If prediction grids are updated this can be done here.
-
analysis-survey/03-calc-slopes.R
calculates the slopes of indices since 2000 so they can be ordered in Figure 3. -
analysis-survey/04-join.R
joins the assessment data with survey indices and scales by the geometric mean. -
analysis-survey/05-plot-assess-surveys.R
plots the latest assessments overlaid with the survey indices by species-region. -
analysis-survey/06-sopo-text.Rmd
can be rendered to get an updated draft. Values used in the text are calculated at the top of the document, use those and manually update last year's word document (update with what SOPO sends as the template/version from the previous year), or choose to use the markdown document. Currently, references are not included and are added manually. -
analysis-survey/06-plot-presentation-figs.R
generates the figures for the presentation.