forked from TURuibo/MVPC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.R
63 lines (51 loc) · 1.76 KB
/
demo.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
# The path of "R-proj"
proj_path<-getwd()
src_path<-paste(proj_path,'/src',sep="")
res_path<-paste(proj_path,'/result',sep="")
data_path<-paste(proj_path,'/data',sep="")
source(paste(src_path,'/CITest.R',sep=""))
source(paste(src_path,'/Evaluation.R',sep=""))
source(paste(src_path,'/MissingValuePC.R',sep=""))
source(paste(src_path,'/SyntheticDataGeneration.R',sep=""))
# Synthethic data generation
num_var=20
num_sample = 10000
myDAG <- randomDAG(num_var,2/(num_var-1))
gen_result_list<-gen_data(num_sample = num_sample,
mode = "mnar",
myDAG = myDAG,
num_extra_e=5,
num_m = 10,
seed = 777)
data_complete = gen_result_list$data_complete
data_m = gen_result_list$data_m
myCPDAG = gen_result_list$ground_truth$cpdag
suffStat_m <- list(data=data_m)
suffStat = list(C = cor(data_complete),n=num_sample)
# PC on the complete dataset
res_com_pc<-pc(suffStat,
gaussCItest,
alpha=0.01,
p=num_var)
# Test-wise deletion PC
res_tw<-pc(suffStat_m,
gaussCItest.td,
alpha=0.01,
p=num_var)
# MVPC with the PermC correction method
res.mvpc.permc <-mvpc(suffStat_m,
gaussCItest.td,
gaussCItest.permc,
alpha=0.01,
p=num_var)
# MVPC with the DRW correction method
res.mvpc.drw <-mvpc(suffStat_m,
gaussCItest.td,
gaussCItest.drw,
alpha=0.01,
p=num_var)
# Evaluation: Compare with the structural Hamming distance
shd(res.mvpc.drw,myCPDAG)
shd(res.mvpc.permc,myCPDAG)
shd(res_tw,myCPDAG)
print(shd(res_com_pc,myCPDAG))