Path: blob/master/sandbox/paper_analysis/illustration/CVaRvsVaRsstbis.R
1433 views
12setwd( "C:/Documents and Settings/Administrator/Desktop/risk budget programs/illustration" )34library( skewt )5n = 5000 ;6df = 5 ;7gamma = 0.8 ;8simret = rskt( n = n , df = df , gamma = gamma ) ;910postscript( "CVaR.eps" )1112par( cex = 1.2 , cex.main = 1.2)13hist( simret , freq = F , breaks = 20 , ylim =c(0,0.4), col="gray" ,14main = "95% Value at Risk and 95% Conditional VaR \n for a Skewed Student t" , xlab = "Portfolio returns" , ylab = "Density" )15mi = min( simret ) ; ma = max( simret );16lines( seq(mi,ma,0.01) , dskt( seq(mi,ma,0.01), df = df , gamma = gamma ),lwd=2 )1718abline ( v = qskt( 0.05 , df = df , gamma = gamma ) , lty = 3, lwd = 2 , col = "red" )19text( x = qskt( 0.05 , df = df , gamma = gamma ) , y = 0.38 , labels = "95% VaR" , col = "red" , lwd = 2 , cex = 1.1)2021library(graphics)22arrows( x0 = min(simret) , x1 = qskt( 0.05 , df = df , gamma = gamma ) ,23y0 = 0.1 , y1 = 0.1 , code = 3 , col = "blue" , lwd = 2 )24text( x = 0.5*(min(simret)+qskt( 0.05 , df = df , gamma = gamma ) ) , y = 0.12 ,25labels = "95% CVaR" , col = "blue" , lwd = 2 , cex = 1.1)2627dev.off()282930