# sizeMat: An R Package to Estimate Size at Sexual Maturity' In sizeMat: Estimate Size at Sexual Maturity

library(sizeMat)


This vignette introduces you to sizeMat package and provide a way to estimate Size at Morphometric and Gonad Maturity.

## Install package

install.packages("sizeMat")


### 1. Size at morphometric maturity

For estimating morphometric maturity use the crabdata base. Ths data set containing allometric measures and other atribbutes (year, month, sex category) of 223 crabs of the specie Chionoectes tanneri.

data(crabdata)

names(crabdata)


The estimation of morphometric maturity involves two processes:

First the data classification, which is refered to the classification of the individuals in two groups. The second is the estimation. This process uses the previous classification to estimate the size at morphometric maturity. The details are given below.

## Classify data (print and plot)

The classify_mature function, classify the individuals in two groups (juvelines = 0 and adult = 1). The classification analisys is based on Principal Components Analisys with two allometric variables (x: independent variable, y: dependent variable) in log base, allowing to distinguish two groups that would represent juveniles and adult. The individuals are assigned to each group using a hierarchical classification procedure (hierarchical cluster with agglomeration method: "Ward.D" and the distance measure: "euclidean"). This method is based on establishing a predetermined number of groups (in this case, two) and assigning individuals to one of the groups according to their loads on the two axes of the PCA (Corgos & Freire, 2006).

Using the results of the classification (PCA + cluster), a discriminant analysis (linear or quadratic) is conducted to obtain a discriminating function that permitted any individuals to be classified as a juvenile or an adult on the basis of the X and Y variables.

The classify_mature function requires a data.frame (e.g. crabdata) with alometric variables and sex category. The argument varNames requires the name of two allometric variables only, and varSex requires the name of the variable containing sex information. If the argument selecSex is NULL all the individuals will be used in the classification analysis. Finally the method is focus in the discriminant analysis to be used ("ld": linear discriminant analysis, "qd": quadratic discriminant analysis). We reccomend begin the analysis with the method = "ld".

The classify_mature function returns an object of class "classify", with the allometric variables "x" (independent) - "y"" (dependent), and classification of maturity (juveniles = 0, adult = 1).

#For all the individuals
classify_data = classify_mature(crabdata, varNames = c("carapace_width", "chela_heigth"),
varSex = "sex_category", selectSex = NULL, method = "ld")

#For males only
classify_data_males = classify_mature(crabdata, varNames = c("carapace_width", "chela_heigth"),
varSex = "sex_category", selectSex = "m", method = "ld")


Print the results of the "classify_data" object. It shows the number of juveniles and adults after classification and the linear regression analysis for juveniles and adults.

print(classify_data)


The example shows the arguments that can be used in the plot for "classify_data" object:

par(mfrow = c(2,2))
plot(classify_data)

plot(classify_data, xlab = "Carapace width (mm.)", ylab = "Chela heigth (mm)", legendPlot = FALSE)
legend("topleft", "Put your legend here", bty = "n")

plot(classify_data, xlab = "Carapace width (mm.)", ylab = "Chela heigth (mm)",
col = c(2, 3), pch = c(5, 6), legendPlot = TRUE)

plot(classify_data, xlab = "Carapace width (mm.)", ylab = "Chela heigth (mm)",
col = c(2, 3), pch = c(5, 6), lty_lines = c(1, 2), lwd_lines = c(1, 3),
cex = c(1, 3), main = "Classification")


## Estimate size at morphometric maturity (maturity ogive estimation)

The morph_mature function use the logit approach (frequentist or bayesian). The size at 50% maturity ($L_{50}$) was estimated as the length at which a randomly chosen specimen has a 50% chance of being mature (Somerton 1980, Roa et al. 1999).

In the regression analysis, $X$ (e.g: carapace width) is considered the explanatory variable and the classification of maturity $CS$ (juvelines: 0, adults: 1) is considered the response variable (binomial). The variables are fitted to a logit function with the form:

$$P_{CS} = \frac{1}{1+e^{-(\hat{\beta}{0} + \hat{\beta}{1}*X)}}$$

where $P_{CL}$ is the probability of an individual of being mature at a determinate $X$ length. $\hat{\beta}{0}$ (intercept) and $\hat{\beta}{1}$ (slope) are parameters estimated. The $L_{50}$ is calculated as:

$$L_{50} = -\frac{\hat{\beta}{0}}{\hat{\beta}{1}}$$

The morph_mature function requires an object of class "classify" with the X, Y (allometric variables) and classification of maturity (juvelines = 0, adults = 1).

The argument method requires a character string indicanting which regression will be used for the test. If method = "fq" the logit regression is based on GLM (frequentist) and if method = "bayes" a sample from the posterior distribution of a logit regression model using a random walk Metropolis algorithm is generated (see MCMClogit function).

The argument niter requires a number. For the GLM regression (method = "fq"), a non-parametric bootstrap method consists in generate B bootstrap samples, by resampling with replacement the original data. Then all statistics for each parameter can be calculated from each bootstrap sample (median and confidence intervals). For the method = "bayes", the argument niter is related to the number of Metropolis iterations for the sampler.

The output is an object of class "morphMat". This object contains a dataframe with the allometric variables X - Y and the classification of maturity. Also the fitted values for the logit regression and confidence intervals (95\%). If you print the object, the median of the size at morphometric maturity estimation ($L_{50}$) and parameters are shown.

#Frequentist regression
my_ogive_fq = morph_mature(classify_data, method = "fq", niter = 1000)

print(my_ogive_fq)

#Bayesian regression
my_ogive_bayes = morph_mature(classify_data, method = "bayes", niter = 1000)

