-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsim_august2017_graphs.R
157 lines (133 loc) · 6.76 KB
/
sim_august2017_graphs.R
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
library(tidyverse)
#box_sync_path <- normalizePath('C:/Users/bobku/Box Sync/')
#setwd(paste0(box_sync_path,'Between Effects/Simulation'))
sim1 <- read_csv("sim1.csv") %>% mutate(beta.mean=as.numeric(beta.mean))
sim2 <- read_csv("sim2.csv") %>% mutate(beta.mean=as.numeric(beta.mean))
sim3 <- read_csv("sim3.csv") %>% mutate(beta.mean=as.numeric(beta.mean))
sim1 <- mutate(sim1, Model = factor(Model,
levels=c("Two-way FE", "Case FE",
"Time FE", "Pooled OLS",
"RE (u_i)", "RE (v_t)")))
sim2 <- mutate(sim2, Model = factor(Model,
levels=c("Two-way FE", "Case FE",
"Time FE", "Pooled OLS",
"RE (u_i)", "RE (v_t)")))
sim3 <- mutate(sim3, Model = factor(Model,
levels=c("Two-way FE", "Case FE",
"Time FE", "Pooled OLS",
"RE (u_i)", "RE (v_t)")))
pdf("simresults_august2017.pdf", width=8, height=5)
## Changing the mean of the within-time slopes
g1 <- ggplot(sim1, aes(x=beta.mean, y=Coefficient)) +
geom_jitter() +
geom_smooth(method="loess") +
geom_line(aes(x = beta.mean, y = -3, linetype="solid"), color="red") +
geom_line(aes(x = beta.mean, y = beta.mean, linetype="dashed"), color="red") +
facet_wrap(~ Model) +
xlab("Mean of the within-time slopes in the DGP") +
theme(legend.position='bottom') +
scale_linetype_manual(name = "",
values = c("dashed" = 2, "solid" = 1),
labels = c("Mean slope within time points (varying) ", "Mean slope within cases (fixed at -3)"))
g1
## Changing the variance of the within-time slopes
g2 <- ggplot(sim2, aes(x=beta.sd, y=Coefficient)) +
geom_jitter() +
geom_smooth(method="loess") +
geom_line(aes(x = beta.sd, y = -3, linetype="solid"), color="red") +
geom_line(aes(x = beta.sd, y = 3, linetype="dashed"), color="red") +
facet_wrap(~ Model) +
xlab("Standard deviation of the within-time slopes in the DGP") +
theme(legend.position='bottom') +
scale_linetype_manual(name = "",
values = c("dashed" = 2, "solid" = 1),
labels = c("Mean slope within time points (fixed at 3) ", "Mean slope within cases (fixed at -3)"))
g2
## Changing the variance of the within-case slopes
g3 <- ggplot(sim3, aes(x=gamma.sd, y=Coefficient)) +
geom_jitter() +
geom_smooth(method="loess") +
geom_line(aes(x = gamma.sd, y = -3, linetype="solid"), color="red") +
geom_line(aes(x = gamma.sd, y = 3, linetype="dashed"), color="red") +
facet_wrap(~ Model) +
xlab("Standard deviation of the within-case slopes in the DGP") +
theme(legend.position='bottom') +
scale_linetype_manual(name = "",
values = c("dashed" = 2, "solid" = 1),
labels = c("Mean slope within time points (fixed at 3) ", "Mean slope within cases (fixed at -3)"))
g3
dev.off()
sim1 <- read_csv("sim1big.csv")
sim2 <- read_csv("sim2big.csv")
sim3 <- read_csv("sim3big.csv")
sim1 <- mutate(sim1, Model = factor(Model,
levels=c("Two-way FE", "Case FE",
"Time FE", "Pooled OLS",
"RE (u_i)", "RE (v_t)")))
sim2 <- mutate(sim2, Model = factor(Model,
levels=c("Two-way FE", "Case FE",
"Time FE", "Pooled OLS",
"RE (u_i)", "RE (v_t)")))
sim3 <- mutate(sim3, Model = factor(Model,
levels=c("Two-way FE", "Case FE",
"Time FE", "Pooled OLS",
"RE (u_i)", "RE (v_t)")))
pdf(paste0(box_sync_path,"Between Effects/Paper/Manuscript/simresults_august2017big.pdf"), width=8, height=5)
## Changing the mean of the within-time slopes
g1 <- ggplot(sim1, aes(x=beta.mean, y=Coefficient)) +
geom_jitter(size=.5,alpha=.5) +
geom_smooth(method="loess") +
geom_line(aes(x = beta.mean, y = -3, linetype="solid"), color="red") +
geom_line(aes(x = beta.mean, y = beta.mean, linetype="dashed"), color="red") +
facet_wrap(~ Model) +
xlab("Mean of the within-time slopes in the DGP") +
theme(legend.position='bottom') +
scale_linetype_manual(name = "",
values = c("dashed" = 2, "solid" = 1),
labels = c("Mean slope within time points (varying) ", "Mean slope within cases (fixed at -3)"))
g1
## Changing the variance of the within-time slopes
g2 <- ggplot(sim2, aes(x=beta.sd, y=Coefficient)) +
geom_jitter(size=.5,alpha=.5) +
geom_smooth(method="loess") +
geom_line(aes(x = beta.sd, y = -3, linetype="solid"), color="red") +
geom_line(aes(x = beta.sd, y = 3, linetype="dashed"), color="red") +
facet_wrap(~ Model) +
xlab("Standard deviation of the within-time slopes in the DGP") +
theme(legend.position='bottom') +
scale_linetype_manual(name = "",
values = c("dashed" = 2, "solid" = 1),
labels = c("Mean slope within time points (fixed at 3) ", "Mean slope within cases (fixed at -3)"))
g2
## Changing the variance of the within-case slopes
g3 <- ggplot(sim3, aes(x=gamma.sd, y=Coefficient)) +
geom_jitter(size=.5,alpha=.5) +
geom_smooth(method="loess") +
geom_line(aes(x = gamma.sd, y = -3, linetype="solid"), color="red") +
geom_line(aes(x = gamma.sd, y = 3, linetype="dashed"), color="red") +
facet_wrap(~ Model) +
xlab("Standard deviation of the within-case slopes in the DGP") +
theme(legend.position='bottom') +
scale_linetype_manual(name = "",
values = c("dashed" = 2, "solid" = 1),
labels = c("Mean slope within time points (fixed at 3) ", "Mean slope within cases (fixed at -3)"))
g3
dev.off()
sim4 <- read_csv("sim4.csv")
sim4 <- mutate(sim4, type = factor(type,
levels=c("(30,30)","(100,10)","(1000,3)")),
Model = factor(Model,
levels=c("Two-way FE", "Case FE",
"Time FE", "Pooled OLS",
"RE (u_i)")))
pdf(paste0(box_sync_path,"Between Effects/Paper/Manuscript/simresults_august2017_2.pdf"), width=9, height=7)
## Changing N and T, temporal autocorrelation
g4 <- ggplot(sim4, aes(y=Coefficient, x=factor(type))) +
geom_boxplot() +
facet_grid(time.ac~Model) +
theme_bw() +
xlab("Sample Sizes (N, T)") +
ylab("Coefficients") +
scale_y_continuous(breaks=c(-3,0,3))
g4
dev.off()