-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_functions.R
More file actions
228 lines (210 loc) · 7.06 KB
/
Copy pathtest_functions.R
File metadata and controls
228 lines (210 loc) · 7.06 KB
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#Script to run functions under various common scenarios.
library(EGprocess)
library(tidyverse)
brood_Igushik <- get_brood(data_Igushik)
goal_Igushik <-
data.frame(
yr = c(1984, 2001, 2015),
lb = c(150000, 150000, 150000),
ub = c(250000, 300000, 400000)
)
goal_Igushik_new <-
data.frame(
yr = c(1984, 2001, 2015, 2026),
lb = c(150000, 150000, 150000, 200000),
ub = c(250000, 300000, 400000, 500000)
)
goal_Igushik_lbSEG <-
data.frame(
yr = c(1984, 2001, 2015),
lb = c(100000, 150000, 100000),
ub = c(NA, 300000, NA)
)
goal_Igushik_lbSEG_new <-
data.frame(
yr = c(1984, 2001, 2015, 2026),
lb = c(100000, 150000, 100000, 150000),
ub = c(NA, 300000, NA, 350000)
)
# Combine profiles list of profiles
post_Igushik <- c(post_Igushik_byr63_05, post_Igushik_byr63_15)
profile_list <- get_profile(post_Igushik, multiplier = 1e-5)
profile_list80 <- get_profile(post_Igushik, multiplier = 1e-5, MSY_pct = 80)
# test plot_s w and wo a new goal finding
plot_escapement(brood_Igushik,
goal_Igushik,
"Igushik River Sockeye Salmon"
)
plot_escapement(brood_Igushik,
goal_Igushik_lbSEG,
"Igushik River Sockeye Salmon"
)
plot_escapement(brood_Igushik,
goal_Igushik_new,
"Igushik River Sockeye Salmon"
) +
geom_bar(aes(y = S),
data = data.frame(yr = c(2024, 2025), S = c(692616, 668268)),
stat = "identity", color = "black", fill = "white", alpha = .1, linewidth = 0.5)
#test plot_SR function
# No goal change, single analysis
plot_SR(post_Igushik[2],
brood_Igushik,
goal_dat = goal_Igushik,
"Igushik River Sockeye Salmon",
multiplier = 1e-5)
# No goal change, two analyses
plot_SR(post_Igushik,
brood_Igushik,
goal_dat = goal_Igushik,
"Igushik River Sockeye Salmon",
multiplier = 1e-5)
# No goal change, two analyses, unknown profile
plot_SR(c(list('Brood years: 1963-2005' = c(lnalpha = 1.5, beta = 0.15, sigma = 0.5)),
post_Igushik_byr63_15),
brood_Igushik,
goal_dat = goal_Igushik,
"Igushik River Sockeye Salmon",
multiplier = 1e-5)
# No goal change, two analyses, unknown SR params
plot_SR(list('Brood years: 1963-2005' = NULL,
'Brood years: 1963-2015' = c(lnalpha = 1.7, beta = 1.4e-6, sigma = 0.5)),
brood_Igushik,
goal_dat = goal_Igushik,
"Igushik River Sockeye Salmon")
#new finding
plot_SR(post_Igushik,
brood_Igushik,
goal_dat = goal_Igushik_new,
"Igushik River Sockeye Salmon",
new_finding = TRUE,
multiplier = 1e-5)
#first finding
plot_SR(post_Igushik[2],
brood_Igushik,
goal_dat = goal_Igushik_new[dim(goal_Igushik_new)[1], ],
"Igushik River Sockeye Salmon",
new_finding = TRUE,
multiplier = 1e-5)
# lbSEG
plot_SR(post_Igushik,
brood_Igushik,
goal_dat = goal_Igushik_lbSEG,
"Igushik River Sockeye Salmon",
new_finding = TRUE,
multiplier = 1e-5)
table_SR(post_Igushik[2], title = "Igushik River Sockeye Salmon", multiplier = 1e-6)
#works wo phi
post_test <- post_Igushik[2]
post_test[[1]] <- post_Igushik[[2]][, names(post_Igushik[[2]]) != "phi"]
table_SR(post_test, title = "Igushik River Sockeye Salmon", multiplier = 1e-6)
#test plot_ey function
# No goal change, single analysis
plot_ey(post_Igushik[2],
brood_Igushik,
goal_dat = goal_Igushik,
"Igushik River Sockeye Salmon",
multiplier = 1e-5)
# No goal change, two analyses
plot_ey(post_Igushik,
brood_Igushik,
goal_dat = goal_Igushik,
"Igushik River Sockeye Salmon",
multiplier = 1e-5)
# No goal change, two analyses, unknown profile
plot_ey(c(list('Brood years: 1963-2005' = c(lnalpha = 1.5, beta = 0.15, sigma = 0.5)),
'Brood years: 1963-2017' = post_Igushik_byr63_15),
brood_Igushik,
goal_dat = goal_Igushik,
"Igushik River Sockeye Salmon",
multiplier = 1e-5)
# No goal change, two analyses, unknown SR params
plot_ey(list('Brood years: 1963-2005' = NULL,
'Brood years: 1963-2017' = c(lnalpha = 1.7, beta = 1.4e-6, sigma = 0.5)),
brood_Igushik,
goal_dat = goal_Igushik,
"Igushik River Sockeye Salmon")
#new finding
plot_ey(post_Igushik,
brood_Igushik,
goal_dat = goal_Igushik_new,
"Igushik River Sockeye Salmon",
new_finding = TRUE,
multiplier = 1e-5)
#first finding
plot_ey(post_Igushik[2],
brood_Igushik,
goal_dat = goal_Igushik_new[dim(goal_Igushik_new)[1], ],
"Igushik River Sockeye Salmon",
new_finding = TRUE,
multiplier = 1e-5)
# lbSEG
plot_ey(post_Igushik,
brood_Igushik,
goal_dat = goal_Igushik_lbSEG,
"Igushik River Sockeye Salmon",
new_finding = TRUE,
multiplier = 1e-5)
# lbSEG
plot_ey(post_Igushik,
brood_Igushik,
goal_dat = goal_Igushik_lbSEG,
"Igushik River Sockeye Salmon",
new_finding = FALSE,
multiplier = 1e-5)
# no goal change
plot_profile(profile_list[2],
goal_Igushik,
"Igushik River Sockeye Salmon")
plot_profile(profile_list80[2],
goal_Igushik,
"Igushik River Sockeye Salmon")
# new finding
plot_profile(profile_list[2],
goal_Igushik_new,
"Igushik River Sockeye Salmon",
new_finding = TRUE
)
plot_profile(profile_list80[2],
goal_Igushik_new,
"Igushik River Sockeye Salmon",
new_finding = TRUE
)
# no goal change
plot_profile(profile_list,
goal_Igushik,
"Igushik River Sockeye Salmon")
plot_profile(profile_list80,
goal_Igushik,
"Igushik River Sockeye Salmon")
# new finding
plot_profile(profile_list,
goal_Igushik_new,
"Igushik River Sockeye Salmon",
new_finding = TRUE
)
plot_profile(profile_list80,
goal_Igushik_new,
"Igushik River Sockeye Salmon",
new_finding = TRUE
)
# lbSEG
plot_profile(profile_list,
goal_Igushik_lbSEG,
"Igushik River Sockeye Salmon",
new_finding = FALSE
)
plot_profile(profile_list80,
goal_Igushik_lbSEG_new,
"Igushik River Sockeye Salmon",
new_finding = TRUE
)
# Test EGoutput
# 90% of MSY
output_SR(post_Igushik, brood_Igushik, goal_Igushik, "Igushik River Sockeye Salmon", multiplier = 1e-5)
output_SR(post_Igushik, brood_Igushik, goal_Igushik_new, "Igushik River Sockeye Salmon", new_finding = TRUE, multiplier = 1e-5)
output_SR(post_Igushik[2], brood_Igushik, goal_Igushik, "Igushik River Sockeye Salmon", multiplier = 1e-5)
# 80% & 90% of MSY
output_SR(post_Igushik, brood_Igushik, goal_Igushik, "Igushik River Sockeye Salmon", MSY_pct = 80, multiplier = 1e-5)
output_SR(post_Igushik, brood_Igushik, goal_Igushik_new, "Igushik River Sockeye Salmon", new_finding = TRUE, MSY_pct = 80, multiplier = 1e-5)
output_SR(post_Igushik[2], brood_Igushik, goal_Igushik, "Igushik River Sockeye Salmon", MSY_pct = 80, multiplier = 1e-5)