-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.2_caa_assessment.Rmd
108 lines (91 loc) · 2.95 KB
/
3.2_caa_assessment.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
---
title: "Catch-at-age: assessment plots"
date: "`r Sys.Date()`"
output:
html_document:
toc: true
toc_depth: 3
toc_float:
collapsed: FALSE
code_folding: show
number_sections: TRUE
---
# SET-UP
```{r markdown, echo=F}
library(knitr)
opts_chunk$set(echo = T, collapse = T, fig.align = "center", fig.width = 9, fig.height = 6)
options(width = 140)
```
## settings
```{r settings, message = F}
source('0.0_settings.R')
```
## load all data
```{r data, message = F}
load(paste0(dir.rdat, "caa.Rdata"))
```
# CAA plots {.tabset}
## RAW
```{r caan_raw, message = F, fig.height = 3,fig.width = 10}
ggplot(caa,aes(x=year,y=age))+
geom_point(alpha=0.8,aes(size=caan))+
scale_size(range = c(1,12))+
scale_y_continuous(breaks=min(caa$age):max(caa$age))
```
## SPAY
```{r caan_spay, message = F, fig.height = 3,fig.width = 10}
d <- reshape2::dcast(caa,age~year,value.var = 'caan')
d <- cbind(age=d[,1],spay(d[,-1]))
d <- reshape2::melt(d,id.vars='age',variable.name='year',value.name='caan')
d$year <- as.numeric(as.character(d$year))
ggplot(d,aes(x=year,y=age))+
geom_point(alpha=0.8,aes(size=caan))+
scale_size(range = c(1,12))+
scale_y_continuous(breaks=min(caa$age):max(caa$age))
```
## SPYA
```{r caan_spya, message = F, fig.height = 3,fig.width = 10}
d <- reshape2::dcast(caa,age~year,value.var = 'caan')
d <- cbind(age=d[,1],spya(d[,-1]))
d <- reshape2::melt(d,id.vars='age',variable.name='year',value.name='caan')
d$year <- as.numeric(as.character(d$year))
ggplot(d,aes(x=year,y=age))+
geom_point(alpha=0.8,aes(size=caan))+
scale_size(range = c(1,12))+
scale_y_continuous(breaks=min(caa$age):max(caa$age))
```
# WAA plots {.tabset}
## Model predictions
```{r waa_fit, message = F, fig.height = 11,fig.width = 10}
caa$waa.cv <- 0.01 # need to calculate this!! this is absurdly small value so all predictions will match observed
caa[caa$caaw==0,'caaw'] <- NA # should be correct in get.caa function
waa.fit <- with(caa, armatrix.fit(year=caa$year,age=caa$age,x=caa$waa,cv=caa$waa.cv))
waa.fit
caa$waa.cv <- with(caa,waa.sd/waa) # need to calculate this!! this is absurdly small value so all predictions will match observed
waa.fit <- armatrix.fit(year=caa$year,age=caa$age,x=caa$waa,cv=caa$waa.cv)
waa.fit
```
## Predicted
```{r waa_predobs, message = F, fig.height = 10,fig.width = 10}
armatrix.predobs(waa.fit,scale='free',ncol=3)
```
## Predicted
```{r waa_pred, message = F, fig.height = 10,fig.width = 10}
armatrix.pred(waa.fit,scale='free',ncol=3)
```
## Resid bubble
```{r waa_res, message = F, fig.height = 3,fig.width = 10}
armatrix.res(waa.fit)
```
## Resid dot
```{r waa_res2, message = F, fig.height = 10,fig.width = 10}
armatrix.res2(waa.fit)
```
## effects
```{r waa_effects, message = F, fig.height = 10,fig.width = 10}
armatrix.effects(waa.fit) # empty plot because of ggplotGrob function within (used to align plots)
```
## cvs
```{r waa_cv, message = F, fig.height = 10,fig.width = 10}
armatrix.cvs(waa.fit,scale='free',ncol=3)
```