Type: Package
Title: Estimating Length-Based Indicators for Fish Stock
Version: 0.1.8
Maintainer: Ataher Ali <ataher.cu.ms@gmail.com>
Description: Provides tools for estimating length-based indicators from length frequency data to assess fish stock status and manage fisheries sustainably. Implements methods from Cope and Punt (2009) <doi:10.1577/C08-025.1> for data-limited stock assessment and Froese (2004) <doi:10.1111/j.1467-2979.2004.00144.x> for detecting overfishing using simple indicators. Key functions include: FrequencyTable(): Calculate the frequency table from the collected and also the extract the length frequency data from the frequency table with the upper length_range. A numeric value specifying the bin width for class intervals. If not provided, the bin width is automatically calculated using Sturges (1926) <doi:10.1080/01621459.1926.10502161> formula. CalPar(): Calculates various lengths used in fish stock assessment as biological length indicators such as asymptotic length (Linf), maximum length (Lmax), length at sexual maturity (Lm), and optimal length (Lopt). FishPar(): Calculates length-based indicators (LBIs) proposed by Froese (2004) <doi:10.1111/j.1467-2979.2004.00144.x> such as the percentage of mature fish (Pmat), percentage of optimal length fish (Popt), percentage of mega spawners (Pmega), and the sum of these as Pobj. This function also estimates confidence intervals for different lengths, visualizes length frequency distributions, and provides data frames containing calculated values. FishSS(): Makes decisions based on input from Cope and Punt (2009) <doi:10.1577/C08-025.1> and parameters calculated by FishPar() (e.g., Pobj, Pmat, Popt, LM_ratio) to determine stock status as target spawning biomass (TSB40) and limit spawning biomass (LSB25). LWR(): Fits and visualizes length-weight relationships using linear regression, with options for log-transformation and customizable plotting.
Depends: R (≥ 4.0.0)
Imports: dplyr, openxlsx, stats, graphics, grDevices, ggplot2, utils
Suggests: testthat, knitr, rmarkdown, devtools, readxl
License: GPL-3
Encoding: UTF-8
LazyData: true
URL: https://github.com/Ataher76/aLBI
BugReports: https://github.com/Ataher76/aLBI/issues
RoxygenNote: 7.3.2
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2025-07-14 22:15:39 UTC; User
Author: Ataher Ali [aut, cre], Mohammed Shahidul Alam [aut]
Repository: CRAN
Date/Publication: 2025-07-14 22:50:02 UTC

CPdata: Example dataset for aLBI package

Description

This dataset contains description of CPdata.

Usage

data(CPdata)

Format

A data frame with 11 columns:

A

Probability values

B

Probability values

C

Probability values

D

Probability values

E

Probability values

F

Probability values

G

Probability values

H

Probability values

I

Probability values

J

Probability values

Tx

Target column compared with LM_ratio to pick probability values

Source

A decision table described by Cope and Punt (2009)

Examples

data(CPdata, package = "aLBI")
head(CPdata)

ExData: Example raw length dataset for aLBI package

Description

This dataset contains description of ExData.

Usage

data(ExData)

Format

A data frame with 1 column:

Length

Sampled length data (cm)

Source

Data collected for fish stock assessment studies

Examples

data(ExData, package = "aLBI")
head(ExData)

Calculate Length-Based Indicators with Monte Carlo Simulation

Description

This function calculates length-based indicators using Monte Carlo simulation for length parameters and non-parametric bootstrap for Froese indicators. Plots are displayed in the plot panel, and PDFs and an Excel file of results are saved to the current working directory.

Usage

FishPar(data, resample = 1000, progress = FALSE, Linf = NULL, Linf_sd = 0.5, Lmat = NULL,
  Lmat_sd = 0.5)

Arguments

data

A data frame containing two columns: Length and Frequency.

resample

An integer indicating the number of Monte Carlo samples or bootstrap resamples (default: 1000).

progress

A logical value indicating whether to display a progress bar (default: FALSE).

Linf

A numeric value for the asymptotic length (optional). If provided, overrides the default Lmax/0.95 calculation.

Linf_sd

A numeric value for the standard deviation of random variation added to Linf (default: 0.5). Only used if Linf is provided.

Lmat

A numeric value for the length at maturity (optional). If provided, overrides the default Monte Carlo estimation.

Lmat_sd

A numeric value for the standard deviation of random variation added to Lmat (default: 0.5). Only used if Lmat is provided.

Value

A list containing estimated length parameters, Froese indicators, and other metrics.


Assess Stock Status Based on Calculated Parameters

Description

This function assesses the stock status based on parameters calculated by the FishPar function.

Usage

FishSS(data, LM_ratio, Pobj, Pmat, Popt)

Arguments

data

A data frame containing the necessary columns for stock status calculation.

LM_ratio

A numeric value representing the length at maturity ratio.

Pobj

A numeric value representing the percentage objective.

Pmat

A numeric value representing the percentage of mature fish.

Popt

A numeric value representing the percentage of optimally sized fish.

Value

A numeric vector containing TSB40 and LSB25.

Examples

utils::data("CPdata", package = "aLBI")
FishSS(CPdata, 0.75, 100, 30, 25)

FrequencyTable Generate a Frequency Distribution Table for Fish Length Data

Description

Creates a frequency distribution table for fish length data using either a custom bin width or Wang's formula for automatic bin width calculation. The bin width is rounded to the nearest integer if calculated. The results are saved to an Excel file and returned as a list of data frames.

Usage

FrequencyTable(
  data,
  bin_width = NULL,
  Lmax = NULL,
  output_file = "FrequencyTable_Output.xlsx"
)

Arguments

data

A numeric vector or data frame containing fish length measurements. If a data frame is provided, the first numeric column is used.

bin_width

Numeric value specifying the bin width for class intervals. If NULL (default), bin width is calculated using Wang's formula.

Lmax

Numeric value for the maximum observed fish length. Required only if ‘bin_width' is NULL and Wang’s formula is used. Defaults to NULL.

output_file

Character string specifying the output Excel file name. Defaults to "FrequencyTable_Output.xlsx".

Value

A list containing two data frames:

lfqTable

Frequency table with length ranges and their frequencies.

lfreq

Table with upper limits of bins and their frequencies.

Examples

# Load required package
library(dplyr)

# Generate random fish length data
set.seed(123)
fish_lengths <- runif(200, min = 5, max = 70)

# Create frequency table with automatic bin width
FrequencyTable(data = fish_lengths, output_file = tempfile(fileext = ".xlsx"))

# Create frequency table with custom bin width and output file
FrequencyTable(data = fish_lengths, bin_width = 5, output_file = tempfile(fileext = ".xlsx"))


Plot and Model Length-Weight Relationships with Optional Log Transformation

Description

This function visualizes and models the relationship between length and weight (or any two continuous variables) using linear regression. It supports both standard and log-transformed models, producing a ggplot2-based plot with a fitted line, optional confidence interval shading, and annotations for the regression equation, R^2, and p-value. When save_output is TRUE, the plot and model summary are saved to the working directory as a PDF and text file, respectively.

Usage

LWR(
  data,
  log_transform = TRUE,
  point_col = "black",
  line_col = "red",
  shade_col = "red",
  point_size = 2,
  line_size = 1,
  alpha = 0.2,
  main = "Length-Weight Relationship",
  xlab = NULL,
  ylab = NULL,
  save_output = TRUE
)

Arguments

data

A data frame with at least two columns: the first for length, the second for weight.

log_transform

Logical. Whether to apply a log-log transformation to the variables. Default is TRUE.

point_col

Color of the data points. Default is "black".

line_col

Color of the regression line. Default is "red".

shade_col

Color for the confidence interval ribbon. Default is "red".

point_size

Size of the data points. Default is 2.

line_size

Size of the regression line. Default is 1.

alpha

Transparency for the confidence interval ribbon. Default is 0.2.

main

Title of the plot. Default is "Length-Weight Relationship".

xlab

Optional. Custom x-axis label. If NULL, a label is generated based on log_transform.

ylab

Optional. Custom y-axis label. If NULL, a label is generated based on log_transform.

save_output

Logical. Whether to save the plot as a PDF and the model summary as a text file. Default is TRUE.

Value

A list containing:

model

The fitted lm object

intercept

The estimated intercept (back-transformed if log_transform = TRUE)

slope

The estimated slope

r_squared

R-squared value

correlation_r

Correlation coefficient (r)

p_value

P-value for slope

plot

The ggplot object for further customization

Examples

data(LWdata, package = "aLBI")
result <- LWR(LWdata, log_transform = TRUE, save_output = FALSE)
print(result$plot)


LWdata: Example length-weight dataset for aLBI package

Description

This dataset contains length and weight measurements for fish.

Usage

data(LWdata)

Format

A data frame with 2 columns:

Length

Length of sampled fish (cm)

Weight

Weight of sampled fish (g)

Source

Data collected for fish stock assessment studies

Examples

data(LWdata, package = "aLBI")
head(LWdata)

lenfreq01: Example dataset for aLBI package

Description

This dataset contains description of lenfreq01.

Usage

data(lenfreq01)

Format

A data frame with 2 columns:

Frequency

Observed individuals in each length class

Length

Upper value of each length class (cm)

Source

Data collected for fish stock assessment studies

Examples

data(lenfreq01, package = "aLBI")
head(lenfreq01)

lenfreq02: Example dataset for aLBI package

Description

This dataset contains description of lenfreq02.

Usage

data(lenfreq02)

Format

A data frame with 2 columns:

Frequency

Observed individuals in each length class

LengthClass

Upper value of each length class (cm)

Source

Data collected for fish stock assessment studies

Examples

data(lenfreq02, package = "aLBI")
head(lenfreq02)