Illegal length specification for @MOV

For questions regarding programming in the EViews programming language.

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

cc100
Posts: 62
Joined: Wed Jul 22, 2015 1:58 pm

Illegal length specification for @MOV

Postby cc100 » Tue Aug 11, 2015 8:00 am

Hi,

I have the following code:

!window = 1300
group g_ma
for !i=1 to group01_rates.count
%name=group01_rates.@seriesname(!i)
series {%name}_ma = @movav({%name}, !window+1)
g_ma.add {%name}_ma
next

As you can see I am just computing simple moving averages of the series in my group. The range has 4832 observations. When I have a window size of 720 it works, also works for 1000. It seems to randomly fail for some numbers, it fails for 1200 and 1300 for example but works for 1100. The error message is Illegal length specification for @MOVAV, @MOVSUM, or @LAG in "SERIES {%NAME}_MAV = @MOVAV(<seriesname>, 1300+1). I don't understand why it is failing when the number of observations is greater than my lag. Am i missing something terribly obvious?? Thanks!

cc100
Posts: 62
Joined: Wed Jul 22, 2015 1:58 pm

Re: Illegal length specification for @MOV

Postby cc100 » Tue Aug 11, 2015 8:04 am

it works when I use @mav instead of @movav, but i don't know why it works :(

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

Re: Illegal length specification for @MOV

Postby EViews Gareth » Tue Aug 11, 2015 9:14 am

Try this:

Code: Select all

!length = !window+1 series {%name}_ma = @movav({%name}, !length)

cc100
Posts: 62
Joined: Wed Jul 22, 2015 1:58 pm

Re: Illegal length specification for @MOV

Postby cc100 » Wed Aug 12, 2015 12:04 am

Hi Gareth - thanks for the reply.. I tried that but it still doesn't work. I get the same error msg (Illegal length specification for @MOVAV, @MOVSUM, or @LAG in "series {%name}_mav = @MOVAV(<seriesname>, 1301)". It seems like it can't go above some value somewhere between 1150 and 2000! But I don't know why when the range has 4832 observations.

cc100
Posts: 62
Joined: Wed Jul 22, 2015 1:58 pm

Re: Illegal length specification for @MOV

Postby cc100 » Wed Aug 12, 2015 1:03 am

..attached is the program which is failing on changing the window size above a certain value (seems to work up to 1500!)
Attachments
test program for gareth.prg
(623 Bytes) Downloaded 474 times

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

Re: Illegal length specification for @MOV

Postby EViews Gareth » Wed Aug 12, 2015 8:02 am

Yeah, you're hitting a limit on how many terms you can have inside @mov.

To be honest, it is exceedingly rare to have more than, say, 5 terms inside @mov. 2000 is a tad high.

cc100
Posts: 62
Joined: Wed Jul 22, 2015 1:58 pm

Re: Illegal length specification for @MOV

Postby cc100 » Wed Aug 12, 2015 8:18 am

Is there another way of finding the moving average where there is no upper limit?

This is actually part of some other code where I am running a PCA over a rolling window - I need to be able to adjust the rolling window up to about 10 years, and only need this movav step so that I can add back the mean to the recalculated data (PCA estimated data).

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

Re: Illegal length specification for @MOV

Postby EViews Gareth » Wed Aug 12, 2015 8:27 am

Use @mav :D

cc100
Posts: 62
Joined: Wed Jul 22, 2015 1:58 pm

Re: Illegal length specification for @MOV

Postby cc100 » Wed Aug 12, 2015 8:37 am

hehe i knew you were going to say that :) I'm just fiddling now to get rid of the first few sets of rows as @mav does not propagate NAs ..

Anyway - thanks Gareth for answering all my queries :)

cc100
Posts: 62
Joined: Wed Jul 22, 2015 1:58 pm

Re: Illegal length specification for @MOV

Postby cc100 » Wed Aug 12, 2015 9:01 am

by the way, is there any chance of having the limit on the movav function removed? :D or at least matched to the limit on the mav function? Thanks! :)


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest