This is the main function in the NWCTrends package which creates the ESU tables and figures from the Northwest Fisheries Science Center's Viability Report: "2015 Status review update for Pacific salmon and steelhead listed under the Endangered Species Act: Pacific Northwest". The 2015 NWFSC Viability Report can be viewed by typing RShowDoc("2015_Status_Review_Update", package="NWCTrends") at the command line. The report has a description of the methods used for computing the smoothed trend lines and the status metrics. A pdf of the methods is also available by typing RShowDoc("Methods", package="NWCTrends") at the command line.

NWCTrends_report(
  inputfile = NULL,
  fit.min.year = NULL,
  fit.max.year = NULL,
  model = list(Z = "identity", R = "diagonal and equal", Q = "equalvarcov", U =
    "unequal"),
  logit.fw = FALSE,
  fit.wild = FALSE,
  plot.min.year = NULL,
  plot.max.year = NULL,
  min.data.points = 5,
  geomean.table.control = list(min.year = 1990, max.year = 2014, lenbands = 5,
    min.band.points = 2, change.col = "last.two"),
  trend.table.control = list(year.ranges = list(1990:2005, 1999:2014)),
  output.type = c("html", "pdf", "word"),
  output.dir = "NWCTrend_output",
  fit.all = FALSE,
  show.all.fracwild = FALSE,
  nwctrends.options = NULL
)

Arguments

inputfile

comma-delimited data file (see demo files for the format). demofiles are in inst/extdata.

fit.min.year

Optional. You can set the earliest year to use when fitting the models. If not passed in, then the min.year is the earliest year in the data file. This is used to fit to a subset of the full data set.

fit.max.year

Optional. You can set the last year to use when fitting the models. If not passed in, then the max.year is the last year in the data file. This is used to use a subset of the full data set for fitting.

model

The structure of the MARSS model to use. Entered as a list specified as a MARSS model.

logit.fw

TRUE/FALSE whether to estimate the smoothed fraction wild from the logit of the fractions or from the raw (0,1) fractions.

fit.wild

fit.wild=TRUE means to do the fit on fracwild*total versus on the total spawners. Note all the Viability Report analyses, use fit.wild=FALSE and the wild fit is total spawner fit x fracwild fit.

plot.min.year

Optional. The earliest year to use when plotting the data if different than the first year in the data set.

plot.max.year

Optional. The last year to use when plotting the data if different than the last year in the data set.

min.data.points

The minimum data points to require from a population (for fitting and plotting).

geomean.table.control

A list with the adjustable variables for geomean_table(). See ?geomean_table

trend.table.control

A list with the adjustable variables for trend_15_table(). See trend_15_table. The year.ranges are the years for the multi-year trends. If any years are missing in the data set, then those trends will be blank.

output.type

"html", "pdf", or "word" Format to produce the report in.

output.dir

Directory (in the working directory) where the output will be saved. Defaults to "NWCTrend_output". The directory will be created if it does not exist.

fit.all

If FALSE, then user can enter what ESUs to fun.

show.all.fracwild

If FALSE, then the populations with no fracwild information are not shown on the fracwild plots.

nwctrends.options

A list of plot options to change the appearance (colors, line types, line widths, point types, etc) in the plots. See nwctrends.options for a description of the options.

Value

Plots and tables that are saved to doc/figures/ESU_figures.

Details

The default model used to fit the data is that used in the 2015 Status Update. This model uses information across the populations in an ESU to estimate the process variance, non-process variance (residuals between smoothed fits and observed spawners), covariance in process errors (good and bad year correlation). However it allows each population to have a different trend. This model is specified as model=list(Z="identity", R="diagonal and equal", U="unequal", Q="equalvarcov") .

This function does all the steps to create the trend plots and figures

  1. Load data (.csv)

  2. Fit model(s)

  3. Make plots and tables and save as report

By default, the plots and tables are saved in a directory named (and created if necessary) NWCTrend_output in your working directory.

The look of the tables can be adjusted by passing in geomean.tables.control. See ?geomean_tables for the elements that can be controlled. Note that if the defaults for geomean.table.control are changed, they must be also changed in geomean_tables.R.

The look of the plots (line widths, types, colors, point types, etc) can be changed by passing in nwctrends.options. These are passed in as a list, e.g. nwctrends.options = list(main.total.col = "blue"). See nwctrends.options for a list of the plot variables that can be changed.

See Status_trendfigure_multipanel for details on the main plot of smoothed total and wild spawners. See NWCTrends for a description of the package.

References

Ford, M. J., K. Barnas, T. Cooney, L. G. Crozier, M. Diaz, J. J. Hard, E. E. Holmes, D. M. Holzer, R. G. Kope, P. W. Lawson, M. Liermann, J. M. Myers, M. Rowse, D. J. Teel, D. M. Van Doornik, T. C. Wainwright, L. A. Weitkamp, M. Williams. 2015. Status Review Update for Pacific Salmon and Steelhead Listed under the Endangered Species Act: Pacific Northwest. Nationa Marine Fisheries Service, Northwest Fisheries Science Center. Available from the NWFSC Publications page.

Author

Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov

Examples

if (FALSE) { # Example of the typical arguments that you will want to set library(NWCTrends) NWCTrends_report(inputfile="thedata.csv", fit.min.year=1949, fit.max.year = 2019, plot.min.year=1980, plot.max.year = 2019, geomean.table.control=list( min.year = 1990, max.year = 2019, lenbands = 5, min.band.points = 2, change.col="last.two"), trend.table.control=list( year.ranges = list(1990:2005, 2004:2019)), output.type = "word", output.dir = "Output" ) # Example of setting the plot variables to customize the look of the plots # Here the data points and wild line for the main plot are changed. NWCTrends_report(inputfile="thedata.csv", nwctrends.options = list(main.raw.pch = 1, main.raw.col = "black", main.wild.lty = 2, main.wild.col = "grey75") ) }