Estimation of VAR(1)-GARCH(1,1) model
Re: Estimation of VAR(1)-GARCH(1,1) model
You can't print a FRML, but you can create a series with its values:
set r1 = e_r1
set r2 = e_r2
print / r1 r2
set r1 = e_r1
set r2 = e_r2
print / r1 r2
Re: Estimation of VAR(1)-GARCH(1,1) model
Dear Tom,
I wants to estimate the VAR(1)-GARCH(1,1) model with following command
the number of observations are 359. The model did not converge with different values of pre iterations and I try this with BHHH and BFGH methods.
How to resolve this problem of estimation? Please help me in resolving this issue of convergence.
Regards, Irfan
I wants to estimate the VAR(1)-GARCH(1,1) model with following command
Code: Select all
system(model=V1)
variables rkse rwti
lags 1
det constant
end(system)
*estiamte
garch(model=V1, p=1,q=1,mv=cc,variance=varma,mvhseries=hhkse_wti,stdresids=reskse_wti,pmethod=simplex,piteration=13, robust,method=bfgh)How to resolve this problem of estimation? Please help me in resolving this issue of convergence.
Regards, Irfan
- Attachments
-
- datafile.xlsx
- (17.63 KiB) Downloaded 760 times
Re: Estimation of VAR(1)-GARCH(1,1) model
Have you looked at your data? The RKSE is basically dead flat for almost 20% of the data set (in the middle no less). It's not surprising that you have a hard time fitting a multivariate GARCH model to the pair.
Re: Estimation of VAR(1)-GARCH(1,1) model
Dear Tom Hello again.
I write the codes for EGARCH model of Nelson(1991) given below.
Then I estimate the model and the results are
Again I estimate the same model by using built-in command of RATS
the results are as under
I have estimated the same model using Eviews for same data the results are identical with the built-in command results of RATS. Why the results are so much different with each other? If you look at the likelihood value they are almost identical. Is there any mistake in my coding? What should I do to get identical results?
The data file is attached with this post.
I write the codes for EGARCH model of Nelson(1991) given below.
Code: Select all
nonlin c1 c2 c3 c4 c5
frml e = dollar(t)-c1
set h = .01
frml var = c2+c3*(abs(e(t-1)/h(t-1))-sqrt(2/%pi))+c4*log(h(t-1))+c5*(e(t-1)/h(t-1))
frml gln = h=exp(var(t)), %logdensity(h, e)
smpl 3 3388
compute c1= .17, c2 = 0.13, c3 = 0.8, c4 = .1, c5 = .0003
maximize(method=bfgh,iterations=500,rob) gln
Code: Select all
MAXIMIZE - Estimation by BFGS
Convergence in 41 Iterations. Final criterion was 0.0000026 <= 0.0000100
With Heteroscedasticity/Misspecification Adjusted Standard Errors
Usable Observations 3386
Function Value -2308.0730
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. C1 -0.001845425 0.007264174 -0.25404 0.79946099
2. C2 0.002808800 0.002303969 1.21911 0.22280117
3. C3 0.035622732 0.003410383 10.44537 0.00000000
4. C4 1.019540332 0.002793323 364.99189 0.00000000
5. C5 0.010143690 0.002605036 3.89388 0.00009865
Code: Select all
GARCH(P=1,Q=1,EXP,ASYMMETRIC,rob) / DOLLARCode: Select all
GARCH Model - Estimation by BFGS
Convergence in 26 Iterations. Final criterion was 0.0000000 <= 0.0000100
With Heteroscedasticity/Misspecification Adjusted Standard Errors
Dependent Variable DOLLAR
Usable Observations 3386
Log Likelihood -2297.7150
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. Mean(DOLLAR) -0.003623162 0.007336290 -0.49387 0.62139904
2. C -0.059493771 0.008272032 -7.19216 0.00000000
3. A 0.073091975 0.009842794 7.42594 0.00000000
4. B 0.995051320 0.001739255 572.11338 0.00000000
5. D 0.016531933 0.006827503 2.42137 0.01546200
I have estimated the same model using Eviews for same data the results are identical with the built-in command results of RATS. Why the results are so much different with each other? If you look at the likelihood value they are almost identical. Is there any mistake in my coding? What should I do to get identical results?
The data file is attached with this post.
- Attachments
-
- awan.xlsx
- (86.72 KiB) Downloaded 795 times
Re: Estimation of VAR(1)-GARCH(1,1) model
You're dividing e by the variance, not the standard deviation. (You also are using an unrealistically small pre-sample value for h, though that will have only a minor effect on a data set this large).
Re: Estimation of VAR(1)-GARCH(1,1) model
Dear Tom,
Thanks for your reply and I got the point and restimate the model got almost identical results.
Now I have another problem; I write the codes of Bivariate EGARCH model (Koutmos). When I estimate the model with my codes and built-in codes the results are not identical. Please check my codes. I shall be very much pleased with your guidance. I have tried different per-iterations but still discrepancy in results...
My codes result
Built-in Code Result
Data file is attached...............
Thanks for your reply and I got the point and restimate the model got almost identical results.
Now I have another problem; I write the codes of Bivariate EGARCH model (Koutmos). When I estimate the model with my codes and built-in codes the results are not identical. Please check my codes. I shall be very much pleased with your guidance. I have tried different per-iterations but still discrepancy in results...
Code: Select all
open data d-spcscointc.txt
data(format=free,org=columns,top=2) 1 2275 sp500 cisco intel
set r1 = sp500
set r2 = cisco
*
*
stats(noprint) r1
set h1 = %variance
stats(noprint) r2
set h2 = %variance
*
nonlin a10 a20 a11 a12 a21 a22 c10 c20 c11 c12 c21 c22 d1 d2 d11 d22 rho
frml e_r1 = r1(t)-a10-a11*r1(t-1)-a12*r2(t-1)
frml e_r2 = r2(t)-a20-a21*r1(t-1)-a22*r2(t-1)
frml fr1 = (abs(e_r1/sqrt(h1))-sqrt(2/%pi))
frml fr2 = (abs(e_r2/sqrt(h2))-sqrt(2/%pi))
frml asy1 = e_r1/sqrt(h1) * asymetric codes
frml asy2 = e_r2/sqrt(h2) * asymetric codes
frml var_r1 = exp(c10+c11*(fr1(t-1)+d11*asy1(t-1))+c12*(fr2(t-1)+d22*asy2(t-1))+d1*log(h1(t-1))
frml var_r2 = exp(c20+c21*(fr1(t-1)+d11*asy1(t-1))+c22*(fr2(t-1)+d22*asy2(t-1))+d2*log(h2(t-1))
frml gln = h1 = var_r1(t), h2 = var_r2(t), %logdensity(||h1|rho*sqrt(h1*h2),h2||,||r1,r2||)
smpl 3 2275
compute a10 = 01, a20 = .2, a11 = .03, a12 = .04, a21 = .09, a22 = .08
compute c10 = .01, c20 = .04, c11= .04, c22 = .014, c12=.08, c21=.06, rho=.05
compute d1 = .01, d2 = .08, d11 = .04, d12 = .08, d21 = .088, d22 = .03
maximize(method=bfgh,ite=500) gln
Code: Select all
GARCH(P=1,Q=1,MV=CC,VARIANCES=KOUTMOS,REGRESSORS) / R1 R2
# Constant R1{1} R2{1}
Code: Select all
MAXIMIZE - Estimation by BFGS
Convergence in 371 Iterations. Final criterion was 0.0000018 <= 0.0000100
Usable Observations 2273
Function Value -7806.3133
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. A10 0.94654129 0.01186322 79.78789 0.00000000
2. A20 -0.96897829 0.01572007 -61.63958 0.00000000
3. A11 1.79161573 0.02272365 78.84367 0.00000000
4. A12 -1.70074997 0.01836631 -92.60160 0.00000000
5. A21 -14.10914474 0.06518259 -216.45571 0.00000000
6. A22 0.83065515 0.00371228 223.75862 0.00000000
7. C10 -0.14594409 0.01654922 -8.81879 0.00000000
8. C20 0.03537544 0.01832068 1.93090 0.05349513
9. C11 0.00717189 0.00179060 4.00529 0.00006194
10. C12 0.04181039 0.00430738 9.70668 0.00000000
11. C21 0.02385552 0.00251985 9.46704 0.00000000
12. C22 0.02444275 0.00346553 7.05312 0.00000000
13. D1 0.92168316 0.00871321 105.78001 0.00000000
14. D2 0.91104776 0.01202741 75.74760 0.00000000
15. D11 0.13514001 0.22268733 0.60686 0.54394389
16. D22 -0.54256036 0.05862743 -9.25438 0.00000000
17. RHO 0.52085735 0.01427604 36.48473 0.00000000
Code: Select all
MV-CC GARCH with Koutmos EGARCH Variances - Estimation by BFGS
Convergence in 71 Iterations. Final criterion was 0.0000087 <= 0.0000100
Usable Observations 2273
Log Likelihood -7779.2762
Variable Coeff Std Error T-Stat Signif
************************************************************************************
Mean Model(R1)
1. Constant 0.046929299 0.014274026 3.28774 0.00100995
2. R1{1} 0.003722419 0.023733139 0.15684 0.87536719
3. R2{1} 0.015022205 0.005620426 2.67279 0.00752238
Mean Model(R2)
4. Constant 0.215860800 0.050275648 4.29355 0.00001758
5. R1{1} -0.035825474 0.067177772 -0.53329 0.59383037
6. R2{1} 0.048751335 0.021288114 2.29007 0.02201708
7. C(1) -0.094504902 0.013451492 -7.02561 0.00000000
8. C(2) -0.006286595 0.016493744 -0.38115 0.70309173
9. A(1,1) 0.117605462 0.015763261 7.46073 0.00000000
10. A(1,2) -0.020509391 0.012259182 -1.67298 0.09433085
11. A(2,1) -0.005126020 0.007676322 -0.66777 0.50428020
12. A(2,2) 0.105497797 0.017962805 5.87312 0.00000000
13. B(1) 0.980616989 0.004045214 242.41409 0.00000000
14. B(2) 0.969452251 0.006773487 143.12454 0.00000000
15. D(1) -0.537680096 0.097963254 -5.48859 0.00000004
16. D(2) -1.007991409 0.183890841 -5.48147 0.00000004
17. R(2,1) 0.519248141 0.014852537 34.96023 0.00000000
- Attachments
-
- d-spcscointc.txt
- (55.57 KiB) Downloaded 870 times
Last edited by irfanawan on Sun Sep 20, 2015 10:13 pm, edited 1 time in total.
Re: Estimation of VAR(1)-GARCH(1,1) model
Your Dxx's aren't right in this---I think you mean D11 then D22 in the second line.
frml var_r1 = exp(c10+c11*(fr1(t-1)+d11*asy1(t-1))+c12*(fr2(t-1)+d22*asy2(t-1))+d1*log(h1(t-1))
frml var_r2 = exp(c20+c21*(fr1(t-1)+d22*asy1(t-1))+c22*(fr2(t-1)+d22*asy2(t-1))+d2*log(h2(t-1))
frml var_r1 = exp(c10+c11*(fr1(t-1)+d11*asy1(t-1))+c12*(fr2(t-1)+d22*asy2(t-1))+d1*log(h1(t-1))
frml var_r2 = exp(c20+c21*(fr1(t-1)+d22*asy1(t-1))+c22*(fr2(t-1)+d22*asy2(t-1))+d2*log(h2(t-1))
Re: Estimation of VAR(1)-GARCH(1,1) model
Dear Tom,
I edit my last post and correct the error in program that you have mentioned in your comment. Still the results are different from each other i.e. results of my codes and built-in codes.I have tried to run my codes with different pre-iterations but same problem.
What should I do to get almost identical results?
Regards, Irfan Malik
I edit my last post and correct the error in program that you have mentioned in your comment. Still the results are different from each other i.e. results of my codes and built-in codes.I have tried to run my codes with different pre-iterations but same problem.
What should I do to get almost identical results?
Regards, Irfan Malik
Re: Estimation of VAR(1)-GARCH(1,1) model
This is using the data rather than the residuals in evaluating the likelihood
frml gln = h1 = var_r1(t), h2 = var_r2(t), %logdensity(||h1|rho*sqrt(h1*h2),h2||,||r1,r2||)
frml gln = h1 = var_r1(t), h2 = var_r2(t), %logdensity(||h1|rho*sqrt(h1*h2),h2||,||r1,r2||)
Re: Estimation of VAR(1)-GARCH(1,1) model
dear Tom,
I wants to estimate the bi-variate EGARCH models which I have discussed with you in previous post but with dynamic correlation structure. Mathematics for dynamic correlation is given file attached with this post.
I write the codes for this mathematics and modified my likelihood function. The complete codes for bi-variate EGRCH model with dynamic correlation structure as
when I run my codes with same data which was uploaded in previous post, the RATS exe stop working. What I should do to overcome this problem?
Regards, Irfan
I wants to estimate the bi-variate EGARCH models which I have discussed with you in previous post but with dynamic correlation structure. Mathematics for dynamic correlation is given file attached with this post.
I write the codes for this mathematics and modified my likelihood function. The complete codes for bi-variate EGRCH model with dynamic correlation structure as
Code: Select all
open data d-spcscointc.txt
data(format=free,org=columns,top=2) 1 2275 sp500 cisco intel
set r1 = sp500
set r2 = cisco
*
* This replaces your initialization of variances to zero.
*
stats(noprint) r1
set h1 = %variance
stats(noprint) r2
set h2 = %variance
*
nonlin a10 a20 a11 a12 a21 a22 c10 c20 c11 c12 c21 c22 d1 d2 d11 d22 c30 c31 c32
frml e_r1 = r1(t)-a10-a11*r1(t-1)-a12*r2(t-1)
frml e_r2 = r2(t)-a20-a21*r1(t-1)-a22*r2(t-1)
frml fr1 = (abs(e_r1/sqrt(h1))-sqrt(2/%pi))
frml fr2 = (abs(e_r2/sqrt(h2))-sqrt(2/%pi))
frml asy1 = e_r1/sqrt(h1)
frml asy2 = e_r2/sqrt(h2)
frml var_r1 = exp(c10+c11*(fr1(t-1)+d11*asy1(t-1))+c12*(fr2(t-1)+d22*asy2(t-1))+d1*log(h1(t-1)))
frml var_r2 = exp(c20+c21*(fr1(t-1)+d11*asy1(t-1))+c22*(fr2(t-1)+d22*asy2(t-1))+d2*log(h2(t-1)))
frml u = c30+c31*fr1(t-1)*fr2(t-1)+c32*u(t-1)
frml rho = (1-exp(-u(t)))/(1+exp(-u(t)))
frml gln = h1 = var_r1(t), h2 = var_r2(t),correl=rho(t), %logdensity(||h1|correl*sqrt(h1*h2),h2||,||e_r1,e_r2||)
smpl 3 2275
compute a10 = 01, a20 = .2, a11 = .03, a12 = .04, a21 = .09, a22 = .08
compute c10 = .01, c20 = .04, c11= .04, c22 = .014, c12=.08, c21=.06
compute d1 = .01, d2 = .08, d11 = .04, d12 = .08, d21 = .088, d22 = .03
compute c30=.04, c31=.004,c32=0.08
maximize(method=bfgh,ite=500,pit=30,pmet=sim) gln
Regards, Irfan
- Attachments
-
- corrl.pdf
- (126.31 KiB) Downloaded 681 times
Re: Estimation of VAR(1)-GARCH(1,1) model
This is recursively defined, which doesn't work:
frml u = c30+c31*fr1(t-1)*fr2(t-1)+c32*u(t-1)
U(t) can't be computed without u(t-1) which can't be computed without u(t-2), ...
You need to create a series of the values for U and use that in the definition of U. You need to look carefully at our examples and see how different series are used. You are using the FRML references way too many times. Anything that's lagged should have been saved into a series at T-1 so you don't have to recompute it, even if there isn't an issue with a self-referencing formula, as it will be much more efficient.
frml u = c30+c31*fr1(t-1)*fr2(t-1)+c32*u(t-1)
U(t) can't be computed without u(t-1) which can't be computed without u(t-2), ...
You need to create a series of the values for U and use that in the definition of U. You need to look carefully at our examples and see how different series are used. You are using the FRML references way too many times. Anything that's lagged should have been saved into a series at T-1 so you don't have to recompute it, even if there isn't an issue with a self-referencing formula, as it will be much more efficient.
Re: Estimation of VAR(1)-GARCH(1,1) model
Dear Tom,
Hello.
I am bit confused with the multivariate GARCH models outputs (I have also try different VARIANCE options). I estiamte the model using following comand with options
I used the following comand to estimat the standarized residuals
I have the standarized residuals series in (n*2) martix obtained by using builtin command
and
When I Print the standardized residuals, the RES_1 and Z1 and the RES_2 and Z2 they are different from each other. The RES_1 and Z1 are slightly different from each other but RES_2 and Z2 are very much different from each other. This difference have an effect on the results of test of auto-correlation and ARCH test
By construction they should be identical with each other.
Please guide me in this regards
Irfan Malik
Pakistan
Hello.
I am bit confused with the multivariate GARCH models outputs (I have also try different VARIANCE options). I estiamte the model using following comand with options
Code: Select all
GARCH(MODEL=V1, P=1,Q=1,MV=CC,VARIANCE=VARMA,MVHSERIES=HH_1_2,asy, $
STDRESIDS=RES_1_2,PMETHOD=SIMPLEX,PITERATION=02,METHOD=BFGh,hmatrices=hh,rvectors=rd)
Code: Select all
set z1 = rd(t)(1)/sqrt(hh(t)(1,1))
set z2 = rd(t)(2)/sqrt(hh(t)(2,2))Code: Select all
STDRESIDS=RES_1_2Code: Select all
SET RES_1 = RES_1_2(1)
SET RES_2 = RES_1_2(2)
By construction they should be identical with each other.
Please guide me in this regards
Irfan Malik
Pakistan
Re: Estimation of VAR(1)-GARCH(1,1) model
STDRESIDS produces jointly standardized residuals, which theoretically have covariance matrix equal to the identity (if the model is correct). Simply dividing through by the standard deviations gives you univariate standardization, where the variances are theoretically 1, but there is no prediction for the covariances.
Re: Estimation of VAR(1)-GARCH(1,1) model
Dear Tom,
Thanks for your comments and now my question is for diagnostics testing which standardized residuals I have to use? Because the choice may alter the results.

Regards, Irfan
Thanks for your comments and now my question is for diagnostics testing which standardized residuals I have to use? Because the choice may alter the results.
Regards, Irfan
Re: Estimation of VAR(1)-GARCH(1,1) model
From the help for GARCH:
STDRESIDS=(output) VECT[SERIES] of (jointly) standardized residuals
FACTORBY=[CHOLESKY]/EIGENDECOMP
If the model is correct, then the jointly standardized residuals should be serially uncorrelated with mean zero and covariance matrix equal to the identity matrix with no residual GARCH effects. Given the model residuals and the series of estimated covariances, there are many (that is, an infinite number) of ways to transform them into jointly standardized residuals. You have the option of a Cholesky factorization or an eigen-based one. Note that different ways of doing the standardization will result in different standardized residuals and thus different diagnostics.
There's nothing you can do to avoid that. You should decide which you plan to use in advance, and stick with it, rather than trying different standardizations to get the results you want.
STDRESIDS=(output) VECT[SERIES] of (jointly) standardized residuals
FACTORBY=[CHOLESKY]/EIGENDECOMP
If the model is correct, then the jointly standardized residuals should be serially uncorrelated with mean zero and covariance matrix equal to the identity matrix with no residual GARCH effects. Given the model residuals and the series of estimated covariances, there are many (that is, an infinite number) of ways to transform them into jointly standardized residuals. You have the option of a Cholesky factorization or an eigen-based one. Note that different ways of doing the standardization will result in different standardized residuals and thus different diagnostics.
There's nothing you can do to avoid that. You should decide which you plan to use in advance, and stick with it, rather than trying different standardizations to get the results you want.