ACST840: Quantitative Research Methods

Added on - 11 Sep 2021

  • ACST840

    Course

  • 14

    Pages

  • 4637

    Words

  • 4

    Views

  • 0

    Downloads

Trusted by +2 million users,
1000+ happy students everyday
Showing pages 1 to 4 of 14 pages
Operational Risk- Modelling
Institution:
Student Name:
Contents
QUESTION 1 R- CODE.............................................................................................................................3
QUESTION 1 OUTPUT............................................................................................................................4
QUESTION 2 R CODE............................................................................................................................12
QUESTION 2 OUTPUT..........................................................................................................................13
References...........................................................................................................................................15
QUESTION 1 R- CODE
####Question 1 A
library(MASS)#Question 1, Monte Carlo Bivariate T-Copula
set.seed(1)# Set seed for number sequence
dof<-10 #Degrees of freedom for the t-copula
Ndim<-3#the number of risks, rsik1,rsik2 and rsik3
rho<-0.4#T-copula correlation parameter
CoRMatrix<-matrix(c(1,rho,rho,rho,rho,rho,rho,rho,1),Ndim,Ndim,Ndim)#the
correlation matrix formed from the 3 risks and 10 degrees of freedom of the t-
copula
sigma<-c(log(c(1.4,1.7,2.0))) #matrix for the standard devistions. We use logs
since the distribution is a log Normal
Nsim<-10000
Z<-mvrnorm(Nsim,rep(0,Ndim), CoRMatrix)# Estimates Z
EZ<-mean(Z)#Ouputs Question 1 part 1, the value of E[ Z]
EZ
var(Z)#Outputs Question 1a, part ii, VaR0:99[Z]
Z #Outputs Question 1a part iii, ES0:99[Z].
n=length(Z)
m=0 #both n and m will be used in calculating the 0.99 confidence interval
con.level<-0.99 # this is the level of confidence
Zed<-sqrt(0.995) # this the z value for calculating confidence interval
T<-Zed/sqrt(n)
se<-sd(T) # output the standard error
CI<-0.99*se #confidence interval
LowerLimit<-m-CI
UpperLimit<-m+CI
#########
####Question 1 B
cat("MLE estimate of E[Z1]=",mean(Z[,1]),"\n")
cat("MLE estimate of E[Z2]=",mean(Z[,2]),"\n")
cat("MLE estimate of E[Z3]=",mean(Z[,3]),"\n")
cat("MLE estimate of standard deviation of Z1=",sd(Z[,1]),"\n")
cat("MLE estimate of standard deviation of Z2=",sd(Z[,2]),"\n")
cat("MLE estimate of standard deviation of Z3=",sd(Z[,3]),"\n")
#########
####Question 1 C
##Kendall’s Correlation for measuring the strength of association between the
variables. Correlation is between 2 variables hence we calculate for each pair
cat("Estimateofkendall’scorrelationbetweenZ1and
Z2=",cor(Z[,1],Z[,2],method="kendall"), "\n")
cat("Estimateofkendall’scorrelationbetweenZ1and
Z3=",cor(Z[,1],Z[,3],method="kendall"), "\n")
cat("Estimate of kendall’s correlation between Z2 and Z3=",cor(Z[,2],Z[,3]
,method="kendall"), "\n")
####Spearsman’s Correlation also measures the strength of association
between two variables hence we calculate for each pair
cat("EstimateofSpearma’scorrelationbetweenZ1and
Z2=",cor(Z[,1],Z[,2],method="spearman"), "\n")
cat("Estimate of Spearman’s correlation between Z1 and
Z3=",cor(Z[,1],Z[,3],method="spearman"), "\n")
cat("Estimate of Spearman’s correlation=",cor(Z[,2],Z[,3],method="spearman"),
"\n")
####Question 1 d
##
U.tcopula<-pt(Z,dof)#gennerates a sample (U1, U2) from the t- copula
U.Gaussiancopula<-pnorm(Z,0,1) #generates sample (U1,U2) from Gaussian
Copula
QUESTION 1 OUTPUT
####Question 1 A
>library(MASS)#Question 1, Monte Carlo Bivariate T-Copula
>set.seed(1)# Set seed for number sequence
>dof<-10 #Degrees of freedom for the t-copula
>Ndim<-3#the number of risks, rsik1,rsik2 and rsik3
>rho<-0.4#T-copula correlation parameter
>CoRMatrix<-matrix(c(1,rho,rho,rho,rho,rho,rho,rho,1),Ndim,Ndim,Ndim)# the
correlation matrix formed from the 3 risks and 10 degrees of freedom of the t-
copula
>sigma<-c(log(c(1.4,1.7,2.0))) #matrix for the standard devistions. We use logs
since the distribution is a log Normal
>Nsim<-10000
>Z<-mvrnorm(Nsim,rep(0,Ndim), CoRMatrix)# Estimates Z
>EZ<-mean(Z)#Ouputs Question 1 part 1, the value of E[ Z]
>EZ
[1] 0.004449141
>var(Z)#Outputs Question 1a, part ii, VaR0:99[Z]
[,1] [,2] [,3]
desklib-logo
You’re reading a preview
Preview Documents

To View Complete Document

Click the button to download
Subscribe to our plans

Download This Document