View source: R/Bhattacharya2.R
Bhattacharya2 | R Documentation |
Analyzes the length frequeney distributions. The middle lengths obtained for each length group
Bhattacharya2(x, length_class = seq(5, 20, by = 0.5), mixpar, plot = FALSE)
x |
|
length_class |
|
mixpar |
|
plot |
# Sample (Peruvian anchovy)
sample_frequency <- c(0,0,0,0,0,0,0,0,0,2,7,14,22,15,13,12,17,22,35,28,7,4,1,0,0,0,0,0,0,0,0)
length <- seq(5,20, by = 0.5)
# identify groups
view_modas <- modas(matrix(sample_frequency, nrow = 1), Lmin = 5, Lmax = 20, dL = 0.5, umbral = 10)
# number of groups
num_modas = apply(view_modas, 1, unique_modas)
# weighted
catch_frequency = weighted_frequency(length = length, frequency = sample_frequency, a = 0.003925, b = 3.2178, catch = 50000)
plot(length, catch_frequency, type = "l", lwd = 2, ylab = "Catch (number of individuals)", xlab = "Length (cm)")
# par
sigma = seq(2, 2+groups-1, by = 1)
pi = rep(1/groups, groups)
dfPars = data.frame(pi = pi, mu = mu, sigma = sigma)
mu = sort(view_modas[!is.na(view_modas)])
# bhattacharya
out_cohortes = Bhattacharya2(x, length_class = seq(5, 20, by = 0.5), mixpar = dfPars, plot = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.