print(my_ogive_bayes)


## Plot maturity ogive

For plotting the maturity ogive, an object of class "morphMat"is required. The function plot generates 4 graphics: 1), 2) and 3) are histograms for the A, B parameters and the size at morphometric maturity ($L_{50}$), the last is the maturity ogive.

par(mfrow = c(2,2))
plot(my_ogive_fq, xlab = "Carapace width (mm.)", ylab = "Proportion mature", col = c("blue", "red"))

par(mfrow = c(2,2))
plot(my_ogive_bayes, xlab = "Carapace width (mm.)", ylab = "Proportion mature", col = c("blue", "red"))


If you want the maturity ogive plot only, you have to add the param onlyOgive = TRUE. Besides you can modify the axis (size, rotation, etc) and add the legend.

plot(my_ogive_fq, xlab = "Carapace width (mm.)", ylab = "Proportion mature", col = c("blue", "red"), onlyOgive = TRUE)


This methodology has been used mainly in the estimation of morphological sexual maturity in crabs, but it can be extended to other taxas as Agostinho (2000) reported.

### 2. Size at gonad maturity

For estimating gonadal maturity use the matFish database. This database contains two variables:

• total_length: Total length in cm.

• stage_mat: The gonadal maturation stages: I, II, III, IV, where I is considered inmature.

data(matFish)



The function to be used to estimate gonadal maturity is gonad_mature. This function use the logistic approach.

The gonad_mature function requires a data.frame with allometric variables (e.g: total length, fork length, carapace width, etc) and a variable containing the stages of sexual maturity (gonadal maturation stages).

The argument varNames requires a character string indicating the name of one allometric and the stage of sexual maturity variable to be used for analysis (e.g varNames = c("total_length", "stage_mat")). So the argument varNames must contain two character strings only, the first is the allometric variable and the second is the stage of sexual maturity.

The arguments inmName and matName require a character string indicanting the name of the stages of sexual maturity in the data.frame. The argument could contain one character string or could be a vector (e.g inmName = "I", matName = c("II", "III", "IV")). The variable stage_mat in the matFish database, contains the stages of the sexual maturity. In this case, stage I is considered inmature and II, III, IV are mature. Then the stages of sexual maturity are transformed in a binomial variable where inmature = 0 and mature = 1.

The argument method requires a character string indicanting which regression will be used for the test. If method = "fq" the logit regression is based on GLM (frequentist) and if method = "bayes" a sample from the posterior distribution of a logit regression model using a random walk Metropolis algorithm is generated (see MCMClogit function).

The argument niter requires a number. For the GLM regression (method = "fq"), a non-parametric bootstrap method consists in generate B bootstrap samples, by resampling with replacement the original data. Then all statistics for each parameter can be calculated from each bootstrap sample (median and confidence intervals). For the method = "bayes", the argument niter is related to the number of Metropolis iterations for the sampler.

The output is an object of class "gonadMat". This object contains a dataframe with the allometric variable "X" and stage of sexual maturity (inmature = 0, mature = 1). Also the fitted values for the curve logistic regression and confidence intervals (95\%). If you print the object, the median of the size at gonad maturity estimation ($L_{50}$) and parameters are shown.

## Estimate size at gonad maturity (maturity ogive estimation)

#Frequentist regression
my_ogive_fq = gonad_mature(matFish, varNames = c("total_length", "stage_mat"), inmName = "I",
matName = c("II", "III", "IV" ), method = "fq", niter = 999)

print(my_ogive_fq)

#Bayesian regression
my_ogive_bayes = gonad_mature(matFish, varNames = c("total_length", "stage_mat"), inmName = "I",
matName = c("II", "III", "IV" ), method = "bayes", niter = 999)

print(my_ogive_bayes)


## Plot maturity ogive

For plotting the maturity ogive the object of class "gonadMat"is required. The function plot generates 4 graphics: 1), 2) and 3) are histograms for the A, B parameters and the size at gonadal maturity ($L_{50}$), the last is the maturity ogive.

par(mfrow = c(2,2))
plot(my_ogive_fq, xlab = "Total length (cm.)", ylab = "Proportion mature", col = c("blue", "red"))

par(mfrow = c(2,2))
plot(my_ogive_bayes, xlab = "Total length (cm.)", ylab = "Proportion mature", col = c("blue", "red"))


If you want the maturity ogive plot only, you have to add the param onlyOgive = TRUE. Besides you can modify the axis (size, rotation, etc) and add the legend.

plot(my_ogive_fq, xlab = "Total length (cm.)", ylab = "Proportion mature", col = c("blue", "red"), onlyOgive = TRUE)


## References

Agostinho, C. S. (2000). Use of otoliths to estimate size at sexual maturity in fish. Brazilian Archives of Biology and Technology, 43(4).

Corgos, A. & Freire, J. (2006). Morphometric and gonad maturity in the spider crab Maja brachydactyla: a comparison of methods for estimating size at maturity in species with determinate growth. ICES Journal of Marine Science: Journal du Conseil, 63(5), 851-859.

Roa, R., Ernst, B. & Tapia, F. (1999). Estimation of size at sexual maturity: an evaluation of analytical and resampling procedures. Fishery Bulletin, 97(3), 570-580.

Somerton, D. A. (1980). A computer technique for estimating the size of sexual maturity in crabs. Canadian Journal of Fisheries and Aquatic Sciences, 37(10), 1488-1494.

## Try the sizeMat package in your browser

Any scripts or data that you put into this service are public.

sizeMat documentation built on Aug. 1, 2019, 1:05 a.m.