-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget results of runs price_uniform_defaults.Rmd
279 lines (197 loc) · 12.5 KB
/
get results of runs price_uniform_defaults.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
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
---
title: "Results_defaults_price uniform"
author: "Kat Leigh"
date: "2/26/2021"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
library(tidyverse)
library(ggplot2)
library(here)
library(quadprog)
library(scales)
library(DT)
```
```{r}
# read in data
output_b_20 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreoutput_b_p20.csv")
NPV_20 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreNPV_b_p20.csv")
output_b_1 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreoutput_b_p1.csv")
NPV_1 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreNPV_b_p1.csv")
output_b_10 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreoutput_b_p10.csv")
NPV_10 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreNPV_b_p10.csv")
output_b_30 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreoutput_b_p30.csv")
NPV_30 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreNPV_b_p30.csv")
output_b_40 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreoutput_b_p40.csv")
NPV_40 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreNPV_b_p40.csv")
output_b_50 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreoutput_b_p50.csv")
NPV_50 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreNPV_b_p50.csv")
output_b_60 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreoutput_b_p60.csv")
NPV_60 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreNPV_b_p60.csv")
output_b_70 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreoutput_b_p70.csv")
NPV_70 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreNPV_b_p70.csv")
output_b_80 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreoutput_b_p80.csv")
NPV_80 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreNPV_b_p80.csv")
output_b_90 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreoutput_b_p90.csv")
NPV_90 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreNPV_b_p90.csv")
output_b_100 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreoutput_b_p100.csv")
NPV_100 <- read_csv("C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost exploreNPV_b_p100.csv")
NPVs <- rbind(NPV_1, NPV_10, NPV_20, NPV_30, NPV_40, NPV_50, NPV_60, NPV_70, NPV_80, NPV_90, NPV_100)
```
# Visualize Results
```{r}
# profits
pfts_1 <- output_b_1 %>%
select(profit_per_t.t_1:profit_per_t.t_5) %>%
mutate(run = "1")
pfts_10 <- output_b_10 %>%
select(profit_per_t.t_1:profit_per_t.t_5) %>%
mutate(run = "10")
pfts_20 <- output_b_20%>%
select(profit_per_t.t_1:profit_per_t.t_5) %>%
mutate(run = "20")
pfts_30 <- output_b_30%>% select(profit_per_t.t_1:profit_per_t.t_5) %>%
mutate(run = "30")
pfts_40 <- output_b_40%>% select(profit_per_t.t_1:profit_per_t.t_5) %>%
mutate(run = "40")
pfts_50 <- output_b_50%>% select(profit_per_t.t_1:profit_per_t.t_5) %>%
mutate(run = "50")
pfts_60 <- output_b_60%>% select(profit_per_t.t_1:profit_per_t.t_5) %>%
mutate(run = "60")
pfts_70 <- output_b_70%>% select(profit_per_t.t_1:profit_per_t.t_5) %>%
mutate(run = "70")
pfts_80 <- output_b_80%>% select(profit_per_t.t_1:profit_per_t.t_5) %>%
mutate(run = "80")
pfts_90 <- output_b_90%>% select(profit_per_t.t_1:profit_per_t.t_5) %>%
mutate(run = "90")
pfts_100 <- output_b_100%>% select(profit_per_t.t_1:profit_per_t.t_5) %>%
mutate(run = "100")
combo_pfts <- rbind(pfts_1, pfts_10, pfts_20, pfts_30, pfts_40, pfts_50, pfts_60, pfts_70, pfts_80, pfts_90, pfts_100)
tots <- combo_pfts$profit_per_t.t_1 + combo_pfts$profit_per_t.t_2 + combo_pfts$profit_per_t.t_3 + combo_pfts$profit_per_t.t_4 + combo_pfts$profit_per_t.t_5
combo_pfts_f <- cbind(combo_pfts, tots)
```
```{r}
pft_g <- ggplot()+
geom_smooth(data = combo_pfts_f, aes(y=tots/1000, x=rep(0:30,11), color = as.factor(run)), se = FALSE)+ theme_minimal()+
labs(title= str_wrap("Predicted annual profits for a multi-species fishery with uniform prices managed by 2 quota baskets", 80),
caption= str_wrap("Results of a 2 quota basket model for 5 species and 5 technologies parameterized such that species are identical in the following parameters: initial stock size = 50, fishing costs = 1, carrying capacities = 100, coefficient for quota basket limits = 0.2. The coefficient for quota basket limit defines the total combined biomass that can be extracted per year as a proportion of the total available biomass for that year. Species differ in terms of: growth rates = 0.15, 0.2, 0.2, 0.3, 0.4 (respective to each species, 1-5), catchabilities per technology = all 0.01 except for t1 catches species1 at 0.04, t2 catches species2 at 0.04, t3 catches species3 at 0.04, t4 catches species4 at 0.04, and t5 catches species5 at 0.04. Model was run for 11 different uniform price levels (see legend).", 100),
x= "Number of Years",
y= "Fishery-wide Annual Profits (thousands)",
color= "Price Level")+
scale_y_continuous(labels=dollar_format(prefix="$"))+
theme(plot.caption = element_text(hjust = 0))
```
```{r}
# stock
stock_1 <- output_b_1 %>%
select(stock.s_1:stock.s_5) %>%
mutate(run = "1")
stock_10 <- output_b_10 %>% select(stock.s_1:stock.s_5) %>%
mutate(run = "10")
stock_20 <- output_b_20 %>% select(stock.s_1:stock.s_5) %>%
mutate(run = "20")
stock_30 <- output_b_30 %>% select(stock.s_1:stock.s_5) %>%
mutate(run = "30")
stock_40 <- output_b_40 %>% select(stock.s_1:stock.s_5) %>%
mutate(run = "40")
stock_50 <- output_b_50 %>% select(stock.s_1:stock.s_5) %>%
mutate(run = "50")
stock_60 <- output_b_60 %>% select(stock.s_1:stock.s_5) %>%
mutate(run = "60")
stock_70 <- output_b_70 %>% select(stock.s_1:stock.s_5) %>%
mutate(run = "70")
stock_80 <- output_b_80 %>% select(stock.s_1:stock.s_5) %>%
mutate(run = "80")
stock_90 <- output_b_90 %>% select(stock.s_1:stock.s_5) %>%
mutate(run = "90")
stock_100 <- output_b_100 %>% select(stock.s_1:stock.s_5) %>%
mutate(run = "100")
combo_stock <- rbind(stock_1, stock_10, stock_20, stock_30, stock_40, stock_50, stock_60, stock_70, stock_80, stock_90, stock_100)
tots <- combo_stock$stock.s_1 + combo_stock$stock.s_2 + combo_stock$stock.s_3 + combo_stock$stock.s_4 + combo_stock$stock.s_5
combo_stock_f <- cbind(combo_stock, tots)
```
```{r}
stock_g <- ggplot()+
geom_smooth(data = combo_stock_f, aes(y=tots, x=rep(0:30,11), color = as.factor(run)), se = FALSE)+ theme_minimal()+
labs(title= str_wrap("Predicted annual stock levels for a multi-species fishery with uniform prices managed by 2 quota baskets", 80),
caption= str_wrap("Results of a 2 quota basket model for 5 species and 5 technologies parameterized such that species are identical in the following parameters: initial stock size = 50, fishing costs = 1, carrying capacities = 100, coefficient for quota basket limits = 0.2. The coefficient for quota basket limit defines the total combined biomass that can be extracted per year as a proportion of the total available biomass for that year. Species differ in terms of: growth rates = 0.15, 0.2, 0.2, 0.3, 0.4 (respective to each species, 1-5), catchabilities per technology = all 0.01 except for t1 catches species1 at 0.04, t2 catches species2 at 0.04, t3 catches species3 at 0.04, t4 catches species4 at 0.04, and t5 catches species5 at 0.04. Model was run for 11 different uniform price levels (see legend).", 100),
x= "Number of Years",
y= "Fishery-wide Annual Stock Level (tons)",
color= "Price Level")+
theme(plot.caption = element_text(hjust = 0))
```
compare levels of each stock
```{r}
longer_stock_f <- combo_stock_f %>%
pivot_longer(cols = c(stock.s_1:stock.s_5, tots), names_to = "Species", values_to = "Stock_Level")
longer_stock_f$facet <- factor(longer_stock_f$run, levels = c(1, seq(10,100,10)))
longer_stock_f <- longer_stock_f %>%
mutate(sign = '$') %>%
transform(newcol=paste(sign, facet, sep="")) %>%
select(-sign)
longer_stock_f$Species <- factor(longer_stock_f$Species, levels = c("stock.s_1", 'stock.s_2', 'stock.s_3', 'stock.s_4', 'stock.s_5', 'tots'),
labels = c("Species 1", "Species 2", "Species 3", 'Species 4', 'Species 5', 'Fishery Total'))
longer_stock_f$facet <- factor(longer_stock_f$facet, levels = c(1, seq(10,100,10)),
labels = unique(longer_stock_f$newcol))
stock_comp_g <- ggplot()+
geom_smooth(data = filter(longer_stock_f, Species != "Fishery Total"), aes(y=Stock_Level, x=rep(0:30,55), color = Species), se = FALSE)+ theme_minimal()+ facet_wrap(~ facet)+
labs(title= str_wrap("Predicted annual stock levels for a multi-species fishery with uniform prices managed by 2 quota baskets", 80),
caption= str_wrap("Results of a 2 quota basket model for 5 species and 5 technologies parameterized such that species are identical in the following parameters: initial stock size = 50, fishing costs = 1, carrying capacities = 100, coefficient for quota basket limits = 0.2. The coefficient for quota basket limit defines the total combined biomass that can be extracted per year as a proportion of the total available biomass for that year. Species differ in terms of: growth rates = 0.15, 0.2, 0.2, 0.3, 0.4 (respective to each species, 1-5), catchabilities per technology = all 0.01 except for t1 catches species1 at 0.04, t2 catches species2 at 0.04, t3 catches species3 at 0.04, t4 catches species4 at 0.04, and t5 catches species5 at 0.04. Model was run for 11 different uniform price levels (see legend).", 100),
x= "Number of Years",
y= "Annual Stock Level (tons)",
color= "Species")+
theme(plot.caption = element_text(hjust = 0))+
scale_color_viridis_d()
```
```{r}
# analyze a bit...
compare_pft_prices <- combo_pfts_f %>%
group_by(as.factor(run)) %>%
summarise(sum = sum(tots, na.rm = TRUE),
average = mean(tots, na.rm = TRUE)) %>%
arrange(-average)
compare_stock_prices <- combo_stock_f %>%
group_by(as.factor(run)) %>%
summarise(sum = sum(tots, na.rm = TRUE),
average = mean(tots, na.rm = TRUE)) %>%
arrange(-average)
level_30 <- stock_20$stock.s_1[31] + stock_20$stock.s_2[31] + stock_20$stock.s_3[31] + stock_20$stock.s_4[31] + stock_20$stock.s_5[31]
```
Export results
```{r}
# data
# pft
path_store <- "C:/Users/kll86/OneDrive/Documents/UCSB/quotabasket_model/working_model/price and cost explore"
csvname <- "pft_data_p_uniform_defaults.csv"
csvfile <- paste(path_store, csvname, sep="")
write.table(na.omit(combo_pfts_f),csvfile, row.names=FALSE, sep=",")
csvname <- "pft_comparison_p_uniform_defaults.csv"
csvfile <- paste(path_store, csvname, sep="")
write.table(na.omit(compare_pft_prices),csvfile, row.names=FALSE, sep=",")
# stock
csvname <- "stock_data_p_uniform_defaults.csv"
csvfile <- paste(path_store, csvname, sep="")
write.table(na.omit(combo_stock_f),csvfile, row.names=FALSE, sep=",")
csvname <- "stock_comparison_p_uniform_defaults.csv"
csvfile <- paste(path_store, csvname, sep="")
write.table(na.omit(compare_stock_prices),csvfile, row.names=FALSE, sep=",")
csvname <- "stock_level30_p_uniform_defaults.csv"
csvfile <- paste(path_store, csvname, sep="")
write.table(na.omit(level_30),csvfile, row.names=FALSE, sep=",")
# graphs
# pft
ggsave(
filename = 'pft_data_p_uniform_defaults.jpg',
plot = pft_g,
path = path_store)
# stock
ggsave(
filename = 'stock_data_p_uniform_defaults.jpg',
plot = stock_g,
path = path_store)
ggsave(
filename = 'stock_comp_p_uniform_defaults.jpg',
plot = stock_comp_g,
path = path_store)
```