Highlights
The function “my.garch11.filter”
where ?(1), ?(2), ?(3), ?(4) are defined as
Test Code
The following code can be used to test the functions above. This is also the code that is used to evaluate the accuracy of the submission.
1 library(tseries)
2 library(datasets)
3
4 # German stock market index
5 DAX <- as.vector(EuStockMarkets[,1])
6
7 ret <- diff(log(DAX))*100
8
9 plot(ret)
10 acf (abs(ret) , ylim=c(-0.2,1))
11
12 # 1) garch(1,1) filter
13 param <- c( var(ret)*(1-0.95) , 0.05 , 0.90 )
14
15 garch11 <- my.garch11.filter(ret,param)
16
17 plot( ret , lwd=1 )
18 lines( 1.96*sqrt(garch11$sig2) , lwd=3 , col=’red’ , t=’l’ )
19 lines( -1.96*sqrt(garch11$sig2) , lwd=3 , col=’red’ , t=’l’ )
20
21 qqnorm( garch11$z , col=’red’ )
22 qqline( garch11$z )
23
24 cat(’log-likelihood:’,garch11$loglik)
25
26 # 2) garch(1,1) objective function for estimation
27 loglik.good <- my.garch11.objective(ret,param)
28 loglik.bad <- my.garch11.objective(ret,c(var(ret),0.25,0.9))
29
30 # 3) garch(1,1) estimation
31 param.mle <- my.garch11.mle(ret,param)
32 param.bench <- garch(ret, order = c(1,1))$coef
33
34 # estimates are close but not be exactly the same.
35 # the numerical routines that maximise the likelihood use different algorithms
36 cbind( param.mle , param.bench )
37
38 # the min negative log likelihoods should be very close
39 print( c(my.garch11.objective(ret,param.mle),my.garch11.objective(ret,param.bench)) )
40
41 # fitte values
42 garch11.mle <- my.garch11.filter(ret,param.mle)
43 plot( sqrt(252*garch11.mle$sig2) , lwd=3 , col=’red’ , t=’l’ )
44
45 # 4) garch(1,1) inference
46 se.mle <- my.garch11.stderr(ret,param.mle,0.01)
47 se.bench <- sqrt(diag(garch(ret, order = c(1,1))$vcov))
48
49 # the standard errors should be of the same order of magnitude but differ
50 # as the variance covariance matrix estimators of the two garch routines
51 # are different
52 cbind( se.mle , se.bench )
53
54 # coefficient table
55 t.val = param.mle/se.mle
56 matcoef = cbind(param.mle, se.mle, t.val, 2*(1-pnorm(abs(t.val))))
57 dimnames(matcoef) = list(c(’omega’,’alpha’,’beta’), c(" Estimate"," Std. Error",
58 " t value", "Pr(>|t|)"))
59 cat("\nCoefficient(s):\n")
60 printCoefmat(matcoef, digits = 3, signif.stars = TRUE)
This Statistics Assignment has been solved by our Statistics experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.