aLBI - A Simple R Package for Estimating Length-Based Indicators and Fish Stock Assessment from Length Frequency Data"

Simple R Package for Fish Stock Assessment

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  cache = TRUE # Ensure caching is appropriately set
)

options(repos = c(CRAN = "https://cran.rstudio.com"))

Introduction

The aLBI package provides tools for estimating length-based indicators and assessing fish stock using methods outlined by Cope and Punt (2009) and Froese (2004). These methods are particularly useful in data-limited situations and for providing simple indicators to address over-fishing. This simple package facilitates the estimation of life history parameters of fish only from the length frequency data.

Function Overview

The aLBI package offers three primary functions: - FrequencyTable: Creates frequency tables from length data. - FishPar: Estimates biological parameters using bootstrapping. - FishSS: Evaluates stock status based on estimated parameters.

Methods

The package includes functions to calculate various length-based indicators and visualize fish stock data. The approaches from Cope and Punt (2009) are used to establish reference points, while Froese (2004)'s indicators help to evaluate over-fishing status.

Installation

To install the aLBI package from GitHub, follow these steps. Note that devtools is required to install packages from GitHub.

# You can install the package using the following commands in your R session:
# Install devtools if you haven't already
# install.packages("devtools")
# # Install dplyr if you haven't already
# install.packages("dplyr")
# # Install readxl if you haven't already
# install.packages("readxl")
# install aLBI package from CRAN
# install.packages("aLBI")
# Install the most updated version of aLBI package from GitHub
# devtools::install_github("Ataher76/aLBI")

Package Management

Ensure the required packages are loaded in your R session. The following code checks for package availability and stops execution with a message if a package is missing.

# Check if required packages are installed and load them
# Check if required packages are installed and load them
required_packages <- c("aLBI", "readxl", "dplyr", "devtools")

for (pkg in required_packages) {
  if (!requireNamespace(pkg, quietly = TRUE)) {
    warning(paste("Package", pkg, "is required but not installed."))
  } else {
    library(pkg, character.only = TRUE)
  }
}


# Load the aLBI package
library(aLBI)
library(readxl)
library(dplyr)
library(devtools)

Data Preparation for Functions

Prepare your collected data in a specific format (.xlsx or .csv) before using the functions. Here's an example of how to load and prepare your data using the readxl package:

Function (i): FrequencyTable

This function will calculate the frequency table from the collected and also the extract the length frequency data from the frequency table with the upper length_range.

Arguments

-Lmax: Optional. The maximum observed length of fish. Required only if default method ("wang") is used and bin_width is not provided. If not provided or left NULL then automatically calculate the frequency table with the observed maximum length of the provided data.

Example with provided data

library(readxl)
# Load your length data from the system file
lenfreq_path <- system.file("exdata", "ExData.xlsx", package = "aLBI")
print(lenfreq_path)  # Check the generated path

if (lenfreq_path == "") {
  stop("The required file ExData.xlsx is missing. Please check the inst/extdata directory.")
}

# load the lenght frequency data
lenght_data <- readxl::read_excel(lenfreq_path)
print(lenght_data)  # check the 
# replace with your data directory
# Running the FrequencyTable function
freqTable <- FrequencyTable(data = lenght_data, bin_width = NULL, Lmax = NULL)

# Viewing the results
freqTable$lfqTable  # Display the frequency table
freqTable$lfreq     # Display the summarized frequencies with upper length ranges

Function (ii): FishPar

The FishPar function estimates biological parameters such as Lmax, Linf, Lmat, and Lopt using bootstrapping resampling method.

Arguments

Example with existing data

library(readxl)
# Load your length-frequency data from the system file
lenfreq_path <- system.file("exdata", "LC.xlsx", package = "aLBI")
print(lenfreq_path)  # Check the generated path

if (lenfreq_path == "") {
  stop("The required file LC.xlsx is missing. Please check the inst/extdata directory.")
}

# load the lenght frequency data
lenfreq_data <- readxl::read_excel(lenfreq_path)
print(lenfreq_data)  # check the data 
# replace with your data directory
# Running the FishPar function
results <- FishPar(data = lenfreq_data, resample = 1000, progress = FALSE)

# Viewing the results
results$estimated_length_par
results$estimated_froese_par
results$estimated_freq_par
results$forese_ind_vs_target
results$LM_ratio
results$Pobj

Explaination of Output

The function returns a list with the following components:

estimated_length_par: Data frame of estimated length parameters with confidence intervals. estimated_froese_par: Data frame of estimated Froese indicators. estimated_freq_par: Data frame of frequency parameters. forese_ind_vs_target: Data frame comparing Froese indicators with targets. LM_ratio: Length at maturity ratio. Pobj: Objective percentage combining Pmat, Popt, and Pmega.

Function (iii): FishSS

The FishSS function evaluates stock status using criteria based on the estimated parameters.

Arguments

Example with CPdata

# Load the stock status criteria data
cpdata_path <- system.file("exdata", "cpdata.xlsx", package = "aLBI")
print(cpdata_path) #check if the path exist

if (cpdata_path == "") {
  stop("The required file cpdata.xlsx is missing. Please check the inst/extdata directory.")
}
# loading the cope and punt table
cpdata <- readxl::read_excel(cpdata_path)
print(cpdata)

# Running the FishSS function
stock_status <- FishSS(data = cpdata,
                       LM_ratio = results$LM_ratio,
                       Pobj = results$Pobj,
                       Pmat = results$estimated_froese_par[1, 2],
                       Popt = results$estimated_froese_par[2, 2])

# Viewing the stock status
stock_status

Output

The function returns a named vector with TSB40 and LSB25 values indicating stock status.

Conclusion

The Fish Stock Assessment package provides a robust framework for estimating biological parameters and assessing fish stock status. By following the steps outlined in this vignette, you can effectively utilize this package for your fish stock assessment needs.

Additional Information

Contact

For any questions or issues, please contact the package maintainer: Name: Ataher Ali Email: ataher.cu.ms@gmail.com

Acknowledgements

I would like to express my heartfelt gratitude to my supervisor, Dr. Mohammed Shahidul Alam, for his unwavering guidance, support, and encouragement. I am also sincerely thankful to the contributors and community members for their valuable feedback and support.

This vignette provides a comprehensive guide to using the Assessment package. By following these instructions, users can effectively conduct fish stock assessments and contribute to sustainable fishery management practices.

References



Try the aLBI package in your browser

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

aLBI documentation built on April 12, 2025, 2:01 a.m.