Title: | Standardized Trend Metrics for Salmonid Populations |
---|---|
Description: | This is runs the standardized trends metrics used in the 2016 and 2020 5-year NWFSC Viability Reports for listed PNW salmonids. To run, type library(NWCTrends) and then NWCTrends_report(). |
Authors: | Holmes Elizabeth [aut, cre] |
Maintainer: | Elizabeth Holmes - NOAA Federal <[email protected]> |
License: | CC-0 |
Version: | 1.30 |
Built: | 2024-11-24 04:10:10 UTC |
Source: | https://github.com/nwfsc-math-bio/NWCTrends |
Utility function to read in a esu choice from a list
choose.esu(esu.names)
choose.esu(esu.names)
esu.names |
The ESUs/DPSs in the input csv file. |
A vector of ESU/DPS names.
This is similar to clean.pops
but does lighter cleaning.
clean.mpg(pops)
clean.mpg(pops)
pops |
A vector of the population names from the input csv file. |
A vector of cleaned population names.
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov
Utility function to clean up the population names and strip run timing in the population names in the input file. Change this file if the abbreviations used need to be changed.
clean.pops(pops)
clean.pops(pops)
pops |
A vector of the population names from the input csv file. |
A vector of cleaned population names.
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov
Read in the csv inputfile and create the data frames and matrices needed for the fitting, plots and tables: matdat.spawners, matdat.wildspawners, and metadata. Some clean up of names and runtiming is done.
data_setup(inputfile, min.year, max.year, fit.all = FALSE)
data_setup(inputfile, min.year, max.year, fit.all = FALSE)
inputfile |
.csv file. See demofiles for the proper format. |
min.year |
The minimum year for the returned data frames. If left off, it will use the minimum year in the data set. You can set later to exclude data or set before to hindcast. |
max.year |
The maximum year for the returned data frames. If left off, it will use the maximum year in the data set. You can set earlier to exclude data or set later to forecast. |
fit.all |
If TRUE, fit all and don't ask about names. |
NAs are specified with -99, -99.00 or -99.0.
A list with four items:
The raw data for the selected ESUs.
A matrix of the total spawners with NAs for missing years. Each column is a year from min.year to max.year and each row is a population.
A matrix of the the wildspawners using the fracwild data if included. NAs for years with either missing fracwild or missing spawner count. Each column is a year from min.year to max.year and each row is a population.
A data.frame with all the metadata for each population: name = population name, ESU = ESU name, Species, Run = run timing for population, PopGroup = name of the Major Population Group (within ESU), Method = data method (eg Survey or Model), Citation = citation, Contributor = Where the data come from.
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov
This is the fracwild figure function. Not exported. It is used by NWCTrends_report
and inst/doc/report_files/esu_report.Rmd
.
The dots are the raw fracwild values, the black line is the smoothed fracwild estimate. For the smoothed fracwild estimates, there is no data sharing across populations.
fracwild_multipanel( esu, pops, fracwild.fit, min.year = NULL, max.year = NULL, show.all = TRUE, nwctrends.options = NULL )
fracwild_multipanel( esu, pops, fracwild.fit, min.year = NULL, max.year = NULL, show.all = TRUE, nwctrends.options = NULL )
esu |
The name of the ESU |
pops |
The population names that will be plotted (populations with too few data are eliminated) |
fracwild.fit |
fracwild fit returned by |
min.year |
The x axis minimum. |
max.year |
The x axis maximum. |
show.all |
If there is no fracwild data for a population, should that population still have a fracwild plot, which will be blank. |
nwctrends.options |
A list of plot options to change the appearance (colors, line types, line widths, point types, etc)
in the plots. See |
A plot
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov
Takes the wild and total data and makes tables of fraction wild via wild/total and constructs averages for given number of years (typically 5 or 10). The wild data might be shorter than total since if there is no fracwild info, the wild data might not have that population. The total data will be subsetted to only have the populations in the wild data.
The function wants the matrices where the rownames are the population names
and the colnames are the years. In the package output, these are call
total: matdat.spawners
and wild: matdat.wildspawners
.
fracwild_table( wild, total, max.year = 2014, lenbands = 5, nbands = 5, type = c("mean", "geomean") )
fracwild_table( wild, total, max.year = 2014, lenbands = 5, nbands = 5, type = c("mean", "geomean") )
wild |
The wild count as a matrix. It is up to the user where this comes from. It could come from the raw fracwild data times raw total data or come from the smoothed frac wild times smoothed total estimates. |
total |
The total count as a matrix. See above notes on the wild count. |
max.year |
The last year to use when constructing the bands |
lenbands |
Number of years to average |
nbands |
Number of averages to show. |
type |
Type of average: mean or geomean. |
a data frame of the formatted table
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov
Create the tables with the geomeans for different time periods. Two tables are produced: one of the
smoothed wild and total (total in parentheses) spawners. This function is called from esu_report.Rmd
and is not exported. The min.year, max.year, lenbands, nbands, and min.band.points control the
look of the table and can be controlled in the call to NWCTrends_report() by passing in
geomean.table.control as list. For example list(min.year=1999)
to change the min year shown
from the minimum in the dataset (the default) to 1999.
Note that for the raw geomeans, the years used for the total count geomeans can be different than for the natural raw geomeans. This happens when there are years that are missing a frac wild number but there is a total count that year. So the raw geomean divided by the total geomean could be quite different than the average fraction wild.
geomean_table( pops, mpg, total.fit, fracwild.fit, min.year = 1990, max.year = 2014, lenbands = 5, min.band.points = 2, change.col = c("last.two", "first.last"), navalue = " " )
geomean_table( pops, mpg, total.fit, fracwild.fit, min.year = 1990, max.year = 2014, lenbands = 5, min.band.points = 2, change.col = c("last.two", "first.last"), navalue = " " )
pops |
which populations to include in the table |
mpg |
Population group. Shown in the table. |
total.fit |
The matrix of total spawner estimates |
fracwild.fit |
The matrix of fraction wild associated with each total row. |
min.year |
The minumum year to include in the tables. |
max.year |
The maximum year to include in the tables. If this is 'mid-band', the rest of the band will be padded with NAs and the band width of the last band will be less than lenbands. |
lenbands |
How many years in each band. Default is 5-years. |
min.band.points |
The minimum data points for the geomean to show in a band. |
change.col |
Either between last 2 bands or 1st and last. |
navalue |
value to show for NAs |
The code will create bands with lenbands years in each band starting with min.year. If max.year, would lead to a final band with less than lenbands years, then the last band will not have lenbands years. If it has fewer than min.band.points, then the last band will be NA. You will need to properly choose min.year and max.year to get the table to look as you want.
The last column of the tables is the percent change. This can be over the last 2 bands or the first and last bands. The change.col argument determines which it is.
A list with the statesgeomean and rawgeomean data frames (tables).
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov
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 )
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 )
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 |
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 |
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
Load data (.csv)
Fit model(s)
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.
Plots and tables that are saved to doc/figures/ESU_figures.
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov
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.
## Not run: # 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") ) ## End(Not run)
## Not run: # 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") ) ## End(Not run)
Set up the plot default line widths, types and colors. Pass in as a list, such as nwctrends.options = list(main.raw.pch = 1)
with the variables that you wish to set. See details for the names and descriptions of the variables.
main.
variables for the main plot with trends for each ESU
main.title.cex
Size of the main ESU titles in the plot. Default is 1.5.
main.poptitle.cex
Size of the population titles in the individual panels. Default is 1.
main.ylabel.cex
Size of the y axis labels in the individual panels. Default is 0.8.
main.total.lty
Line type for the smoothed total spawners line. Default is 1 (solid).
main.total.lwd
Line width for the smoothed total spawners line. Default is 3 (thick).
main.total.col
Line color for the smoothed total spawners line. Default is black.
main.wild.lty
Line type for the smoothed wild spawners line. Default is 1 (solid).
main.wild.lwd
Line width for the smoothed wild spawners line. Default is 1 (thin).
main.wild.col
Line color for the smoothed wild spawners line. Default is red (#D44045) from the NMFS palette.
main.raw.pch
Point type for the raw spawners data points. Default is 19 (solid circle).
main.raw.col
Color for the raw spawners data points. Default is blue (#00467F) from the NMFS palette.
main.ci.col
Color for the confidence polygon around the smoothed total spawners line. Default is "grey75".
main.ci.border
Border for the confidence polygon around the smoothed total spawners line. Default is NA which is no border. See polygon()
for the options.
main.NAtotal.lty
Line type for the smoothed total spawners line before the first data points. Default is 1 (solid).
main.NAtotal.lwd
Line width for the smoothed total spawners line before the first data points. Default is 3 (thick).
main.NAtotal.col
Line color for the smoothed total spawners line before the first data points. Default is "grey".
main.NAci.col
Color for the confidence polygon around the smoothed total spawners line before the first data points. Default is "grey95".
main.NAci.border
Border for the confidence polygon around the smoothed total spawners line before the first data points. Default is NA which is no border. See polygon()
for the options.
fracwild.
variables for the fracwild plot
fracwild.title.cex
Size of the main ESU titles in the plot. Default is 1.5.
fracwild.poptitle.cex
Size of the population titles in the individual panels. Default is 1.
fracwild.ylabel.cex
Size of the y axis labels in the individual panels. Default is 0.8.
fracwild.lty
Line type for the smoothed fracwild line. Default is 1 (solid).
fracwild.lwd
Line width for the smoothed fracwild line. Default is 2 (medium thick).
fracwild.col
Line color for the smoothed fracwild line. Default is blue (#00467F) from the NMFS palette.
fracwild.raw.pch
Point type for the fracwild raw data points. Default is 1 (open circle).
fracwild.raw.col
Color for the fracwild raw data points. Default is black.
prod.
variables for the productivity plot
prod.title.cex
Size of the main ESU titles in the plot. Default is 1.5.
prod.poptitle.cex
Size of the population titles in the individual panels. Default is 1.
prod.ylabel.cex
Size of the y axis labels in the individual panels. Default is 0.8.
prod.col.neg
Color of the negative productivity bars. Default is red (#D44045) from the NMFS palette.
prod.col.pos
Color of the positive productivity bars. Default is green (#007934) from the NMFS palette.
geomean.
variables for the geomeans plot
geomean.title.cex
Size of the main titles in the plot. Default is 1.
geomean.xaxis.cex
Size of the x axis tick labels in the individual panels. Default is 0.9.
geomean.yaxis.cex
Size of the y axis tick labels in the individual panels. Default is 0.9.
geomean.pch
Point type for the data points. Default is 19 (solid circle).
geomean.cex
Point size for the data points. Default is 1.5.
geomean.col.neg
Color of the negative data points. Default is red (#D44045) from the NMFS palette.
geomean.col.pos
Color of the positive data points. Default is black.
geomean.abline.lty
Line type for the horizontal reference lines. Default is 2 (dashed).
geomean.abline.col
Line color for the horizontal reference lines. Default is "grey".
trend.
variables for the trends plot showing the x-year (e.g. 15-year) trend values in a plot
trend.title.cex
Size of the main title in the plot. Default is 1.
trend.ylabel.cex
Size of the y axis label. Default is 1.
trend.axis.cex
Size of the axis tick labels. Default is 1.
trend.pch
Point type for the data points. Default is 19 (solid circle).
trend.cex
Point size for the data points. Default is 1.5.
trend.col.neg
Color of the negative data points. Default is red (#D44045) from the NMFS palette.
trend.col.pos
Color of the positive data points. Default is black.
Nothing is returned. The variables are set in the internal package environment.
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov
NWCTrends_report()
This uses the smoothed spawner estimates and smoothed fracwild estimates to compute a
productivity metric. Type 3: wild(t+1)/wild(t)
. Type 1: wild(t+lag)/total(t)
, where wild
is smoothed total estimate times smoothed fracwild estimate and total
is the smoothed total
estimate.
In the Viability Report, type=1
and the lag is set to 3 or 4 (depending on species).
productivity_plot( esu, pops, total.fit, fracwild.fit, min.year = NULL, max.year = NULL, type = 1, lag = 4, nwctrends.options = NULL )
productivity_plot( esu, pops, total.fit, fracwild.fit, min.year = NULL, max.year = NULL, type = 1, lag = 4, nwctrends.options = NULL )
esu |
The name of the ESU |
pops |
The population names that will be plotted. |
total.fit |
total fit returned by |
fracwild.fit |
fracwild fit returned by |
min.year |
The x axis minimum. First year for numerator. |
max.year |
The x axis maximum. Last year for numerator. |
type |
The type of plot. Type 3: wild(t+1)/wild(t). Type 1: wild(t+lag)/total(t) |
lag |
The number of years prior to use in the denominator, e.g. spawnwers(year-lag). Note not used if type=3. |
nwctrends.options |
A list of plot options to change the appearance (colors, line types, line widths, point types, etc)
in the plots. See |
A plot
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov
This is the main figure function. Not exported. It is used by NWCTrends_report
and inst/doc/report_files/esu_report.Rmd
.
The dots are the raw spawner counts, the black line is the smoothed total spawners estimate, and the red line is the smoothed wild spawners estimate which is "smoothed total estimate x smoothed fracwild estimate". Note that the wild spawner estimate is only shown from 1 year before and one year after the last actual fracwild estimate (in the data file). This is done so that the wild estimate does not over-extend the fracwild data. Fracwild estimates can be interpolated for missing years, but would not be appropriate to extend much before or past actual observed (or expert) fracwild data.
For the smoothed total estimates, information from all populations (via a non-diagonal year-to-year variance matrix) is used to estimate missing values and to account for observation error in the total spawner count. Because data from all populations are used, estimates can be made even for missing years at the beginning of the time series if there is data for those early years in other populations.
Status_trendfigure_multipanel( esu, pops, total.fit, fracwild.fit, plot.min.year = NULL, plot.max.year = NULL, silent = FALSE, CI.method = "hessian", CI.sim = 1000, log.scale = FALSE, same.scale = FALSE, nwctrends.options = NULL )
Status_trendfigure_multipanel( esu, pops, total.fit, fracwild.fit, plot.min.year = NULL, plot.max.year = NULL, silent = FALSE, CI.method = "hessian", CI.sim = 1000, log.scale = FALSE, same.scale = FALSE, nwctrends.options = NULL )
esu |
The name of the ESU |
pops |
The population names that will be plotted (populations with too few data are eliminated) |
total.fit |
total fit returned by |
fracwild.fit |
fracwild fit returned by |
plot.min.year |
The x axis minimum. |
plot.max.year |
The x axis maximum. |
silent |
No output |
CI.method |
Method sent to |
CI.sim |
If doing bootstrap CI, this is the number of bootstraps sent to MARSSparamCIs |
log.scale |
Put plot on log-scale versus the original raw scale |
same.scale |
Tweak the scale of wild and total in graph. Not used. |
nwctrends.options |
A list of plot options to change the appearance (colors, line types, line widths, point types, etc)
in the plots. See |
A plot
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov
Status_trendfigure_multipanel_csv
, NWCTrends_report()
This returns a data frame that is written to a csv file. Not exported. It is used by
inst/doc/report_files/esu_report.Rmd
.
It returns the smoothed total spawners estimate and the smoothed wild spawners estimate which is "smoothed total estimate x smoothed fracwild estimate". The wild spawner estimate is only shown from 1 year before and one year after the last actual fracwild estimate (in the data file). This is done so that the wild estimate does not over-extend the fracwild data. Fracwild estimates can be interpolated for missing years, but would not be appropriate to extend much before or past actual observed (or expert) fracwild data.
For the smoothed total estimates, information from all populations (via a non-diagonal year-to-year variance matrix) is used to estimate missing values and to account for observation error in the total spawner count. Because data from all populations are used, estimates can be made even for missing years at the beginning of the time series if there is data for those early years in other populations.
Status_trendfigure_multipanel_csv( esu, pops, total.fit, fracwild.fit, log.scale = FALSE )
Status_trendfigure_multipanel_csv( esu, pops, total.fit, fracwild.fit, log.scale = FALSE )
esu |
The name of the ESU |
pops |
The population names that will be plotted (populations with too few data are eliminated) |
total.fit |
total fit returned by |
fracwild.fit |
fracwild fit returned by |
log.scale |
Return values on log-scale versus the original raw scale |
A dataframe
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov
Create the tables with the trends for different time periods using the smoothed
spawner estimates. The trend is the slope of a linear regression of the log spawner counts versus year. Despite the name of the function, the range of years need not be 15 years.
The years to show are specified
by list year.ranges
. The ranges are specified as begin.year:end.year
, for example
1990:2005
. year.ranges
can be padded into the NWCTrends_report() call by passing in
trend.table.control as list. For example list(year.ranges=list(1990:2000,2000:2010))
.
trend_15_table( pops, mpg, total.fit, fracwild.fit, year.ranges = list(1990:2005, 1999:2014), wild = TRUE, navalue = " " )
trend_15_table( pops, mpg, total.fit, fracwild.fit, year.ranges = list(1990:2005, 1999:2014), wild = TRUE, navalue = " " )
pops |
which populations to include in the table |
mpg |
Population group. Shown in the table. |
total.fit |
The matrix of total spawner estimates |
fracwild.fit |
The matrix of fraction wild associated with each total row. |
year.ranges |
The columns of years. |
wild |
Show smoothed wild or smoothed total. |
navalue |
Value to use for NAs in the table. Default is a blank. |
A data frames with the estimates trend for each year range in a different column.
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov
Fis a MARSS model to data from each ESUs treating each population as a subpopulation. The structure of the variance-covariance matrix, the U matrix, the Z matrix, and the R matrix can be specified. If you want to fit a specific model, then pass in model as a list as per a MARSS model. The populations in the ESU with < min.years of data points are not used in the fitting and no states are estimated for those.
trend_fits( datalist, outputfile, wild = TRUE, model = NULL, logit.fw = TRUE, min.years = 5 )
trend_fits( datalist, outputfile, wild = TRUE, model = NULL, logit.fw = TRUE, min.years = 5 )
datalist |
The list output by data_detup() |
outputfile |
The name of the RData file to save the results to. |
wild |
wild=TRUE means to do the fit on fracwild*total versus on the total spawners. |
model |
If null, a set of models is fit. Otherwise pass in a model specified as a list in MARSS format. |
logit.fw |
If TRUE fit to logit of fracwild instead of the raw percentages. |
min.years |
Only populations with at least min.years will be used in the fitting. |
If model=NULL then a set of all possible models is fit. This takes awhile but will allow one to use AIC to compare the model set. wild=TRUE means to do the fit on fracwild*total versus on the total spawners. logit.fw says whether to fit to logit of fracwild or to the percentages.
This function produces a states estimate and a fracwild fit;
A list with three items:
A list with the fits for each ESUs included.
If there are multiple models fit, then the AIC will be returned.
If there are multiple models fit, then the best model is returned.
Eli Holmes, NOAA, Seattle, USA. eli(dot)holmes(at)noaa(dot)gov