## Rolling VaR estimates

For questions regarding programming in the EViews programming language.

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

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

### Rolling VaR estimates

.
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

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

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

### Re: Rolling VaR estimates

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

.
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

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!!

Thanks.

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

### Re: Rolling VaR estimates

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

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: 13096
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Rolling VaR estimates

Code: Select all

%smpl = @str(!i) + " 1250"
scalar x = @elem(ewma, %smpl)

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

### Re: Rolling VaR estimates

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: 13096
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Rolling VaR estimates

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.

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

### Re: Rolling VaR estimates

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

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: 13096
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Rolling VaR estimates

Code: Select all

scalar x = @elem(ewma, "1251")

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

### Re: Rolling VaR estimates

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

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

### Re: Rolling VaR estimates

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