-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.Rmd
154 lines (121 loc) · 5.37 KB
/
index.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
---
title: "Fish stock assessment with R"
subtitle: "The a4a Initiative"
author: "John Doe and friends"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib, packages.bib]
url: your book url like https://ejardim.github.io/a4abook/
# cover-image: path to the social sharing image like images/cover.jpg
description: |
How to do stock assessment in R using the a4a framework
link-citations: yes
github-repo: ejardim/a4abook
output:
pdf_document:
extra_dependencies: ["a4a"]
---
# Before starting
```{r, knitr_opts, echo=FALSE, message=FALSE, warning=FALSE}
library(knitr)
library(formatR)
#thm = knit_theme$get("bclear") #moe, bclear
#knit_theme$set(thm)
opts_chunk$set(dev='png', dev.args=list(type="cairo"))
# lattice theme
```
## License, documentation and development status
The software is released under the [EUPL 1.1](https://joinup.ec.europa.eu/community/eupl/home).
For more information on the a4a methodologies refer to [Jardim, et.al, 2014](http://icesjms.oxfordjournals.org/content/early/2014/04/03/icesjms.fsu050.abstract), [Millar, et.al, 2014](http://icesjms.oxfordjournals.org/content/early/2014/03/31/icesjms.fsu043.abstract) and [Scott, et.al, 2016](http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0154922).
Documentation can be found at <http://flr-project.org/FLa4a>. You are welcome to:
- Submit suggestions and bug-reports at: <https://github.com/flr/FLa4a/issues>
- Send a pull request on: <https://github.com/flr/FLa4a/>
- Compose a friendly e-mail to the maintainer, see `packageDescription('FLa4a')`
## Installing and loading libraries
To run the `FLa4a` methods the reader will need to install the package and its dependencies and load them. Some datasets are distributed with the package and as such need to be loaded too.
```{R, eval=FALSE}
# from CRAN
install.packages(c("copula","triangle", "coda", "grid", "gridExtra", "latticeExtra"))
# from FLR
install.packages(c("FLCore", "FLa4a"), repos="http://flr-project.org/R")
```
```{R, message=FALSE, warning=FALSE}
# libraries
library(devtools)
library(FLa4a)
library(XML)
library(reshape2)
library(ggplotFL)
# datasets
data(ple4)
data(ple4.indices)
data(ple4.index)
data(rfLen)
```
```{R}
packageVersion("FLCore")
packageVersion("FLa4a")
```
## How to read this document
The target audience for this document are readers with some experience in R and some background on stock assessment.
The document explains the approach being developed by `a4a` for fish stock assessment and scientific advice. It presents a mixture of text and code, where the first explains the concepts behind the methods, while the last shows how these can be run with the software provided. Moreover, having the code allows the reader to copy/paste and replicate the analysis presented here.
The sections and subsections are as independent as possible, so it can be used as a reference document for the `FLa4a`.
## How to get help
`a4a` is build around S4 classes. S4 classes and methods in R offer an object-oriented programming framework but in order to access the documentation requires specific terminology. In this section we will demonstrate how to get information on the main building blocks of `a4a`.
For example, `FLStock` is one of our main components in order to run our stock assessment model. We can check the structure of an `FLStock` object as follows:
```{r}
showClass("FLStock")
```
The object oriented structure of `a4a` gives the opportunity to change the behavior of a function according to the object that is applied to. For example we can check the available methods of the function `plot`
```{r}
showMethods("plot")
```
by calling `showMethods` R prints all the possible uses of the **plot** function. We want to see what it does when it is called on an `FLStock` object with no other object. We observe that `plot` takes two arguments, `x` and `y`. So, in the signature of the `getMethod` function we are going to use, we need to define both `x` and `y`.
```{r}
getMethod('plot', signature = list("FLStock","missing"))
```
## Notation
Along this chapter the notation presented in Table \@ref(tab:mathsnotation) will be used. Mathematical descriptions will be kept as simple as possible for readability.
|Type|Symbol|Description|
|:---|-----:|:----------|
|variables| | |
| |$C$ | catches|
| |$F$ | fishing mortality |
| |$M$ | natural mortality |
| |$R$ | recruitment |
| |$Q$ | vessel or fleet catchability |
| |$w$ | weights |
| |$l$ | likelihood |
| |$I$ | abundance index |
| |$S$ | spawning stock biomass |
| |$CV$ | coefficient of variation |
| |$D$ | residuals or deviances |
| |$N$ | normal distribution |
| |$\beta$ | parameter |
| |$a$ | stock-recruitment parameter |
| |$b$ | stock-recruitment parameter |
| |$\sigma^2$ | variance of catch |
| |$\tau^2$ | variance of index |
| |$\phi^2$ | variance of predicted recruitment |
| |$\upsilon^2$ | variance of residuals |
|subscripts | | |
| |$a$ | age |
| |$y$ | year |
| |$C$ | catch |
| |$I$ | abundance index |
| |$N$ | normal distribution |
| |$s$ | survey |
| |$SR$ | stock recruitment relationship |
|superscripts and accents | | |
| |$\hat{}$ | observation |
| |$\tilde{}$ | prediction |
| |$c$ | catches |
| |$s$ | abundance index |
Table: (\#tab:mathsnotation) Mathematical notation
```{r include=FALSE}
# automatically create a bib database for R packages
knitr::write_bib(c(
.packages(), 'bookdown', 'knitr', 'rmarkdown'
), 'packages.bib')
```