Rolling VaR estimates

For questions regarding programming in the EViews programming language.

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

Stu
Posts: 10
Joined: Fri Aug 09, 2013 5:34 pm

Rolling VaR estimates

Postby Stu » Sun Aug 11, 2013 7:51 am

.
Last edited by Stu on Mon Aug 19, 2013 3:56 am, edited 1 time in total.

Stu
Posts: 10
Joined: Fri Aug 09, 2013 5:34 pm

Re: Rolling VaR estimates

Postby Stu » Sun Aug 11, 2013 4:16 pm

Last edited by Stu on Mon Aug 19, 2013 7:56 am, edited 1 time in total.

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

Re: Rolling VaR estimates

Postby trubador » Mon Aug 12, 2013 2:30 am

Suppose you have a return series called rt. Then, for EWMA you can try:

Code: Select all

!alpha = 0.02 'you should provide an appropriate value for this parameter smooth(s,!alpha) rt^2 ewma
And as for GJR with t-distribution:

Code: Select all

arch(1,1,thrsh=1,tdist) rt c
Finally, to obtain the lower %1 quantile of a series y:

Code: Select all

scalar q1 = @quantile(y,0.01)
Please note that, all these commands (and many more) are available in the users guide.

Stu
Posts: 10
Joined: Fri Aug 09, 2013 5:34 pm

Re: Rolling VaR estimates

Postby Stu » Mon Aug 12, 2013 7:25 am

.
Last edited by Stu on Mon Aug 19, 2013 3:56 am, edited 1 time in total.

Stu
Posts: 10
Joined: Fri Aug 09, 2013 5:34 pm

Re: Rolling VaR estimates

Postby Stu » Mon Aug 12, 2013 8:34 am

I run the programs, but it keeps showing up error messages. And have tried to adpat the codes, but couldnt figure out what the problem is!!
Could someone please help, by perhaps even giving some hints at the problems? I very much appreciate your time!

Thanks.

Stu
Posts: 10
Joined: Fri Aug 09, 2013 5:34 pm

Re: Rolling VaR estimates

Postby Stu » Mon Aug 12, 2013 9:40 am

Last edited by Stu on Mon Aug 19, 2013 7:56 am, edited 1 time in total.

Stu
Posts: 10
Joined: Fri Aug 09, 2013 5:34 pm

Re: Rolling VaR estimates

Postby Stu » Mon Aug 12, 2013 9:51 am

Last edited by Stu on Mon Aug 19, 2013 7:56 am, edited 1 time in total.

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

Re: Rolling VaR estimates

Postby EViews Gareth » Mon Aug 12, 2013 10:41 am

Code: Select all

%smpl = @str(!i) + " 1250" scalar x = @elem(ewma, %smpl)
Follow us on Twitter @IHSEViews

Stu
Posts: 10
Joined: Fri Aug 09, 2013 5:34 pm

Re: Rolling VaR estimates

Postby Stu » Mon Aug 12, 2013 11:05 am

Gareth,

When i run it, it shows up 'Illegal date 1 1250 in “scalar x = @elem(ewma, "1 1250")"

What could be the problem here?

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

Re: Rolling VaR estimates

Postby EViews Gareth » Mon Aug 12, 2013 11:07 am

Sorry, I posted without thinking.

I don't understand what you're trying to do with that line. @elem takes a single date, not a range of dates.
Follow us on Twitter @IHSEViews

Stu
Posts: 10
Joined: Fri Aug 09, 2013 5:34 pm

Re: Rolling VaR estimates

Postby Stu » Mon Aug 12, 2013 11:13 am

Last edited by Stu on Mon Aug 19, 2013 7:57 am, edited 1 time in total.

Stu
Posts: 10
Joined: Fri Aug 09, 2013 5:34 pm

Re: Rolling VaR estimates

Postby Stu » Mon Aug 12, 2013 12:51 pm

Last edited by Stu on Mon Aug 19, 2013 7:57 am, edited 1 time in total.

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

Re: Rolling VaR estimates

Postby EViews Gareth » Mon Aug 12, 2013 1:04 pm

Code: Select all

scalar x = @elem(ewma, "1251")
Follow us on Twitter @IHSEViews

Stu
Posts: 10
Joined: Fri Aug 09, 2013 5:34 pm

Re: Rolling VaR estimates

Postby Stu » Mon Aug 12, 2013 1:13 pm

.
Last edited by Stu on Mon Aug 19, 2013 3:55 am, edited 1 time in total.

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

Re: Rolling VaR estimates

Postby trubador » Tue Aug 13, 2013 1:23 am

I tried to modify your code so as to perform what you want and to give you the idea for further adjustments. However, I suggest you to go over An Introduction to Eviews Programming before moving forward.

Code: Select all

!window = 1250 !length = @obsrange !alpha = 1-0.94 '1-alpha is the coefficient of estimated variance !scale = 10000 'it might be a good idea to adjust the scale series x 'create the output series beforehand matrix(!window,!length) results 'you can create a matrix to store all the resulting smoothed series ' move sample !step obs at a time for !i = 1 to !length-!window smpl @first+!i-1 @first+!i+!window-2 smooth(s,!alpha) !scale*returns^2 ewma stom(ewma,ewmat) 'convert series to a vector colplace(results,ewmat,!i) 'place the vector into the matrix x(!window+!i) = ewma(!window+!i) next smpl @all


Return to “Programming”

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests