Abstract
A short account of Robert Bates’ conjecture on prosperity and violence with dynamic implications.# defaults
<- .4
.c <- .2
.d <- .4
.s <- .2
.v <- .4
.delta <- 1.5
.A_cooptn <- 1
.A_nocoop <- 1.4
.A_defect <- c(.3, .4, .5)
.c_range <- c(0, .2, .4)
.v_range <- c(.2, .4, .6) .delta_range
We define a function to describe the evolution of capital and utility given parameters.
# Total welfare if you pay cost c each period, form production, and produce according to A k ^ a
# Evolution of capital and instantaneous utility
# Can be used for path segment for regime specific A and starting k
<- function(k, A = .A_nocoop, c = 0, d = .d, a = .5, s = .s, max = 100, delta = .5){
k_path
# Initiate
<- function(k) max(0, A*k^a - c)
f <- list(f(k))
ys <- list(k)
ks <- list((1-s)*(ys[[1]] - c))
us
if(max>1)
for(j in 2:max){
<- max(0, ks[[j-1]]*(1-d) + s*(ys[[j-1]]))
ks[[j]] <- f(ks[[j]])
ys[[j]] <- (1-s)*ys[[j]]
us[[j]]
}
<- unlist(ks)
k <- c(k[-1], max(0, tail(k,1)*(1-d) + s*(A*tail(k,1)^a-c)))
k_end
data.frame(t = 1:max, k = k, y = unlist(ys), u = unlist(us), k_end = k_end)
}
# k_path(1, max = 1)
# k_path(1, max = 3)
# Welfare function
# Welfare during a regime starting at k with path defined for that regime
<- function(k, delta = .5, ...){
W <- k_path(k, ...)
H sum((delta^(0:(nrow(H)-1))) * H$u)
}
# Illustration of concatenation of paths
# Note: when adding the second chunk we need to input the ending capital
k_path(1, max = 4) %>% kable(caption = "Sample evolution")
t | k | y | u | k_end |
---|---|---|---|---|
1 | 1.000000 | 1.000000 | 0.6000000 | 1.200000 |
2 | 1.200000 | 1.095445 | 0.6572671 | 1.398178 |
3 | 1.398178 | 1.182446 | 0.7094675 | 1.591521 |
4 | 1.591521 | 1.261555 | 0.7569329 | 1.777839 |
If parameters change, a complex path can be defined by concatenating two paths, with appropriate discounting.
W(1, max = 4) = 1.200617
W(1, max = 2) + .25*W(k = k_path(1, max = 2)$k_end[2], max = 2) = 1.200617
We have a function to search over \(k\) values to assess when, starting at \(k\), players prefer general cooperation to produce \(A\) at cost \(c\) rather than defection.
# Willing to start cooperating
<- function(k, c = .c, s = .s, d = .d, a = .5,
will_cooperate A_cooptn = .A_cooptn,
A_nocoop = .A_nocoop,
A_defect = .A_defect,
delta = .delta,
...) {# Defector's capital
<- (1-d)*k + s*A_defect*k^a
k2_defect
1-s)*A_defect*k^a + # This period cheater payoff + future anarchy
((*W(k2_defect, delta = delta, c = 0, s = s, a = a, d = d, A = A_nocoop, ...)) <=
delta
W(k, delta = delta, c = c, s = s, a = a, d=d, A = A_cooptn, ...)
}
<- function(kmax = 8, fine =.01, ...){
coopertion_cutoff # large kmax as we can go beyond the steady state of no cooperation when violence is an option
<- seq(0, kmax, fine)
ks <- data.frame(k = ks, will = sapply(ks, will_cooperate, ...))
df if(all(!df$will)) return(NA)
$k[df$will][1]
df
}
print(paste("sample cutoff:", coopertion_cutoff()))
## [1] "sample cutoff: 5.68"
The enforcer is willing to start enforcing the collective action when this is better than no cooperation given equilibria in which (a) it might go forever or (b) it might transition to cooperation if others get wealthy enough.
# for these calculations max is assumed large: at any point we imagine discounted payoffs far into the future
<- function(k,
values c = .c,
s = .s,
d = .d,
a = .5,
A_cooptn = .A_cooptn,
A_nocoop = .A_nocoop,
A_defect = .A_defect,
delta = .delta,
v = .v,
max = 400,
coop_cut = NULL,
...) {# capital cutoff point when all cooperate is sustainable
if(is.null(coop_cut)) coop_cut <-
coopertion_cutoff(c = c, s = s, d = d, a = a, delta = delta, A_cooptn = A_cooptn, A_defect = A_defect)
# Violence paths, from here
<- k_path(k, A = A_defect, c = c, s = s, d = d, a = a, delta = delta, max = max)
cit_path_v <- k_path(k, A = A_defect, c = v, s = s, d = d, a = a, delta = delta, max = max)
enf_path_v
# Anarchy path, from here
<- k_path(k, A = A_nocoop, c = 0, s = s, d = d, a = a, delta = delta, max = max)
path_n
# Cooperation path, from here
<- k_path(k, A = A_cooptn, c = c, s = s, d = d, a = a, delta = delta, max = max)
path_c
# Length of violence period, from now
<-
l_violence ifelse(any((cit_path_v$k_end >= coop_cut)), min(cit_path_v$t[cit_path_v$k_end >= coop_cut]), max(cit_path_v$t))
# capital at end of violence period
<- enf_path_v %>% filter(t == l_violence) %>% pull(k_end)
k_enf_at_end <- cit_path_v %>% filter(t == l_violence) %>% pull(k_end)
k_cit_at_end
# length of natural transition path and capital at end
<-
t_AC ifelse(any((path_n$k_end >= coop_cut)), min(path_n$t[path_n$k_end >= coop_cut]), max)
<- path_n %>% filter(t == t_AC) %>% pull(k_end)
k_n
# Payoff to enforcer from temp violence
<- W(k, delta = delta, c = v, A = A_defect, max = l_violence) +
U_enf_v W(k_enf_at_end, delta = delta, c = c, d=d, a=a, s=s, A = A_cooptn, max = max - l_violence) *
^l_violence
delta
# Payoff to citizen from temp violence
<- W(k, delta = delta, c = c, d=d, a=a, s=s, A = A_defect, max = l_violence) +
U_cit_v W(k_cit_at_end, delta = delta, c = c, d=d, a=a, s=s, A = A_cooptn, max = max - l_violence) *
^l_violence
delta
# Payoff to enforcer from permanent violence
<- W(k, delta = delta, c = v, d=d, a=a, s=s, A = A_defect, max = max)
U_enf_vv
# Payoff to citizen from permanent violence
<- W(k, delta = delta, c = c, d=d, a=a, s=s, A = A_defect, max = max)
U_cit_vv
# Payoff from natural transition to cooperation
<- W(k, delta = delta, c = 0, d=d, a=a, s=s, A = A_nocoop, max = t_AC) +
U_cit_n W(k_n, delta = delta, c = c, d=d, a=a, s=s,, A = A_cooptn, max = max - t_AC) *
^t_AC
delta
# Payoff from anarchy
<- W(k, delta = delta, c = 0, d=d, a=a, s=s, A = A_nocoop, max = max)
U_anarchy
# Payoff from all cooperate path
<- W(k, delta = delta, c = c, d = d, a = a, s = s , A = A_cooptn, max = max)
U_cit_c
# Payoff to citizen from *defecting* from a cooperation path
# =
# Payoff to enforcer from *defecting* (not investing in v)
<-
U_enf_df1 W(k, delta = delta, c = 0, d = d, a = a, s = s, A = A_defect, max = 1) +
W((1-d)*k + s * A_defect*k^a,
delta = delta, c = 0, d=d, a=a, s=s, A = A_nocoop, max = max - 1) * delta
# Payoff to enforcer from *defecting* this time (investing in c!)
<-
U_enf_df2 W(k, delta = delta, c = c, d=d, a=a, s=s, A = A_cooptn, max = 1) +
W((1-d)*k + s * (A_cooptn*k^a - c),
delta = delta, c = 0, d=d, a=a, s=s, A = A_nocoop, max = max - 1) *
delta
# Returns
c(k= k,
U_enf_v = U_enf_v,
U_cit_v= U_cit_v,
U_enf_vv = U_enf_vv,
U_cit_vv = U_cit_vv,
U_anarchy = U_anarchy,
U_cit_n = U_cit_n,
U_cit_c = U_cit_c,
U_enf_df1 = U_enf_df1,
U_enf_df2 = U_enf_df2,
l_violence = l_violence,
t_AC=t_AC
) }
Given k, can a violent period be sustained in equilibrium starting now?
<- sapply(c(1, 1.5, 2, 2.5, 3, 3.5, 4), values) %>% t() %>% data.frame
values_given_k
%>% kable(digits = 2) values_given_k
k | U_enf_v | U_cit_v | U_enf_vv | U_cit_vv | U_anarchy | U_cit_n | U_cit_c | U_enf_df1 | U_enf_df2 | l_violence | t_AC |
---|---|---|---|---|---|---|---|---|---|---|---|
1.0 | 1.20 | 0.85 | 1.20 | 0.85 | 1.06 | 1.06 | 0.97 | 1.33 | 0.89 | 33 | 400 |
1.5 | 1.50 | 1.16 | 1.50 | 1.16 | 1.27 | 1.27 | 1.30 | 1.59 | 1.17 | 31 | 400 |
2.0 | 1.75 | 1.41 | 1.75 | 1.41 | 1.45 | 1.45 | 1.58 | 1.82 | 1.41 | 28 | 400 |
2.5 | 1.98 | 1.64 | 1.98 | 1.64 | 1.61 | 1.61 | 1.82 | 2.02 | 1.62 | 26 | 400 |
3.0 | 2.18 | 1.84 | 2.18 | 1.84 | 1.75 | 1.75 | 2.03 | 2.19 | 1.81 | 24 | 400 |
3.5 | 2.36 | 2.02 | 2.36 | 2.02 | 1.88 | 1.88 | 2.23 | 2.36 | 1.98 | 22 | 400 |
4.0 | 2.53 | 2.20 | 2.53 | 2.20 | 2.00 | 2.00 | 2.42 | 2.51 | 2.14 | 19 | 400 |
Function to find cutoffs.
# Where is the cutoff for the start of enforced cooperation?
<- function(kmax = 10,
find_cutoff_start fine = .2,
c = .c,
s = .s,
d = .d,
a = .5,
A_cooptn = .A_cooptn,
A_nocoop = .A_nocoop,
A_defect = .A_defect,
delta = .delta,
v = .v,
coop_cut = NULL,
max = 200,
improvement_for_c = FALSE,
improvement_for_e = FALSE
) {<- coopertion_cutoff(
coop_cut c = c, s = s, d = d, a = a, delta = delta, A_cooptn = A_cooptn, A_defect = A_defect, A_nocoop=A_nocoop
)
# Hack for no equilibrium case
if(is.na(coop_cut)) coop_cut <- max + 1
<- sapply(seq(0.01, kmax, fine), values, coop_cut = coop_cut,
values_given_k c = c, s = s, d = d, a = a, v = v, delta = delta, A_cooptn = A_cooptn, A_defect = A_defect
%>% t() %>% data.frame
)
# Allow equilibrium selection to depend on citizen valuation
= values_given_k %>%
.cut_transition_to_temp_violence filter((U_enf_v > U_enf_df1) & (U_enf_v > U_enf_df2))
if(improvement_for_e) .cut_transition_to_temp_violence <-
filter(.cut_transition_to_temp_violence, U_enf_v > U_anarchy)
if(improvement_for_c) .cut_transition_to_temp_violence <-
filter(.cut_transition_to_temp_violence, U_cit_v > U_anarchy)
# Allow equilibrium selection to depend on citizen valuation
= values_given_k %>%
.cut_transition_to_perm_violence filter((U_enf_vv > U_enf_df1) & (U_enf_vv > U_enf_df2))
if(improvement_for_e) .cut_transition_to_perm_violence <-
filter(.cut_transition_to_perm_violence, U_enf_vv > U_anarchy)
if(improvement_for_c) .cut_transition_to_perm_violence <-
filter(.cut_transition_to_perm_violence, U_cit_vv > U_anarchy)
list(
transitions =c(
# Point at which violence preferred (assuming citizen won't defect) with no shift to all cooperate
# # enforcer prefers enforcement payoff to anarchy
# # citizens prefers enforcement payoff to anarchy
# enforcer prefers enforcement payoff to defecting down
cut_transition_to_temp_violence =
%>% pull(k) %>% min,
.cut_transition_to_temp_violence
# Point at which not tempted to defect
cut_transition_to_all_coop = coop_cut,
cut_transition_to_all_coop_check = values_given_k %>%
filter(U_cit_c >= U_enf_df1) %>% pull(k) %>% min,
# Point at which violence preferred (assuming citizen won't defect) with no shift to all cooperate
cut_transition_to_perm_violence =
%>% pull(k) %>% min
.cut_transition_to_perm_violence
),values_given_k = values_given_k
)
}
Sample cutoffs:
find_cutoff_start(delta = .8, fine = .1, c = .5, v = .2)$transitions %>%
kable(caption = "delta = .8, fine = .1, c = .5, v = .2")
x | |
---|---|
cut_transition_to_temp_violence | 0.11 |
cut_transition_to_all_coop | 0.98 |
cut_transition_to_all_coop_check | 1.01 |
cut_transition_to_perm_violence | 0.11 |
# Should prefer coop to perm violence when costs the same
find_cutoff_start(delta = .6, fine = .1, c = .5, v = .5)$transitions %>%
kable(caption = "delta = .6, fine = .1, c = .5, v = .5")
x | |
---|---|
cut_transition_to_temp_violence | 7.11 |
cut_transition_to_all_coop | 3.53 |
cut_transition_to_all_coop_check | 3.61 |
cut_transition_to_perm_violence | 8.71 |
find_cutoff_start(delta = .01, fine = .1, c = .5, v = .2)$transitions %>%
kable(caption = "delta = .01, fine = .1, c = .5, v = .2")
x | |
---|---|
cut_transition_to_temp_violence | Inf |
cut_transition_to_all_coop | 201 |
cut_transition_to_all_coop_check | Inf |
cut_transition_to_perm_violence | Inf |
find_cutoff_start( delta = .4, fine = .1, c = .4, v = 0)$transitions %>%
kable(caption = "delta = .4, fine = .1, c = .4, v = 0")
x | |
---|---|
cut_transition_to_temp_violence | 0.11 |
cut_transition_to_all_coop | 5.68 |
cut_transition_to_all_coop_check | 5.71 |
cut_transition_to_perm_violence | 0.11 |
find_cutoff_start( delta = .4, fine = .1, c = .4, v = .1)$transitions %>%
kable(caption = "delta = .4, fine = .1, c = .4, v = .1")
x | |
---|---|
cut_transition_to_temp_violence | 0.51 |
cut_transition_to_all_coop | 5.68 |
cut_transition_to_all_coop_check | 5.71 |
cut_transition_to_perm_violence | 0.51 |
find_cutoff_start(delta = .4, fine = .1, c = .c, v = .1)$values_given_k %>%
%>% kable(digits = 2) head
k | U_enf_v | U_cit_v | U_enf_vv | U_cit_vv | U_anarchy | U_cit_n | U_cit_c | U_enf_df1 | U_enf_df2 | l_violence | t_AC |
---|---|---|---|---|---|---|---|---|---|---|---|
0.01 | 0.06 | -0.24 | 0.06 | -0.24 | 0.18 | 0.18 | -0.24 | 0.22 | NaN | 400 | 400 |
0.11 | 0.45 | -0.17 | 0.45 | -0.17 | 0.42 | 0.42 | -0.11 | 0.52 | 0.00 | 46 | 400 |
0.21 | 0.63 | 0.06 | 0.63 | 0.06 | 0.54 | 0.54 | 0.13 | 0.68 | 0.18 | 40 | 400 |
0.31 | 0.77 | 0.21 | 0.77 | 0.21 | 0.64 | 0.64 | 0.29 | 0.80 | 0.31 | 38 | 400 |
0.41 | 0.89 | 0.34 | 0.89 | 0.34 | 0.72 | 0.72 | 0.43 | 0.90 | 0.42 | 37 | 400 |
0.51 | 0.99 | 0.45 | 0.99 | 0.45 | 0.79 | 0.79 | 0.54 | 0.99 | 0.52 | 36 | 400 |
Function to find equilibrium paths given utility profiles. We seek specifically paths for four equilibria, in which:
These are based on utilities from each path given \(k\).
= .1; kmax = 10; fine = .2; c = .5; s = .s; d = .d; a = .5; A_cooptn = .A_cooptn; A_nocoop = .A_nocoop; A_defect = .A_defect; delta = .6; v = .v; coop_cut = NULL; max = 200
k_start
<- function(k_start = .05,
paths kmax = 10,
fine = .1,
c = .c,
s = .s,
d = .d,
a = .5,
A_cooptn = .A_cooptn,
A_nocoop = .A_nocoop,
A_defect = .A_defect,
delta = .delta,
v = .v,
coop_cut = NULL,
max = 200,
improvement_for_c = FALSE,
improvement_for_e = FALSE) {
<- find_cutoff_start(
cutoffs kmax = kmax, fine = fine,
c = c, s = s, d = d, a = a,
A_cooptn = A_cooptn, A_nocoop = A_nocoop, A_defect = A_defect,
delta = delta, v = v,
coop_cut = coop_cut,
improvement_for_c = improvement_for_c,
improvement_for_e = improvement_for_c,
max = 200)
# Find transitions; replace infinite with finite endpoint
<- cutoffs$transitions
transitions ==Inf] <- max + 1
transitions[transitions# Check in out timing for k: k in or k end?
<- k_path(k_start, A = A_nocoop, c = 0, s = s, d = d, a = a, delta = delta, max = max)%>%
path_anarchy mutate(eq = "A", i = "citizens")
# Transition only when all ready to
<- filter(path_anarchy, (k <= transitions["cut_transition_to_all_coop"]))
path_AC <- path_AC %>%
path_AC rbind(k_path(max(path_AC$k_end), A = A_cooptn, c = c, s = s,
d = d, a = a, delta = delta, max = max - nrow(path_AC)) %>%
mutate(eq = "C", i = "citizens")) %>%
mutate(t = 1:n())
# Transition to, and stay in, violent equilibria
<- filter(path_anarchy, (k <= transitions["cut_transition_to_perm_violence"]))
path_perm_violence_c <- path_perm_violence_c %>%
path_perm_violence_c rbind(k_path(max(path_perm_violence_c$k_end), A = A_defect, c = c, s = s,
d = d, a = a, delta = delta, max = max - nrow(path_perm_violence_c)) %>%
mutate(eq = "V", i = "citizens")) %>%
mutate(t = 1:n())
<- filter(path_anarchy, (k <= transitions["cut_transition_to_perm_violence"]))
path_perm_violence_e <- path_perm_violence_e %>%
path_perm_violence_e rbind(k_path(max(path_perm_violence_e$k_end), A = A_defect, c = v, s = s,
d = d, a = a, delta = delta, max = max - nrow(path_perm_violence_e)) %>%
mutate(eq = "V", i = "agent")) %>%
mutate(t = 1:n(), i = "agent")
# Transition to, and out of, violent equilibria
<- path_anarchy %>%
path_temp_violence_c select(-i) %>% filter((k <= transitions["cut_transition_to_temp_violence"]))
<- path_temp_violence_c %>%
path_temp_violence_c rbind(k_path(max(path_temp_violence_c$k_end), A = A_defect, c = c, s = s,
d = d, a = a, delta = delta, max = max - nrow(path_temp_violence_c)) %>%
mutate(eq = "V"))
<- filter(path_temp_violence_c,
path_temp_violence_c <= transitions["cut_transition_to_all_coop"]))
(k <- path_temp_violence_c %>%
path_temp_violence_c rbind(k_path(max(path_temp_violence_c$k_end), A = A_cooptn, c = c, s = s,
d = d, a = a, delta = delta, max = max - nrow(path_temp_violence_c)) %>%
mutate(eq = "C")) %>%
mutate(t = 1:n(), i = "citizens")
# Enforcers 2nd transition to all coop time depends on citizen's capital
<- filter(path_temp_violence_c, (k <= transitions["cut_transition_to_all_coop"])) %>% pull(t) %>% max
second_transition_time
# Enforcer temp violence path
<- path_anarchy %>%
path_temp_violence_e select(-i) %>% filter((k <= transitions["cut_transition_to_temp_violence"]))
<- path_temp_violence_e %>%
path_temp_violence_e rbind(k_path(max(path_temp_violence_e$k_end), A = A_defect, c = v, s = s,
d = d, a = a, delta = delta, max = max - nrow(path_temp_violence_e)) %>%
mutate(eq = "V")) %>%
mutate(t = 1:n()) # Clock needed to find switch time
# Select up to citizen's transition point
<- filter(path_temp_violence_e,
path_temp_violence_e <= second_transition_time)
t # Continue
<- path_temp_violence_e %>%
path_temp_violence_e rbind(k_path(max(path_temp_violence_e$k_end), A = A_cooptn, c = c, s = s,
d = d, a = a, delta = delta, max = max - nrow(path_temp_violence_e)) %>%
mutate(eq = "C")) %>%
mutate(t = 1:n(), i = "agent")
<- list(
paths anarchy = path_anarchy,
AC = path_AC,
AP_c = path_perm_violence_c,
AP_e = path_perm_violence_e,
APC_c = path_temp_violence_c,
APC_e = path_temp_violence_e)
<- bind_rows(paths, .id = "path") %>% mutate(delta = delta, c = c, v = v)
out
}
<- paths() out
<-
main_1 paths(delta = .4,
v = .2,
c = .4,
d = .2,
s = .4,
A_cooptn = 1.5,
A_nocoop = 1,
A_defect = 1.4)
write_rds(main_1, "single_graph_data.rds")
## graph the results
read_rds("single_graph_data.rds") %>%
filter(t < 100) %>% filter(path %in% c("AC", "APC_c", "APC_e")) %>%
ggplot(aes(t, k, color=path)) + geom_line(position = position_dodge(0.9)) + theme_bw()
## build the dataset
<- data.frame(c=numeric(), delta=numeric(), t=numeric(), k=numeric(), u=numeric(), eq=character())
graph_data
for(c in .c_range) {
for(delta in .delta_range){
<-
graph_data paths(delta = delta, c = c) %>%
bind_rows(graph_data,.)
}}
write_rds(graph_data, "graph_data_2.rds")
<- read_rds("graph_data_2.rds") graph_data
## graph the results
%>% filter(t < 100) %>% filter(path %in% c("AC", "APC_c", "APC_e")) %>%
graph_data ggplot(aes(t, k, color=path)) + geom_line(position = position_dodge(0.9)) + facet_grid(c ~ delta , labeller = label_both) +
theme_bw()
pdf("main.pdf", width = 6, height = 4)
%>% filter(t < 100) %>% filter(path %in% c("AC", "APC_c", "APC_e")) %>% filter(delta == .4, c == .4) %>%
graph_data ggplot(aes(t, k, color=path)) + geom_line() +
theme_bw() + xlab("Time") + ylab("Capital")
dev.off()
## png
## 2
pdf("main_bw.pdf", width = 6, height = 4)
%>% filter(t < 100) %>% filter(path %in% c("AC", "APC_c", "APC_e")) %>%
graph_data mutate(path = factor(path, c("AC", "APC_c", "APC_e"), c("AC", "APC[c]", "APC[e]"))) %>%
filter(delta == .4, c == .4) %>%
ggplot(aes(t, k, linetype =path)) + geom_line() +
theme_bw() + xlab("Time") + ylab("Capital") +
scale_linetype_discrete(labels = scales::parse_format())
dev.off()
## png
## 2
Utility can take a drop or jump in transition periods as players start paying for public goods in anticipation of future gains. Bigger drops when delta is large. Bigger drops for transition to violence than to natural transition.
## graph the results
%>% filter(t < 100) %>% filter(path %in% c("AC", "APC_c", "APC_e")) %>%
graph_data ggplot(aes(t, u, color=path)) + geom_line(position = position_dodge(0.9)) + facet_grid(c ~ delta , labeller = label_both) +
theme_bw()
Citizens prefer a temporary violence equilibriunm when available Agents sometimes prefer a temporary violence equilibrium and sometimes permanent violence. This likely depends on the extent to which they would gain from their own returns to investing in public goods give their capital.
## graph the results
%>% filter(t < 100) %>% filter(path %in% c("AP_c", "AP_e", "APC_c", "APC_e")) %>%
graph_data ggplot(aes(t, k, color=path)) + geom_line(position = position_dodge(0.9)) + facet_grid(c ~ delta , labeller = label_both) +
theme_bw()
<- find_cutoff_start(delta = .2, fine = .1, c = .4)
cutoffs $transitions cutoffs
## cut_transition_to_temp_violence cut_transition_to_all_coop
## Inf 201
## cut_transition_to_all_coop_check cut_transition_to_perm_violence
## Inf Inf
<- paths(delta = .2, c = .4)
main_3 write_rds(main_3, "single_graph_data_3.rds")
## graph the results
read_rds("single_graph_data_3.rds") %>% filter(t < 100) %>% #filter(path %in% c("AC", "APC_c", "APC_e")) %>%
ggplot(aes(t, k, color=path)) + geom_line(position = position_dodge(0.9)) + theme_bw()
## build the dataset
<- data.frame(c=numeric(), delta=numeric(), t=numeric(), k=numeric(), u=numeric(), eq=character())
graph_data2
for(c in .c_range) {
for(v in .v_range){
<-
graph_data2 paths(v = v, c = c) %>%
bind_rows(graph_data2,.)
}}
<- graph_data2 %>%
graph_data2 mutate(c = factor(c, labels = c(
expression(c[a]*" = 0.3"),
expression(c[a]*" = 0.4"),
expression(c[a]*" = 0.5")))) %>%
mutate(v = factor(v, labels = c(
expression(c[v]*" = 0.0"),
expression(c[v]*" = 0.2"),
expression(c[v]*" = 0.4"))))
write_rds(graph_data2, "graph_data2_2.rds")
<- read_rds("graph_data2_2.rds") graph_data2
<-
costs_graph %>% filter(t < 100) %>% filter(path %in% c("AC", "APC_c", "APC_e")) %>%
graph_data2 mutate(path = factor(path, c("AC", "APC_c", "APC_e"), c("AC", "APC[c]", "APC[e]"))) %>%
ggplot(aes(t, k, linetype=path)) + geom_line(position = position_dodge(0.9)) + facet_grid(c ~ v ,
labeller = label_parsed
+ xlab("Time") + ylab("Capital") + theme_bw() +
) scale_linetype_discrete(labels = scales::parse_format())
## graph the results
costs_graph
pdf("costs_bw.pdf", width = 10, height = 7)
costs_graphdev.off()
## png
## 2
lapply(c(F, T), function(cit)
paths(c = .45, v = .01,
A_cooptn = 1.6,
improvement_for_c = cit,
improvement_for_e = TRUE) %>%
mutate(cit = cit)) %>%
bind_rows(.) %>%
mutate(cit = factor(cit, labels = c("Non-paretian shifts", "Paretian shifts"))) %>%
write_rds("eq_selection.rds")
## graph the results
<-
pareto_plot read_rds("eq_selection.rds") %>%
filter(t < 100) %>% filter(path %in% c("APC_c", "APC_e")) %>%
mutate(path = factor(path, c("AC", "APC_c", "APC_e"), c("AC", "APC[c]", "APC[e]"))) %>%
ggplot(aes(t, k, linetype=path)) +
geom_line(position = position_dodge(0.9)) + facet_grid(. ~ cit) +
theme_bw() + xlab("Time") + ylab("Capital") +
scale_linetype_discrete(labels = scales::parse_format())
pdf("pareto_bw.pdf", width = 7.5, height = 3)
pareto_plotdev.off()
## png
## 2
pareto_plot
Huge thanks for Linan Yao for support with this code↩︎