MBA19141 - Assignment 3
MBA19141 - Assignment 3
R
ARHUM
2021-01-12
rm(list=ls()) #clear the previous memory
setwd("F:/TERM 5/FRMM/Assignments") #set WD
## [1] 0.2172895
write.csv(garch_ccc$h,"CCC_GARCH_Var.csv")
## ****************************************************************
## * Estimation has been completed. *
## * The outputs are saved in a list with components: *
## * out : the estimates and their standard errors *
## * loglik : the value of the log-likelihood at the estimates *
## * h : a matrix of estimated conditional variances *
## * DCC : a matrix of DCC estimates *
## * std.resid : a matrix of the standardised residuals *
## * first : the results of the first stage estimation *
## * second : the results of the second stage estimation *
## ****************************************************************
corr_dcc=garch_dcc$DCC
var_dcc=garch_dcc$h
out=cbind(var_dcc,corr_dcc)
write.table(out,"Corr_out.csv",sep=",")
write.csv(garch_ccc$h,"CCC_GARCH_Var_10.csv")
write.csv(corr_1,"Corr_Matrix_10_CCC.csv")
## ****************************************************************
## * Estimation has been completed. *
## * The outputs are saved in a list with components: *
## * out : the estimates and their standard errors *
## * loglik : the value of the log-likelihood at the estimates *
## * h : a matrix of estimated conditional variances *
## * DCC : a matrix of DCC estimates *
## * std.resid : a matrix of the standardised residuals *
## * first : the results of the first stage estimation *
## * second : the results of the second stage estimation *
## ****************************************************************
corr_dcc=garch_dcc$DCC
var_dcc=garch_dcc$h
out=cbind(var_dcc,corr_dcc)
write.table(out,"Corr_Dcc_out.csv",sep=",")
#Monte-Carlo 10 Assets
#This code is to generate correlated Random Numbers
correl=matrix(c(1, 0.291299026793378, 0.371342320625672,
0.251947662913924, 0.225018893793893, 0.401811186637609,
0.270793686729448, 0.442170247126175, 0.250151556771484,
0.292439442357404,
0.291299026793378, 1, 0.272397648218998,
0.141975702500437, 0.15023634850428, 0.371896133942635,
0.207554308432132, 0.251972412983337, 0.15565792650742,
0.154892377023923,
0.371342320625672, 0.272397648218998, 1, 0.25689759648536,
0.149151506681028, 0.324000733781084, 0.376482313288284,
0.430089193388842, 0.201933596472416, 0.245897926544068,
0.251947662913924, 0.141975702500437, 0.25689759648536,
1, 0.222313433202035, 0.194980964851881, 0.17855860694452,
0.264999207626123, 0.180017153809134, 0.165863293859964,
0.225018893793893, 0.15023634850428, 0.149151506681028,
0.222313433202035, 1, 0.17682063298195, 0.10989287155797,
0.165860116989631, 0.18876679003336, 0.137310312939035,
0.401811186637609, 0.371896133942635, 0.324000733781084,
0.194980964851881, 0.17682063298195, 1, 0.216919923880998,
0.308499724267648, 0.188892454493974, 0.247922978615251,
0.270793686729448, 0.207554308432132, 0.376482313288284,
0.17855860694452, 0.10989287155797, 0.216919923880998, 1,
0.322184722468269, 0.155707225617494, 0.195147784261079,
0.442170247126175, 0.251972412983337, 0.430089193388842,
0.264999207626123, 0.165860116989631, 0.308499724267648,
0.322184722468269, 1, 0.226649656954128, 0.292069736533152,
0.250151556771484, 0.15565792650742, 0.201933596472416,
0.180017153809134, 0.18876679003336, 0.188892454493974,
0.155707225617494, 0.226649656954128, 1, 0.147352084480652,
0.292439442357404, 0.154892377023923, 0.245897926544068,
0.165863293859964, 0.137310312939035, 0.247922978615251,
0.195147784261079, 0.292069736533152, 0.147352084480652, 1),10,10)
#Using Cholesky Decomposition
choles=chol(correl)
#Generating three series of Independent Random Nos from Standard Normal
Distribution
z1=rnorm(1000,0,1)
z2=rnorm(1000,0,1)
z3=rnorm(1000,0,1)
z4=rnorm(1000,0,1)
z5=rnorm(1000,0,1)
z6=rnorm(1000,0,1)
z7=rnorm(1000,0,1)
z8=rnorm(1000,0,1)
z9=rnorm(1000,0,1)
z10=rnorm(1000,0,1)
z=cbind(z1,z2,z3,z4,z5,z6,z7,z8,z9,z10)
#Matrix multiplication of Independent Random Number and Cholesky
x=z%*%choles
write.csv(x,"correl_Random_Number_10Assets.csv")