-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_versiontable.R
More file actions
96 lines (68 loc) · 3.99 KB
/
make_versiontable.R
File metadata and controls
96 lines (68 loc) · 3.99 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
setwd("E:/Dropbox/projects/ownership/calibration")
rm(list = ls())
library(stringr)
library(stargazer)
for (f in list.files(path = "functions", pattern="*.R")) {
source(paste("functions/", f, sep = ""))
}
pctmaker = function(numvec, digits = 2) {
temp = format(round(numvec * 100, digits = digits), nsmall = 2)
out = p(temp, "%")
return(out)
}
load("results/lognormal_beta_calout.RData")
data = data.table(invfrac = numeric(0), totOpt_tau = numeric(0), totOpt_total_gain = numeric(0),
totOpt_alloc_gain = numeric(0), totOpt_inv_loss = numeric(0), tau25_total_gain = numeric(0), tau5_total_gain = numeric(0))
for(my_invfrac in c(0, 0.1, 0.4, 0.7)) {
taxdata = solve_investment_value(taxdata, inv_frac = my_invfrac, theta = 0.85, delta = 0.95)
temp = make_summarystats(taxdata, effdata, params = list(delta = 0.95), moment_matching_out = list(moment_vec = c(0,0)), dir_string = "test")
temp2 = temp[, .(invfrac = my_invfrac, totOpt_tau, totOpt_total_gain, totOpt_alloc_gain, totOpt_inv_loss, tau25_total_gain, tau5_total_gain)]
data = rbindlist(list(data, temp2))
}
data[, invfrac := percent(invfrac)]
data[, totOpt_tau := pctmaker(totOpt_tau, digits = 1)]
data[, totOpt_total_gain := pctmaker(totOpt_total_gain)]
data[, totOpt_alloc_gain := pctmaker(totOpt_alloc_gain)]
data[, totOpt_inv_loss := pctmaker(totOpt_inv_loss)]
data[, tau25_total_gain := pctmaker(tau25_total_gain)]
data[, tau5_total_gain := pctmaker(tau5_total_gain)]
data[, tau5_total_gain := NULL]
write.csv(data, file = "results/versiontable.csv")
stargazer(data, type = "latex", summary = FALSE, out = "results/versiontable.tex",
out.header = FALSE, rownames = FALSE)
# Appendix table
rm(list = ls())
for (f in list.files(path = "functions", pattern="*.R")) {
source(paste("functions/", f, sep = ""))
}
pctmaker = function(numvec, digits = 2) {
temp = format(round(numvec * 100, digits = digits), nsmall = 2)
out = p(temp, "%")
return(out)
}
my_invfrac = 0.4
load("results/lognormal_beta_calout.RData")
taxdata = solve_investment_value(taxdata, inv_frac = my_invfrac, theta = 0.85, delta = 0.95)
temp = make_summarystats(taxdata, effdata, params = list(delta = 0.95), moment_matching_out = list(moment_vec = c(0,0)), dir_string = "test")
baseline_data = temp[, .(type = "Baseline", totOpt_tau, totOpt_total_gain, totOpt_alloc_gain, totOpt_inv_loss, tau25_total_gain, tau5_total_gain, allOpt_alloc_gain_pctmax)]
load("results/lognormal_mixbeta_25_calout.RData")
taxdata = solve_investment_value(taxdata, inv_frac = my_invfrac, theta = 0.85, delta = 0.95)
temp = make_summarystats(taxdata, effdata, params = list(delta = 0.95), moment_matching_out = list(moment_vec = c(0,0)), dir_string = "test")
mixbeta_data = temp[, .(type = "Mixbeta", totOpt_tau, totOpt_total_gain, totOpt_alloc_gain, totOpt_inv_loss, tau25_total_gain, tau5_total_gain, allOpt_alloc_gain_pctmax)]
load("results/lognormal_consjump_calout.RData")
taxdata = solve_investment_value(taxdata, inv_frac = my_invfrac, theta = 0.85, delta = 0.95)
temp = make_summarystats(taxdata, effdata, params = list(delta = 0.95), moment_matching_out = list(moment_vec = c(0,0)), dir_string = "test")
consjump_data = temp[, .(type = "Jump", totOpt_tau, totOpt_total_gain, totOpt_alloc_gain, totOpt_inv_loss, tau25_total_gain, tau5_total_gain, allOpt_alloc_gain_pctmax)]
data = rbindlist(list(baseline_data, mixbeta_data, consjump_data))
data[, invfrac := percent(invfrac)]
data[, totOpt_tau := pctmaker(totOpt_tau, digits = 1)]
data[, totOpt_total_gain := pctmaker(totOpt_total_gain)]
data[, totOpt_alloc_gain := pctmaker(totOpt_alloc_gain)]
data[, totOpt_inv_loss := pctmaker(totOpt_inv_loss)]
data[, tau25_total_gain := pctmaker(tau25_total_gain)]
data[, tau5_total_gain := pctmaker(tau5_total_gain)]
data[, allOpt_alloc_gain_pctmax := pctmaker(allOpt_alloc_gain_pctmax)]
data[, tau5_total_gain := NULL]
write.csv(data, file = "results/spectable.csv")
stargazer(data, type = "latex", summary = FALSE, out = "results/spectable.tex",
out.header = FALSE, rownames = FALSE)