-
Notifications
You must be signed in to change notification settings - Fork 2
/
R_Fig7.NumPred.R
110 lines (97 loc) · 5.49 KB
/
R_Fig7.NumPred.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
############### Line Point Plot Mean Number of predictors #########################
setwd("path")
library(ggplot2)
#Appendix E
appendixE<-read.csv('AppendixE.csv')
#Change the order of the Methods
appendixE$Method <- factor(appendixE$Method, levels = c("ADL", "IADL", "WALK", "DEATH", "Union", "baBIC", "Intersect", "Full"))
#appendixE$Method2 <- factor(appendixE$Method2, levels = c("Individual ADL", "Individual IADL", "Individual WALK", "Individual DEATH", "Union", "baBIC", "Intersect", "Full"))
# Modify labels for Data
appendixE$Data <- factor(appendixE$Data,
levels = c("CaseStudy", "Scenario1_corig", "Scenario1_c25", "Scenario2_corig", "Scenario2_c25", "Scenario3_corig", "Scenario3_c25"),
labels = c("Case-study", "Scenario 1 Case-study censoring", "Scenario 1 25% Censoring", "Scenario 2 Case-study censoring", "Scenario 2 25% Censoring", "Scenario 3 Case-study censoring", "Scenario 3 25% Censoring"))
#appendix E
png('Fig7.NumPred.png')
ggplot(appendixE, aes(x = Method, y = Mean,label=Mean, color=Method)) +
geom_point(size = .8) +
geom_errorbar(aes(ymax = upper, ymin = lower, width = 0.1)) +
geom_text(aes(label=Mean),hjust=-0.3, vjust=0.5, size=2.8) + #add labels to the points
facet_wrap(~ Data, ncol=3, strip.position = "top") +
theme_bw() +
theme(strip.background =element_rect(color="black",fill="white"))+
theme(strip.text = element_text(face="bold"))+
## removed box around the facet title;decrease the margin between panels and text;
theme(strip.background = element_blank())+
theme(panel.spacing = unit(0.2, "lines"))+
theme(text = element_text(size=10.6))+
theme(strip.text.x = element_text( margin = margin( b = 1, t = 0) ) )+
#theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank()) +
labs(y="Mean of number of predictors") +
theme (axis.title.x = element_blank(), axis.text.x = element_blank(), axis.ticks.x = element_blank()) +
theme(axis.title.y = element_text(face="bold", vjust=2)) +
scale_y_continuous(limits=c(0, 40), breaks=seq(2,40,by=10)) +
scale_color_manual(name = "Method of model selection:",
labels = c("Individual Outcome, ADL",
"Individual Outcome, IADL",
"Individual Outcome, WALK",
"Individual Outcome, DEATH",
"Union",
"baBIC",
"Intersection",
"Full"),
values = c("ADL"="blue",
"IADL"="#ff0000",
"WALK"="darkgreen",
"DEATH"="brown",
"Union"="orange",
"baBIC"="#ff00ff",
"Intersect"="#00AFBB",
"Full"="black")) +
theme(legend.position = c(0.6,0.1),
legend.title = element_text(size = rel(0.8), face = "bold", vjust = 1),
legend.key.size = unit(1.2, "lines"),
legend.text=element_text(size = rel(0.78)) ) +
guides(col=guide_legend(ncol=2))
dev.off()
pdf('Fig7.NumPred.pdf')
ggplot(appendixE, aes(x = Method, y = Mean,label=Mean, color=Method)) +
geom_point(size = .8) +
geom_errorbar(aes(ymax = upper, ymin = lower, width = 0.1)) +
geom_text(aes(label=Mean),hjust=-0.3, vjust=0.5, size=2.8) + #add labels to the points
facet_wrap(~ Data, ncol=3, strip.position = "top") +
theme_bw() +
theme(strip.background =element_rect(color="black",fill="white"))+
theme(strip.text = element_text(face="bold"))+
## removed box around the facet title;decrease the margin between panels and text;
theme(strip.background = element_blank())+
theme(panel.spacing = unit(0.2, "lines"))+
theme(text = element_text(size=10.6))+
theme(strip.text.x = element_text( margin = margin( b = 1, t = 0) ) ) +
#theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank()) +
labs(y="Mean of number of predictors") +
theme (axis.title.x = element_blank(), axis.text.x = element_blank(), axis.ticks.x = element_blank()) +
theme(axis.title.y = element_text(face="bold", vjust=2)) +
scale_y_continuous(limits=c(0, 40), breaks=seq(2,40,by=10)) +
scale_color_manual(name = "Method of model selection:",
labels = c("Individual Outcome, ADL",
"Individual Outcome, IADL",
"Individual Outcome, WALK",
"Individual Outcome, DEATH",
"Union",
"baBIC",
"Intersection",
"Full"),
values = c("ADL"="blue",
"IADL"="#ff0000",
"WALK"="darkgreen",
"DEATH"="brown",
"Union"="orange",
"baBIC"="#ff00ff",
"Intersect"="#00AFBB",
"Full"="black")) +
theme(legend.position = c(0.6,0.1),
legend.title = element_text(size = rel(0.8), face = "bold", vjust = 1),
legend.key.size = unit(1.2, "lines"),
legend.text=element_text(size = rel(0.78)) ) +
guides(col=guide_legend(ncol=2))
dev.off()