Title: | Graphics and diagnostics tools for SPRFMO's Joint Jack Mackerel model |
---|---|
Description: | Graphics and diagnostics tools for SPRFMO's Joint Jack Mackerel model. |
Authors: | Ricardo Oliveros-Ramos [cre, aut], Wencheng Lau-Medrano [aut], Giancarlo Moron [aut], Josymar Torrejon-Magallanes [aut], Niels Hintzen [aut], Enrique Ramos-Vasquez [ctb], Jim Ianelli [aut] |
Maintainer: | Ricardo Oliveros-Ramos <[email protected]> |
License: | GPL-2 |
Version: | 1.2020.1 |
Built: | 2025-03-03 05:19:51 UTC |
Source: | https://github.com/SPRFMO/jjmr |
This function internally replaces the name of a JJM output object with a user-specified string. Mostly useful for plots.
changeNameModel(modList, nameVector)
changeNameModel(modList, nameVector)
## Not run: recmods <- compareModels(c("mod1.00.hl","mod1.00.ll","mod1.00.hs","mod1.00.ls")) changeNameModel(recmods,c( "h=0.8, full series","h=0.8, short series","h=0.65, full series","h=0.65, short series" )) ## End(Not run)
## Not run: recmods <- compareModels(c("mod1.00.hl","mod1.00.ll","mod1.00.hs","mod1.00.ls")) changeNameModel(recmods,c( "h=0.8, full series","h=0.8, short series","h=0.65, full series","h=0.65, short series" )) ## End(Not run)
This function takes model objects (class outputs
) of JJM and generate an object
with combined models.
combineModels(...)
combineModels(...)
... |
One or more output objects, to be combined to list of models. |
## Not run: mod1 <- runJJM(modelName = "mod2.1") mod2 <- runJJM(modelName = "mod2.2") mod3 <- runJJM(modelName = "mod2.3") mod_123 = combineModels(mod1, mod2, mod3) ## End(Not run)
## Not run: mod1 <- runJJM(modelName = "mod2.1") mod2 <- runJJM(modelName = "mod2.2") mod3 <- runJJM(modelName = "mod2.3") mod_123 = combineModels(mod1, mod2, mod3) ## End(Not run)
This function takes a vector of model names, reads in the JJM runs, and combines them.
Basically a wrapper function for combineModels
.
Assumes model runs are in the same folder.
compareModels(mods)
compareModels(mods)
## Not run: mod_123 = compareModels(c("h1_0.00", "h1_0.01", "h1_0.02") ## End(Not run)
## Not run: mod_123 = compareModels(c("h1_0.00", "h1_0.01", "h1_0.02") ## End(Not run)
Function to generate plots from results of readJJM function
diagnostics(object, ...)
diagnostics(object, ...)
object |
Object ob class outputs. |
... |
Extra arguments |
## Not run: model = readJJM(modelName = "mod2.4") diagnostics(object = model) ## End(Not run)
## Not run: model = readJJM(modelName = "mod2.4") diagnostics(object = model) ## End(Not run)
Calculate or input a fixed Bmsy value for the jjm model Updates the msy_mt table in the jjm output with new B/Bmsy ratios.
fixed_bmsy(mod, refpt = NULL)
fixed_bmsy(mod, refpt = NULL)
mod |
jjm object that is a list of lists |
refpt |
A number to input as Bmsy. If not filled, calculated as the average of the Bmsy estimated for the last ten years (as determined in SCW14 benchmark 2022) |
A model
# fixed_bmsy(mod_h1_1.00, refpt=5500) # To input a fixed Bmsy # fixed_bmsy(mod_h1_1.00) # To calculate the Bmsy
# fixed_bmsy(mod_h1_1.00, refpt=5500) # To input a fixed Bmsy # fixed_bmsy(mod_h1_1.00) # To calculate the Bmsy
Get fits to indices
get_age_fits(models)
get_age_fits(models)
models |
an object of class jjm.output |
a tidy dataframe of age fits
Get estimated catchability coefficients
get_catchabilities(models)
get_catchabilities(models)
models |
an object of class jjm.output |
a data frame of estimated catchabilities
Get fishing mortality at age
get_fishing_mortality(models)
get_fishing_mortality(models)
models |
an object of class jjm.output |
a tidy dataframe of fishing mortality at age
Get fits to indices
get_index_fits(models)
get_index_fits(models)
models |
an object of class jjm.output |
a tidy dataframe of index fits
Get fits to length compositions
get_len_fits(models)
get_len_fits(models)
models |
an object of class jjm.output |
a tidy dataframe of length composition fits
Get and tidy msy_my table
get_msy_mt(models)
get_msy_mt(models)
models |
series of class jjm.output |
a tidy msy_mt
## Not run: mod0.00 <- readJJM("h2_0.00", path = "config", input = "input") get_msy_mt(mod0.00) ## End(Not run)
## Not run: mod0.00 <- readJJM("h2_0.00", path = "config", input = "input") get_msy_mt(mod0.00) ## End(Not run)
Get estimated recruits
get_recruits(models)
get_recruits(models)
models |
an object of class jjm.output |
a tidy dataframe of recruits
Get and tidy selectivity-at-age ogives over time by model and fleet
get_selectivities(models)
get_selectivities(models)
models |
an object of class jjm.output |
a tidy data frame of selectivity estimates
## Not run: h1.mod <- jjmR::readJJM("h2_0.02", path = "config", input = "input") selectivities <- get_selectivities(h1.mod) ## End(Not run)
## Not run: h1.mod <- jjmR::readJJM("h2_0.02", path = "config", input = "input") selectivities <- get_selectivities(h1.mod) ## End(Not run)
Get total metrics (biomass, spawning biomass, and recruitment)
get_totals(models)
get_totals(models)
models |
an object of class jjm.output |
a dataframe of total values
Add hypothesis number to a model name
geth(mod, h = hyp)
geth(mod, h = hyp)
mod |
A character string of a model name. |
h |
A character string containing the hypothesis to use. |
A character string containing the hypothesis name and the model name.
geth("1.00", "h1")
geth("1.00", "h1")
Get elements of a list by string matching on name
getter(x, pattern = "^sel_", things = NA)
getter(x, pattern = "^sel_", things = NA)
x |
the object |
pattern |
the string pattern (regex supported) to search for |
an object subset to matches in names with strings
This function create a kobe plot from JJM model outputs
kobe( obj, add = FALSE, col = "black", stock = 1, Bref = 1, Fref = 1, Blim = Bref, Flim = Fref, xlim = NULL, ylim = NULL, engine = "ggplot", ... )
kobe( obj, add = FALSE, col = "black", stock = 1, Bref = 1, Fref = 1, Blim = Bref, Flim = Fref, xlim = NULL, ylim = NULL, engine = "ggplot", ... )
obj |
a jjm model outputs object. |
add |
boolean, add to an existing kobe plot? |
col |
color for the lines and points. |
stock |
Number of the stock chosen for the kobe plot. |
Bref |
Reference point for B/B_MSY, default=1. |
Fref |
Reference point for F/F_MSY, default=1. |
Blim |
Limit reference point for B/B_MSY, default=0.5. |
Flim |
Limit reference point for F/F_MSY, default=1.5. |
xlim |
'x' axis limits. |
ylim |
'y' axis limits. |
... |
Additional parameters passed to plot. |
## Not run: kobe(model) ## End(Not run)
## Not run: kobe(model) ## End(Not run)
Plot selectivities by age, year, fleet, and model
plot_selectivities( sels, fleet = "fsh", alpha = 0.4, scale = 4, size = 0.5, years = "all" )
plot_selectivities( sels, fleet = "fsh", alpha = 0.4, scale = 4, size = 0.5, years = "all" )
sels |
selectivity data frame generated by |
fleet |
fleets to plot: "fsh" (fishery), "ind" (survey), or "all" (both) |
a ggplot2 plot object
## Not run: oldnewMods <- combineModels(mod0.00,mod_prev) selectivities <- get_selectivities(oldnewMods) plot_selectivities(selectivities) ## End(Not run)
## Not run: oldnewMods <- combineModels(mod0.00,mod_prev) selectivities <- get_selectivities(oldnewMods) plot_selectivities(selectivities) ## End(Not run)
Read external files
readExFiles( fileName, type, path = NULL, version = "2015MS", parameters = FALSE, parData, nameFishery, nameIndex, nAges, nStock = NULL )
readExFiles( fileName, type, path = NULL, version = "2015MS", parameters = FALSE, parData, nameFishery, nameIndex, nAges, nStock = NULL )
fileName |
filename |
type |
type |
path |
path |
version |
version of JJM, default to "2015MS" (2015 SC multi-stock). |
parameters |
parameters |
parData |
parData |
nameFishery |
nameFishery |
nameIndex |
nameIndex |
nAges |
nAges |
nStock |
nStock |
Function to read models and list if models and generate results
readJJM( model, path = NULL, output = "results", input = NULL, version = "2015MS", ... )
readJJM( model, path = NULL, output = "results", input = NULL, version = "2015MS", ... )
model |
String with the name of model that will be readed or run. |
path |
Directory where the 'admb' folder is located. |
output |
Path to the model outputs directory. |
input |
Path to model inputs directory. |
version |
version of JJM, default to "2015MS" (2015 SC multi-stock). |
... |
Extra arguments |
## Not run: readJJM(model = "mod2.4") ## End(Not run)
## Not run: readJJM(model = "mod2.4") ## End(Not run)
Store in an R object (of class jjm.config) the dat and ctl files needed to run a model.
readJJMConfig(model, path, input = NULL, ...)
readJJMConfig(model, path, input = NULL, ...)
model |
Model object or outputs |
path |
Path to the ctl file |
input |
Path to the input files |
... |
Additional arguments passed to other functions. |
## Not run: readJJMConfig(mod1) ## End(Not run)
## Not run: readJJMConfig(mod1) ## End(Not run)
Function to create and save reports in PDF and MS Word formats.
report(object, format, output, tangle = FALSE, tidy = TRUE, ...)
report(object, format, output, tangle = FALSE, tidy = TRUE, ...)
object |
The object to create the report with, can be of classes
'jjm.output' or 'jjm.diag' as created with |
format |
Format for the report: either "pdf", "html" or "word". |
output |
Path to save the report, by default the working directory. |
tangle |
Boolean, if TRUE the R script to create the report is produced. |
tidy |
Boolean, if TRUE the intermediate files (Rmd, tex) are deleted. |
... |
Extra arguments |
## Not run: report(mod0.0) ## End(Not run)
## Not run: report(mod0.0) ## End(Not run)
Run a retrospective analysis for a model
retro( model, n = 5, output = "results", exec = NULL, parallel = FALSE, temp = NULL, wait = TRUE, iprint = 100, ... )
retro( model, n = 5, output = "results", exec = NULL, parallel = FALSE, temp = NULL, wait = TRUE, iprint = 100, ... )
model |
An object of class jjm.output |
n |
Number of years to run a retrospective analysis. |
output |
Path to save results. |
exec |
Path to JJM executable file. |
parallel |
Boolean flag to run models in parallel. |
temp |
Folder to run retrospective analysis. If NULL, a temporal folder is used. |
wait |
Boolean, passed to runJJM, should we wait for the parameter estimation? |
iprint |
Command line argument passed to jjm. |
... |
Additional arguments passed to other functions. |
## Not run: retro(mod1) ## End(Not run)
## Not run: retro(mod1) ## End(Not run)
Shortcut to fit, run, read and plot a JJM model
runit( mod, est = FALSE, exec = NULL, path = "config", input = "input", output = "results", version = "2015MS", pdf = FALSE, portrait = TRUE, ... )
runit( mod, est = FALSE, exec = NULL, path = "config", input = "input", output = "results", version = "2015MS", pdf = FALSE, portrait = TRUE, ... )
mod |
A character specifying the name of a model (by it's ctl filename). |
est |
Boolean, should we run the parameter estimation for a model? |
exec |
Path to the JJM executable file. By default, 'jjms' will be used. |
path |
Directory where the configuration files will be written. |
input |
Input |
output |
Folder to save the outputs, 'arc' by default. |
version |
version of JJM, default to "2015MS" (2015 SC multi-stock). |
pdf |
Produce outputs in a pdf file? |
portrait |
Orientation of the pdf output, default TRUE. |
## Not run: writeJJM(mod1) ## End(Not run)
## Not run: writeJJM(mod1) ## End(Not run)
Function to run one or several JJM models
runJJM( models, path = NULL, output = "results", input = NULL, exec = NULL, version = NULL, useGuess = FALSE, guess = NULL, piner = NULL, iprint = 100, wait = TRUE, parallel = FALSE, temp = NULL, ... )
runJJM( models, path = NULL, output = "results", input = NULL, exec = NULL, version = NULL, useGuess = FALSE, guess = NULL, piner = NULL, iprint = 100, wait = TRUE, parallel = FALSE, temp = NULL, ... )
models |
String with the name of the models to be run. |
path |
Directory where the 'admb' folder is located. |
output |
Folder to save the outputs, 'arc' by default. |
input |
Input |
exec |
Path to the jjm executable |
version |
version of JJM, default to "2015MS" (2015 SC multi-stock). |
useGuess |
boolean, to use an initial guess for the parameters? |
guess |
File with the initial guess for the parameters. If |
piner |
A number to start the profiling on the meanlogrec |
iprint |
iprint parameter for the JJM model, 100 by default. |
wait |
boolean, wait for the model to finish? Forced to be TRUE. |
parallel |
Should model run in parallel? A cluster need to be setup to be used with foreach. |
temp |
character, path for a temporal directory to run models, if |
... |
Arguments passed from |
## Not run: model = runJJM(models = "mod2.4") ## End(Not run)
## Not run: model = runJJM(models = "mod2.4") ## End(Not run)
ggplot2 theme for jjmR
theme_jjm(base_size = 14, ...)
theme_jjm(base_size = 14, ...)
... |
a ggplot2 theme object
library(ggplot2) ggplot(mtcars, aes(mpg)) + geom_histogram() + theme_jjm()
library(ggplot2) ggplot(mtcars, aes(mpg)) + geom_histogram() + theme_jjm()
Tidy results of JJM model
tidy_JJM(models)
tidy_JJM(models)
models |
an object of class jjm.output |
a list of tidy dataframes
## Not run: mod0.00 <- readJJM("h2_0.00", path = "config", input = "input") tidy_jjm_results <- tidy_JJM(mod0.00) ## End(Not run)
## Not run: mod0.00 <- readJJM("h2_0.00", path = "config", input = "input") tidy_jjm_results <- tidy_JJM(mod0.00) ## End(Not run)
Function write to the disk dat and ctl files
writeJJM(object, path, ...)
writeJJM(object, path, ...)
object |
An object of class jjm.config or jjm.output. |
path |
Directory where the configuration files will be written. |
... |
Additional arguments |
## Not run: writeJJM(mod1) ## End(Not run)
## Not run: writeJJM(mod1) ## End(Not run)