Package 'ss3diags'

Title: Stock Synthesis Model Diagnostics for Intergated Stock Assessments
Description: Compilation of diagnostic functions for Stock Synthesis models, which developed for the manuscript "Using Model Diagnostics in Integrated Stock Assessments".
Authors: Henning Winker [aut], Felipe Carvalho [aut], Massimiliano Cardinale [aut], Laurence Kell [aut], Megumi Oshima [aut, cre], Eric Fletcher [aut]
Maintainer: Megumi Oshima <[email protected]>
License: EUPL
Version: 2.2.1
Built: 2024-11-20 03:39:14 UTC
Source: https://github.com/PIFSCstockassessments/ss3diags

Help Index


Francis Weighting for compositional data

Description

TA1.8 Francis function modified from r4ss::SSMethod.TA1.8 and r4ss::SSMethod.Cond.TA1.8 apply Francis weighting method TA1.8 to length-, age-, generalized size-composition data, or conditional age-at-length data from a Stock Synthesis model. For conditional age-at-length data, the mean age by year is calculated based on recommendations by Punt (2015). The main purpose is to create a dataframe of the annual observed and expected mean length or age for each fleet that is used to calculate residuals for testing model fit. This function is used in SSplotRunstest and SSplotJABBAres.

Usage

SScompsTA1.8(
  ss3rep,
  type = c("len", "age", "size", "con"),
  fleet = NULL,
  seas = NULL,
  plotit = FALSE,
  maxpanel = 1000
)

Arguments

ss3rep

Stock Synthesis output as read by r4SS function SS_output

type

string of either 'len' (for length composition data), 'size' (for generalized size composition data), 'age' (for age composition data), or 'con' (for conditional age at length data)

fleet

vector of one or more fleet numbers whose data are to be analysed simultaneously, if NULL, all fleets will be analysed

seas

string indicating how to treat data from multiple seasons 'comb' - combine seasonal data for each year and plot against Yr 'sep' - treat season separately, plotting against Yr.S. If is.null(seas), it is assumed that there is only one season and option 'comb' is used.

plotit

if TRUE, make an illustrative plot like one or more panels of Fig. 4 in Francis (2011).

maxpanel

maximum number of panels within a plot, default 1000

Value

ss_out data.frame of observed, predicted mean length/age and 95% confidence intervals based on stage 1 and stage 2 weighting

runs_dat data.frame of observed and predicted mean length or age for each year/fleet.

Author(s)

Chris Francis, Andre Punt, Ian Taylor (modified by Henning Winker and Meg Oshima)

References

Francis, R.I.C.C. (2011). Data weighting in statistical fisheries stock assessment models. Canadian Journal of Fisheries and Aquatic Sciences 68: 1124-1138.

#' Punt, A.E. (2015). Some insights into data weighting in integrated stock assessments. Fish. Res. <http://dx.doi.org/10.1016/j.fishres.2015.12.006


Joint Distributions for Stock Status Ratios

Description

A function to generate joint distributions for stock status ratios (SSB/SSBref and F/Fref where ref can be MSY, SSB40, F40, etc.) using a Multivariate Log-Normal Distribution. The function produces a Kobe plot, maximum likelihood estimates and the MVLN Monte-Carlo distributions of the Kobe values which can be input into SSplotEnsemble().

Usage

SSdeltaMVLN(
  ss3rep,
  Fref = NULL,
  years = NULL,
  mc = 5000,
  weight = 1,
  run = "MVLN",
  plot = TRUE,
  addprj = FALSE,
  ymax = NULL,
  xmax = NULL,
  legendcex = 1,
  verbose = TRUE,
  variance_method = "ww2019",
  bias_correct_mean = FALSE
)

Arguments

ss3rep

from r4ss::SS_output

Fref

Choice of Fratio c("MSY","Btgt"), correponding to F_MSY and F_Btgt

years

single year or vector of years for mvln

mc

number of monte-carlo simulations

weight

weighting option for model ensembles weight*mc

run

qualifier for model run

plot

option to show plot

addprj

include forecast years

ymax

ylim maximum

xmax

xlim maximum

legendcex

Allows to adjust legend cex

verbose

Report progress to R GUI?

variance_method

Specify method for approximating the variance and covariance of the multivariate lognormal distribution

ww2019

Use the approximation from Walter and Winker 2019 (Default for backwards compatibility).

2T

Use the delta-method and a 2nd order Taylor series approximation.

bias_correct_mean

Specify if the Stock Synthesis MLE estimates should be bias corrected when used to specify the mean of the multivariate lognormal distribution

FALSE

Do not apply bias correction (Default for backwards compatibility).

TRUE

Apply bias correction.

Value

output list of maximum likelihood estimates and the MVLN Monte-Carlo distributions of the Kobe values, and kobe plot

Author(s)

Henning Winker (JRC-EC)

Nicholas Ducharme-Barth (PIFSC)


Joint Distributions for Stock Status Ratios

Description

A function to generate kobe pdfs from a Multivariate Log-Normal Distribution including plotting option. This version is used for older versions of Stock Synthesis. For newer versions (v3.24 and newer), use SSdeltaMVLN().

Usage

SSdeltaMVLN_old(
  ss3rep,
  status = c("Bratio", "F"),
  quants = c("SSB", "Recr"),
  Fref = c("MSY", "Ftrg"),
  years = NULL,
  mc = 5000,
  weight = 1,
  run = "MVLN",
  plot = TRUE,
  addtrj = TRUE,
  ymax = NULL,
  xmax = NULL,
  legendcex = 1,
  verbose = TRUE
)

Arguments

ss3rep

from r4ss::SSgetoutput()["replist1"]

status

covarying stock status quantaties to extract from Hessian

quants

additional stock quantaties to extract from Hessian

Fref

Choice of reference point for stock SSB/XFref=c("MSY","Ftrg"),only if F_report_basis: 0 or 3

years

single year or vector of years for mvln

mc

number of monte-carlo simulations

weight

weighting option for model ensembles weight*mc

run

qualifier for model run

plot

option to show plot

addtrj

TRUE/FALSE add trajectory of years. Default is TRUE

ymax

ylim maximum

xmax

xlim maximum

legendcex

Allows to adjust legend cex

verbose

Report progress to R GUI?

Value

output list of kobe objects and mle's

Author(s)

Henning Winker (JRC-EC)


MCMC Joint Distributions

Description

A function to generate joint distributions for stock status ratios (SSB/SSBref and F/Fref where ref can be MSY, SSB40, F40, etc.) using MCMC. The function produces a Kobe plot, maximum likelihood estimates and the MVLN Monte-Carlo distributions of the Kobe values which can be input into SSplotEnsemble().

Usage

