-
Notifications
You must be signed in to change notification settings - Fork 1
/
sim_august2017.R
61 lines (45 loc) · 2.13 KB
/
sim_august2017.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
library(tidyverse)
#setwd("~/Box Sync/Between Effects/Simulation")
source("twsim.R")
require(parallel)
set.seed(22902)
## Changing the mean of the within-time slopes
sim1 <- twsim(iter=30, parallel=FALSE, arg="beta.mean", at=-2:5)
sim1 <- gather(sim1, `Two-way FE`:`RE (v_t)`, key="Model", value="Coefficient",
factor_key=TRUE)
write_csv(sim1, path="sim1.csv")
## Changing the variance of the within-time slopes
sim2 <- twsim(iter=30, parallel=FALSE, arg="beta.sd", at=seq(0,1,by=.1))
sim2 <- gather(sim2, `Two-way FE`:`RE (v_t)`, key="Model", value="Coefficient",
factor_key=TRUE)
write_csv(sim2, path="sim2.csv")
## Changing the variance of the within-case slopes
sim3 <- twsim(iter=30, parallel=FALSE, arg="gamma.sd", at=seq(0,1,by=.1))
sim3 <- gather(sim3, `Two-way FE`:`RE (v_t)`, key="Model", value="Coefficient",
factor_key=TRUE)
write_csv(sim3, path="sim3.csv")
## Changing N and T, temporal autocorrelation
iterations <- 500
parallel <- TRUE
sim4 <- data.frame()
simtemp <- twsim(iter=iterations, parallel=parallel, arg="time.ac", at=c(0,.25,.75,.95), N=30, T=30, re_vt=FALSE)
simtemp <- gather(simtemp, `Two-way FE`:`RE (u_i)`, key="Model", value="Coefficient",
factor_key=TRUE)
simtemp <- mutate(simtemp, type="(30,30)")
sim4 <- bind_rows(sim4, simtemp)
simtemp <- twsim(iter=iterations, parallel=parallel, arg="time.ac", at=c(0,.25,.75,.95), N=100, T=10, re_vt=FALSE)
simtemp <- gather(simtemp, `Two-way FE`:`RE (u_i)`, key="Model", value="Coefficient",
factor_key=TRUE)
simtemp <- mutate(simtemp, type="(100,10)")
sim4 <- bind_rows(sim4, simtemp)
simtemp <- twsim(iter=iterations, parallel=parallel, arg="time.ac", at=c(0,.25,.75,.95), N=1000, T=3, re_vt=FALSE)
simtemp <- gather(simtemp, `Two-way FE`:`RE (u_i)`, key="Model", value="Coefficient",
factor_key=TRUE)
simtemp <- mutate(simtemp, type="(1000,3)")
sim4 <- bind_rows(sim4, simtemp)
sim4 <- sim4 %>%
mutate(ac="AC =",
type = factor(type, levels=c("(30,30)","(100,10)","(1000,3)"))) %>%
unite(time.ac, ac, time.ac, sep=" ")
write_csv(sim4, path="sim4.csv")
source("sim_august2017_graphs.R")