-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplicate.r
More file actions
72 lines (57 loc) · 1.87 KB
/
Copy pathreplicate.r
File metadata and controls
72 lines (57 loc) · 1.87 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
library(loop.estimator)
library(parallel)
library(tikzDevice)
library(dplyr)
library(purrr)
library(ggplot2)
library(readr)
library(xtable)
library(ggeffects)
library(clubSandwich)
library(estimatr)
library(forcats)
library(ggpmisc)
nclust <- commandArgs(TRUE)
full <- FALSE
fast <- TRUE
### the code saves each result in a separate file (in the "miniResults" folder), in case it
### gets interrupted, then deletes these once all of the results are saved in larger
### files. By change the option below to "TRUE" you can keep the intermediate files as well
### (but beware that if you re-run the code it will just load them in, rather than re-estimate anything).
keepIntermediateResults <- FALSE
if(length(nclust)==0) nclust <- 0 else nclust <- as.numeric(nclust)
print(nclust)
if(nclust>0){
if(.Platform$OS.type=='windows'){
sock <- TRUE
cl <- makeCluster(nclust, outfile="")
ce <- clusterEvalQ(cl,source('code/reloopFunctions.r'))
ce <- clusterEvalQ(cl,library(loop.estimator))
ce <- clusterEvalQ(cl,library(dplyr))
ce <- clusterEvalQ(cl,library(readr))
ce <- clusterEvalQ(cl,library(purrr))
} else sock <- FALSE
}
source('code/dirs.r')
source('code/reloopFunctions.r')
#############################
### main analysis
#############################
### make pairwise data
## merge remnant imputations w treatment assignment, outcome, and covariate files
## mean-imputation for covariates
## format the data into pairwise comparisons
## create processedData/datPW.RData
runData <- TRUE
if(file.exists('processedData/pairwiseData.RData'))
if(file.mtime('processedData/pairwiseData.RData')>file.mtime('code/data.r'))
runData <- FALSE
if(runData | full){
print('processing data')
source('code/data.r')
} else print('skipping data')
### estimate effects & standard errors
print('estimation')
source('code/estimate.r')
print('plots')
source('code/plots.r')