SSdiagsMCMC(
  mcmc,
  ss3rep,
  Fref = NULL,
  years = NULL,
  run = "MCMC",
  thin = 1,
  plot = TRUE,
  addprj = FALSE,
  ymax = NULL,
  xmax = NULL,
  legendcex = 1,
  verbose = TRUE
)

Arguments

mcmc

file path for folder with the derived_posteriors.sso file

ss3rep

from r4ss::SS_output

Fref

Choice of Fratio c("MSY","Btgt), correponding to F_MSY and F_Btgt

years

single year or vector of years for mvln

run

qualifier for model run

thin

option to use additional thinning

plot

option to show plot

addprj

include forecast years

ymax

ylim maximum

xmax

xlim maximum

legendcex

Allows to adjust legend cex

verbose

Report progress to R GUI?

Value

output list maximum likelihood estimates and the MCMC posterier distributions of the Kobe values and a Kobe plot

Author(s)

Henning Winker (JRC-EC), Massimiliano and Laurence Kell (Sea++)

See Also

SSdeltaMVLN(), SSplotEnsemble(), SSplotKobe()


MCMC Joint Distributions

Description

A function to generate joint distributions for stock status ratios (SSB/SSBref and F/Fref where ref can be MSY, SSB40, F40, etc.) using MCMC. The function produces a Kobe plot, maximum likelihood estimates and the MVLN Monte-Carlo distributions of the Kobe values which can be input into SSplotEnsemble(). Use for Stock Synthesis models older than 3.24, for later versions use SSdiagsMCMC().

Usage

SSdiagsMCMC_ancient(
  mcmc,
  ss3rep,
  Fref = NULL,
  years = NULL,
  run = "MCMC",
  thin = 1,
  plot = TRUE,
  addprj = FALSE,
  ymax = NULL,
  xmax = NULL,
  legendcex = 1,
  verbose = TRUE
)

Arguments

mcmc

file path for folder with the derived_posteriors.sso file

ss3rep

from r4ss::SS_output

Fref

Choice of Fratio c("MSY","Btgt), correponding to F_MSY and F_Btgt

years

single year or vector of years for mvln

run

qualifier for model run

thin

option to use additional thinning

plot

option to show plot

addprj

include forecast years

ymax

ylim maximum

xmax

xlim maximum

legendcex

Allows to adjust legend cex

verbose

Report progress to R GUI?

Value

output list maximum likelihood estimates and the MCMC posterier distributions of the Kobe values and a Kobe plot

Author(s)

Henning Winker (JRC-EC), Massimiliano and Laurence Kell (Sea++)


Mohn's Rho and Forecast Bias

Description

This function produces the statistics from retrospective analysis (Mohn's rho and forecast bias). To visualize the retrospective forecasts from a Stock Synthesis model, use SSplotRetro().

Usage

SShcbias(
  summaryoutput,
  quants = c("SSB", "F"),
  models = "all",
  endyrvec = "default",
  verbose = TRUE
)

Arguments

summaryoutput

List created by r4ss::SSsummarize()

quants

SSB or F quantity

models

Optional subset of the models described in r4ss function summaryoutput(). Either "all" or a vector of numbers indicating columns in summary tables.

endyrvec

Optional single year or vector of years representing the final year of values to show for each model. By default it is set to the ending year specified in each model.

verbose

Report progress to R GUI?

Author(s)

Henning Winker (JRC-EC) and Laurance Kell (Sea++)

See Also

SSplotRetro()


Mean Absolute Scaled Error

Description

MASE for one-step ahead hindcasting cross-validations and computes MASE from prediction residuals of indices. MASE is calculated the average ratio of mean absolute error (MAE) of prediction residuals (MAE.PR) and Naive Predictions (MAE.base) MASE.adj sets the MAE.base to a minimum MAE.base.adj (default=0.1) MASE.adj allow passing (MASE<1) if MAE.PE < 0.1 and thus accurate, when obs show extremely little variation

Usage

SSmase(
  retroSummary,
  quants = c("cpue", "len", "age", "con"),
  Season = "default",
  models = "all",
  endyrvec = "default",
  indexselect = NULL,
  MAE.base.adj = 0.1,
  residuals = FALSE,
  verbose = FALSE,
  indexfleets = 1
)

Arguments

retroSummary

raw list of retrospective runs created by r4ss::SSgetoutput(). Depending on the type of data, the function will call r4ss::SSsummarize or ss3diags:SSretroComps to summarize the list.

quants

data type, either "cpue" for index data, "len" for length composition data, or "age" for age composition data. Note, if using "age" or "len", SSretroComps() will be used to extract and summarize the composition data first.

Season

option to specify Season as an integer of value 1-4 - Default uses first available, i.e. usual Seas = 1

models

Optional subset of the models described in r4ss function summaryoutput(). Either "all" or a vector of numbers indicating columns in summary tables.

endyrvec

Optional single year or vector of years representing the final year of values to show for each model. By default it is set to the ending year specified in each model.

indexselect

Vector of fleet numbers for each model for which to compare

MAE.base.adj

minimum MASE demoninator (naive predictions) for MASE.adj (default = 0.1)

residuals

If true, includes a dataframe in the output of the prediction residuals and naive prediction residuals. Default is FALSE.

verbose

Report progress to R GUI?

indexfleets

Single value or vector of length n = number of models in summary object of the fleet number(s) for the index to compare.

Value

MASE and hcxval statistic

Author(s)

Henning Winker (JRC-EC) and Laurence Kell (Sea++)

See Also

SSretroComps() r4ss::SSsummarize()

Examples

## Not run: 
# calculate MASE for CPUE indices only for fleets 1 and 2
SSmase(retro.sma, quant = "cpue", indexselect = c(1:2))

## End(Not run)

Model ensemble plots

Description

Plots model ensembles and forecasts with uncertainty represented by MVLN or MCMC posteriors

Usage

SSplotEnsemble(
  kb,
  subplots = c("stock", "harvest", "SSB", "F", "Recr", "Catch"),
  models = "all",
  quantiles = list(c(0.025, 0.975)),
  ylabs = NULL,
  endyrvec = "default",
  plot = TRUE,
  print = deprecated(),
  print_plot = FALSE,
  png = deprecated(),
  use_png = print_plot,
  pdf = FALSE,
  use_pdf = FALSE,
  col = NULL,
  pch = NULL,
  lty = 1,
  lwd = 2,
  tickEndYr = FALSE,
  xlim = NULL,
  ylimAdj = 1.05,
  xaxs = "i",
  yaxs = "i",
  xylabs = TRUE,
  type = "l",
  uncertainty = TRUE,
  legend = TRUE,
  legendlabels = "default",
  legendloc = "topright",
  legendorder = "default",
  legendncol = 1,
  legendcex = 1,
  legendsp = 0.9,
  pwidth = 6.5,
  pheight = 5,
  punits = "in",
  res = 300,
  ptsize = 10,
  cex.main = 1,
  plotdir = NULL,
  filenameprefix = "",
  par = list(mar = c(5, 4, 1, 1) + 0.1),
  verbose = TRUE,
  shadealpha = 0.3,
  new = TRUE,
  add = FALSE,
  mcmcVec = FALSE,
  indexQlabel = TRUE,
  indexQdigits = 4,
  legendindex = NULL
)

Arguments

kb

kb type output created by SSdeltaMVLN()

subplots

vector to create subplots with these options:

  • "stock" Fish Population

  • "harvest" Harvest Rate

  • "SSB" Spawning Stock Biomass

  • "F" Fishing Mortality

  • "Recr" Recruitment

  • "Catch" Total Catch

models

option to manually subset the models in kb[["run"]]

quantiles

quantiles for uncertainty in plots. Input as a list, default is the 95TH percentile: list(c(0.025, 0.975))

ylabs

y-axis labels for quants

endyrvec

Optional single year or vector of years representing the final year of values to show for each model. By "default" it is set to the ending year specified in each model.

plot

DEPRECATED. By default, TRUE, Plots (and subplots) are drawn to the plot device. The option to explicitly disable this option (FALSE), is not implemented. This option flag will be defunct in a future version

print

DEPRECATED, please use print_plot.

print_plot

Flag to enable plot graphic device to print to PNG or PNG files.

png

DEPRECATED. Please use use_png.

use_png

Enables plots to be generated to PNG files. Defaults to print value

pdf

DEPRECATED. Please use use_pdf.

use_pdf

Enables plots to be generated to pdf file.

col

Optional vector of colors to be used for lines. Input NULL

pch

Optional vector of plot character values

lty

Optional vector of line types

lwd

Optional vector of line widths

tickEndYr

Logical flag: set TRUE or FALSE to switch to turn on/off extra axis mark at final year in timeseries plots.

xlim

Optional, years to use for x-axis. Default value NULL (or "default"), uses all years available.

ylimAdj

Multiplier for ylim parameter. Allows additional white space.

xaxs

Choice of xaxs parameter See ?par for more info.

yaxs

Choice of yaxs parameter. See ?par for more info.

xylabs

Logical flag: set TRUE or FALSE to include x- and y-axis labels to the plot. Defaults to TRUE

type

The type of plot to be drawn. For more details, see plot.

uncertainty

Logical flag to enable plots with uncertainty intervals. Either a single TRUE/FALSE value, or a vector of TRUE/FALSE values around SSB or F estimated timeseries, or a set of integers corresponding to the choice of models.

legend

Flag to enable legend to plot. TRUE by default.

legendlabels

Optional vector of labels to include in legend.

legendloc

Location of legend. Either a string like "topleft" or a vector of two numeric values representing the fraction of the maximum in the x and y dimensions, respectively. See help("legend") for more info on the string options.

legendorder

Optional vector of model numbers that can be used to have the legend display the model names in an order that is different than that which is represented in the summary input object.

legendncol

Number of columns for the legend.

legendcex

Allows to adjust legend cex

legendsp

Space between legend labels

pwidth

Default width of plot printed to plot in units of punits

pheight

Height of plot printed to plot in units of punits

punits

Measurement units for pwidth and pheight. Default is "in".

  • "px" (pixels)

  • "in" (inches)

  • "cm" (centimeters)

  • "mm" (millimeters)

res

Resolution for plots printed to files.

ptsize

Point size for plotted text in plots printed in files. See help("png") for more details

cex.main

Character expansion for plot titles.

plotdir

Directory where output plot file will be written. By default, it will be the directory where the model was run.

filenameprefix

Additional text to append to output plot file name. It will be separated from default name by an underscore.

par

A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot,which is passed to par(). Entering NULL passes plot's default par() values (which depends on whether the main title is included or not)

verbose

Flag to print additional diagnostic messages to R console

shadealpha

Transparency adjustment used to make uncertainty regions, default is 0.3

new

Deprecated. New plot windows are created by default (TRUE), and the option to disable this, via FALSE, is unused.

add

suppresses par() to create multiplot figs

mcmcVec

Logical vector of TRUE/FALSE values (or single value) indicating whether input values are from MCMC or to use normal distribution around MLE.

indexQlabel

TRUE/FALSE include labels for indices. Default is TRUE (currently not used)

indexQdigits

Number of significant digits for catchability in legend. Default is 4

legendindex

Allows to add legend for selected indices (plots)

Author(s)

Mostly adopted from r4ss::SSplotComparisons by Taylor et al

Examples

## Not run: 

mvln <- SSdeltaMVLN(simple, run = "Simple")
sspar(mfrow = c(3, 2), plot.cex = 0.7)
SSplotEnsemble(mvln[["kb"]], ylabs = mvln[["labels"]], add = T, verbose = F)

## End(Not run)

Hindcasting Cross-Validations of Multiple Models

Description

Plots one-step ahead hindcasting cross-validations and computes MASE from prediction residuals.MASE is calculated as the average ratio of mean absolute error (MAE) of prediction residuals (MAE.PR) and naive predictions (MAE.base). MASE.adj sets the MAE.base to a minimum MAE.base.adj (default=0.1). MASE.adj allow passing (MASE<1) if MAE.PE < 0.1 and thus accurate if obs show very little annual variation

Usage

SSplotHCxval(
  retroSummary,
  subplots = c("cpue", "len", "age"),
  Season = "default",
  print = deprecated(),
  print_plot = FALSE,
  png = deprecated(),
  use_png = print_plot,
  pdf = deprecated(),
  use_pdf = FALSE,
  models = "all",
  endyrvec = "default",
  xmin = NULL,
  indexselect = NULL,
  MAE.base.adj = 0.1,
  show.mase.adj = TRUE,
  indexUncertainty = TRUE,
  col = NULL,
  pch = NULL,
  lty = 1,
  lwd = 2,
  tickEndYr = TRUE,
  xlim = "default",
  ylimAdj = 1.15,
  ylim = NULL,
  xaxs = "i",
  yaxs = "i",
  xylabs = TRUE,
  type = "o",
  uncertainty = TRUE,
  legend = TRUE,
  legendlabels = "default",
  legendloc = "topright",
  legendorder = "default",
  legendncol = 1,
  legendcex = 1,
  legendsp = 0.9,
  legendindex = NULL,
  pwidth = 6.5,
  pheight = 5,
  punits = "in",
  res = 300,
  ptsize = 10,
  cex.main = 1,
  plotdir = NULL,
  filenameprefix = "",
  par = list(mar = c(5, 4, 1, 1) + 0.1),
  verbose = TRUE,
  shadecol = grey(0.5, 0.4),
  shadecol2 = grey(0.5, 0.4),
  shadealpha = 0.3,
  new = TRUE,
  add = FALSE,
  mcmcVec = FALSE,
  indexQlabel = TRUE,
  indexQdigits = 4,
  indexfleets = 1,
  plot = TRUE,
  shadecol1 = grey(0.5, 0.4)
)

Arguments

retroSummary

List created by r4ss::SSsummarize() or SSretroComps()

subplots

optional use of the following:

  • "cpue" Index of abundance data

  • "len" Length-composition data

  • "age" Age-composition data

Season

option to specify Season as an integer of value 1-4. Default uses first available, i.e. usual Seas = 1

print

DEPRECATED, please use print_plot.

print_plot

Flag to enable plot graphic device to print to PNG or PNG files.

png

DEPRECATED. Please use use_png.

use_png

Enables plots to be generated to PNG files. Defaults to print value

pdf

DEPRECATED. Please use use_pdf.

use_pdf

Enables plots to be generated to pdf file.

models

Optional subset of the models of summaryoutput (or a similar field with a different name): a list created by the function r4ss::SSsummarize. Either "all" or a vector of numbers indicating columns in summary tables.

endyrvec

Optional single year or vector of years representing the final year of values to show for each model. By default it is set to the ending year specified in each model.

xmin

optional number first year shown in plot (if available)

indexselect

Vector of fleet numbers for each model for which to compare

MAE.base.adj

minimum MASE denominator (naive predictions) for MASE.adj (default = 0.1)

show.mase.adj

if TRUE, it show mase.adj in plot

indexUncertainty

Show fixed uncertainty intervals on index (not estimated)

col

Optional vector of colors to be used for lines. Input NULL

pch

Optional vector of plot character values

lty

Optional vector of line types

lwd

Optional vector of line widths

tickEndYr

Logical flag: set TRUE or FALSE to switch to turn on/off extra axis mark at final year in timeseries plots.

xlim

Optional, years to use for x-axis. Default value NULL (or "default"), uses all years available.

ylimAdj

Multiplier for ylim parameter. Allows additional white space.

ylim

will over-write ylimAdj if specified

xaxs

Choice of xaxs parameter See ?par for more info.

yaxs

Choice of yaxs parameter. See ?par for more info.

xylabs

Logical flag: set TRUE or FALSE to include x- and y-axis labels to the plot. Defaults to TRUE

type

The type of plot to be drawn. For more details, see plot.

uncertainty

Logical flag to enable plots with uncertainty intervals. Either a single TRUE/FALSE value, or a vector of TRUE/FALSE values around SSB or F estimated timeseries, or a set of integers corresponding to the choice of models.

legend

Flag to enable legend to plot. TRUE by default.

legendlabels

Optional vector of labels to include in legend.

legendloc

Location of legend. Either a string like "topleft" or a vector of two numeric values representing the fraction of the maximum in the x and y dimensions, respectively. See help("legend") for more info on the string options.

legendorder

Optional vector of model numbers that can be used to have the legend display the model names in an order that is different than that which is represented in the summary input object.

legendncol

Number of columns for the legend.

legendcex

Allows to adjust legend cex

legendsp

Space between legend labels

legendindex

Allows to add legend for selected indices (plots)

pwidth

Default width of plot printed to plot in units of punits

pheight

Height of plot printed to plot in units of punits

punits

Measurement units for pwidth and pheight. Default is "in".

  • "px" (pixels)

  • "in" (inches)

  • "cm" (centimeters)

  • "mm" (millimeters)

res

Resolution for plots printed to files.

ptsize

Point size for plotted text in plots printed in files. See help("png") for more details

cex.main

Character expansion for plot titles.

plotdir

Directory where output plot file will be written. By default, it will be the directory where the model was run.

filenameprefix

Additional text to append to output plot file name. It will be separated from default name by an underscore.

par

A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot,which is passed to par(). Entering NULL passes plot's default par() values (which depends on whether the main title is included or not)

verbose

Flag to print additional diagnostic messages to R console

shadecol

uncertainty shading of hcxval horizon

shadecol2

color for uncertainty in early years not affected by hindcast

shadealpha

Transparency adjustment used to make default shadecol. (currently not used)

new

Deprecated. New plot windows are created by default (TRUE), and the option to disable this, via FALSE, is unused.

add

suppresses par() to create multiplot figs

mcmcVec

Logical vector of TRUE/FALSE values (or single value) indicating whether input values are from MCMC or to use normal distribution around MLE.

indexQlabel

Logical flag to add catchability to legend in plot of index fits.

indexQdigits

Number of significant digits for catchability in legend

indexfleets

Fleet numbers for each model to compare indices of abundance. Can take different forms:

  • integer: (default) create a single comparison plot for the chosen index

  • NULL: create a separate plot for each index as long as the fleet numbering is the same across all models.

  • vector of length equal to number of models: a single fleet number for each model to be compared in a single plot

  • list: list of fleet numbers associated with indices within each model to be compared, where the list elements are each a vector of the same length but the names of the list elements don't matter and can be absent.

plot

DEPRECATED. By default, TRUE, Plots (and subplots) are drawn to the plot device. The option to explicitly disable this option (FALSE), is not implemented. This option flag will be defunct in a future version

shadecol1

uncertainty shading of early years not affected by hindcast (currently not used)

Author(s)

Henning Winker (JRC-EC) and Laurence Kell (Sea++)


Residual plot

Description

Plots residuals for all indices as boxplot (color coded by fleet) with a loess showing systematic trends over time. This function is from the package JABBA (Just Another Bayesian Biomass Assessment).

Usage

SSplotJABBAres(
  ss3rep,
  subplots = c("cpue", "len", "age", "size", "con")[1],
  seas = NULL,
  plot = TRUE,
  print = lifecycle::deprecated(),
  print_plot = FALSE,
  png = lifecycle::deprecated(),
  use_png = print_plot,
  pdf = lifecycle::deprecated(),
  use_pdf = FALSE,
  indexselect = NULL,
  miny = 3,
  col = NULL,
  pch = 21,
  lty = 1,
  lwd = 2,
  tickEndYr = TRUE,
  xlim = "default",
  ylim = "default",
  ylimAdj = 1.1,
  xaxs = "i",
  yaxs = "i",
  xylabs = TRUE,
  type = "o",
  legend = TRUE,
  legendlabels = "default",
  legendloc = "bottomleft",
  legendorder = "default",
  legendncol = 1,
  legendcex = 1,
  legendsp = 0.9,
  legendindex = NULL,
  pwidth = 6.5,
  pheight = 5,
  punits = "in",
  res = 300,
  ptsize = 10,
  cex.main = 1,
  plotdir = NULL,
  filenameprefix = "",
  par = list(mar = c(5, 4, 1, 1) + 0.1),
  verbose = TRUE,
  boxcol = grey(0.8, 0.5),
  new = TRUE,
  add = FALSE
)

Arguments

ss3rep

Stock Synthesis output as read by r4ss::SS_output()

subplots

string of type of data to plot:

  • "cpue" Index of abundance data

  • "len" Length-composition data

  • "age" Age-composition data

  • "size" Generalized size composition data

  • "con" Conditional age-at-length data.

seas

string indicating how to treat data from multiple seasons:

  • "comb" Combine seasonal data for each year and plot against Yr

  • "sep" Treat season separately, plotting against Yr.S.

  • NULL If NULL, it is assumed that there is only one season and option "comb" is used.

plot

DEPRECATED. By default, TRUE, Plots (and subplots) are drawn to the plot device. The option to explicitly disable this option (FALSE), is not implemented. This option flag will be defunct in a future version

print

DEPRECATED, please use print_plot.

print_plot

Flag to enable plot graphic device to print to PNG or PNG files.

png

DEPRECATED. Please use use_png.

use_png

Enables plots to be generated to PNG files. Defaults to print value

pdf

DEPRECATED. Please use use_pdf.

use_pdf

Enables plots to be generated to pdf file.

indexselect

Vector of fleet numbers for each model for which to compare

miny

minimum abs values of ylim

col

Optional vector of colors to be used for lines. Input NULL

pch

Optional vector of plot character values

lty

Optional vector of line types

lwd

Optional vector of line widths

tickEndYr

Logical flag: set TRUE or FALSE to switch to turn on/off extra axis mark at final year in timeseries plots.

xlim

Optional, years to use for x-axis. Default value NULL (or "default"), uses all years available.

ylim

Optional, min and max values for the ylim to override the "default" value (-0.7, 0.5)

ylimAdj

Multiplier for ylim parameter. Allows additional white space.

xaxs

Choice of xaxs parameter See ?par for more info.

yaxs

Choice of yaxs parameter. See ?par for more info.

xylabs

Logical flag. Enables x- and y-axis labels.

type

The type of plot to be drawn. For more details, see plot.

legend

Flag to enable legend to plot. TRUE by default.

legendlabels

Optional vector of labels to include in legend.

legendloc

Location of legend. Either a string like "topleft" or a vector of two numeric values representing the fraction of the maximum in the x and y dimensions, respectively. See help("legend") for more info on the string options.

legendorder

Optional vector of model numbers that can be used to have the legend display the model names in an order that is different than that which is represented in the summary input object.

legendncol

Number of columns for the legend.

legendcex

Allows to adjust legend cex

legendsp

Space between legend labels

legendindex

Allows to add legend for selected indices (plots)

pwidth

Default width of plot printed to plot in units of punits

pheight

Height of plot printed to plot in units of punits

punits

Measurement units for pwidth and pheight. Default is "in".

  • "px" (pixels)

  • "in" (inches)

  • "cm" (centimeters)

  • "mm" (millimeters)

res

Resolution for plots printed to files.

ptsize

Point size for plotted text in plots printed in files. See help("png") for more details

cex.main

Character expansion for plot titles.

plotdir

Directory where output plot file will be written. By default, it will be the directory where the model was run.

filenameprefix

Additional text to append to output plot file name. It will be separated from default name by an underscore.

par

A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot,which is passed to par(). Entering NULL passes plot's default par() values (which depends on whether the main title is included or not)

verbose

Flag to print additional diagnostic messages to R console

boxcol

color boxes

new

Deprecated. New plot windows are created by default (TRUE), and the option to disable this, via FALSE, is unused.

add

suppresses par() to create multiplot figs

Author(s)

Henning Winker (JRC-EC)


KOBE phase plot

Description

Generates a Kobe plot or phase plot illustrating the stock status uncertainty over SSB/SSBmsy and F/Fmsy

Usage

SSplotKobe(
  kb,
  joint = TRUE,
  year = NULL,
  posterior = c("points", "kernel"),
  xlab = expression(SSB/SSB[MSY]),
  ylab = expression(F/F[MSY]),
  ylim = NULL,
  xlim = NULL,
  fill = TRUE,
  showMedian = TRUE,
  legend = TRUE,
  legendpos = "right",
  legendcex = 0.7,
  legendruns = TRUE,
  yr.label = TRUE,
  yr.int = 5,
  verbose = TRUE
)

Arguments

kb

output from SSdeltaMVLN()["kb"]

joint

option FALSE shows individual runs

year

option to choose year for kobe, last year is default

posterior

visualization of posterior c("points","kernel")

xlab

graphic parameter

ylab

graphic parameter

ylim

graphic parameter

xlim

graphic parameter

fill

shows color-coded quadrants

showMedian

option for median trajectory. TRUE by default

legend

option for legend. TRUE by default.

legendpos

legend position

legendcex

legend size

legendruns

show legend for run labels

yr.label

show year along trajectory

yr.int

year intervals along trajectory

verbose

Output to R console. Default is TRUE

Value

Kobe Quadrant percentages


Compare Multiple SS Model Estimates

Description

A function to plot SSB, B-ratio, F, Recruits, and/or Index of Abundance fits from multiple SS models. This function uses an object of multiple SS models summarized with r4ss::SSsummarize().

Usage

SSplotModelcomp(
  summaryoutput,
  plot = TRUE,
  print = deprecated(),
  print_plot = FALSE,
  png = deprecated(),
  use_png = print_plot,
  pdf = deprecated(),
  use_pdf = FALSE,
  models = "all",
  subplots = c("SSB", "Bratio", "Fvalue", "Recruits", "Index", "RecDevs"),
  brp = c("msy", "btargs"),
  fmsy = TRUE,
  ylabs = c("SSB (t)", expression(SSB/SSB[MSY]), "Fishing mortality F",
    "Recruits ('000s)", "Index", "Recruitment Deviations"),
  endyrvec = "default",
  xmin = NULL,
  indexselect = NULL,
  indexUncertainty = TRUE,
  col = NULL,
  pch = NULL,
  lty = 1,
  lwd = 2,
  tickEndYr = FALSE,
  xlim = "default",
  ylimAdj = 1.05,
  xaxs = "i",
  yaxs = "i",
  xylabs = TRUE,
  type = "l",
  uncertainty = TRUE,
  legend = TRUE,
  legendlabels = "default",
  legendloc = "topright",
  legendorder = "default",
  legendncol = 1,
  legendcex = 1,
  legendsp = 0.9,
  legendindex = NULL,
  pwidth = 6.5,
  pheight = 5,
  punits = "in",
  res = 300,
  ptsize = 10,
  cex.main = 1,
  plotdir = NULL,
  filenameprefix = "",
  par = list(mar = c(5, 4, 1, 1) + 0.1),
  verbose = TRUE,
  shadecol = NULL,
  shadealpha = 0.3,
  new = TRUE,
  add = FALSE,
  mcmcVec = FALSE,
  indexQlabel = TRUE,
  indexQdigits = 4,
  indexfleets = 1
)

Arguments

summaryoutput

List created by r4ss::SSsummarize()

plot

DEPRECATED. By default, TRUE, Plots (and subplots) are drawn to the plot device. The option to explicitly disable this option (FALSE), is not implemented. This option flag will be defunct in a future version

print

DEPRECATED, please use print_plot.

print_plot

Flag to enable plot graphic device to print to PNG or PNG files.

png

DEPRECATED. Please use use_png.

use_png

Enables plots to be generated to PNG files. Defaults to print value

pdf

DEPRECATED. Please use use_pdf.

use_pdf

Enables plots to be generated to pdf file.

models

Optional subset of the models of summaryoutput (or a similar field with a different name): a list created by the function r4ss::SSsummarize. Either "all" or a vector of numbers indicating columns in summary tables.

subplots

option to "SSB","Bratio","Fvalue","Recruits","Index"

  • "SSB" Spawning Stock Biomass

  • "Bratio" Stock Biomass relative to biomass reference point

  • "Fvalue" Fishing Mortality

  • "Recruits" Age-0 Recruits

  • "Index" Index of abundance

  • "RecDev" Recruitment Deviations

brp

option to set reference point c("msy","btargs")

fmsy

to specify Fvalue as F/Fmsy if so in starter file setting

ylabs

yaxis labels for quants final year of values to show for each model. By default it is set to the

endyrvec

Optional single year or vector of years representing the final year of values to show for each model. By "default" it is set to the ending year specified in each model.

xmin

NULL optional number first year shown in plot (if available)

indexselect

Vector of fleet numbers for each model for which to compare

indexUncertainty

Show fixed uncertainty intervals on index (not estimated)

col

Optional vector of colors to be used for lines. Input NULL

pch

Optional vector of plot character values

lty

Optional vector of line types

lwd

Optional vector of line widths

tickEndYr

Logical flag: set TRUE or FALSE to switch to turn on/off extra axis mark at final year in timeseries plots.

xlim

Optional, years to use for x-axis. Default value NULL (or "default"), uses all years available.

ylimAdj

Multiplier for ylim parameter. Allows additional white space.

xaxs

Choice of xaxs parameter See ?par for more info.

yaxs

Choice of yaxs parameter. See ?par for more info.

xylabs

Logical flag: set TRUE or FALSE to include x- and y-axis labels to the plot. Defaults to TRUE

type

The type of plot to be drawn. For more details, see plot.

uncertainty

Logical flag to enable plots with uncertainty intervals. Either a single TRUE/FALSE value, or a vector of TRUE/FALSE values around SSB or F estimated timeseries, or a set of integers corresponding to the choice of models.

legend

Flag to enable legend to plot. TRUE by default.

legendlabels

Optional vector of labels to include in legend.

legendloc

Location of legend. Either a string like "topleft" or a vector of two numeric values representing the fraction of the maximum in the x and y dimensions, respectively. See help("legend") for more info on the string options.

legendorder

Optional vector of model numbers that can be used to have the legend display the model names in an order that is different than that which is represented in the summary input object.

legendncol

Number of columns for the legend.

legendcex

Allows to adjust legend cex

legendsp

Space between legend labels

legendindex

Allows to add legend for selected indices (plots)

pwidth

Default width of plot printed to plot in units of punits

pheight

Height of plot printed to plot in units of punits

punits

Measurement units for pwidth and pheight. Default is "in".

  • "px" (pixels)

  • "in" (inches)

  • "cm" (centimeters)

  • "mm" (millimeters)

res

Resolution for plots printed to files.

ptsize

Point size for plotted text in plots printed in files. See help("png") for more details

cex.main

Character expansion for plot titles.

plotdir

Directory where output plot file will be written. By default, it will be the directory where the model was run.

filenameprefix

Additional text to append to output plot file name. It will be separated from default name by an underscore.

par

A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot,which is passed to par(). Entering NULL passes plot's default par() values (which depends on whether the main title is included or not)

verbose

Flag to print additional diagnostic messages to R console

shadecol

uncertainty shading of hcxval horizon

shadealpha

Transparency adjustment used to make default shadecol

new

Deprecated. New plot windows are created by default (TRUE), and the option to disable this, via FALSE, is unused.

add

suppresses par() to create multiplot figs

mcmcVec

Logical vector of TRUE/FALSE values (or single value) indicating whether input values are from MCMC or to use normal distribution around MLE.

indexQlabel

Logical. If TRUE add catchability to legend in plot of index fits (currently not used)

indexQdigits

Number of significant digits for catchability in legend

indexfleets

Fleet numbers for each model to compare indices of abundance. Can take different forms:

  • integer (default): create a single comparison plot for the chosen index

  • NULL: create a separate plot for each index as long as the fleet numbering is the same across all models.

  • vector of length equal to number of models: a single fleet number for each model to be compared in a single plot

  • list: list of fleet numbers associated with indices within each model to be compared, where the list elements are each a vector of the same length but the names of the list elements don't matter and can be absent.

Author(s)

Mostly adopted from r4ss::SSplotComparisons by Taylor et al


Retrospective-Forecast with One-Step Ahead Hindcasting

Description

Plots retrospective pattern, including (optional) one-step ahead forecast and computes Mohn's Rho

Usage

SSplotRetro(
  summaryoutput,
  subplots = c("SSB", "F"),
  plot = TRUE,
  print = deprecated(),
  print_plot = FALSE,
  png = deprecated(),
  use_png = print_plot,
  pdf = deprecated(),
  use_pdf = FALSE,
  models = "all",
  endyrvec = "default",
  xlim = NULL,
  xmin = NULL,
  labels = NULL,
  ylim = NULL,
  forecast = TRUE,
  forecastrho = TRUE,
  showrho = TRUE,
  col = NULL,
  pch = NULL,
  lty = 1,
  lwd = 2,
  tickEndYr = TRUE,
  ylimAdj = 1.05,
  xaxs = "i",
  yaxs = "i",
  xylabs = TRUE,
  type = "o",
  uncertainty = TRUE,
  legend = TRUE,
  legendlabels = "default",
  legendloc = "topright",
  legendorder = "default",
  legendncol = 1,
  legendcex = 1,
  legendsp = 0.7,
  legendindex = NULL,
  pwidth = 6.5,
  pheight = 5,
  punits = "in",
  res = 300,
  ptsize = 10,
  cex.main = 1,
  plotdir = NULL,
  filenameprefix = "",
  par = list(mar = c(5, 4, 1, 1) + 0.1),
  verbose = TRUE,
  shadecol = grey(0.4, 0.6),
  new = TRUE,
  add = FALSE,
  mcmcVec = FALSE,
  shadecol1 = grey(0.5, 0.4),
  indexQlabel = TRUE,
  indexQdigits = 4,
  shadealpha = 0.3
)

Arguments

summaryoutput

List created by r4ss::SSsummarize()

subplots

Optional vector of subplots to be created:

  • "SSB" Spawning Stock Biomass

  • "F" Fishing Mortality

plot

DEPRECATED. By default, TRUE, Plots (and subplots) are drawn to the plot device. The option to explicitly disable this option (FALSE), is not implemented. This option flag will be defunct in a future version

print

DEPRECATED, please use print_plot.

print_plot

Flag to enable plot graphic device to print to PNG or PNG files.

png

DEPRECATED. Please use use_png.

use_png

Enables plots to be generated to PNG files. Defaults to print value

pdf

DEPRECATED. Please use use_pdf.

use_pdf

Enables plots to be generated to pdf file.

models

Optional subset of the models of summaryoutput (or a similar field with a different name): a list created by the function r4ss::SSsummarize. Either "all" or a vector of numbers indicating columns in summary tables.

endyrvec

Optional single year or vector of years representing the final year of values to show for each model. By default it is set to the ending year specified in each model.

xlim

Optional, years to use for x-axis. Default value NULL (or "default"), uses all years available.

xmin

optional minimum year shown in plot (default first yr)

labels

yaxis label for biomass (bony fish and sharks)

ylim

option to specify ylim range

forecast

Logical. If TRUE, one-step ahead forecasts are shown in plot

forecastrho

Logical. If TRUE, one-step ahead forecast rho value is denoted in plot

showrho

Logical flag to include Mohn's rho value. Defaults to TRUE

col

Optional vector of colors to be used for lines. Input NULL

pch

Optional vector of plot character values

lty

Optional vector of line types

lwd

Optional vector of line widths

tickEndYr

Logical flag: set TRUE or FALSE to switch to turn on/off extra axis mark at final year in timeseries plots.

ylimAdj

Multiplier for ylim parameter. Allows additional white space.

xaxs

Choice of xaxs parameter See ?par for more info.

yaxs

Choice of yaxs parameter. See ?par for more info.

xylabs

Logical flag: set TRUE or FALSE to include x- and y-axis labels to the plot. Defaults to TRUE

type

The type of plot to be drawn. For more details, see plot.

uncertainty

Logical flag to enable plots with uncertainty intervals. Either a single TRUE/FALSE value, or a vector of TRUE/FALSE values around SSB or F estimated timeseries, or a set of integers corresponding to the choice of models.

legend

Flag to enable legend to plot. TRUE by default.

legendlabels

Optional vector of labels to include in legend.

legendloc

Location of legend. Either a string like "topleft" or a vector of two numeric values representing the fraction of the maximum in the x and y dimensions, respectively. See help("legend") for more info on the string options.

legendorder

Optional vector of model numbers that can be used to have the legend display the model names in an order that is different than that which is represented in the summary input object.

legendncol

Number of columns for the legend.

legendcex

Allows to adjust legend cex

legendsp

Space between legend labels

legendindex

Allows to add legend for selected indices (plots)

pwidth

Default width of plot printed to plot in units of punits

pheight

Height of plot printed to plot in units of punits

punits

Measurement units for pwidth and pheight. Default is "in".

  • "px" (pixels)

  • "in" (inches)

  • "cm" (centimeters)

  • "mm" (millimeters)

res

Resolution for plots printed to files.

ptsize

Point size for plotted text in plots printed in files. See help("png") for more details

cex.main

Character expansion for plot titles.

plotdir

Directory where output plot file will be written. By default, it will be the directory where the model was run.

filenameprefix

Additional text to append to output plot file name. It will be separated from default name by an underscore.

par

A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot,which is passed to par(). Entering NULL passes plot's default par() values (which depends on whether the main title is included or not)

verbose

Flag to print additional diagnostic messages to R console

shadecol

uncertainty shading of hcxval horizon

new

Deprecated. New plot windows are created by default (TRUE), and the option to disable this, via FALSE, is unused.

add

suppresses par() to create multiplot figs

mcmcVec

Logical vector of TRUE/FALSE values (or single value) indicating whether input values are from MCMC or to use normal distribution around MLE.

shadecol1

uncertainty shading of early years not affected by hindcast

indexQlabel

Logical. If TRUE, add catchability to legend in plot of index fits (currently not used)

indexQdigits

Number of significant digits for catchability in legend

shadealpha

set the transparency level (alpha) of the area of uncertainty. Defaults to 0.3 (currently not used)

Author(s)

Henning Winker (JRC-EC) and Laurance Kell (Sea++)


Residual Diagnostics

Description

Function for residual diagnostics. Plots residuals and 3x sigma limits for indices or mean age or length and outputs a runs test table. Note, if you do not want to plot the residuals, use SSrunstest().

Usage

SSplotRunstest(
  ss3rep,
  mixing = "less",
  subplots = c("cpue", "len", "age", "size", "con")[1],
  plot = TRUE,
  print = deprecated(),
  print_plot = FALSE,
  png = deprecated(),
  use_png = print_plot,
  pdf = deprecated(),
  use_pdf = FALSE,
  indexselect = NULL,
  miny = 1,
  col = NULL,
  pch = 21,
  lty = 1,
  lwd = 2,
  tickEndYr = FALSE,
  xlim = "default",
  ylim = "default",
  ylimAdj = 1.4,
  xaxs = "i",
  yaxs = "i",
  xylabs = TRUE,
  type = "o",
  legend = TRUE,
  legendloc = "top",
  legendcex = 1,
  pwidth = 6.5,
  pheight = 5,
  punits = "in",
  res = 300,
  ptsize = 10,
  cex.main = 1,
  plotdir = NULL,
  filenameprefix = "",
  par = list(mar = c(5, 4, 1, 1) + 0.1),
  verbose = TRUE,
  new = TRUE,
  add = FALSE
)

Arguments

ss3rep

Stock Synthesis output as read by r4ss::SS_output()

mixing

c("less","greater","two.sided"). Default less is checking for positive autocorrelation only

subplots

optional flag for:

  • "cpue" Index of abundance data

  • "len" Length composition data

  • "size" Generalized size composition data

  • "age" Age composition data

  • "con" Conditional age-at-length data

plot

DEPRECATED. By default, TRUE, Plots (and subplots) are drawn to the plot device. The option to explicitly disable this option (FALSE), is not implemented. This option flag will be defunct in a future version

print

DEPRECATED, please use print_plot.

print_plot

Flag to enable plot graphic device to print to PNG or PNG files.

png

DEPRECATED. Please use use_png.

use_png

Enables plots to be generated to PNG files. Defaults to print value

pdf

DEPRECATED. Please use use_pdf.

use_pdf

Enables plots to be generated to pdf file.

indexselect

Vector of fleet numbers for each model for which to compare

miny

the absolute value of the min and max value for ylim. Default is 1

col

Optional vector of colors to be used for lines. Input NULL

pch

Optional vector of plot character values

lty

Optional vector of line types

lwd

Optional vector of line widths

tickEndYr

Logical flag: set TRUE or FALSE to switch to turn on/off extra axis mark at final year in timeseries plots.

xlim

Optional, years to use for x-axis. Default value NULL (or "default"), uses all years available.

ylim

Optional, values for y-axis range to display on plot. The default: "default", will range from -1 to 1.

ylimAdj

Multiplier for ylim parameter. Allows additional white space.

xaxs

Choice of xaxs parameter See ?par for more info.

yaxs

Choice of yaxs parameter. See ?par for more info.

xylabs

Logical flag: set TRUE or FALSE to include x- and y-axis labels to the plot. Defaults to TRUE

type

The type of plot to be drawn. For more details, see plot.

legend

Flag to enable legend to plot. TRUE by default.

legendloc

Location of legend. Either a string like "topleft" or a vector of two numeric values representing the fraction of the maximum in the x and y dimensions, respectively. See help("legend") for more info on the string options.

legendcex

Allows to adjust legend cex

pwidth

Default width of plot printed to plot in units of punits

pheight

Height of plot printed to plot in units of punits

punits

Measurement units for pwidth and pheight. Default is "in".

  • "px" (pixels)

  • "in" (inches)

  • "cm" (centimeters)

  • "mm" (millimeters)

res

Resolution for plots printed to files.

ptsize

Point size for plotted text in plots printed in files. See help("png") for more details

cex.main

Character expansion for plot titles.

plotdir

Directory where output plot file will be written. By default, it will be the directory where the model was run.

filenameprefix

Additional text to append to output plot file name. It will be separated from default name by an underscore.

par

A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot,which is passed to par(). Entering NULL passes plot's default par() values (which depends on whether the main title is included or not)

verbose

Flag to print additional diagnostic messages to R console

new

Deprecated. New plot windows are created by default (TRUE), and the option to disable this, via FALSE, is unused.

add

suppresses par() to create multiplot figs

Value

a dataframe with runs test p-value, if the test has passed or failed, 3x sigma high and low limits, and the type of data used. Rows are for each fleet. Note, runs test passed if p-value > 0.05 (residuals are random) and failed if p-value < 0.5 (residuals are not random)

Author(s)

Henning Winker (JRC-EC) and Laurance Kell (Sea++)


Read SS MCMC

Description

A function to read mcmc file outputs from a Stock Synthesis model

Usage

SSreadMCMC(mcmcdir)

Arguments

mcmcdir

file path for folder with the derived_posteriors.sso file

Value

Stock Synthesis mcmc output file

Author(s)

Henning Winker (JRC-EC) & Laurence Kell (Sea++)


Retrieve Composition Data from Multiple SS Models

Description

Wrapper to get observed and expected mean length/age from multiple Stock Synthesis models.

Usage

SSretroComps(retroModels)

Arguments

retroModels

object list of replists from r4ss::SSgetoutput()

Value

list of observed and expected mean Length/age comps (c.f. ss3rep[["cpue"]])

Author(s)

Henning Winker


Function for calculating RMSE used for SSplotJABBAres()

Description

Function for calculating RMSE used for SSplotJABBAres()

Usage

SSrmse(
  ss3rep,
  quants = c("cpue", "len", "age", "con"),
  seas = NULL,
  indexselect = NULL
)

Arguments

ss3rep

output from SS_output()

quants

the dataset to calculate RMSE for. "cpue" for index of abundance, "len" for length comp, "age" for age composition, and "con" for conditional age-at-length.

seas

string indicating how to treat data from multiple seasons 'comb' - combine seasonal data for each year and plot against Yr 'sep' - treat season separately, plotting against Yr.S. If is.null(seas), it is assumed that there is only one season and option 'comb' is used.

indexselect

Vector of fleet numbers for each model for which to compare

Value

returns a list that includes the RMSE table output (by fleet and combined) and the dataframe of residuals which can be used for creating the SSplotJABBAres() plot


Runs Test for Residuals

Description

This function uses randtests::runs.test to do perform a runs test on residuals to determine if they are randomly distributed. It also calculates the 3 x sigma limits

Usage

ssruns_sig3(x, type = NULL, mixing = "less")

Arguments

x

residuals from CPUE fits

type

only c("resid","observations")

mixing

c("less","greater","two.sided"). Default less is checking for positive autocorrelation only

Details

runs test is conducted with library(randtests)

Value

runs p value and 3 x sigma limits

Author(s)

Henning Winker (JRC-EC) and Laurence Kell (Sea++)


Residual Diagnostics Plot

Description

Function for residual diagnostics. Outputs a runs test table that gives runs test p-values, if the runs test passed (p-value > 0.05, residuals are random) or failed (p-value < 0.05, residuals are not random), the 3x sigma limits for indices or mean age or length and the type of input data (cpue, length comp, age comp, size comp, or conditional age-at-length).

Usage

SSrunstest(
  ss3rep,
  mixing = "less",
  quants = c("cpue", "len", "age", "con")[1],
  indexselect = NULL,
  verbose = TRUE
)

Arguments

ss3rep

Stock Synthesis output as read by r4ss::SS_output()

mixing

c("less","greater","two.sided"). Default less is checking for positive autocorrelation only

quants

optional use of c("cpue","len","age","con"), default uses "cpue".

  • "cpue" Index of abundance data

  • "len" Length composition data

  • "age" Age composition data

  • "con" Conditional age-at-length data

indexselect

Vector of fleet numbers for each model for which to compare

verbose

Report progress to R GUI?

Value

a dataframe with runs test p-value, if the test has passed or failed, 3x sigma high and low limits, and the type of data used. Rows are for each fleet. Note, runs test passed if p-value > 0.05 (residuals are random) and failed if p-value < 0.5 (residuals are not random)

Author(s)

Henning Winker (JRC-EC) and Laurance Kell (Sea++)


Get Stock Status Settings

Description

A function to get Bratio and F settings

Usage

SSsettingsBratioF(ss3rep, status = c("Bratio", "F"), verbose = TRUE)

Arguments

ss3rep

from r4ss::SSgetoutput()

status

covarying stock status quantaties to extract from Hessian

verbose

Report progress to R GUI?

Value

output list with Bratio and F settings

Author(s)

Henning Winker (JRC-EC)