ACST840 Quantitative Research Methods For Operational Risk Modelling
Questions:
a) Estimate λ, µ, σ using the maximum likelihood method.
b) Using Markov chain Monte Carlo method (random walk Metropolis-Hastings within Gibbs
algorithm studied during the course) with 104
chain iterations, under the Bayesian approach
with constant priors, estimate the posterior mean and the posterior standard deviation for
λ, µ, σ.
c) Using closed form solution, under the Bayesian approach with constant priors, estimate the
posterior mean and posterior standard deviation for λ.
d) Under the Bayesian approach, model parameter λ is modelled by random variable Λ. Suppose that expert’s best estimates for the expected number of annual losses and associated
uncertainty are E[Λ] = 1 and Vco[Λ] = 0.5. If the prior distribution for Λ is Gamma(α, β),
find α and β using expert estimates and calculate (using closed form solution and MCMC)
the posterior mean and posterior standard deviation for Λ.
Answer:
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("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
> 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&
lt;-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]
[1,] 1.0162244 0.4117166 0.4229360
[2,] 0.4117166 0.4085383 0.4085549
[3,] 0.4229360 0.4085549 1.0076161
> Z #Outputs Question 1a part iii, ES0:99[Z].
[,1] [,2] [,3]
[1,] 0.9861174186 2.494692e-01 0.1050162967
[2,] 0.4534764159 -1.820795e-01 -0.7038894508
[3,] 1.1890447540 6.647049e-01 0.0548255003
[4,] -0.8877186086 -1.716365e-01 -2.1864349065
[5,] 0.1157733377 -5.348002e-01 -0.4324306808
[6,] 0.9365952471 5.321820e-01 0.3614989325
[7,] -0.3945724223 2.317379e-01 -0.7258711271
[8,] -0.7907853384 -6.413838e-01 -0.2737701533
[9,] -0.1167143098 -1.009505e+00 -0.3888052931
[10,] -0.3556636452 -9.216153e-02 1.0238501385
[11,] -1.3486615794 -1.104422e+00 -0.9642469235
[12,] -0.7347963565 -3.986172e-01 0.2109217273
[13,] 0.7460218493 4.272179e-01 0.2214007953
[14,] 2.4129771118 1.405025e+00 1.1110633579
[15,] -0.8649885710 -3.462986e-01 -1.1591882928
[16,] 0.0512678656 1.176738e-01 -0.0366098979
[17,] 0.1155564246 -1.000934e-01 -0.0194415051
[18,] -0.5434974102 -1.078669e+00 -0.6524282596
[19,] -0.1251018787 -7.439065e-01 -1.0395290469
[20,] -1.6224439481 3.858225e-02 0.4126515771
[21,] -0.4504477838 -6.071954e-01 -0.9964143642
[22,] 0.1343519455 -6.875284e-01 -1.2569231706
[23,] 0.5175397849 -2.470938e-01 -0.5088306279
[24,] 1.6463028972 1.459214e-01 2.2306563096
[25,] 0.2845703586 -5.490302e-02 -1.4865048874
[26,] 0.2612151331 -9.898811e-02 -0.0861030137
[27,] 0.3678974156 5.481286e-02 -0.0919306520
[28,] 1.1948009994 1.166460e+00 0.9966833700
[29,] -0.0703004581 3.395729e-01 0.8080397170
[30,] 0.1273972715 -4.125270e-01 -0.6984784141
[31,] -1.2507842970 -6.346667e-01 -1.0560418715
[32,] -0.1660870190 4.848480e-01 0.0621411372
[33,] -0.6974023556 -4.057219e-01 0.1823903942
[34,] 0.8750889413 1.639643e-01 -0.8722352811
[35,] 0.2589037308 7.498773e-01 2.0111598338
[36,] 0.0538421460 2.722704e-01 0.6007657221
[37,] 0.1503261532 1.309845e-01 0.5530272183
[38,] 0.3717352630 -2.751404e-01 -0.0779779973
[39,] -1.4354164306 -5.337674e-01 -0.4195549441
[40,] -1.3397826211 3.286976e-01 -0.3927527055
[41,] -0.0516126742 -5.640009e-01 0.7394655201
[42,] 0.0435693178 1.903135e-01 0.3407258431
[43,] -0.7018876832 -5.195360e-01 -0.3577994496
[44,] -0.6498897622 -1.002010e+00 0.1777450374
[45,] 0.6926466879 3.081159e-01 0.4854326836
[46,] 0.3073162204 6.024017e-01 0.7205648776
[47,] 0.0548373538 -6.118715e-01 -0.3923594317
[48,] -0.4044836076 -6.796340e-01 -0.6959729086
[49,] 0.1101910883 -1.422543e-01 0.2046898333
[50,] -0.7536996562 -5.253960e-02 -0.9711594205
[51,] -0.5910085212 -3.562418e-01 0.0236322922
[52,] 0.1348510300 7.244603e-01 0.6247039200
[53,] -0.0385736308 -4.871161e-01 -0.3316532662
[54,] 0.9501446205 1.093916e+00 0.6063019015
[55,] -0.8059296064 -9.079927e-01 -1.4750247706
[56,] -1.7455370914 -9.231347e-01 -1.6181164811
[57,] 0.7849993186 6.854961e-02 -0.0958645450
[58,] 0.9027511188 7.811673e-01 0.6829767091
[59,] -0.6398686207 -3.585422e-01 -0.2685160389
[60,] -0.2594971036 6.557416e-01 0.1110058395
[61,] -1.6438009007 -1.142315e+00 -2.4207228027
[62,] -0.0579835200 -5.939347e-01 0.5149001853
[63,] -0.3274897390 -5.240733e-01 -0.7148887373
[64,] 0.3710579969 8.525273e-02 -0.4812845812
[65,] 0.3260007144 -6.607009e-02 1.1994026408
[66,] 0.3389612339 -9.852651e-02 -0.6529112138
[67,] 2.0351046949 9.170053e-01 0.9823430783
[68,] -0.9901267800 -1.039332e+00 -1.2720240719
[69,] -0.2667324020 -3.489143e-01 0.1833163012
[70,] -1.6282318005 -1.014161e+00 -2.0609766538
[71,] -1.0181445230 -1.536798e-01 0.1671755564
[72,] 0.7348652941 -1.730445e-01 0.7922224174
[73,] -1.3504497784 1.685272e-01 0.0242465936
[74,] 0.7676404536 4.778956e-01 0.7918191815
[75,] 0.3158141502 1.022237e+00 1.5343203205
[76,] -0.1963131609 3.190889e-01 -0.5887069911
[77,] -0.6080821051 -2.636346e-02 1.5095271822
[78,] 0.1677794343 -3.363765e-01 0.0444407971
[79,] -0.6037537798 2.317131e-01 0.3076896657
[80,] 0.0540002283 -1.065663e-02 1.1292491779
[81,] 0.0702482369 -2.292012e-01 1.2107013349
[82,] 0.1179220183 1.491830e-01 0.0567443300
[83,] -1.1347301895 -4.298866e-01 -0.9422417541
[84,] 1.5349640029 1.519146e+00 0.5370943065
[85,] 0.4115783509 -5.169401e-01 -1.2673377544
[86,] -1.0087396264 3.287866e-01 0.1347113522
[87,] -1.5915513338 -5.122122e-01 -0.2034715044
[88,] 0.6574667263 1.710231e-01 -0.1594531568
[89,] -0.1637689015 -2.757378e-01 -0.3988743621
[90,] 0.3550569878 5.258569e-01 -1.2232951007
[91,] -0.1616928936 4.245904e-01 0.9736946608
[92,] -1.0617025994 -7.708415e-01 -0.8573557463
[93,] -0.9422019773 -6.485094e-01 -0.9601157844
[94,] 0.0135205780 -3.061104e-01 -1.2157440386
[95,] -1.9423445148 -9.673069e-01 -0.6077444258
[96,] -0.3553743506 -2.735336e-01 -0.5847825905
[97,] 0.9252331320 5.593320e-01 1.2658011561
[98,] 0.5468904170 2.597236e-01 0.4315629980
[99,] 0.4162821966 6.438214e-01 1.6171623705
[100,] 0.6382715435 -9.274246e-02 0.3655728643
[101,] 0.6970056220 6.222609e-01 0.1443412042
[102,] -0.6532657708 -3.076301e-01 0.7653202144
[103,] 0.5816515240 7.645928e-01 0.7488001787
[104,] 0.1573606968 -4.530070e-01 -0.1839519291
[105,] 1.0440545113 6.126438e-01 -0.1282912995
[106,] -1.6336580435 -1.386374e+00 -1.0094093821
[107,] -0.2734951709 -5.445205e-01 -0.8096670022
[108,] -0.9657569833 -2.502771e-01 -0.6910581170
[109,] -0.2918811600 1.619258e-01 -0.5780255139
[110,] -1.6436837879 -5.586258e-01 -1.3571895063
[111,] -0.1836800488 1.072637e-01 1.3839884187
[112,] 0.1534576614 2.830931e-01 0.5873468600
[113,] -0.8837347819 -8.946057e-01 -1.4042735538
[114,] -0.4889630892 4.974690e-01 1.4703859079
[115,] 0.0906517754 4.526356e-01 0.0346636446
[116,] 0.8041196477 -2.244867e-02 -0.0059165551
[117,] -0.8439490982 7.631856e-02 1.4338814168
[118,] 0.0236645648 1.522435e-01 0.4362889331
[119,] 0.9874183459 -7.106935e-01 -1.5205898294
[120,] -0.4791181512 2.228657e-02 0.8187945729
[121,] 0.1301040560 6.508803e-01 0.4646824643
[122,] -1.5568034454 -4.278497e-01 -0.8506471186
[123,] -0.3810199136 -1.326226e-01 0.8937790039
[124,] -0.3131398857 -6.275225e-02 0.7114673682
[125,] 0.1776352206 -4.120474e-01 0.2849700140
[126,] -1.2027420096 2.223164e-01 -0.3611823481
[127,] -0.5117572675 -6.859732e-02 0.7022913705
[128,] 0.3041619664 -1.741341e-01 -0.1180554049
[129,] 0.3552607041 3.267392e-01 0.7967877670
[130,] 0.3366141641 4.358414e-01 0.0326732865
[131,] -0.2838767187 -2.554047e-01 0.3266296487
[132,] 0.4457261398 7.830734e-01 0.2303030562
[133,] -0.3643382628 -3.799964e-01 -0.4540909693
[134,] 0.8697090896 8.865614e-01 1.5952731751
[135,] 0.1111720845 -6.792939e-01 -0.2899214623
[136,] 0.9453523696 8.211048e-01 1.5973880637
[137,] 0.8654920334 -3.716333e-01 -0.0279590242
[138,] 0.9416535662 2.577295e-01 -0.0517026728
[139,] 1.4460321200 -4.902532e-02 -0.1134510439
[140,] -0.3014256879 5.218493e-01 0.0823123828
[141,] 1.5737770602 7.838106e-01 1.7468985481
[142,] 0.0477563407 -2.712533e-01 -2.2228497168
[143,] 0.9185469841 9.185291e-01 1.8185709873
[144,] 0.9083593880 -3.799721e-01 0.2588848720
[145,] 1.4331750574 6.806470e-01 0.3598863904
[146,] 0.4460506418 6.725712e-01 0.6235579243
[147,] -2.0413370987 -1.172374e+00 -1.3765015676
[148,] 0.5221066686 -5.580021e-01 -0.2011183776
[149,] 1.1721344197 1.208608e+00 0.6243873998
[150,] 1.6151429217 9.217082e-01 1.0713216137
[151,] 0.4906882614 3.063489e-01 -1.5843726844
[152,] 0.5820796924 -8.920919e-01 0.0236302066
[153,] 0.8616151415 -3.712208e-01 0.0097644553
[154,] 0.4337669244 2.829420e-01 1.2405173324
[155,] 0.5861011686 4.851031e-01 2.0730622667
[156,] 1.0609669016 1.338238e-02 1.0761711674
[157,] 0.0748761367 -7.797860e-01 -1.5734663293
[158,] -0.0970635150 7.148284e-01 0.8811985084
[159,] 1.2475271408 1.161148e+00 0.7750707078
[160,] -1.6478353060 -1.407518e+00 -1.1853124296
[161,] -0.0590472697 -5.615106e-01 -0.4313492327
[162,] 0.5052149736 1.797925e-02 -0.0404285127
[163,] -0.2439653639 -7.779968e-01 -1.3724174462
[164,] -1.1208966167 -5.471530e-01 -0.2992734106
[165,] 0.9038561244 1.146001e-01 0.2588611256
[166,] -2.5393360161 -1.270377e+00 -1.0533800657
[167,] -0.0641192587 -1.027518e-01 0.6385547609
[168,] 0.6350964749 5.564924e-01 1.8529041171
[169,] 0.6610889498 -1.005540e-01 -0.3088240509
[170,] 0.3203489775 1.305792e-01 -0.8177542162
[171,] -2.3790622169 -1.455767e+00 -1.2987805533
[172,] 0.6057547430 -1.031096e+00 -0.1596141071
[173,] 0.1249332408 -3.686077e-01 -0.8019542839
[174,] 0.4073515769 -3.149810e-01 -0.0525967279
[175,] 0.1317920121 1.603722e-01 0.4325141154
[176,] -0.7318280889 -6.671000e-01 1.2263764852
[177,] -1.1934197227 -5.877712e-01 -0.0037250761
[178,] -1.1257262284 -1.155837e+00 -2.2788637150
[179,] -1.0427174995 -4.387680e-01 -0.7278647513
[180,] -1.6456703197 -5.191377e-01 -0.4339197691
[181,] 1.3875042454 6.230914e-01 0.6725469845
[182,] -1.1714167155 -8.236619e-01 -0.2670086823
[183,] -0.3574558163 -8.557515e-01 0.4640769929
[184,] 0.9611122251 1.182384e+00 1.2132314717
[185,] -1.3980619300 -1.633977e-01 0.4624609561
[186,] -0.0810637248 2.085422e-01 0.2649395933
[187,] -0.2309545987 -6.398164e-01 -2.2839398733
[188,] 0.2604371207 5.392775e-01 0.9245997202
[189,] -0.0424878569 -3.043987e-02 0.9204286032
[190,] 1.3636251714 4.993892e-01 0.1661919693
[191,] 0.3031921623 1.124064e-02 0.0430735382
[192,] -0.1535718517 6.815553e-02 -0.6921348085
[193,] 0.2711686302 3.809559e-01 0.9462746529
[194,] -0.5765444298 -3.671866e-01 -0.8464936378
[195,] 0.5882168805 3.492836e-01 1.5999961662
[196,] 1.3397956685 3.199422e-01 0.5476267936
[197,] -1.5155758351 -8.469226e-01 -0.8205405087
[198,] -0.0248644868 9.704456e-01 1.4334849652
[199,] -0.9595390658 1.209642e-01 0.0602869071
[200,] -0.5692293681 2.146602e-01 1.1928730758
[201,] -0.3233465634 1.750968e-01 -0.6052784497
[202,] -0.9616067025 -1.194417e+00 -1.6473411530
[203,] -1.1257317991 -9.106101e-01 -1.4600099860
[204,] 0.2058486421 6.779101e-01 0.0223759722
[205,] 1.3050316034 1.347895e+00 2.3961890391
[206,] -2.7001155260 -1.385545e+00 -1.4010252585
[207,] 0.0100674325 -5.910188e-01 -0.9645240001
[208,] -0.3779038264 -5.782807e-01 -0.3337465414
[209,] 0.4085318231 -1.375243e-01 -0.2941255124
[210,] -0.6110806234 1.779958e-01 -0.5203638337
[211,] -0.9621657212 -4.992378e-01 1.6084398633
[212,] -0.1040365188 -5.104926e-01 -0.4100897084
[213,] 1.8054686031 3.495480e-01 -1.2295529705
[214,] 0.7857727988 1.560126e+00 0.9541176718
[215,] -0.6289614544 -6.273401e-01 -0.9424790685
[216,] -1.5178551618 -5.294903e-01 -1.1774410808
[217,] 0.5463511680 -5.174450e-02 0.1027608026
[218,] 1.1515434305 5.874793e-01 0.9750453810
[219,] -0.7787040928 -7.600173e-01 -0.0184820829
[220,] -0.6049231415 -1.448061e-01 0.7864532107
[221,] 0.8067218789 1.579072e+00 1.6455197215
[222,] 0.4985619621 8.819590e-02 -0.5590375646
[223,] 2.0870378518 2.113014e-01 -0.9638976086
[224,] 0.3929218934 -2.724252e-02 0.3048857491
[225,] 0.4426600321 8.623906e-02 1.8104381139
[226,] -1.3617344451 -1.084839e+00 -1.5451010132
[227,] 1.0454605576 -1.941861e-01 -0.2608632191
[228,] 2.0010001109 5.669088e-01 0.8416040324
[229,] -0.3056821257 3.143201e-01 -0.2882059142
[230,] -0.0934537539 -1.535297e-02 -0.4219563610
[231,] 1.4669894721 1.136163e+00 -0.2239167078
[232,] 1.8832948759 1.918272e+00 2.6590568402
[233,] 1.3188883720 1.361693e-01 -0.1275364410
[234,] -0.6983739744 -3.839562e-01 -0.1953828720
[235,] -0.2019604364 4.034308e-01 0.0639746006
[236,] -0.4649983479 -1.263989e-01 0.7414992677
[237,] -0.5340753136 -1.657660e-02 -0.5745394766
[238,] 1.4491548864 2.145187e-01 0.7818117758
[239,] -0.8870622884 -3.067359e-02 -1.2821281742
[240,] -0.4572093251 3.816814e-01 0.2245678574
[241,] -0.1032690043 -4.632574e-01 -1.0129426157
[242,] -1.2067990144 -1.635450e-01 -0.7526276689
[243,] -0.3767003202 2.816157e-01 -0.2487986838
[244,] 1.7769863513 2.819761e-01 -0.2031732477
[245,] -0.4667850677 -5.001909e-01 -1.5351922385
[246,] 1.7761231128 8.013933e-01 1.7045789634
[247,] 0.2406841566 3.539307e-01 0.6208916584
[248,] 0.8171994438 9.103933e-02 -0.3650132035
[249,] -0.0413265240 8.539191e-02 0.3184061785
[250,] -0.4734319865 -7.724775e-01 -1.0705976088
[251,] -0.4815846018 2.366651e-01 0.0588741081
[252,] -1.2004035301 -4.847159e-02 0.4187528031
[253,] 0.3987438814 -2.842766e-01 -0.0785252281
[254,] 0.1943026979 5.876537e-01 -0.0746651570
[255,] 0.1194229038 -3.446876e-01 -1.2877497100
[256,] -0.2837439721 -7.396306e-01 -1.5322014625
[257,] 1.3873701648 9.396443e-01 2.8092978882
[258,] -0.1645696078 -1.426377e-02 -0.9693048906
[259,] -0.4257726342 -2.869155e-01 -0.1391358877
[260,] 0.6465667672 -2.578817e-01 0.3664923298
[261,] -0.5586616897 -6.668523e-01 -0.9141020137
[262,] -0.2431601998 -1.543633e-02 1.0297673822
[263,] 0.1897051640 -2.387356e-01 0.5298931632
[264,] -1.1844305472 -9.225178e-01 0.0614385149
[265,] -1.8333642394 -7.059100e-01 -1.1483596150
[266,] 0.0772874655 -1.344114e-01 -0.5305310869
[267,] 1.1841699389 1.560266e-01 -0.4411141458
[268,] 1.2844639463 4.070245e-01 0.8290858785
[269,] 0.1709612961 8.596084e-01 -0.0583120316
[270,] 0.3233607747 7.361074e-01 1.0829377783
[271,] -0.6792608077 3.994416e-01 0.9413627850
[272,] 0.0059636494 1.778813e-01 -0.9063842067
[273,] 0.2672142786 -1.458160e-02 1.4420588125
[274,] -3.1702995910 -1.164722e+00 -1.3739528598
[275,] 0.8372221760 -6.365684e-02 -1.1079826542
[276,] -1.1672134742 -3.394895e-01 -0.8718334751
[277,] 2.3070913251 1.023556e+00 1.6086420160
[278,] -0.5523556159 -2.679038e-01 -0.7556190462
[279,] 1.3154480835 2.137050e-01 1.1750410740
[280,] -0.1672680356 -4.786325e-01 -1.3631966277
[281,] -0.1320014291 3.567547e-01 -0.8899290578
[282,] 0.0209321163 3.324969e-01 0.5803845977
[283,] -1.1507981230 -7.811807e-01 -0.9939405282
[284,] 1.4186749779 6.920921e-02 -0.0634052590
[285,] 0.8278937434 4.119342e-01 0.0681972733
[286,] 0.4297376418 5.919978e-01 1.1906419149
[287,] -0.0487195733 5.201953e-01 1.0505431454
[288,] 0.5301297642 -6.627776e-01 -1.9938608094
[289,] -0.6676805076 2.399644e-01 -0.3507889266
[290,] -1.1866543168 -5.714432e-01 -0.4549840661
[291,] 1.3296738641 -3.037132e-01 -0.3575429937
[292,] -0.6410393068 -4.686836e-02 -0.0801738676
[293,] 0.2010760637 -5.458123e-01 -0.3404022237
[294,] 1.2560847312 9.019229e-01 1.0152358719
[295,] -1.8156411946 -7.984624e-01 -1.2244304298
[296,] -0.6087604194 -6.433610e-01 0.7505708093
[297,] -0.8521680424 -5.610586e-02 -0.6399068622
[298,] -1.2690247301 -9.354994e-01 -0.0407172545
[299,] -0.6392237540 7.474636e-01 0.2636562540
[300,] -0.3208828699 5.313820e-01 0.5924383389
[301,] -0.5917384809 -3.431409e-01 -0.9729511588
[302,] 0.7398230512 5.034846e-01 1.0292291766
[303,] -2.1315514239 -9.695901e-01 -1.1844034403
[304,] -0.9393352947 3.625334e-01 1.4738168277
[305,] -0.5078137775 -1.072228e+00 -2.1097207334
[306,] -1.5444911635 -5.978234e-01 -1.0922139277
[307,] 0.3222937015 -4.963874e-02 -0.4562186345
[308,] 0.3157290329 -6.635592e-01 -1.0246915053
[309,] 0.9671707378 7.069453e-01 0.6267841564
[310,] -1.0159860836 2.470982e-01 0.2138749006
[311,] -1.4647574613 -5.154073e-01 -0.2893393077
[312,] -0.5391129938 -8.445515e-02 0.3952272427
[313,] 0.5609670776 1.411549e-01 0.2553344909
[314,] 1.0282409697 9.088285e-01 -0.2988941169
[315,] -0.5481978141 8.139748e-02 0.5679975790
[316,] -1.0626872519 -9.435713e-01 -0.4694586464
[317,] 0.3858533066 1.031710e-01 0.5142065738
[318,] -0.7499666746 2.756825e-01 0.8157199814
[319,] 0.9798052570 4.841253e-01 1.2941888097
[320,] 0.5953488112 -4.475553e-02 -1.5532766220
[321,] -0.6372062806 -2.049611e-01 -1.8422060750
[322,] -0.7114139435 -1.309014e+00 -1.4416595011
[323,] -0.5915801616 9.704658e-02 -1.0961151771
[324,] 1.8663119070 1.096958e+00 1.1657996375
[325,] 0.0989127148 1.452490e-02 -1.0701165538
[326,] -1.7277981423 -9.409071e-01 1.4173168862
[327,] 0.5650189098 3.298338e-01 -0.0700237495
[328,] 0.1316764791 4.503867e-01 -0.7590105197
[329,] 1.2064345674 1.592536e-01 0.4163301013
[330,] -0.7306106464 -1.447086e-01 -0.5326260164
[331,] 0.9114570566 4.288888e-01 -0.5320885653
[332,] 0.7411042574 1.024646e+00 1.7370086185
[333,] 0.2742027321 -1.184494e-01 0.5345936927
[ reached getOption("max.print") -- omitted 9667 rows ]
> n=length(Z)
> m=0 #both n and m will be used in calculating the 0.99 confidence interval for last part of Question 1a
> 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+C
> #########
> ####Question 1 B
> cat("MLE estimate of E[Z1]=",mean(Z[,1]),"n")
MLE estimate of E[Z1]= 0.008552179
> cat("MLE estimate of E[Z2]=",mean(Z[,2]),"n")
MLE estimate of E[Z2]= 0.0008330524
> cat("MLE estimate of E[Z3]=",mean(Z[,3]),"n")
MLE estimate of E[Z3]= 0.003962192
> cat("MLE estimate of standard deviation of Z1=",sd(Z[,1]),"n")
MLE estimate of standard deviation of Z1= 1.00808
> cat("MLE estimate of standard deviation of Z2=",sd(Z[,2]),"n")
MLE estimate of standard deviation of Z2= 0.63917
> cat("MLE estimate of standard deviation of Z3=",sd(Z[,3]),"n")
MLE estimate of standard deviation of Z3= 1.003801
> #########
> ####Question 1 C
> ##Kendall’s Correlation
> cat("Estimate of kendall’s correlation between Z1 and Z2=",cor(Z[,1],Z[,2],method="kendall"), "n")
Estimate of kendall’s correlation between Z1 and Z2= 0.4385115
> cat("Estimate of kendall’s correlation between Z1 and Z3=",cor(Z[,1],Z[,3],method="kendall"), "n")
Estimate of kendall’s correlation between Z1 and Z3= 0.2745759
> cat("Estimate of kendall’s correlation between Z2 and Z3=",cor(Z[,2],Z[,3]
+ ,method="kendall"), "n")
Estimate of kendall’s correlation between Z2 and Z3= 0.4418381
>
> ####Spearsman’s Correlation
> cat("Estimate of Spearma’s correlation between Z1 and Z2=",cor(Z[,1],Z[,2],method="spearman"), "n")
Estimate of Spearma’s correlation between Z1 and Z2= 0.6179661
> cat("Estimate of Spearman’s correlation between Z1 and Z3=",cor(Z[,1],Z[,3],method="spearman"), "n")
Estimate of Spearman’s correlation between Z1 and Z3= 0.4013849
> cat("Estimate of Spearman’s correlation=",cor(Z[,2],Z[,3],method="spearman"), "n")
Estimate of Spearman’s correlation= 0.6231296
> ####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
##2a Maximum Liklihood estimate
Xdata<-c(0.15,0.10,0.39,0.17,8.39,30.77,2.53,0.26,8.71,85.99)
Npara<-length(Xdata)
mTrue<-mean(Xdata)
SigTrue<-sd(Xdata)
sim<-exp(rnorm(1000,mTrue,SigTrue))
sigMLE<-sd(log(sim))
cat("MLE lamda=", "MLE sigma=", sigMLE,"n")
##2b Posterior Mean and sdev
#Postrior mean and standard devition
cat("mu MCMC Posterior mean=",mean(Xdata), "Posterior Standard deviaion=", sd (Xdata))
## 2c
##Bayes Posterior Mean and Sdve
Posteriormean=mean(Xdata)
Posteriormean
[1] 13.746
PosteriorSdev=sd(Xdata)
PosteriorSdev
[1] 27.08933
mydata=rgamma(100,1,0.5)
nMydata=mean(mydata)
sigMydata=sd(mydata)
cat("Alpha Estimate=",nMydata,"Sigma Estimate=",sigMydata)
Alpha Estimate= 1.907266 Sigma Estimate= 1.779147
Mydata
## 2a Maximum Liklihood estimate
Xdata<-c(0.15,0.10,0.39,0.17,8.39,30.77,2.53,0.26,8.71,85.99)
> Npara<-length(Xdata)
> mTrue<-mean(Xdata)
> SigTrue<-sd(Xdata)
> sim<-exp(rnorm(1000,mTrue,SigTrue))
> sigMLE<-sd(log(sim))
> cat("MLE lamda=", "MLE sigma=", sigMLE,"n")
MLE lamda= MLE sigma= 27.16486
##2b Posterior Mean and sdev
> #Postrior mean and standard devition > cat("mu MCMC Posterior mean=",mean(Xdata), "Posterior Standard deviaion=", sd (Xdata)) mu MCMC Posterior mean= 13.746 Posterior Standard deviaion= 27.08933 | |
|
###Question 2d
mydata=rgamma(100,1,0.5)
> nMydata=mean(mydata)
> sigMydata=sd(mydata)
> cat("Alpha Estimate=",nMydata,"Sigma Estimate=",sigMydata)
Alpha Estimate= 1.907266 Sigma Estimate= 1.779147
> Mydata
[1] 2.44136898 0.85149048 0.41384965 0.84938249 0.58331153 1.27044932 2.12686491
[8] 1.36902755 9.52569191 5.68138784 0.76164651 1.92839205 0.67777985 2.06393150
[15] 0.72339954 3.62025169 0.17015991 0.63162312 0.73862618 6.11082158 0.34913997
[22] 4.95750348 6.29234613 8.63575314 2.70652608 1.01832155 0.58920045 2.30464240
[29] 1.28160445 1.47862286 1.34225547 0.21040981 0.43350751 0.61302264 2.82009340
[36] 0.67102777 0.05862084 3.90269521 2.02580475 2.72265960 1.21655099 0.43253271
[43] 0.45952903 0.47923713 0.02389339 0.89271301 2.84006227 4.54072762 1.46763958
[50] 2.14184923 0.81090395 2.29649594 0.51929692 3.38478321 0.15130158 1.13247705
[57] 1.01459582 3.19501380 0.09954389 0.77016261 0.55715698 1.48989538 0.58341984
[64] 0.47705564 0.15832176 1.75816313 4.04534005 0.27093537 0.76474419 0.60988719
[71] 0.17588551 0.34920563 0.28925759 0.79391739 2.48770786 0.04930602 2.59389880
[78] 2.86008462 4.52476874 0.84937332 0.39871474 0.78114947 0.44275953 0.64414873
[85] 3.99213029 3.16239544 2.40686075 7.15048162 0.40343135 0.87551093 0.91287086
[92] 0.05226923 2.54082561 1.85557218 0.75560271 1.49962976 1.79272573 1.02665746
[99] 1.01812117 2.24809242
Buy ACST840 Quantitative Research Methods For Operational Risk Modelling Answers Online
Talk to our expert to get the help with ACST840 Quantitative Research Methods For Operational Risk Modelling Answers to complete your assessment on time and boost your grades now
The main aim/motive of the management assignment help services is to get connect with a greater number of students, and effectively help, and support them in getting completing their assignments the students also get find this a wonderful opportunity where they could effectively learn more about their topics, as the experts also have the best team members with them in which all the members effectively support each other to get complete their diploma assignments. They complete the assessments of the students in an appropriate manner and deliver them back to the students before the due date of the assignment so that the students could timely submit this, and can score higher marks. The experts of the assignment help services at urgenthomework.com are so much skilled, capable, talented, and experienced in their field of programming homework help writing assignments, so, for this, they can effectively write the best economics assignment help services.