TropFishR (development version)
New features
- Bootstrapped ELEFAN (Schwamborn et al. 2019) to assess the uncertainty of the growth parameters:
-
lfqResampleresamples length-frequency data. -
ELEFAN_GA_bootandELEFAN_SA_bootfitELEFAN_GAorELEFAN_SAto many resampled data sets (optionally in parallel) and return the estimates with maximum density, medians and confidence intervals (classlfqBoot). - Plots of the results:
univariate_density,LinfK_scatterhist(withadd_phiprimefor phi’ isolines),vbgfCI_timeandplotBoot. - Example data set
alba_boot. - The bootstrapped growth parameters can be passed on to the following steps of the assessment with the new argument
bootofM_empirical(methods “Then_growth” and “Pauly_Linf”),catchCurve(with automatic choice of the regression line, optional selectivity, andnatMortfor F = Z - M),VPA(length-based) andpredict_mod(Thompson and Bell and Beverton and Holt with reference points and current F relative to them), so that the uncertainty is propagated to mortality rates and reference points. -
MstochThenestimates M with the formula of Then et al. (2015) including the uncertainty of the formula and optionally the residual error (resid = TRUE), based on coefficients refitted to bootstrap samples of the data of Then et al. (2015). - Estimates of the steps after the growth analysis are summarised by the mode of their univariate kernel density (
maxDen), the median and quantiles (CI). Resamples that cannot be analysed areNAand a warning gives their number. -
predict_modwithboot:bootSelselects the selectivity fromcatchCurve(L50,L75) or the fishing mortality at length fromVPA. -
catchCurvewithbootassumes knife-edge selection if the selection ogive cannot be estimated because there are fewer than two length classes with catch below the regression line. -
plotBootwithpType = "cc"andpType = "ypr"shows the catch curves and yield per recruit curves of the resamples. - New vignette “Uncertainty in length-based stock assessment with bootstrapped ELEFAN”.
- New dependency:
ks.
-
-
catchCurve: new argumentbinSizeto re-bin the length classes. -
lfqRaiseraises the sampled numbers of fish to the total catch with the total landings in weight (per sample or per year) and the measured or estimated weight of the samples (issue #53). -
VPA: new argumentslandings,sampleWeightandraiseBy. Withlandings, the lfq data keep the sampled numbers of fish, which are raised to the total catch withlfqRaiseand summed per year; withboot, each resample is raised. The documentation ofcatch_unitandcatch_corFacis clearer:catch_unit = "kg"means the catch in weight per length group, not the total landings. -
lfqResample,ELEFAN_GA_boot,ELEFAN_SA_bootandcatchCurve/VPAwithbootstop if the lfq data contain raised catches (lfqRaise) and warn if the catch is not in whole numbers, because the resampling requires the sampled numbers of fish. - Vignette “Length-frequency data for TropFishR”: new sections on data of several years (issue #45) and on sampled numbers and total catch.
- Shorter examples (
alba,ELEFAN_SA,ELEFAN_SA_boot,plotBoot) to reduce the time ofR CMD checkwith--run-donttest. Thealbahelp page no longer fits ELEFAN_SA (see the examples ofELEFAN_SAandELEFAN_GA) (issue #41). - The example files of the vignette “Length-frequency data for TropFishR” (
lfq1.csv,lfq2.csv,lfq2.txt,lfq3.csv,lfq3.xlsx) are now included in the package (system.file("extdata", package = "TropFishR")) and the import code of the vignette is run when the vignette is built. The code did not work with the files before: wrong separators (read.csv2for comma separated files), a wrong column name (dateinstead ofDATE), and dates in the header of data arrangement 3 that R changed when reading the file, so that all dates becameNA(issue #42). -
VPAandpredict_mod: new argumentLW_unit("kg", default, or"g") for the unit of the weight in the length-weight relationship. -
growth_length_age(method = "LSM",CI = TRUE): the confidence band of the growth curve usesci.level(before always 95 %) and the t distribution with the residual degrees of freedom, and is returned aspredCI(before only plotted) (issue #40). -
predictmethod forselect_Millarresults: relative retention of the fitted selectivity model for any lengths and mesh sizes (also for mesh sizes that were not used in the experiment) (issue #43). -
select_Millar_curve: retention of the selection curves ofselect_Millar(all curve types) for given parameters, e.g. published gillnet selectivity parameters, on the usual scale (mode and standard deviation, or L50 and selection range, for a reference mesh size) (issue #43). -
select_Millar_compare: compares selection curves fitted withselect_Millarto the same data by AICc and QAICc, with a common overdispersion factor (c_hat) estimated from the most general model (issue #39). NewlogLikmethod forselect_Millarresults, so thatAICandBICcan be used. -
select_Millar: the gamma curve (rtype = "gamma") can now be fitted;estimatescontains its mode and standard deviation for the first mesh size. The help page explains the scale ofparandx0. -
univariate_density: new argumentparsto select the parameters, and the line of maximum density is now the mode of the kernel density (before: mean of the values with the highest 1 % of the density). -
VBGF: the age at length of the seasonalised VBGF is calculated faster and more precisely (interpolation in the lookup table). -
ELEFAN: new argumentplot.score(defaultTRUE), as inELEFAN_GAandELEFAN_SA, to switch off the score graph (response surface or K-scan). The argumentplotonly controls the plot of the restructured data with the growth curves.
Bug fixes
-
lfqRestructure(andELEFAN,ELEFAN_SA,ELEFAN_GAand their bootstrap versions) withaddl.sqrt = TRUE: the square-root adjustment used the counts of the wrong length classes when a sample started with empty length classes (positions counted from the first non-zero class), so that positive restructured values were divided by other counts or set to 0. -
ELEFAN_GA_bootandELEFAN_SA_boot:median,CIandmultiCIofphiLandagemaxare now the median, quantiles and range of the values of the resamples. Before, they were calculated from the median and the limits ofLinfandK, which made the confidence intervals ofphiLmuch too wide, becauseLinfandKare negatively correlated. The summaries of the data setalba_bootwere updated (same resamples). -
ELEFAN_GA_boot,ELEFAN_SA_bootandunivariate_density:t_anchorandtsare times of the year (0.98 and 0.02 are close). If the resamples clearly wrap around the turn of the year, they are now summarised on a continuous range: the median and the value with maximum density are between 0 and 1, the limits ofCIandmultiCIcan be below 0 or above 1. Before, the median and the confidence intervals of such resamples were wrong (e.g. a median around 0.5 for estimates around 0). The summaries of the precomputed bootstrap in the vignette “Bootstrapped ELEFAN” were updated (same resamples);alba_bootis unchanged. -
plot.catchCurve: the regression line failed (“‘x’ and ‘y’ lengths differ”) if the regression range included a point without catch-curve value, such as the plus group, whichlmdrops. The tutorial vignette now ends the regression at the last point before the plus group. -
ELEFAN_GA_boot,ELEFAN_SA_boot,plotBoot,vbgfCI_time: clear error messages if the kernel density of the bootstrapped parameters cannot be estimated (fewer resamples than parameters, a parameter with the same value in all resamples, or other failures ofks::Hpi), instead of errors like “the leading minor of order 4 is not positive”. InELEFAN_GA_bootandELEFAN_SA_boot, this is a warning: the fits of the resamples are returned (with medians and univariate confidence intervals,maxDenandmultiCIareNA), so that they are not lost after a long run. -
select_Millar: invalid parameters during the optimisation (e.g. a negative scale of the gamma curve) gave missing values that were dropped from the likelihood, so that the optimisation could end at invalid parameters with a singular Hessian (“It is impossible to invert the matrix”). The likelihood of such parameters is now infinite. -
VBGF: the age at length of the seasonalised VBGF is nowInfatLinfandNaNaboveLinf(as for the non-seasonal VBGF). Previously the maximum age of an internal lookup table was returned, so that length classes at or aboveLinfappeared as very old fish, e.g. in the length-converted catch curve with seasonal growth parameters. Also, the age range of the lookup table now depends on the largest length instead of the last one, so that lengths that are not sorted get correct ages. -
catchCurve: infinite values of ln(C/dt) (e.g. dt = 0) are ignored like missing values. Previously the regression failed with an error. -
ELEFAN_SA: the score graph (plot.score = TRUE) is drawn again (issue #54). It shows the score of each evaluation of the cost function and the best score so far, recorded byELEFAN_SAitself, because the trace ofGenSA(trace.mat) is usually empty for the run times of ELEFAN_SA. -
ELEFAN_SA: the argumentnb.stop.improvementis now passed toGenSA; previously it was ignored. -
Bhattacharya: a selection of points whose regression line does not fall (slope >= 0) or that contains infinite values is now rejected and the points can be chosen again. Previously this failed with “need finite ‘ylim’ values” or gave a standard deviation of NaN, e.g. when the third cohort of the help example was selected first (issue #52). The help page explains that the cohorts have to be selected from left to right. -
Bhattacharya: the length class in the middle of the selected points, from which the numbers of a cohort are calculated, is now correct for class widths other than 1 (the class width was used as the step between rows). -
Bhattacharya: the mean length and standard deviation are returned if only one cohort is selected (previouslyLmean_SD_listwas NA). -
Bhattacharyais reproducible: the length range of a cohort is now the expected smallest and largest ofn_rnormlengths (normal quantiles, Blom’s approximation) instead of the extremes ofn_rnormrandom draws, so repeated runs with the same selection give the same results. Also, the class of these lengths is found without rounding them to whole numbers first (relevant for class widths below 1). -
Bhattacharya: the result contains the elements of the input list (midLengths,catch, …) as stated in the help page, instead of the input list as an unnamed first element. -
catchCurve:reg_intis checked. It has to contain the numbers of the first and last point of the regression line (whole numbers within the number of points), not lengths or ages. Before, values likec(10.5, 14.5)were silently truncated to points 10 and 14, and values beyond the last point failed with an unclearlm.fiterror. The order of the two points no longer matters (issue #48). -
catchCurve: clear error messages ifcatch_columnsis used with a catch vector or does not match the columns of the catch matrix, and ifLinforKare missing for length data (with how to add them tolfq$par) (issue #48). -
VPA:terminalFandterminalEare checked. Several values (e.g.Z - Mwith M of several methods) gave the error “the condition has length > 1” (issue #47) and now give an error asking to choose one value.terminalFhas to be > 0 andterminalE> 0 and < 1 (before,terminalE = 1gave an infinite andterminalF < 0a negative terminal F);NULLis treated as not provided; if both are provided, a warning says thatterminalEis ignored. - Vignette “bootstrapped ELEFAN”: the bootstrapped VPA requires the sampled numbers of fish in the lfq data and the landings (
landings), not the total catch in the lfq data as stated before. -
catchCurvewithauto = TRUE: the regression line now ends at the point with the largest age and ln(C/dt) > 0.2. Previously the position of this point among the points with ln(C/dt) > 0.2 was used as index of all points, so that the line ended too early if there were points with ln(C/dt) <= 0.2 (or missing) before it. -
catchCurve: seasonal growth parameters (C,ts) inparam$par(e.g. from ELEFAN) are now used. Previously they were only used if they were elements ofparamitself. -
VPA:t0inparam$paris now used (previously always 0 withpar). -
stock_sim(length-based, used bypredict_modwithtype = "ThompBell"): the length class includingLinfis now the plus group and length classes aboveLinfareNA. Previously only the last length class was treated as plus group; with length classes aboveLinf, the fish growing beyond the last class belowLinfwere lost, so that catch, yield and biomass were too low. - ELEFAN score (
lfqFitCurves, used byELEFAN,ELEFAN_SAandELEFAN_GA): if the first cell of the data (smallest length class of the first sample) was part of a positive peak, the cells outside of positive peaks were treated as one peak, so that their (negative) scores were mostly ignored and scores were too high. This could happen e.g. after removing small length classes withlfqModify(Lmin = ...). -
lfqCreatewithplus_group: the plus group no longer counts the fish in its own length class twice. -
growth_taggingwithmethod = "Munro":Kis now the mean of the individual growth rates at the optimalLinf. Previously the coefficient of variation of the individual growth rates was returned asK. -
stock_sim(age-based):- Mean biomass is now also correct without fishing (
FM = 0); previously it was 0. - The yield and value of the plus group now include all of its catch. Previously only the catch beyond the first time step of the plus group was used, so yield and value were too low.
- With a plus group,
meanBno longer depends on age classes that are older than the plus group.
- Mean biomass is now also correct without fishing (
-
predict_modwithtype = "ThompBell":- The exploitation rates of the reference points (
E01,Emax,E05,E04) are now calculated asE = F / (F + M). Previously they could be greater than 1. - The reference points are searched over the full range of
FM_change. Previously the search was limited toFbetween 0 and 5. - The biomass per recruit at F0.1 is now returned as
BPR_F01. Previously it was returned under the duplicate nameYPR_F01(showing up asYPR_F01.1). - Because of the fixes in
stock_sim, the biomass atF = 0and the reference point F0.5 are now correct for age-based data.
- The exploitation rates of the reference points (
-
prod_mod: the Fox virgin biomass (Fox_Bv) is nowexp(c), the CPUE at zero effort of the Fox modelln(CPUE) = c + d * f. Previously the interceptcitself was returned. -
yeardec2dateno longer returns the previous day for some dates because of floating point error (e.g. 2019-07-15 was returned as 2019-07-14).
Minor changes
-
ELEFAN_GA: new defaultspopSize = 100,maxiter = 200andrun = 50(beforepopSize = 50,maxiter = 100,run = maxiter). The ELEFAN score has many local maxima, and in simulations the former defaults often stopped far from the best solution. Results with the default settings therefore differ from earlier versions, also with the sameseed; the former behaviour is obtained by setting these arguments explicitly.ELEFAN_GA_bootkeeps its defaults. - Vignette “ELEFAN”: new sections on repeating the search with different seeds and on the limitations of ELEFAN (harmonics with sparse data, the
Linf-Kridge for slowly growing species). - Faster ELEFAN: the score calculation in
lfqFitCurvesanddate2yeardecare faster (same results), which speeds upELEFAN,ELEFAN_SA(more iterations withinSA_time) andELEFAN_GAseveral times. - Faster vignettes.
- Added unit tests (
testthat).
TropFishR 1.6.6 (2025-04-06)
CRAN release: 2025-05-01
Minor changes
- Removed the dependency on the package
propagate, which was archived on CRAN. The confidence band of the fitted growth curve ingrowth_length_age(method = "LSM",CI = TRUE) is now calculated with the delta method. -
growth_length_age: the argumentdo.simis deprecated and has no effect (a warning is given ifdo.sim = TRUE); the argumentnsimwas removed.
TropFishR 1.6.5 (2024-10-21)
CRAN release: 2024-10-31
Minor changes
- Fixed CRAN notes: package authors are given as
Authors@R(incl. ORCID), updated link to the FAO manual, and corrected documentation links. - Links between the vignettes were restored.
- Shorter vignette building time: fewer iterations in the ELEFAN vignette and shorter
SA_timein theELEFAN_SAexample.
TropFishR 1.6.4 (2024-01-29)
CRAN release: 2024-03-01
Bug fixes
-
ELEFAN_GAandELEFAN_SAwithplot = TRUE: the growth curves are drawn with the estimated parameters (par); previously the non-existing elementparswas used.
Minor changes
-
Bhattacharyarequires an interactive session and returnsNULLwith a message otherwise. -
catchCurveandpowell_wetherall: ifreg_intis not provided (andauto = FALSEincatchCurve), the points for the regression line can only be chosen in an interactive session; otherwiseNULLis returned with a message. - Progress bars in
ELEFANandpredict_modare only shown in interactive sessions. -
lfqRestructure(and thus all ELEFAN functions) gives an informative error if a sample contains only zeros. -
ELEFAN: the score graph is only drawn ifplot = TRUE. -
ELEFAN_SA: the score graph (plot.score) is currently not drawn, because the trace of the optimisation is not available fromGenSAany more. -
growth_length_age(method = "LSM",CI = TRUE) plots the confidence band of the growth curve again, usingpropagate::predictNLS. -
Matrixmoved fromDependstoImports;statsandutilsmoved fromSuggeststoImports. - Updated URLs; links between vignettes were removed for CRAN.
TropFishR 1.6.3 (2021-09-02)
CRAN release: 2021-10-04
New features
- Exclude NA in
VBGFfunction with argumentna.rm = TRUE(default isFALSE) - SPR calculation in Thompson and Bell yield per recruit model + SPR-based reference points
Bug fixes
- Correct separation index calculation in Bhattacharya’s method (correct =
(L1 - L2) / (sd1 + sd2)/2) - Correct standard deviation calculation in Bhattacharya’s method (correct =
sqrt(-dL/b) - Correct equations of Heincke and Robson & Chapman methods in the
Z_CPUEfunction - Return
score_matinELEFANfunction
Minor changes
- Updated vignettes
-
LazyData = falsewhich implies thatdata("...")has to be used to load a package into the R environment, e.g.data("snyLFQ7") - Argument
plots_refsinplot.predict_modfunction to select which reference points in the prediction models should be plotted. By default all reference points are plotted:plot_refs = c("F01","Fmax","F05","F04"). - Argument
cols_refsinplot.predict_modfunction to select the colour for the reference points in the prediction models. Default colours arecols_refs = c("goldenrod2","darkred","darkgreen","darkorange"). - Change naming from ‘Fmsy’ in prediction models to ‘Fmax’.
TropFishR 1.6
New features
- The Length-based Bayesian biomass estimator method (LBB) by
Froese et al. (2018) has been added to the package.
- Improved implementation of compilation of length-frequency
data allowing for faster compilation of lfq data with
lfqCreate and lfqModify (with argument bin_size) and allowing
compilation of large data sets
- New possibilities to easily modify length-frequency data
objects by means of "lfqModify", including aggregating catch
matrix per year, per quarter, or per month, subsetting lfq
data with range of length classes or sampling datesTropFishR 1.2.1
CRAN release: 2018-01-08
Bug fixes
- The ELEFAN functions did not overwrite any element of the lfq object but instead
concatinated parameters onto the object. This can have unintended side effects, e.g. if several
growth parameters are saved in the lfq object and the plotting functions are called.
Now, the application of ELEFAN functions overwrites any growth parameters in the lfq object.TropFishR 1.2
CRAN release: 2017-12-13
New features
- Due to more efficient matrix computations ELEFAN is 2-4 times faster as before
- missing seed values were added in ELEFAN_GA()
- `plot.lfq()` allows plotting relative frequencies, this is
in particular useful in cases where one sampling time has a large number of samples
- `plot.catchCurve()` allows plotting results according to length rather
than relative age. This can be done with the argument `xaxis`.
- lfq plot can be used to plot 2 different lfq data sets; this allows to visually compare the two data sets
- `lfqModfiy()` allows combining two different lfq data sets. This
might be interesting when different fleets are investigated separately
- possible to define and plot multiple regression lines
in the catch curve analysis
- length converted catch curve can account for the seasonalized VBGFBug fixes
- crash report of ELEFAN_GA with interactive sessions (Rstudio) fixed
and more stable on windows
- plot.catchCurve() was not displaying the regression line, but
a straight line from the first to last point of the chosen interval
- restructering of lfq data was not in line with FiSAT implementation
- fixing bug in handling of leap years
- when merging lfq data with another list using c() one has to reassign
the class "lfq" to the merged object, this has been added in the tutorial
- beep sound was causing R crashes on windows computers and was therefore removed