Dynamic conditional correlations

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

startz
Non-normality and collinearity are NOT problems!
Posts: 3798
Joined: Wed Sep 17, 2008 2:25 pm

Re: Dynamic conditional correlations

Postby startz » Mon Sep 16, 2013 5:54 pm

Try setting "warn on close" under options/general.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Dynamic conditional correlations

Postby EViews Gareth » Mon Sep 16, 2013 5:56 pm

Be careful if you use Word to program in. Office products use "smartquotes", which can kill EViews programs when you copy an paste them.

barryoli
Posts: 18
Joined: Sun Sep 01, 2013 10:52 pm

Re: Dynamic conditional correlations

Postby barryoli » Tue Sep 17, 2013 4:21 pm

I'm on a roll!
Fixed the warning on close- Thanks for that!

Since I've fixed the warning this resolves the word issue- thanks for that too!

Next step...I've found a DCC codes and I'm trying to run it.
I can understand the code to some limited extent but I'm stuck on the sample.
I've read some of the other posts and they have mentioned a similar issue but I just don't get it...'thick' is a good description...:-(

Anyway, I've attached my eviews workfile and the program file...any help once again very much appreciated.

Cheers
Barry
Attachments
dcc.prg
(2.26 KiB) Downloaded 350 times
trubador.wf1
(1014.93 KiB) Downloaded 273 times

barryoli
Posts: 18
Joined: Sun Sep 01, 2013 10:52 pm

Re: Dynamic conditional correlations

Postby barryoli » Thu Sep 19, 2013 4:22 pm

Anyone have any ideas on where I might be able to begin...anything?...:-(

I've found someone who can do it in Matlab in a couple of weeks...I've a program in RATs from someone else...

Maybe i've picked the wrong application to start this project??

Anyway, I shall leave if for a few more days and if no success I shall jump ship.

Thanks to those who have helped me so far.

Cheers
Barry

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Dynamic conditional correlations

Postby trubador » Fri Sep 20, 2013 12:51 am

Change the following line:

Code: Select all

'estimate the model pagesmpl 1
with this one:

Code: Select all

'estimate the model smpl !beg+1 @last

barryoli
Posts: 18
Joined: Sun Sep 01, 2013 10:52 pm

Re: Dynamic conditional correlations

Postby barryoli » Fri Sep 20, 2013 1:08 am

OMG!!! I was that close?????

Thank you so much for your help!

Now I'm off to learn more about this beast DCC and eviews!

Hopefully, you won't see me here again!
(although I wouldn't bet on that!)

Thanks, thanks, thanks...

Cheers
Barry

barryoli
Posts: 18
Joined: Sun Sep 01, 2013 10:52 pm

Re: Dynamic conditional correlations

Postby barryoli » Thu Oct 17, 2013 4:50 pm

Hi guys,
I've been running this program (DCC below)- seems to work ok. However, where i'm getting stuck is that it only works when I've got data beginning on row one. I'm trying to get it to work on a new data set where one of the series doesn't have any data for a few rows. I'd like to get it to run somewhat generic so it runs on different data sets (obviously I'll need to change the two series names but that's not such a bit problem). The problem I seem to be having is that it crashes if one of the series has a NA at the beginning. If there anyway i can get it to begin where the first obs is rather than the first row?

It also doesn't like it when my data is monthly rather than undated- as soon as I put the data into a monthly format it crashes...this isn't a major problem but it would be nice to get the program to run generically.

Cheers and thanks for any help.




'change path to program path
%path=@runpath
cd %path


'Determine the sample range
%pagesmpl = @pagesmpl
%beg = @word(%pagesmpl,1)
!beg = @dtoo(%beg)
scalar pi=3.14159

'defining the return series in terms of y1 and y2
series y1=ret_jaci
series y2=ret_asia


'fitting univariate GARCH(1,1) models to each of the two returns series
equation eq_y1.arch(1,1,m=1000,h) y1 c
equation eq_y2.arch(1,1,m=1000,h) y2 c

'extract the standardized residual series from the GARCH fit
eq_y1.makeresids(s) z1
eq_y2.makeresids(s) z2

'extract garch series from univariate fit
eq_y1.makegarch() garch1
eq_y2.makegarch() garch2

'Caculate sample variance of series z1, z2 and covariance of z1and z2 and correlation between z1 and z2
scalar var_z1=@var(z1)
scalar var_z2=@var(z2)
scalar cov_z1z2=@cov(z1,z2)
scalar corr12=@cor(z1,z2)

'defining the starting values for the var(z1) var(z2) and covariance (z1,z2)
series var_z1t=var_z1
series var_z2t=var_z2
series cov_z1tz2t=cov_z1z2

'declare the coefficient starting values
coef(2) T
T(1)=0.2
T(2)=0.7

' ...........................................................
' LOG LIKELIHOOD for correlation part
' set up the likelihood
' 1) open a new blank likelihood object and name it 'dcc'
' 2) specify the log likelihood model by append
' ...........................................................

logl dcc
dcc.append @logl logl

'specify var_z1t, var_z2t, cov_z1tz2t
dcc.append var_z1t=@nan(1-T(1)-T(2)+T(1)*(z1(-1)^2)+T(2)*var_z1t(-1),1)
dcc.append var_z2t=@nan(1-T(1)-T(2)+T(1)*(z2(-1)^2)+T(2)*var_z2t(-1),1)
dcc.append cov_z1tz2t=@nan((1-T(1)-T(2))*corr12+T(1)*z1(-1)*z2(-1)+T(2)*cov_z1tz2t(-1),1)

dcc.append pen=(var_z1t<0)+(var_z2t<0)

'specify rho12
dcc.append rho12=cov_z1tz2t/@sqrt(@abs(var_z1t*var_z2t))

'defining the determinant of correlation matrix and determinant of Dt
dcc.append detrRt=(1-(rho12^2))
dcc.append detrDt=@sqrt(garch1*garch2)
dcc.append pen=pen+(detrRt<0)
dcc.append detrRt=@abs(detrRt)

'define the log likelihood function
dcc.append logl=(-1/2)*(2*log(2*pi)+log(detrRt)+(z1^2+z2^2-2*rho12*z1*z2)/detrRt)-10*pen

'estimate the model
smpl !beg+1 @last
dcc.ml(showopts, m=500, c=1e-5)

'display output and graphs
show dcc.output
graph corr.line rho12
show corr

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Dynamic conditional correlations

Postby trubador » Mon Oct 21, 2013 6:44 am

Generic use of such codes requires extensive programming, which as you give it a try you'll become more grateful for having the developers.

There might be other problems in the data even in terms of missing values. For instance, since ARCH estimation requires no missing values in the data, you should also be careful about discontinuities. And multivariate extension requires exact match of the series in your data. For now, you can try the following workaround:

Code: Select all

... 'defining the return series in terms of y1 and y2 series y1=ret_jaci series y2=ret_asia group ygr.add y1 y2 pagecontract if @rnas(ygr)=0 'Determine the sample range %pagesmpl = @pagesmpl %beg = @word(%pagesmpl,1) !beg = @dtoo(%beg) scalar pi=3.14159 ...
As for the second, the code seems OK with handling the dated workfile. If you continue to have the problem, you can try using %beg directly instead of !beg.

barryoli
Posts: 18
Joined: Sun Sep 01, 2013 10:52 pm

Re: Dynamic conditional correlations

Postby barryoli » Mon Oct 21, 2013 5:31 pm

Thanks...I appreciate whatever you guys do...you've already been a great help.

Cheers
Barry.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest