Single-species fish stock assessment with TropFishR

knitr::opts_chunk$set(echo = TRUE,
                      cache = FALSE,
                      warning = FALSE,
                      eval = TRUE,
                      error = FALSE,
                      warning = FALSE,
                      message = FALSE,
                      include = TRUE,
                      collapse = TRUE,
                      comment = "#>",
             = "hold",
                      fig.width=8, fig.height=7)

This tutorial illustrates the application of the TropFishR package to perform a single-species fish stock assessment with length frequency (LFQ) data. According to @Sparre1998b, this includes following steps: (1) estimation of biological stock characteristics (growth and natural mortality), (2) exploration of fisheries aspects (exploitation rate and selectivity), (3) assessment of stock size and status. The order of the methods is important as they build upon each other in a sequential way. Data from literature might be used to skip a step in this workflow or to compare them to the outcomes of this routine.

Installing TropFishR

The current version of TropFishR (v1.2) requires R $>= 3.0.0$ and can be downloaded from CRAN as follows:

install.packages("TropFishR", repos = "")

The package is loaded into the R environment with:

install_github("tokami/TropFishR", ref="master")

The tutorial will make use of a synthetic LFQ data set included in the package ("synLFQ7"). To load the data set into the R environment use:


Biological stock characteristics

Growth, natural mortality, recruitment patterns and the stock-recruitment relationship are important biological stock characteristics and input parameters for population dynamics and yield per recruit models.

Growth parameters

Commonly used growth parameters are the asymptotic length ($L_{inf}$), the growth coefficient (K) and the theoretical length at age zero ($t_{0}$) of the von Bertalanffy growth function (VBGF). The ELEFAN (ELectronic LEngth Frequency ANalysis) methods allow to estimate $L_{inf}$ and K from LFQ data by restructuring the data and fitting growth curves through the restructured LFQ data [@Pauly1980]. I recommend to start by visualising the raw and restructured LFQ data, which aids in determining an appropriate bin size and the moving average of the restructuring procedure. The function "lfqModify" allows to change the bin size by setting the argument "bin_size" to a numeric. The function "lfqRestructure" is used for the restructuring process, where the argument "MA" allows to control the number of bins used for the moving average and the argument "addl.sqrt" allows to apply an additional squareroot transformation in the restructuring process, which reduces the weighting of large individuals.

# set seed value for reproducible results

# adjust bin size
synLFQ7a <- lfqModify(synLFQ7, bin_size = 4)

# plot raw and restructured LFQ data
lfqbin <- lfqRestructure(synLFQ7a, MA = 5, addl.sqrt = FALSE)
opar <- par(mfrow = c(2,1), mar = c(2,5,2,3), oma = c(2,0,0,0))
plot(lfqbin, Fname = "catch", date.axis = "modern")
plot(lfqbin, Fname = "rcounts", date.axis = "modern")

For synLFQ7, a bin size of 4 cm and a moving average of 5 seems appropriate and will be used in the following. To get a first estimate of $L_{inf}$, the Powell-Wetherall method [@Wetherall1987] can be applied. The method requires a catch vetor per length class representative for the length distribution in yearly catches instead of the catch matrix. The argument catch_columns allows to choose the columns of the catch matrix which will be summarised for the analysis. Here all columns are used as the catch matrix only includes catches from 2016. If data of several years are available, the data can be aggregated yearly and the results can be averaged or the data of several years is analysed jointly assuming constant growth parameters.

# Powell Wetherall plot
res_PW <- powell_wetherall(param = synLFQ7a,
                           catch_columns = 1:ncol(synLFQ7a$catch),
                           reg_int = c(10,28))
# show results
paste("Linf =",round(res_PW$Linf_est), "±", round(res_PW$se_Linf))

The argument reg_int is necessary in this tutorial because the "powell_wetherall" function includes an interactive plotting function where points for the regression analysis have to be selected by the user. Typically, one would not use this argument and instead choose which points to include in the regression analysis by clicking on the interactive plot (for more information see help(powell_wetherall)).

For the data of this exercise the Powell-Wetherall method returns a $L_{inf}$ (± standard error) of r {round(res_PW$Linf_est,2)} ± r {round(res_PW$se_Linf,2)} cm, as determined by the x-intercept of the regression line. This estimate can be used for further analysis with ELEFAN. In TropFishR, there are 4 different methods based on the ELEFAN functionality: (i) K-Scan for the estimation of K for a fixed value of $L_{inf}$, (ii) Response Surface Analysis (RSA), (iii) ELEFAN with simulated annealing ("ELEFAN_SA"), and (iv) ELEFAN with a genetic algorithm ("ELEFAN_GA"), where the last three methods all allow to estimate K and $L_{inf}$ simultaneously.

To get a quick K value corresponding to the $L_{inf}$ estimate of the Powell-Wetherall method, the estimate can be assigned to the argument Linf_fix in the function "ELEFAN":

# ELEFAN with K-Scan
res_KScan <- ELEFAN(synLFQ7a, Linf_fix = res_PW$Linf_est,
                    MA=5, addl.sqrt = TRUE, hide.progressbar = TRUE)

# show results
res_KScan$par; res_KScan$Rn_max

This method, however, does not allow to test if different combinations of $L_{inf}$ and K might result in a better fit. RSA with a range around the $L_{inf}$ estimate from the Powell-Wetherall method can be used to check different combinations. Alternatively, the maximum length in the data or the maxmimum length class^[or average of the several largest lengths or length classes] might be used as an reference for the search space of $L_{inf}$ [@Taylor1958; @Beverton1963]. For this data set we chose a conservative range of the estimate from the Powell-Wetherall method plus/minus 10 cm. Any range can be chosen, while a larger search space increases computing time but gives a better overview of the score over a wide range of $L_{inf}$ and K combinations. A K range from 0.01 to 2 is relatively wide and should generally be sufficient.

# Response surface analyss
res_RSA <- ELEFAN(synLFQ7a, Linf_range = seq(119,139,1), MA = 5,
                  K_range = seq(0.01,2,0.1), addl.sqrt = TRUE,
                  hide.progressbar = TRUE, contour=5)

# show results
res_RSA$par; res_RSA$Rn_max

It is generally not recommendable to settle with the first estimate from RSA, as the method might find many local optima with close score values, but returns only the estimates associated with the highest score value. I recommend analysing several local maxima of the score function with a finer resolution for both parameters and compare the calculated score values and fit graphically. For this data, this automated procedure (code below) returns the highest score value (0.781) for the parameters $L_{inf}$ = 122.2, K = 0.21, and $t_{anchor}$ = 0.38 (more information on $t_{anchor}$ further down).

# find 3 highest score values
n <- length(res_RSA$score_mat)
best_scores <- sort(res_RSA$score_mat,partial=n-0:2)[n-0:2]
ind <- arrayInd(which(res_RSA$score_mat %in% best_scores),
Ks <- as.numeric(rownames(res_RSA$score_mat)[ind[,1]])
Linfs <- as.numeric(colnames(res_RSA$score_mat)[ind[,2]])

res_loop <- vector("list", 3)
for(i in 1:3){
  tmp <- ELEFAN(synLFQ7a,
                Linf_range = seq(Linfs[i]-2, Linfs[i]+2, 0.2),
                K_range = seq(Ks[i]-0.1, Ks[i]+0.1, 0.05),
                MA = 5,
                addl.sqrt = TRUE,
                hide.progressbar = TRUE,
  res_loop[[i]] <- cbind(Rn_max=tmp$Rn_max, t(as.matrix(tmp$par)))
results <-, res_loop)

Note that RSA does not allow to optimise over the parameters C and $t_s$ of the seasonalised VBGF (soVBGF). It only allows to compare the score of ELEFAN runs with manually fixed C and $t_s$ values. In contrast, the newly implemented ELEFAN method ELEFAN_SA using a simulated annealing algorithm [@Xiang2013] and ELEFAN_GA using genetic algorithms allow for the optimisation of the soVBGF [@Taylor2016]. The optimisation procedure in the simulated annealing algorithm gradually reduces the stochasticity of the search process as a function of the decreasing "temperature" value, which describes the probability of accepting worse conditions. In reference to the results of the Powell-Wetherall plot a second search within the range of r {round(res_PW$Linf_est)} ± 10 cm for $L_{inf}$ is conducted. The search space of K is limted by 0.01 and 1.

# run ELEFAN with simulated annealing
res_SA <- ELEFAN_SA(synLFQ7a, SA_time = 60*0.5, SA_temp = 6e5,
                    MA = 5, seasonalised = TRUE, addl.sqrt = FALSE,
                    init_par = list(Linf = 129, K = 0.5, t_anchor = 0.5, C=0.5, ts = 0.5),
                    low_par = list(Linf = 119, K = 0.01, t_anchor = 0, C = 0, ts = 0),
                    up_par = list(Linf = 139, K = 1, t_anchor = 1, C = 1, ts = 1))
# show results
res_SA$par; res_SA$Rn_max

Note that the computing time can be controlled with the argument "SA_time" and the results might change when increasing the time, in case the stable optimum of the objective function was not yet reached^[Stable optimum is indicated by overlapping blue and green dots in the score graph.]. Due to the limitations of the vignette format the computation time was set to 0.5 minutes, which results already in acceptable results of $L_{inf}$ = r {round(res_SA$par$Linf,2)}, K = r {round(res_SA$par$K,2)}, $t_{anchor}$ = r {round(res_SA$par$t_anchor,2)}, C = r {round(res_SA$par$C,2)}, and $t_s$ = r {round(res_SA$par$ts,2)} with a score value ($Rn_{max}$) of r {round(res_SA$Rn_max,2)}. I recommend to increase 'SA_time' to 3 - 5 minutes to increase chances of finding the stable optimum. The jack knife technique allows to estimate a confidence interval around the parameters of the soVBGF [@Quenouille1956; @Tukey1958; @Tukey1986]. This can be automated in R with following code:

JK <- vector("list", length(synLFQ7a$dates))
for(i in 1:length(synLFQ7a$dates)){
  loop_data <- list(dates = synLFQ7a$dates[-i],
                  midLengths = synLFQ7a$midLengths,
                  catch = synLFQ7a$catch[,-i])
  tmp <- ELEFAN_SA(loop_data, SA_time = 60*0.5, SA_temp = 6e5,
                   MA = 5, addl.sqrt = TRUE,
                   init_par = list(Linf = 129, K = 0.5, t_anchor = 0.5, C=0.5, ts = 0.5),
                   low_par = list(Linf = 119, K = 0.01, t_anchor = 0, C = 0, ts = 0),
                   up_par = list(Linf = 139, K = 1, t_anchor = 1, C = 1, ts = 1),
                   plot = FALSE)
  JK[[i]] <- unlist(c(tmp$par,list(Rn_max=tmp$Rn_max)))
JKres <-, JK)
# mean
JKmeans <- apply(as.matrix(JKres), MARGIN = 1, FUN = mean)
# confidence intervals
JKconf <- apply(as.matrix(JKres), MARGIN = 1, FUN = function(x) quantile(x, probs=c(0.025,0.975)))
JKconf <- t(JKconf)
colnames(JKconf) <- c("lower","upper")

# show results

Depending on the number of sampling times (columns in the catch matrix) and the "SA_time", this loop can take some time as ELEFAN runs several times, each time removing the catch vector of one of the sampling times. Another new optimisation routine is based on generic algorithms and is applied by:

# run ELEFAN with genetic algorithm
res_GA <- ELEFAN_GA(synLFQ7a, MA = 5, seasonalised = TRUE, maxiter = 50, addl.sqrt = FALSE,
                    low_par = list(Linf = 119, K = 0.01, t_anchor = 0, C = 0, ts = 0),
                    up_par = list(Linf = 139, K = 1, t_anchor = 1, C = 1, ts = 1),
                    monitor = FALSE)
# show results
res_GA$par; res_GA$Rn_max

The generation number of the ELEFAN_GA was set to only 50 generations (argument 'maxiter'), which returns following results: $L_{inf}$ = r {round(res_GA$par$Linf,2)}, K = r {round(res_GA$par$K,2)}, $t_{anchor}$ = r {round(res_GA$par$t_anchor,2)}, C = r {round(res_GA$par$C,2)}, and $t_s$ = r {round(res_GA$par$ts,2)} with a score value ($Rn_{max}$) of r {round(res_GA$Rn_max,2)}. As with ELEFAN_SA the generation number was hold down due to the vignette format and should be increased in order to find more stable results. According to [@Pauly1980] it is not possible to estimate $t_{0}$ (theoretical age at length zero) from LFQ data alone. However, this parameter does not influence results of the methods of the traditional stock assessment workflow (catch curve, VPA/CA, and yield per recruit model) and can be set to zero (Mildenberger, unpublished). The ELEFAN methods in this package do not return starting points as FiSAT II users might be used to. Instead, they return the parameter "t_anchor", which describes the fraction of the year where yearly repeating growth curves cross length equal to zero; for example a value of 0.25 refers to April 1st of any year. The maximum age is estimated within the ELEFAN function: it is the age when length is 0.95 $L_{inf}$. However, this value can also be fixed with the argument "agemax", when alternative information about the maximum age of the fish species is available.

The fit of estimated growth parameters can also be explored visually and indicates high similarity with true growth curves and a good fit through the peaks of the LFQ data.

# plot LFQ and growth curves
plot(lfqbin, Fname = "rcounts",date.axis = "modern", ylim=c(0,130))
lt <- lfqFitCurves(synLFQ7a, par = list(Linf=123, K=0.2, t_anchor=0.25, C=0.3, ts=0),
                   draw = TRUE, col = "grey", lty = 1, lwd=1.5)
# lt <- lfqFitCurves(synLFQ7, par = res_RSA$par,
#                    draw = TRUE, col = "goldenrod1", lty = 1, lwd=1.5)
lt <- lfqFitCurves(synLFQ7a, par = res_SA$par,
                   draw = TRUE, col = "darkblue", lty = 1, lwd=1.5)
lt <- lfqFitCurves(synLFQ7a, par = res_GA$par,
                   draw = TRUE, col = "darkgreen", lty = 1, lwd=1.5)

For further analysis, we use the outcomes of the simulated annealing approach by adding them to the Thumbprint Emperor data list.

# assign estimates to the data list
synLFQ7a <- c(synLFQ7a, res_SA$par)
class(synLFQ7a) <- "lfq"

Natural mortality

The instantaneous natural mortality rate (M) is an influential parameter of stock assessment models and its estimation is challenging [@Kenchington2014; @Powers2014]. When no controlled experiments or tagging data is available the main approach for its estimation is to use empirical formulas. Overall, there are at least 30 different empirical formulas for the estimation of this parameter [@Kenchington2014] relying on correlations with life history parameters and/or environmental information. We apply the most recent formula, which is based upon a meta-analysis of 201 fish species [@Then2015]. This method requires estimates of the VBGF growth parameters [$L_{inf}$ and K; @Then2015].

# estimation of M
Ms <- M_empirical(Linf = res_SA$par$Linf, K_l = res_SA$par$K, method = "Then_growth")
synLFQ7a$M <- as.numeric(Ms)
# show results
paste("M =", as.numeric(Ms))

The result is a natural mortality of r {round(as.numeric(Ms),2)} year$^{-1}$.

Fisheries aspects

Exploitation level

In order to estimate the level of exploitation, knowledge on fishing mortality (F) (usually derived by subtracting natural mortality from total mortality) and gear selectivity is necessary. The length-converted catch curve allows the estimation of the instantaneous total mortality rate (Z) of LFQ data and the derivation of a selection ogive. Here we skip an in-depth selectivity exploration, because more data would be required for this assessment^[For a comprehensive description of selectivity estimation refer to @Millar1997b.]. The following approach assumes a logistic selection ogive, typical for trawl-net selectivity, which may provide an appropriate first estimate in the case of LFQ data derived from a mixture of gears. Total mortality rate is estimated with a sample of the catch representative for the whole year. Besides, changing the bin size, the function lfqModify allows to rearrange the catch matrix in the required format (catch vector per year) and to pool the largest length classes with only a few individuals into a plus group (necessary later for the cohort analysis). As with the Powell-Wetherall method, the reg_int argument is necessary to avoid the interactive plotting function (more information in help(catchCurve)). The argument calc_ogive allows the estimation of the selection ogive.

# summarise catch matrix into vector and add plus group which is smaller than Linf
synLFQ7b <- lfqModify(synLFQ7a, vectorise_catch = TRUE, plus_group = 118)
# run catch curve
res_cc <- catchCurve(synLFQ7b, reg_int = c(8,26), calc_ogive = TRUE)
# assign estimates to the data list
synLFQ7b$Z <- res_cc$Z
synLFQ7b$FM <- as.numeric(synLFQ7b$Z - synLFQ7b$M)
synLFQ7b$E <- synLFQ7b$FM/synLFQ7b$Z
paste("Z =",round(synLFQ7b$Z,2))
paste("FM =",round(synLFQ7b$FM,2))
paste("E =",round(synLFQ7b$E,2))
paste("L50 =",round(res_cc$L50,2))

The catch curve analysis returns a Z value of r {round(synLFQ7b$Z,2)} $year^{-1}$. By subtracting M from Z, the fishing mortality rate is derived: r {round(synLFQ7b$FM,2)} $year^{-1}$. The exploitation rate is defined as $E = F/Z$ and in this example r {round(synLFQ7b$E,2)} The selectivity function of the catch curve estimated a length at first capture ($L_{50}$) of r {round(res_cc$L50,2)} cm.

Stock size and status

Stock size and composition

The stock size and fishing mortality per length class can be estimated with Jones' length converted cohort analysis [CA, @Jones1984] - a modification of Pope's virtual population analysis (VPA) for LFQ data. It requires the estimates from preceeding analysis and in addition the parameters a and b of the allometric length-weight relationship^[Here the true parameters of a = 0.015 and b = 3 are used assuming that this was calculated from length-weight data.]. Furthermore, CA needs an estimate for the terminal fishing mortality (terminal_F), which was set here to the result of the catch curve minus natural mortality (r {round(synLFQ7b$FM,2)}^[For a discussion on this parameter see @Hilborn1992]). The cohort analysis estimates the stock size based on the total catches, it is therefore necessary that the catch vector is representative for the full stock and for all fisheries catches targeting this stock. The argument "catch_corFac" can be used to raise the catches to be yearly or spatially representative. Here I assume that all fisheries targeting the stock were sampled and the catch during the four missing months corresponds to the average monthly catch (catch_corFac = (1 + 4/12)). The use of the function lfqModify with the argument "plus_group" is necessary as CA does not allow length classes larger than $L_{inf}$. If the argument "plus_group" is set to TRUE only, the function shows the catches per length class and asks the user to enter a length class corresponding to the length class of the new "plus group". If "plus_group" is set to a numeric (here 122, which is just below $L_{inf}$), the plus group is created at this length class (numeric has to correspond to existing length class in vector "midLengths").

synLFQ7c <- synLFQ7b

# assign length-weight parameters to the data list
synLFQ7c$a <- 0.015
synLFQ7c$b <- 3
# run CA
vpa_res <- VPA(param = synLFQ7c, terminalF = synLFQ7c$FM,
               analysis_type = "CA",
               plot=TRUE, catch_corFac = (1+4/12))
# stock size
sum(vpa_res$annualMeanNr, na.rm =TRUE) / 1e3
# stock biomass
sum(vpa_res$meanBiomassTon, na.rm = TRUE)
# assign F per length class to the data list
synLFQ7c$FM <- vpa_res$FM_calc

The results show the logistic shaped fishing pattern across length classes (red line in CA plot). The size of the stock is returned in numbers and biomass and according to this method r {round(sum(vpa_res$annualMeanNr, na.rm =TRUE))} individuals and r {round(sum(vpa_res$meanBiomassTon, na.rm = TRUE))} tons, respectively.

Yield per recruit modelling

Prediction models (or per-recruit models, e.g. Thompson and Bell model) allow to evaluate the status of a fish stock in relation to reference levels and to infer input control measures, such as restricting fishing effort or regulating gear types and mesh sizes. By default the Thompson and Bell model assumes knife edge selection ($L_{25}$ = $L_{50}$ = $L_{75}$)^[Note that the length at capture has 2 abbreviations $L_{50}$ and $L_c$.]; however, the parameter s_list allows for changes of the selectivity assumptions. The parameter FM_change determines the range of the fishing mortality for which to estimate the yield and biomass trajectories. In the second application of this model, the impact of mesh size restrictions on yield is explored by changing $L_{c}$ (Lc_change) and F (FM_change, or exploitation rate, E_change) simultaneously. The resulting estimates are presented as an isopleth graph showing yield per recruit. By setting the argument stock_size_1 to 1, all results are per recruit. If the number of recruits (recruitment to the fishery) are known, the exact yield and biomass can be estimated. The arguments curr.E and curr.Lc allow to derive and visualise yield and biomass (per recruit) values for current fishing patterns.

# Thompson and Bell model with changes in F
TB1 <- predict_mod(synLFQ7c, type = "ThompBell",
                   FM_change = seq(0,1.5,0.05),  stock_size_1 = 1,
                   curr.E = synLFQ7c$E, plot = FALSE, hide.progressbar = TRUE)
# Thompson and Bell model with changes in F and Lc
TB2 <- predict_mod(synLFQ7c, type = "ThompBell",
                   FM_change = seq(0,1.5,0.1), Lc_change = seq(25,50,0.1),
                   stock_size_1 = 1,
                   curr.E = synLFQ7c$E, curr.Lc = res_cc$L50,
                   s_list = list(selecType = "trawl_ogive",
                                 L50 = res_cc$L50, L75 = res_cc$L75),
                   plot = FALSE, hide.progressbar = TRUE)
# plot results
par(mfrow = c(2,1), mar = c(4,5,2,4.5), oma = c(1,0,0,0))
plot(TB1, mark = TRUE)
mtext("(a)", side = 3, at = -1, line = 0.6)
plot(TB2, type = "Isopleth", xaxis1 = "FM", mark = TRUE, contour = 6)
mtext("(b)", side = 3, at = -0.1, line = 0.6)

# Biological reference levels
# Current yield and biomass levels

Please note that the resolution of the $L_c$ and F changes is quite low and the range quite narrow due to the limitations in computation time of the vignette format. The results indicate that the fishing mortality of this example (F = r {round(synLFQ7b$FM,2)}) is higher than the maximum fishing mortality ($F_{max} =$ r {round(TB1$df_Es$Fmsy,2)}), which confirms the indication of the slightly increased exploitation rate (E = r {round(synLFQ7b$E,2)}). The prediction plot shows that the yield could be increased when fishing mortality and mesh size is increased. The units are grams per recruit.


For management purposes, fish stock assessments are mainly conducted for single species or stocks, which describe the manamgent units of a population. There is much to be gained from multi-species and ecosystem models, but data requirements and complexity make them often unsuitable for deriving management advice. For data-poor fisheries, a traditional fish stock assessment solely based on length-frequency (LFQ) data of one year (as presented here) is particularly useful. LFQ data comes with many advantages over long time series of catch and effort or catch-at-age data [@Mildenberger2016]. In this exercise, the exploitation rate and results of the yield per recruit models indicate that the fiseries is close to sustainable exploitation. The exploration of stock status and fisheries characteristics can of course be extended, but go beyond the scope of this tutorial, which is thought to help getting started with the TropFishR package. Further details about functions and their arguments can be found in the help files of the functions (help(...) or ?.., where the dots refer to any function of the package). Also the two publications by @Mildenberger2016 and by @Taylor2016 provide more details about the functionality and context of the package.

Author's comment

If you have comments or questions please write an email or post an issue at GitHub. You can follow the development of TropFishR on ResearchGate.


Try the TropFishR package in your browser

Any scripts or data that you put into this service are public.

TropFishR documentation built on June 29, 2018, 5 p.m.