-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlasso_diagram_figure2.R
103 lines (88 loc) · 2.94 KB
/
lasso_diagram_figure2.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
########################################################################################
## This R code is used for plotting Figure 2 and 3 in paper "The Complete Lasso Diagram"
##--------------------------------------------------------------------------------------
## Copyright @ Hua Wang, Yachong Yang, Zhiqi Bu, and Weijie Su, 2020
##--------------------------------------------------------------------------------------
########################################################################################
library(pracma)
#pdf("figure_dt_combine.pdf", width=20, height=5)
#par(mfrow=c(1, 3))
color = 'indianred2'
color_inner = 'skyblue2'
source("q_lower.R")
## Case 1
## Get the upper boundary
delta = 1
eps = 0.3
L=1000
tppmax = powermax(delta, eps)
xu = seq(0, tppmax, length.out = L)
yu = rep(0,L)
for (i in 1:L){
yu[i] = min(1-eps, 1-eps/delta*xu[i])
}
## Get the data of lower boundary
xx = seq(0, tppmax, length.out = L)
yy = rep(0,L)
for (i in 1:L){
yy[i] = fdrlasso(xx[i], delta, eps)
}
par(mar=c(5,6,1,2),xpd=FALSE)
plot(0,0,xlim = c(0, 1), ylim=c(0, 1), xaxs='i', yaxs='i',xlab='TPP',ylab='FDP', cex.lab=2.5,cex.axis=1.5, type="n")
polygon(c(0,1,1,0),c(0,0,1,1),col=color)
polygon(c(xx,rev(xu)),c(yy,rev(yu)),col=color_inner)
text(0.5, 0.85, 'Unachievable', cex=2)
text(0.5,0.45,'Achievable',cex=2)
text(0.8, 0.08, 'Unachievable', cex=2)
##################################################
## Case 2
## Get the upper boundary
delta = 0.7
eps = 0.3
L=1000
tppmax = min(powermax(delta, eps), 1)
xu = seq(0, tppmax, length.out = L)
yu = rep(0,L)
for (i in 1:L){
yu[i] = min(1-eps, 1-eps/delta*xu[i])
}
## Get the data of lower boundary
xx = seq(0, tppmax, length.out = L)
yy = rep(0,L)
for (i in 1:L){
yy[i] = fdrlasso(xx[i], delta, eps)
}
par(mar=c(5,6,1,2),xpd=FALSE)
plot(0,0,xlim = c(0, 1), ylim=c(0, 1), xaxs='i', yaxs='i',xlab='TPP',ylab='FDP', cex.lab=2.5,cex.axis=1.5, type="n")
polygon(c(0,1,1,0),c(0,0,1,1),col=color)
polygon(c(xx,rev(xu)),c(yy,rev(yu)),col=color_inner)
text(0.5, 0.85, 'Unachievable', cex=2)
text(0.5,0.45,'Achievable',cex=2)
text(0.8,0.15,'Unachievable',cex=2)
##################################################
## Case 3
## Get the upper boundary
delta = 0.5
eps = 0.3
L=1000
tppmax = powermax(delta, eps)
xu = seq(0, tppmax, length.out = L)
yu = rep(0,L)
for (i in 1:L){
yu[i] = min(1-eps, 1-eps/delta*xu[i])
}
## Get the data of lower boundary
xx = seq(0, tppmax, length.out = L)
yy = rep(0,L)
for (i in 1:L){
yy[i] = fdrlasso(xx[i], delta, eps)
}
par(mar=c(5,6,1,2),xpd=FALSE)
plot(0,0,xlim = c(0, 1), ylim=c(0, 1), xaxs='i', yaxs='i',xlab='TPP',ylab='FDP', cex.lab=2.5,cex.axis=1.5, type="n")
polygon(c(0,1,1,0),c(0,0,1,1),col=color)
polygon(c(xx,rev(xu)),c(yy,rev(yu)),col=color_inner)
abline(v =tppmax, lwd=2,lty=2)
text(0.5, 0.85, 'Unachievable', cex=2)
text(0.4,0.48,'Achievable',cex=2)
text(0.7,0.2,'Unachievable',cex=2)
#dev.off()