-
Notifications
You must be signed in to change notification settings - Fork 0
/
Figure_4_0_data_creation1000.R
47 lines (37 loc) · 1.23 KB
/
Figure_4_0_data_creation1000.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
## Validating Synthetic Anchors (UTAS 2012) Data Creation
## (Ingroup=Candidates, Outgroup=Voters, Outsample-N=1000)
## Author: Tzu-Ping Liu & Gento Kato
## Date: 07/25/2020
## Environment: R 4.0.2 and Ubuntu 20.04
## Clear Workspace
rm(list = ls())
## Set Working Directory (Automatically) ##
require(rprojroot); require(rstudioapi)
if (rstudioapi::isAvailable()==TRUE) {
setwd(dirname(rstudioapi::getActiveDocumentContext()$path));
}
projdir <- find_root(has_file("thisishome.txt"))
cat(paste("Working Directory Set to:\n",projdir))
setwd(projdir)
## Load Data
load(paste0(projdir,"/Outputs/application/utas12_data.rda"))
## Load Function
source(paste0(projdir, "/Codes/ipbridge_density.R"))
## Other Packages
require(pbapply)
## Set Number of experiments
ntimes <- 400
#################
## Experiments ##
#################
#### (ingroup: candidates, outgroup: voters) ####
## 1000 Outsamples (ingroup: candidates, outgroup: voters)
set.seed(20200725)
d <- pblapply(1:ntimes, function(i) {
data.frame(
ipbridge_density(utas2_v_p,utas2_c_p,1000,polarity1=rep(utas2_rightcand_v,2),
polarity2=rep(utas2_rightcand_c,2))
)
})
save(d, file=paste0(projdir, "/Outputs/simulation/utas12_sim_400_1000s_cand.rda"))
rm(d)