-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhcr_summary_table.Rmd
194 lines (179 loc) · 6.76 KB
/
hcr_summary_table.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
---
title: "hcr summary table - base run"
output:
html_document:
code_folding: hide
fig_height: 6
fig_width: 9
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)
```
```{r}
Blim <- 1.94
Bpa <- 2.57
library(tidyverse)
root <- "/net/hafkaldi/export/u2/reikn/hoski/Mackerel/HCRSimulations/2periods"
runs <- c("BevHEstAcf",
"HockeyEstAcf",
"RickerEstAcf",
"HockeyEstAcfdensdepnotrend",
"BevHEstAcfdensdepnotrend",
"HockeyEstAcfdensdepTrend",
"BevHEstAcfdensdepTrend")
default <- "HockeyEstAcf"
```
```{r, eval = FALSE}
load(paste0(root, "/", default, "/", "HCRrunresponse.rdata"))
d <-
alldata %>%
select(Btrigger, Meanwtyears, FishingMortality, MaxChange, year:refbio) %>%
gather(variable, value, catch:refbio) %>%
mutate(value = ifelse(variable != "refF", value/1e3, value),
value = ifelse(variable == "n1", value/1e3, value)) %>%
group_by(Btrigger, Meanwtyears, FishingMortality, MaxChange, year, variable) %>%
summarise(q05 = quantile(value, 0.05),
q25 = quantile(value, 0.25),
q50 = quantile(value, 0.50),
m = mean(value),
q75 = quantile(value, 0.75),
q95 = quantile(value, 0.95)) %>%
ungroup()
probs <-
alldata %>%
select(Btrigger, Meanwtyears, FishingMortality, MaxChange, year, ssb) %>%
group_by(Btrigger, Meanwtyears, FishingMortality, MaxChange, year) %>%
summarise(n = n(),
pBlim = sum(ssb < Blim * 1e3) / n,
pBpa = sum(ssb < Bpa * 1e3) / n,
pBtrigger = sum(ssb < Btrigger) / n) %>%
ungroup()
save(d, probs, file = "data/hcr_summary_default.rda")
```
```{r}
load("data/hcr_summary_default.rda")
pBlim <-
probs %>%
select(Btrigger:year, q50 = pBlim) %>%
mutate(variable = "pBlim") %>%
filter(year > 2014)
d2 <-
d %>%
bind_rows(pBlim)
dummy <-
data_frame(variable = c("ssb", "pBlim"),
lim = c(Blim, 0.05)) %>%
mutate(variablef = factor(variable, levels = c("ssb", "pBlim")))
d2 %>%
filter(variable %in% c("catch", "ssb", "refF", "pBlim"),
Btrigger == 600,
Meanwtyears == 5,
MaxChange == 3,
FishingMortality %in% c(0.18, 0.19, 0.20, 0.22, 0.25, 0.30, 0.35)) %>%
mutate(variablef = factor(variable, levels=c('ssb','catch','refF','pBlim'))) %>%
ggplot(aes(year)) +
geom_vline(xintercept = 2015) +
geom_hline(data = dummy, aes(yintercept = lim)) +
geom_ribbon(aes(ymin = q05, ymax = q95), fill = "red", alpha = 0.25) +
geom_ribbon(aes(ymin = q25, ymax = q75), fill = "red", alpha = 0.25) +
geom_line(aes(y = q50)) +
facet_grid(variablef ~ FishingMortality, scale = "free_y") +
expand_limits(y = 0) +
labs(title = "Default run, no trigger (value used 600kt), no buffer, weights last 5 years",
subtitle = "Data show q05, q25, median, q75 and q95")
```
In the tables below we have 4 variables:
* MaxChange: The catch stabilizer, if 3 then effectively this means no catch stabilizer
* term: The time period
- LT: 2033-2085
- MT: 2023-2032
- ST: 2018:2022
* Btrigger: Here the lowest value is 600 kt, set because a value of 40 kt resulted in crashing under some scenarios. Effectively the lowest value is equivalent to no Btrigger under likely fishing mortality multipliers.
* Meanwtyears
- 5: Mean weights last 5 years
- 20: Mean weights last 20 years
```{r}
# We need to evaluate short-term (ST), medium-term (MT) and long-term (LT)
# (2018-2022), medium term (2023-2032) and long term (2033-2052)
terms <- data_frame(year = 2018:2052,
term = ifelse(year %in% 2018:2022, "ST",
ifelse(year %in% 2023:2032, "MT", "LT")))
ptable <-
probs %>%
left_join(terms) %>%
filter(!is.na(term),
FishingMortality < 0.36) %>%
group_by(MaxChange, term, Btrigger, Meanwtyears, FishingMortality) %>%
summarise(pBlim = round(max(pBlim) * 100, 1)) %>%
ungroup() %>%
#filter(term == "LT") %>%
spread(FishingMortality, pBlim) %>%
arrange(desc(MaxChange), term, Meanwtyears, Btrigger)
ptable %>%
knitr::kable(caption = "Probability of ssb going below Blim")
d3 <-
d2 %>%
left_join(terms) %>%
filter(!is.na(term)) %>%
group_by(MaxChange, term, Btrigger, Meanwtyears, FishingMortality, variable) %>%
# Not sure if one should take the mean of the medians??
summarise(median = mean(q50))
d3 %>%
filter(variable == "catch",
FishingMortality < 0.36) %>%
select(-variable) %>%
mutate(median = round(median, 3)) %>%
spread(FishingMortality, median) %>%
arrange(desc(MaxChange), term, Meanwtyears, Btrigger) %>%
knitr::kable(caption = "Median catch")
d3 %>%
filter(variable == "ssb",
FishingMortality < 0.36) %>%
select(-variable) %>%
mutate(median = round(median, 3)) %>%
spread(FishingMortality, median) %>%
arrange(desc(MaxChange), term, Meanwtyears, Btrigger) %>%
knitr::kable(caption = "Median ssb")
```
```{r, eval = FALSE, echo = FALSE}
# NOT RUN
basedir <- "/net/hafkaldi/export/u2/reikn/hoski/Mackerel"
subdirs <- c("HockeyAcf0008PinFile",
"HockeyAcf0008PinFilemcrb2",
"HockeyAcf0012PinFile",
"HockeyAcf0012PinFilemcrb2",
"HockeyAcf00sqrt08PinFile",
"HockeyAcf00sqrt12PinFile",
"HockeyAcf00sqrt12PinFilemcrb02",
"HockeyAcf00FixedSSBBreak")
txt <- c("log, low lim 800","log, low lim 800 mcrb2","log, low lim 1200","log, low lim 1200 mcrb 2","sqrt, low lim 800","sqrt low lim 1200", "sqrt low lim 1200 mcrb2","SSBbreak fixed at 2000")
sumdata1 <- sumdata2 <- data.frame()
for(i in 1:length(subdirs)){
load(paste(basedir,"HCRSimulations/Final",subdirs[i],"HCRrunsum.rdata",sep="/"))
sumdata$run <- txt[i]
sumdata20 <- sumdata[sumdata$Meanwtyears==20 & sumdata$Btrigger < 50,]
sumdata5 <- sumdata[sumdata$Meanwtyears==5 & sumdata$Btrigger < 50,]
sumdata1 <- rbind(sumdata1,sumdata20)
sumdata2 <- rbind(sumdata2,sumdata5)
}
ggplot(sumdata2, aes(FishingMortality, catchmean, col = run)) +
geom_vline(xintercept=seq(0.16,0.3,by=0.02),col="lightgrey") +
geom_line(lwd=2)+theme_bw() +
scale_colour_brewer(palette = "Set1") +
theme(legend.position=c(0.8,0.75))
ggplot(sumdata2,aes(FishingMortality,catchmed,col=run)) +
theme_bw()+
geom_vline(xintercept=seq(0.16,0.3,by=0.02),col="lightgrey")+
geom_line(lwd=2)+
scale_colour_brewer(palette = "Set1") +
theme(legend.position=c(0.4,0.4))
ggplot(sumdata2,aes(FishingMortality,ssb05,col=run))+
theme_bw()+
geom_vline(xintercept=seq(0.16,0.3,by=0.02),col="lightgrey")+
geom_line(lwd=1)+
scale_colour_brewer(palette = "Set1") +
theme(legend.position=c(0.8,0.7))+
geom_abline(intercept = 1840,lwd=2) +
ylab("1000 tonnes")
#load("/net/hafkaldi/export/u2/reikn/hoski/Mackerel/HCRSimulations/Final/HockeyAcf0012PinFilemcrb2/HCRrunsum.rdata")
```