Mean in model

For questions regarding programming in the EViews programming language.

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

Katjes
Posts: 56
Joined: Thu Oct 02, 2008 5:46 am

Mean in model

Postby Katjes » Fri May 04, 2012 1:37 am

Hi there,
I need to implement a formula that take quarterly data (e.g. AA) and is multiplied with the mean of the previous YEAR (NOT the last 4 values!!), which seems difficult to implement, in particular if I would add the formula to a model.

In case that I take only the previous value (instead of the mean of the previous year) it is easy

Code: Select all

genr AGG=AA*AB(-1)/AC(-1)+BA*BB(-1)/AC(-1)
model.append AGG=AA*AB(-1)/AC(-1)+BA*BB(-1)/AC(-1)


Then I tried at least for ex-post data to calculate the formula
'if we calculate the mean over the previous YEAR

Code: Select all

for !i=0 to 100
   smpl 1991.1+!i 1991.4+!i 'ex  post
   series mean_AB=@mean(AB)
   series mean_BB=@mean(BB)
   series mean_AC=@mean(AC)
!i=!i+3
next  '--> this gives you the same (mean) value in each quarter
   
genr    AGG=AA*mean_AB(-4)/mean_AC(-4)+BA*mean_BB(-4)/mean_AC(-4)
model.append '?????


But in which way I can add this to a model which will run over the next years?

Any suggestions for improvement and simplification?

Katjes
Posts: 56
Joined: Thu Oct 02, 2008 5:46 am

Re: Mean in model

Postby Katjes » Tue Jul 10, 2012 8:26 am

After a while I find an easy solution:
for each variable %G

Code: Select all

   genr mean_{%g}=@MOVAV({%g},4)
      {%model}.append mean_{%g}=@MOVAV(310,4)

'and then add the mean values:
{%model}.append AGG=AA*mean_AB(-4)/mean_AC(-4)+AB*mean_AB(-4)/mean_AC(-4)


Return to “Programming”

Who is online

Users browsing this forum: Google [Bot] and 38 guests