logo

ACST840: Quantitative Research Methods

14 Pages4637 Words41 Views
   

Macquarie University

   

Quantitative Research Methods (ACST840)

   

Added on  2021-09-11

ACST840: Quantitative Research Methods

   

Macquarie University

   

Quantitative Research Methods (ACST840)

   Added on 2021-09-11

ShareRelated Documents
Operational Risk- Modelling
Institution:
Student Name:
Contents
QUESTION 1 R- CODE.............................................................................................................................3
ACST840: Quantitative Research Methods_1
QUESTION 1 OUTPUT............................................................................................................................4
QUESTION 2 R CODE............................................................................................................................12
QUESTION 2 OUTPUT..........................................................................................................................13
References...........................................................................................................................................15
QUESTION 1 R- CODE
####Question 1 A
ACST840: Quantitative Research Methods_2
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")
ACST840: Quantitative Research Methods_3
#########
####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("Estimate of kendall’s correlation between Z1 and
Z2=",cor(Z[,1],Z[,2],method="kendall"), "\n")
cat("Estimate of kendall’s correlation between Z1 and
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("Estimate of Spearma’s correlation between Z1 and
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]
ACST840: Quantitative Research Methods_4

End of preview

Want to access all the pages? Upload your documents or become a member.