Introduction This vignette provides an overview of the aLBI package…
Installation You can install the package from GitHub using devtools:
# Install devtools if you haven't already
if (!requireNamespace("devtools", quietly = TRUE)) {
install.packages("devtools")
}
Detach or remove the package if previously attached
# Unload the aLBI package if it is already loaded
if ("package:aLBI" %in% search()) {
detach("package:aLBI", unload = TRUE)
}
# Remove the aLBI package if it is installed
if ("aLBI" %in% rownames(installed.packages())) {
remove.packages("aLBI")
}
#> Removing package from 'C:/Users/User/AppData/Local/Temp/Rtmpc3U2Yf/temp_libpath4edc451a4ef2'
#> (as 'lib' is unspecified)
Install and Load the Package in your R session
# Install the Fish StockAssessment package
devtools::install_github("Ataher76/aLBI")
#> Using GitHub PAT from the git credential store.
#> Downloading GitHub repo Ataher76/aLBI@HEAD
#> ── R CMD build ─────────────────────────────────────────────────────────────────
#> ✔ checking for file 'C:\Users\User\AppData\Local\Temp\RtmpWYRiB6\remotes4da850614fa9\Ataher76-aLBI-06ceb1d/DESCRIPTION'
#> ─ preparing 'aLBI': (440ms)
#> checking DESCRIPTION meta-information ... ✔ checking DESCRIPTION meta-information
#> ─ checking for LF line-endings in source and make files and shell scripts
#> ─ checking for empty or unneeded directories
#> ─ building 'aLBI_0.1.2.tar.gz'
#>
#>
#> Installing package into 'C:/Users/User/AppData/Local/Temp/Rtmpc3U2Yf/temp_libpath4edc451a4ef2'
#> (as 'lib' is unspecified)
Data Preparation Prepare your data in a specific format before using the functions. Ensure the data frame has two columns: Length and Frequency. Here’s an example of how to load and prepare your data using the readxl package:
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
#> [1] "C:/Users/User/AppData/Local/Temp/Rtmpc3U2Yf/temp_libpath4edc451a4ef2/aLBI/exdata/LC.xlsx"
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
#> # A tibble: 15 × 2
#> LengthClass Frequency
#> <dbl> <dbl>
#> 1 12 26
#> 2 15 166
#> 3 18 244
#> 4 21 582
#> 5 24 973
#> 6 27 1067
#> 7 30 963
#> 8 33 511
#> 9 36 472
#> 10 39 286
#> 11 42 173
#> 12 45 171
#> 13 48 83
#> 14 51 36
#> 15 54 36
Function: FishPar The FishPar function estimates biological parameters such as Lmax, Linf, Lmat, and Lopt using bootstrapping resampling method.
Arguments
data: A data frame containing Length and Frequency columns. resample: Number of bootstrap resamples. Default is 1000. progress: Logical value indicating whether to show progress. Default is TRUE.
Example
# Running the FishPar function
results <- FishPar(data = lenfreq_data, resample = 1000, progress = FALSE)
# Viewing the results
results$estimated_length_par
#> Parameter Mean_estimate Lower_CI Upper_CI
#> 1 Lmax 52.57200 45.00000 54.00000
#> 2 Linf 55.33895 47.36842 56.84211
#> 3 Lmat 30.67750 26.68219 31.42811
#> 4 Lopt 32.29570 27.88119 33.12655
#> 5 Lopt_p10 35.52527 30.66930 36.43920
#> 6 Lopt_m10 29.06613 25.09307 29.81389
results$estimated_froese_par
#> Parameter Estimate
#> 1 Pmat 29.91881
#> 2 Popt 25.46208
#> 3 Pmega 21.09173
results$estimated_freq_par
#> Parameter Estimate
#> 1 sumT 5789
#> 2 sum_mat 1732
#> 3 sum_opt 1474
#> 4 sum_mega 1221
results$forese_ind_vs_target
#> Parameters Froese_catch Froese_tar
#> 1 Pmat 29.91881 100
#> 2 Popt 25.46208 100
#> 3 Pmega 21.09173 20
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: FishSS The FishSS function evaluates stock status using criteria based on the estimated parameters.
Arguments data: A data frame of the stock status according to Cope and Punt (2009). LM_ratio: Length at maturity ratio from FishPar function. Pobj: Objective percentage from FishPar function. Pmat: Percentage of mature fish. Popt: Percentage of optimal fish.
Example
# Load the stock status criteria data
cpdata_path <- system.file("exdata", "cpdata.xlsx", package = "aLBI")
print(cpdata_path) #check if the path exist
#> [1] "C:/Users/User/AppData/Local/Temp/Rtmpc3U2Yf/temp_libpath4edc451a4ef2/aLBI/exdata/cpdata.xlsx"
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)
#> # A tibble: 21 × 11
#> Tx A B C D E F G H I J
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 100 0 0 0 0 0 0 0 0 100 100
#> 2 95 0 0 0 0 22 0 11 0 100 93
#> 3 90 0 0 0 0 100 44 83 22 100 74
#> 4 85 0 0 0 0 100 100 100 67 100 63
#> 5 80 0 0 0 0 100 100 100 100 89 52
#> 6 75 0 0 0 0 100 100 100 100 74 37
#> 7 70 0 0 0 0 100 100 100 100 48 30
#> 8 65 0 0 0 0 100 100 100 100 33 22
#> 9 60 0 0 0 0 100 100 100 100 22 15
#> 10 55 0 0 0 0 100 100 100 100 11 7
#> # ℹ 11 more rows
# 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
#> $Target_Cols
#> Tx B D
#> 1 100 0 0
#> 2 95 0 0
#> 3 90 0 0
#> 4 85 0 0
#> 5 80 0 0
#> 6 75 0 0
#> 7 70 0 0
#> 8 65 0 0
#> 9 60 0 0
#> 10 55 0 0
#> 11 50 0 0
#> 12 45 0 0
#> 13 40 0 0
#> 14 35 0 0
#> 15 30 7 7
#> 16 25 19 11
#> 17 20 37 22
#> 18 15 52 44
#> 19 10 67 67
#> 20 5 67 67
#> 21 0 67 67
#>
#> $Target_value
#> [1] 29.91881
#>
#> $Colesest_value
#> [1] 15
#>
#> $StockStatus
#> TSB40 LSB25
#> 7 7
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 thank the contributors and the community for their support and feedback.
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.