Question
Questions: 1. Interpret and compare the VaR95 estimate for each of the three companies with the historical method. 2. Interpret and compare each of the
Questions:
1. Interpret and compare the VaR95 estimate for each of the three companies with the historical method.
2. Interpret and compare each of the three companies' ES95 estimate with the historical method.
3. Interpret and compare the estimated VAR95 vs ES95 of the portfolio (equally weighted) of the three companies with the historical method.
4. Interpret and compare the VAR95 estimate of the portfolio (equally weighted) of the three companies with the historical method versus the normal distribution method
R code
######4.2. Empirical VaR and ES ####
n <- length(Ra_daily_port_ts) #Number of observations
VaR95 <- quantile(Ra_daily_port_ts,0.95,na.rm=T)
VaR95
VaR99 <- quantile(Ra_daily_port_ts,0.99,na.rm=T)
VaR99
which(Ra_daily_port_ts>=VaR99)
n <- length(Ra_daily_port_ts) #Number of observations
#Useful in back-testing: is the percentage of exceedances "close" to 1-alpha (99%)?
1-length(which(Ra_daily_port_ts>=VaR99))/n
chartSeries(Ra_daily_port_ts,up.col="red",theme = "white")
abline(h=VaR95,col="black")
abline(h=VaR99,col="blue")
ES95 <- mean(Ra_daily_port_ts[Ra_daily_port_ts>=VaR95])
ES95
ES99 <- mean(Ra_daily_port_ts[Ra_daily_port_ts>=VaR99])
ES99
######4.3. VaR and ES assuming Normal Distribution) ####
m=mean(Ra_daily_port_ts,na.rm=TRUE)# empirical mean
s=sd(Ra_daily_port_ts,na.rm=TRUE)# empirical sd
times=index(Ra_daily_port_ts)
n=sum(is.na(Ra_daily_port_ts))+sum(!is.na(Ra_daily_port_ts))
# we generate normal observations with mean m and standard deviation s
x=seq(1,n)
y=rnorm(n, m, s)
plot(times,Ra_daily_port_ts,pch=19,xaxs="i",cex=0.03,col="blue",ylab="Ra_daily_port_ts",xlab="Time",main ='')
segments(x0 =times,x1 =times,y0 =0,y1 =Ra_daily_port_ts,col="blue")
points(times,y,pch=19,cex=0.3,col="red",ylab="X",xlab="n",main ='')
VaR99_Emp <- quantile(Ra_daily_port_ts,0.99,na.rm=T)#empirical
VaR99_Emp
VaR99_Norm <- qnorm(0.99,m,s)# normal
VaR99_Norm
ES99_Emp <- mean(Ra_daily_port_ts[Ra_daily_port_ts>=quantile(Ra_daily_port_ts,0.99,na.rm=T)],na.rm=T)# empirical
ES99_Emp
ES99_Norm <- m+s*(dnorm(qnorm(0.99,0,1),0,1))/0.01# normal
ES99_Norm
######4.4. Backtesting Normal VaR) ####
VaR99_BT_Exp <- round(0.01*n) #Number of observation expected
VaR99_BT_Exp
VaR99_BT_Obs <- length(which(Ra_daily_port_ts>=VaR99_Norm)) #Number of observation observed in the data
VaR99_BT_Obs
#Right-tail Binomial test
1-pbinom(VaR99_BT_Obs-1,n,0.01)
#If p-value<=significance level, then we confirm that we are underestimating VaR under Normality (Normal Distribution)
######4.5. VaR and ES using Package Performance Analytics ####
VaR99_pa <- VaR(Ra_daily_port_ts, p=.99, method="historical", invert = F)
VaR99_ga <- VaR(Ra_daily_port_ts, p=.99, method="gaussian", invert = F)
VaR99_mo <- VaR(Ra_daily_port_ts, p=.99, method="modified", invert = F)
ES99_pa <- ES(Ra_daily_port_ts, p=.99, method="historical", invert = F)
ES99_ga <- ES(Ra_daily_port_ts, p=.99, method="gaussian", invert = F)
VaRES99_qa <- hs(Ra_daily_port_ts, p = 0.99, method = "plain", lambda = 0.98)
VaRES99_fc <- rollcast(Ra_daily_port_ts, p=.99, method="plain",
nout=nout, nwin=nwin)
plot(VaRES99_fc)
trftest(VaRES99_fc)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started