-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
113 lines (83 loc) · 7.51 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
output: github_document
bibliography: "pkgdown/README_references.bib"
link-citations: true
link-external-newwindow: true
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# morphmat
<img src="man/figures/logo.png" alt="Hex sticker logo for morphmat package" class="pkgdown-hide" align="right" height="139"/>
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) [![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
<!-- badges: end -->
A compilation of methods used to estimate size at (sexual) maturity based on morphometric data, most commonly applied to crabs, lobsters, and other crustaceans. Approaches include modeling approaches based on piecewise/segmented linear regression as well as numerous clustering-based methods.
`morphmat` is intended to help fisheries scientists and managers to implement the multitude of computational methods that have been developed for estimating crustacean size at maturity. This package is being developed as part of my graduate work at the University of Maine. **This is still a work in progress and should not yet be used for research purposes.**
`morphmat` will include user-friendly functions for estimating size at morphometric maturity, along with guidelines for choosing the optimal method for a given dataset and correctly interpreting results. Both novel and historically popular (e.g., broken-stick regression) methods will be included, and users will be able to obtain SM50 estimates from nearly a dozen different approaches with a single function call. By combining code for the various models within a single package, morphmat will enable the application of multi-model inference to SM50 estimation, avoiding the arbitrary selection of a single “best” model [@katsanevakis2006]. By increasing the accessibility of modern statistical methods for estimating SM50, I hope to facilitate the widespread adoption of improved SM50 modeling procedures.
`morphmat` will include versions of the methods implemented in these existing GitHub repositories:
| | | | |
|------------------|------------------|------------------|------------------|
| **Type** | **Authors** | **GitHub repository** | **Description/notes** |
| Package | Josymar Torrejon-Magallanes | [ejosymart/sizeMat](https://github.com/ejosymart/sizeMat) | [sizeMat: An R Package to Estimate Size at Sexual Maturity](https://cran.r-project.org/web/packages/sizeMat/vignettes/sizeMat.html) |
| Package | Rodrigo Sant'Ana, Fernando Mayer | [rodrigosantana/Regrans: Fits Segmented Linear Regression Models](https://github.com/rodrigosantana/Regrans) | Older repository: [fernandomayer/Regrans](https://github.com/fernandomayer/Regrans/blob/master/change.point.R) |
| Package | Derek Sonderegger | [siZer](https://cran.r-project.org/web/packages/SiZer/index.html) | [Conduct size at morphometric maturity analysis (SMM) and plot results using the SiZer extension package](https://zenodo.org/records/5002120) by Olson, Andrew P., Siddon, Chris E., and Eckert, Ginny L. |
| Package | Vito M. R. Muggeo | [segmented](https://cran.r-project.org/web/packages/segmented/index.html) | [package reference manual](https://cran.r-project.org/web/packages/segmented/segmented.pdf) |
| Package | Youyi Fong | [chngpt](https://doi.org/10.32614/CRAN.package.chngpt) | [Fitting Threshold Regression Models Using chngpt](https://cran.r-project.org/web/packages/chngpt/vignettes/chngpt-vignette.pdf) (vignette) |
| Package | Tobie Surette | [TobieSurette/gulf.stats](https://github.com/TobieSurette/gulf.stats) | See files [morphometric.maturity.R](https://github.com/TobieSurette/gulf.stats/blob/master/R/morphometric.maturity.R) and [morphometry.R](https://github.com/TobieSurette/gulf.stats/blob/master/R/morphometry.R) |
| R scripts | Bradley Stevens | [Crabman52/Crustacean_Sensation](https://github.com/Crabman52/Crustacean_Sensation) | Include three different methods for separating mature from immature crabs based on allometric growth of body parts, with code based on Somerton's (1980) program MATURE |
The following scripts do not use morphometric data and require individuals to already be classified as mature or immature. They provide various examples of how to fit maturity\~length binomial models to estimate SM50 and obtain confidence intervals. These tools can also be used to calculate size at maturity for non-crustacean fisheries. For a comprehensive examination of this type of model, see Mainguy et al [-@mainguy2024].
| | | | |
|------------------|------------------|------------------|------------------|
| **Type** | **Authors** | **GitHub repository** | **Description/notes** |
| R scripts | Lucas Rodrigues | [lvcasrodrigues/maturity_at_size](https://github.com/lvcasrodrigues/maturity_at_size) | Does not use morphometric data; takes size classes with known numbers of mature individuals per size class and fits a binomial model (frequentist or Bayesian). Finds SM50 by generating new data from the model rather than from ratio of parameters |
| R scripts | Mainguy et al. | [rafamoral/L50](https://github.com/rafamoral/L50): Monitoring reproduction in fish: Assessing the adequacy of ogives and the predicted uncertainty of their *L*~50~ estimates for more reliable biological inferences | Over a dozen methods for estimating L50 values and obtaining confidence intervals from (frequentist or Bayesian) binomial models (Delta, Fieller, bootstrap resampling, profile-likelihood, etc.). See accompanying manuscript by Mainguy et al. [-@mainguy2024]. |
| R script | [Alastair V. Harry](https://scholar.google.com.au/citations?user=hb4nzPYAAAAJ&hl) | [Alharry/Maturity.ogive.R](https://gist.github.com/alharry/4576675) | Includes bootstrap resampling to obtain 95% CIs |
## Installation
You can install the development version of morphmat from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("rmk118/morphmat")
```
## Articles/vignettes
- [Getting Started](https://rmk118.github.io/morphmat/articles/morphmat.html)
- [Broken-stick models](https://rmk118.github.io/morphmat/articles/broken-stick.html)
- [Two-line models](https://rmk118.github.io/morphmat/articles/two-line.html)
- [Classification methods](https://rmk118.github.io/morphmat/articles/classification.html)
- [Post-classification logistic regression](https://rmk118.github.io/morphmat/articles/logistic.html)
- [Simulating data](https://rmk118.github.io/morphmat/articles/simulations.html)
## Basic Examples
```{r example_generate}
library(morphmat)
set.seed(12) # for reproducibility when generating the simulated data
# Generate a simulated dataset with known size at maturity
fc <- fake_crustaceans(
error_scale = 17,
slope = 9,
L50 = 75,
n = 800,
allo_params = c(0.9, 0.25, 1.05, 0.2),
x_mean = 85
)
```
Compare estimates from all piecewise regression methods:
```{r}
piecewise_mods(fc, xvar = "x", yvar = "y", method = "all")
```
### Clustering methods
Compare all clustering methods
```{r}
all_clusters <- cluster_mods(fc, xvar = "x", yvar = "y", method = c("all"), plot = TRUE)
```
Somerton method:
```{r}
out_df <- somerton(fc, xvar = "x", yvar = "y")[[1]]
mod <- glm(data = out_df, pred_mat_num ~ x, family = binomial(link = "logit"))
unname(-coef(mod)[1] / coef(mod)[2])
```
## References