forked from renatoamorais/rfishprod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
110 lines (77 loc) · 3.07 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# rfishprod
<!-- badges: start -->
<!-- badges: end -->
Implements a framework to generate individual-level estimates
of fish productivity, with a focus on reef fishes. This individual
approach works by combining estimates of somatic growth through the
von Bertalanffy Growth Model, and deterministic or stochastic natural
mortality using instantaneous mortality rates.
## Installation
You can install rfishprod from [GitHub](https://github.com/renatoamorais/rfishprod) with:
``` r
devtools::install_github("renatoamorais/rfishprod")
```
To get [`devtools`](https://cran.r-project.org/web/packages/devtools/index.html), simply use `install.packages("devtools")`.
Although not a dependency, I recommend using R 3.6.3 or higher. This is mainly because [`xgboost`]( https://CRAN.R-project.org/package=xgboost), the machine behind internal prediction, demands R 3.6.3 in its most recent version.
## Example
```{r example, eval = F}
library(rfishprod)
# Check dataset repdata #
(repdata <- rfishprod:::repdata)
# Getting levels ready #
repdata <- tidytrait (repdata, db)
# Formula from Morais and Bellwood (2018) #
fmod <- formula (~ sstmean + MaxSizeTL + Diet + Position + Method)
# Predicting Kmax, the standardised VBGF parameter (Recommendation: use 100s to 1000s iterations) #
datagr <- predKmax (repdata,
dataset = db,
fmod = fmod,
niter = 10,
return = 'pred')
datagr <- datagr$pred
# Predicting M/Z: the instantaneous mortality rate (Recommendation: see help file for) #
datagr$Md <- with (datagr,
predM (Lmeas = Size,
Lmax = MaxSizeTL,
Kmax = Kmax,
method = 'Gislason'))
# Positioning your fish in their growth trajectory #
# aka. what's the size they're supposed to have on the next day? #
with (datagr, applyVBGF (Lmeas = Size,
Lmax = MaxSizeTL,
Kmax = Kmax))
# Compare with their size on the previous day #
datagr$Size
# Estimating gross somatic growth (g) #
with(datagr, somaGain (a = a,
b = b,
Lmeas = Size,
Lmax = MaxSizeTL,
Kmax = Kmax))
# Applying stochastic mortality #
applyMstoch (datagr$Md)
# Alternatively, estimating per capita mass loss due to mortality #
with(datagr, somaLoss (M = Md,
Lmeas = Size,
a = a,
b = b))
```
## Citation
Please, if you're using `rfishprod`, the relevant citation for the package can be obtained from:
```{r, eval = FALSE}
citation("rfishprod")
```
## Issues
Please [report issues or bugs](https://github.com/renatoamorais/rfishprod/issues) or shoot me an email (just hit `?rfishprod`)