THIS PACKAGE IS UNDER ACTIVE DEVELOPMENT AND SHOULD NOT BE USED FOR INDIVIDUAL STOCK ASSESSMENT AT THIS TIME
sraplus
is a flexible assessment package based around Ovando et
al. 2019. At the most “data limited” end, the model approximates the
behavior of catch-msy, sampling from prior distributions to obtain
parameter values that given a catch history do not crash the population
and are match supplied priors on initial and final depletion. At the
most data rich end the model the model can fit to an abundance index
with priors on fishing mortality over time and initial and final
depletion.
This is an in-development package hosted on github, so you will need to do a few things to install it.
-
open R
-
If you don’t have the
devtools
package installed yet, run
install.packages("devtools")
You’ll need to be connected to the internet.
- Once
devtools
has been installed, you can then installsraplus
by running
devtools::install_github("danovando/sraplus")
That’s probably going to ask you to install many other packages, agree to the prompts.
Make sure you try the install with a fresh R session (go to “Session>Restart R” to make sure)
If you run into an error, first off try updating your R packages. From there….
If your version of R is lower than 3.5, you might want to consider updating R itself. Updating from 3.3 to 3.5 shouldn’t be any hassle. BIG WARNING THOUGH, updating from say R 2.9 to 3.5 is a major update, and you’ll lose all your installed packages in the process. I recommend following the instructions here to deal with that, but even with that fix it can take a while, so I don’t recommend doing a major R update if you’re on a deadline.
From there…
-
On Windows, make sure you have the appropriate version of Rtools installed (here), most likely Rtools35 if you have R version 3.3 or higher
-
On macOS, there might be some issues with the your compiler. If you get an error that says something like
clang: error: unsupported option '-fopenmp'
, follow the instructions here
Once you’ve tried those, restart your computer and try running
install.packages("devtools")
devtools::install_github("danovando/sraplus")
again
Once you’ve successfully installed sraplus
you can take for a test
drive with these examples.
For the first example we’ll run use a sampling-importance-resampling (SIR) algorithm, using fisheries management index scores and swept area ratio data to provide priors on B/Bmsy and U/Umsy in the final year
library(sraplus)
library(ggplot2)
library(dplyr)
example_taxa <- "gadus morhua"
data(cod)
driors <- format_driors(
taxa = example_taxa,
catch = cod$catch,
years = cod$year,
initial_b = 1,
initial_b_sd = 0.2,
terminal_b = 0.75,
terminal_b_sd = 1,
use_heuristics = FALSE,
sar = 2,
fmi = c("research" = 0.5,"management" = 0.8, "enforcement" = 0.75, "socioeconomics" = .67),
)
plot_driors(driors)
sir_fit <- fit_sraplus(driors = driors,
use_sir = TRUE,
draws = 1e6)
plot_sraplus(sir_fit = sir_fit)
We’ll now use maximum likelihood to fit to the same fishery, but now using an index of abundance and a swept area ratio as a penalty on U/Umsy in the final year
driors <- format_driors(
taxa = example_taxa,
catch = cod$catch,
years = cod$year,
index = cod$index,
index_years = cod$year,
initial_b = 1,
initial_b_sd = 0.01,
terminal_b = 0.5,
sar = 2,
sar_sd = 0.1
)
plot_driors(driors)
ml_fit <- fit_sraplus(driors = driors,
use_sir = FALSE,
model = "sraplus_tmb")
And we can now compare the two results
plot_sraplus(sir_fit = sir_fit, ml_fit = ml_fit)