programming rolling moving averages

For questions regarding programming in the EViews programming language.

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

yoniboi
Posts: 16
Joined: Mon Oct 12, 2009 5:26 am

programming rolling moving averages

Postby yoniboi » Tue Oct 27, 2009 1:29 am

I am trying to program a rolling moving average, meaning i want to run

Code: Select all

'a is how many leaps back !a= 2 ' x is the series genr x =y matrix (!a , !a) mataic matrix (!a , !a) matschw matrix (!a , !a) mathq matrix (!a , !a) matlogl for !i =1 to !a for !j =1 to !a equation eq!i_!j eq!i_!j.ls x c x(-1 to -!i) ma(1 to !j) mataic(!i , !j) = eq!i_!j.@aic matschw(!i , !j) = eq!i_!j.@schwarz mathq(!i , !j) = eq!i_!j.@hq matlogl(!i , !j) = eq!i_!j.@logl next next
i want the output to give me 4 equations:

x c x(-1) ma(1)
x c x(-1) ma(1) ma(2)
x c x(-1) x(-2) ma(1)
x c x(-1) x(-2) ma(1) ma(2)

but what i am getting is:

x c x(-1) ma(1)
x c x(-1) ma(1)
x c x(-1) x(-2) ma(1)
x c x(-1) x(-2) ma(1)

i tried writing:

Code: Select all

eq!i_!j.ls x c x(-1 to -!i) ma(!j)
and i get:
x c x(-1) ma(1)
x c x(-1) ma(2)
x c x(-1) x(-2) ma(1)
x c x(-1) x(-2) ma(2)

is there a way to do this parsimoniously in the code?

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

Re: programming rolling moving averages

Postby EViews Gareth » Tue Oct 27, 2009 7:31 am


yoniboi
Posts: 16
Joined: Mon Oct 12, 2009 5:26 am

Re: programming rolling moving averages

Postby yoniboi » Tue Oct 27, 2009 7:50 am

thank you


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests