mixdist_polymod: Polymodal decomposition

mixdist_polymodR Documentation

Polymodal decomposition

Description

mixdist_polymod returns the numbers-at-age using a polymodal decomposition of length frequencies. Can be done by year or other period (quarter, semester, month...) by specifying it.

Usage

mixdist_polymod(
  data_freq,
  K,
  L_inf,
  t0,
  fix_mu,
  fix_sigma,
  ngroup,
  step_class,
  step_time,
  get_lmsd = FALSE,
  lmsd,
  plot = FALSE,
  sigma_adjust = 1,
  age = 0
)

Arguments

data_freq

Input dataset table. Must include a gear column and total by size and gear in total_gear. It should be extrapolated.

K

value for K

L_inf

value for L_inf

t0

value for t0

fix_mu

Vector with mean length values-at-age to fix

fix_sigma

Vector with standard deviation values-at-age to fix

ngroup

number of age class

step_class

length step between two length class

get_lmsd

When TRUE, a linear model is done on sd, values are saved and retruned. Otherwise sigma are fixed accrodingly to "fix_sigma"

lmsd

Linear model object from previous model

plot

To plot values.

sigma_adjust

In some case, algorith may not be able to converge, relax hypothesis on sigma (sigma_value = 1 for exemple)

age

Age at which begin polymodal decomposition. Set on zero.

title

Title in the plots

Examples


#--------------------------------------------------


                Data Extrapolation


#--------------------------------------------------

 data(data_LF_LBB)
 data_catch_quarter = data_frame(gear = c(rep("Artisanal",4), rep("Industrial",4)),
 step_time = rep(c(1:4),2),
 capture = c(1153, 1042, 1046, 1132, 1206, 1124, 1155, 1176))
 data_freq <- data_LF_LBB %>%  group_by(lclass, month) %>%  dplyr::summarise(total_sampling=sum(frequence, na.rm = T))
# biological parameters from literature or estimated in previous work

Linf <- 44.4 # Asymptotic length
K <- 0.34 # Growth parameter
t0 <- -0.24 # theoric age for length 0 cm

a <- 0.006 # parameters from length-size relationship
b <- 3.08


# 6. Preparing length frequencies data. We remove data from San Pedro because samples weren't consistent.
data_freq_mixdist <- data_LF_LBB %>%
 filter(data_type == "Data Bio DEMERSTEM", data_from != "San Pedro") %>%
 mutate(gear = case_when(
   data_from == "Abidjan" ~ 'Industrial',
   data_from %in% c("Tadkoradi","Tema") ~ "Artisanal")) %>%
 mutate(step_time = ceiling((month)/(12/step_time)))

data_freq_mixdist %>%  group_by(lclass, month, gear) %>% mutate(total = sum(frequence,na.rm = T)) %>%  ggplot(aes(x = lclass, y = total)) + geom_bar(stat = 'identity') + facet_grid(month~gear)

# 7. Extrapolation of length frequencies
data_freq_mixdist <- data_freq_mixdist %>%
 group_by(lclass, step_time, gear) %>%
 dplyr::summarise(total_sampling=sum(frequence, na.rm = T)) %>%  mutate(weight_sampling = total_sampling * a*lclass^b/1000)



data_freq_mixdist <- data_freq_mixdist %>% full_join(data_catch_quarter, by = c("step_time", "gear")) %>% dplyr::rename(Wtot = capture) %>%  mutate(Wtot = 1000 * Wtot)


data_freq_mixdist <- data_freq_mixdist %>% group_by(step_time, gear) %>%  dplyr::mutate(W_sampling = sum(weight_sampling),
                                                                                       N_sampling = sum(total_sampling),
                                                                                       Ntot= floor(Wtot * N_sampling/W_sampling),
                                                                                       total_gear = floor(total_sampling*Ntot/N_sampling)) %>%  na.omit()

#--------------------------------------------------


           Polymodal decomposition


#--------------------------------------------------
espece <- "P. senegalensis"

Linf <- 44.4 # Asymptotic length
K <- 0.34 # Growth parameter
t0 <- -0.24 # theoric age for length 0 cm

ngroup <- 3 # number of age group we want to detect
fixmu <- rep(T, ngroup) # We fix the mean length at age using growth parameters estimated/from literature : We specify 'TRUE'
fixsigma <- rep(F, ngroup) # We want to get an estimation of sigma : We specify 'FALSE'
step_time = 4 # We will try to examine at a quarter level.

mixdist_polymod(data_freq = data_freq_mixdist,
               K,
               Linf,
               t0,
               step_class = 1, # bin size
               step_time = step_time,
               ngroup = ngroup,
               fix_mu = fixmu,
               fix_sigma = fixsigma,
               sigma_adjust = 2,
               get_lmsd = T, # We will perform a linear model with these data
               plot = T)




polehalieutique/demerstem documentation built on Aug. 4, 2024, 5:12 a.m.