-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchapter3figure4
88 lines (73 loc) · 3.26 KB
/
chapter3figure4
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
library(CDVine)
#################gumbel norm
CoVaR=function(alpha,beta,theta){
uVal=function(x){
f=BiCopCDF(x,alpha,family=4,theta)-alpha*beta
return(f)
}
u=uniroot(uVal,lower=0,upper=1)$root
CoVaR=qnorm(u,0,1)
return(CoVaR)
}
theta=matrix(seq(1.0001,10,length.out=1000),ncol=1)
covar1=apply(theta,1,CoVaR,alpha=0.01,beta=0.01)
covar2=apply(theta,1,CoVaR,alpha=0.05,beta=0.05)
covar3=apply(theta,1,CoVaR,alpha=0.1,beta=0.1)
covar.bench1=apply(theta,1,CoVaR,alpha=0.5,beta=0.01)
covar.bench2=apply(theta,1,CoVaR,alpha=0.5,beta=0.05)
covar.bench3=apply(theta,1,CoVaR,alpha=0.5,beta=0.1)
delta.covar1=(covar1-covar.bench1)/abs(covar.bench1)
delta.covar2=(covar2-covar.bench2)/abs(covar.bench2)
delta.covar3=(covar3-covar.bench3)/abs(covar.bench3)
#################################################plot
par(mar=c(5, 6, 4, 6))
plot(theta,covar1,pch=2,lty=1, lwd=3,col="white" , axes=F, ylim=c(min(covar1),max(covar3)), xlab="", ylab="",
main=expression(paste("CoVaR as funtion of ",theta,"(gumbel norm)")))
mtext(expression(theta),side=1,line=2.5)
mtext("CoVaR",side=2,line=2.5)
axis(1)
axis(2, ylim=c(min(covar1),max(covar3)),las=1)
box()
lines(theta,covar1,pch=2,lty=1, lwd=3,col=2)
lines(theta,covar2,pch=3,lty=1, lwd=3,col=3)
lines(theta,covar3,pch=4,lty=1, lwd=3,col=4)
legend(x=0.6*max(theta),y=0.9*max(covar3),c(expression(paste(alpha,"=",beta,"=0.01")),expression(paste(alpha,"=",beta,"=0.05")),expression(paste(alpha,"=",beta,"=0.1")))
, lty=c(1,1,1),col=c(2,3,4), lwd=3,cex=1
,box.lwd = 0,box.col = "white")
dev.print(pdf,file="E:/HU/fourth_semester/master_thesis/figures/covar_gumbel_norm.pdf", paper="a4r",width = 28, height = 18);
##################gumbel t#############
CoVaR=function(alpha,beta,theta){
uVal=function(x){
f=BiCopCDF(x,alpha,family=4,theta)-alpha*beta
return(f)
}
u=uniroot(uVal,lower=0,upper=1)$root
CoVaR=qt(u,30)
return(CoVaR)
}
theta=matrix(seq(1.001,10,length.out=1000),ncol=1)
covar1=apply(theta,1,CoVaR,alpha=0.01,beta=0.01)
covar2=apply(theta,1,CoVaR,alpha=0.05,beta=0.05)
covar3=apply(theta,1,CoVaR,alpha=0.1,beta=0.1)
covar.bench1=apply(theta,1,CoVaR,alpha=0.5,beta=0.01)
covar.bench2=apply(theta,1,CoVaR,alpha=0.5,beta=0.05)
covar.bench3=apply(theta,1,CoVaR,alpha=0.5,beta=0.1)
delta.covar1=(covar1-covar.bench1)/abs(covar.bench1)
delta.covar2=(covar2-covar.bench2)/abs(covar.bench2)
delta.covar3=(covar3-covar.bench3)/abs(covar.bench3)
#################################################plot
par(mar=c(5, 6, 4, 6))
plot(theta,covar1,pch=2,lty=1, lwd=3,col="white" , axes=F, ylim=c(min(covar1),max(covar3)), xlab="", ylab="",
main=expression(paste("CoVaR as funtion of ",theta,"(gumbel t)")))
mtext(expression(theta),side=1,line=2.5)
mtext("CoVaR",side=2,line=2.5)
axis(1)
axis(2, ylim=c(min(covar1),max(covar3)),las=1)
box()
lines(theta,covar1,pch=2,lty=1, lwd=3,col=2)
lines(theta,covar2,pch=3,lty=1, lwd=3,col=3)
lines(theta,covar3,pch=4,lty=1, lwd=3,col=4)
legend(x=0.6*max(theta),y=0.9*max(covar3),c(expression(paste(alpha,"=",beta,"=0.01")),expression(paste(alpha,"=",beta,"=0.05")),expression(paste(alpha,"=",beta,"=0.1")))
, lty=c(1,1,1),col=c(2,3,4), lwd=3,cex=1
,bty = "n")
dev.print(pdf,file="E:/HU/fourth_semester/master_thesis/figures/covar_gumbel_t.pdf", paper="a4r",,width = 28, height = 18);