Package {aLBI}


Type: Package
Title: Estimating Length-Based Indicators for Fish Stock Assessment
Version: 0.2.0
Description: Provides tools for estimating length-based indicators (LBIs) from length-frequency data to assess fish stock status and evaluate growth and recruitment overfishing in data-limited fisheries. Implements the sustainability indicators of Froese (2004) <doi:10.1111/j.1467-2979.2004.00144.x>, empirical biological reference points from Froese and Binohlan (2000) <doi:10.1111/j.1095-8649.2000.tb00870.x>, and the decision framework of Cope and Punt (2009) <doi:10.1577/C08-025.1>. Incorporates a three-tier Monte Carlo and bootstrap uncertainty propagation framework for sustainability indicators, optimum bin size calculations following Wang et al. (2020) <doi:10.1016/j.fishres.2019.105474>, multi-month length-frequency harmonization, and length-weight relationship fitting. Methodology is detailed in Ali et al. (2025) <doi:10.1016/j.fishres.2025.107467>.
Depends: R (≥ 4.0.0)
Imports: ggplot2, graphics, grDevices, openxlsx, stats, utils
Suggests: dplyr, knitr, readxl, rmarkdown, testthat
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: 2026-09-26 21:49:03 UTC; User
Author: Ataher Ali ORCID iD [aut, cre], Mohammed Shahidul Alam ORCID iD [aut]
Maintainer: Ataher Ali <ataher.cu.ms@gmail.com>
Repository: CRAN
Date/Publication: 2026-09-26 22:20: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)

Length-Based Indicators with Three-Tier Uncertainty Propagation

Description

Estimates Froese (2004) length-based sustainability indicators via a two-stage simulation and a novel three-tier uncertainty decomposition:

  1. Monte Carlo for length parameters (Lmax, Linf, Lmat, Lopt) based on Froese & Binohlan (2000) allometric regressions.

  2. Three-tier uncertainty propagation to Pmat, Popt, Pmega:

    • Tier 1: Parameter uncertainty only (MC parameters, observed catch).

    • Tier 2: Data-sampling uncertainty only (fixed parameters, bootstrap catch).

    • Tier 3: Total/joint uncertainty (MC parameters + bootstrap catch simultaneously), the novel contribution.

Plots are rendered in the active graphics device. When save_output = TRUE, all PDFs and an Excel workbook are written to getwd(). The Excel workbook contains a dedicated FishSS_Inputs sheet with all values required by FishSS().

Usage

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

Arguments

data

Data frame – two columns: Length and Frequency.

resample

Monte Carlo / bootstrap iterations (default 1000).

progress

Logical; display a text progress bar (default FALSE).

Linf

Optional asymptotic length; overrides Lmax / 0.95.

Linf_sd

Gaussian noise SD for Linf samples (default 0.5).

Lmat

Optional length at first maturity; overrides regression.

Lmat_sd

Gaussian noise SD for Lmat samples (default 0.5).

save_output

Logical; write all PDFs and Excel to disk (default FALSE). Set TRUE to persist outputs to getwd().

Value

Invisibly, a named list:

estimated_length_par

MC mean \pm 95% CI for length parameters.

froese_par_mc

Tier 1 – parameter-uncertainty CIs for Pmat, Popt, Pmega.

froese_par_bootstrap

Tier 2 – data-sampling CIs.

froese_par_joint

Tier 3 – total/joint CIs (novel).

froese_ind_vs_target

Observed vs. Froese (2004) targets.

LM_ratio

Lmat / Lopt.

Pobj

Pmat + Popt + Pmega (0-300 scale; Cope & Punt 2009).

Total_ind

Total observed individuals.

References

Froese, R. (2004). Keep it simple: three indicators to deal with overfishing. Fish and Fisheries, 5, 86-91.

Froese, R. & Binohlan, C. (2000). Empirical relationships to estimate asymptotic length, length at first maturity and length at maximum yield per recruit in fishes. J. Fish Biol., 56, 758-773.

Silverman, B.W. (1986). Density Estimation for Statistics and Data Analysis. Chapman & Hall, London.

Efron, B. & Tibshirani, R.J. (1993). An Introduction to the Bootstrap. Chapman & Hall, New York.


Assess Stock Status and Classify Fish Selectivity

Description

Assesses stock status against target and limit spawning biomass reference points (0.40 SB0 and 0.25 SB0) and classifies catch selectivity patterns using the decision framework of Cope & Punt (2009).

Usage

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

Arguments

data

Data frame containing the Cope & Punt (2009) look-up table with columns: Tx, A, B, C, D, E, F, G, H, I, J.

LM_ratio

Numeric; length at maturity ratio (Lmat / Lopt).

Pmat

Numeric; percentage of mature fish in catch (0-100).

Popt

Numeric; percentage of optimally sized fish in catch (0-100).

Pmega

Numeric; percentage of mega-spawners in catch (0-100).

Value

A named list containing:

Pobj

Composite indicator sum (Pmat + Popt + Pmega; 0-300 scale).

Px_trigger

Name of trigger indicator used ("Pmat" or "Popt").

Px_value

Calculated value of the trigger indicator.

StockStatus

Named vector with probabilities: p_below_target (P(biomass < 0.40 SB0)) and p_below_limit (P(biomass < 0.25 SB0)).

Selectivity

Character description of the catch selectivity pattern.

References

Cope, J. M., & Punt, A. E. (2009). Length-based reference points for data-limited situations: Applications and restrictions. Marine and Coastal Fisheries, 1(1), 169-186.

Ali, A., Sarker, M. R., & Alam, M. S. (2025). Development of a simple R package (aLBI) for the estimation of stock status from the length frequency data. Fisheries Research, 288, 107467.

Examples

utils::data("CPdata", package = "aLBI", envir = environment())
if (exists("CPdata")) {
  FishSS(CPdata, LM_ratio = 0.95, Pmat = 56.5, Popt = 38.4, Pmega = 36.4)
}


Generate Frequency Distribution Table Across Months

Description

Creates a standardized frequency distribution table for fish length data across multiple months using a consistent length-class lattice. The bin width is determined by either user input or Wang's empirical formula applied across the full dataset. Columns for month and length are dynamically detected. Months are converted to sequential date headers in 'dd.mm.yy' format.

Usage

FreqTM(
  data,
  bin_width = NULL,
  Lmax = NULL,
  save_output = FALSE,
  output_file = "FreqTM_Output.xlsx",
  date_config = list(day = 1, year = 2025)
)

Arguments

data

A data frame containing columns for months and lengths.

bin_width

Numeric; class interval width (cm). If NULL (default), calculated using Wang's formula.

Lmax

Numeric; maximum observed length. If NULL, the observed maximum in data is used.

save_output

Logical; write the output table to an Excel workbook (default FALSE).

output_file

Character; name of the output Excel file when save_output = TRUE. Defaults to "FreqTM_Output.xlsx".

date_config

A list with numeric elements day (default 1) and year (default 2025) for formatting date headers.

Value

A data frame where the first column is Length (upper class boundaries) and subsequent columns contain catch frequencies for each sampling date formatted as 'dd.mm.yy'.

References

Wang, K., Zhang, C., Xu, B., Xue, Y., & Ren, Y. (2020). Selecting optimal bin size to account for growth variability in Electronic LEngth Frequency ANalysis (ELEFAN). Fisheries Research, 225, 105474.

Examples

set.seed(123)
sample_data <- data.frame(
  SamplingMonth = rep(c("Aug", "Sep", "Oct"), each = 50),
  TotalLength   = runif(150, min = 8.5, max = 22.4)
)

# Run in-memory (CRAN compliant)
res <- FreqTM(data = sample_data, bin_width = 2)
head(res)


Generate a Frequency Distribution Table for Fish Length Data

Description

Creates a standardized length-frequency distribution table from individual fish length measurements. The bin width is determined by either user specification or Wang's empirical formula. Class intervals are represented by their upper boundaries for direct compatibility with FishPar().

Usage

FrequencyTable(
  data,
  bin_width = NULL,
  Lmax = NULL,
  save_output = FALSE,
  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; class interval width (cm). If NULL (default), calculated using Wang's formula.

Lmax

Numeric; maximum observed length. If NULL, the observed maximum in data is used.

save_output

Logical; write the output tables to an Excel workbook (default FALSE).

output_file

Character; name of the output Excel file when save_output = TRUE. Defaults to "FrequencyTable_Output.xlsx".

Value

A list containing two data frames:

lfqTable

Complete frequency table with class intervals (Length_Range) and observed counts (Frequency).

lfreq

Condensed two-column table with upper class boundaries (Length) and observed counts (Frequency), ready for FishPar().

References

Wang, K., Zhang, C., Xu, B., Xue, Y., & Ren, Y. (2020). Selecting optimal bin size to account for growth variability in Electronic LEngth Frequency ANalysis (ELEFAN). Fisheries Research, 225, 105474.

Examples

set.seed(123)
fish_lengths <- runif(200, min = 5, max = 70)

# Run in-memory (CRAN compliant)
res <- FrequencyTable(data = fish_lengths)
head(res$lfreq)

# Custom bin width
res_custom <- FrequencyTable(data = fish_lengths, bin_width = 5)
head(res_custom$lfreq)


Plot and Model Length-Weight Relationships with Optional Log Transformation

Description

Visualizes and models the relationship between fish length and body weight (or any two continuous allometric variables) using linear regression. Supports both natural scale and log-log linearised models (W = a * L^b). Produces a publication-ready ggplot2 figure with regression diagnostics, confidence intervals, and parameter estimates.

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 = FALSE
)

Arguments

data

A data frame containing at least two numeric columns: length (first column) and weight (second column).

log_transform

Logical; apply log-log transformation (default TRUE).

point_col

Color of data points (default "black").

line_col

Color of fitted regression line (default "red").

shade_col

Color of confidence interval ribbon (default "red").

point_size

Numeric; size of data points (default 2).

line_size

Numeric; thickness of regression line (default 1).

alpha

Numeric; transparency of CI ribbon (default 0.2).

main

Character; plot title (default "Length-Weight Relationship").

xlab

Character; optional custom x-axis label.

ylab

Character; optional custom y-axis label.

save_output

Logical; save plot PDF and summary text file to disk (default FALSE).

Value

A list containing:

model

The fitted lm model object.

intercept

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

slope

The estimated allometric slope b.

r_squared

Coefficient of determination (R^2).

correlation_r

Pearson correlation coefficient (r).

p_value

P-value for the slope parameter.

plot

The ggplot2 object for further customization.

Examples

utils::data("LWdata", package = "aLBI", envir = environment())
if (exists("LWdata")) {
  res <- LWR(LWdata, log_transform = TRUE, save_output = FALSE)
  print(res$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)

lenfreqM: Example length-weight dataset for aLBI package

Description

This dataset contains length data of multiple months

Usage

data(lenfreqM)

Format

A data frame with 2 columns: First one is month and second one is length

Months

Name of the Sampling Months

Length

Measured lengths of the sampled fish

Source

Data collected for fish stock assessment studies

Examples

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