Problem with a simple loop

For questions regarding programming in the EViews programming language.

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

epeter
Posts: 16
Joined: Wed May 28, 2014 1:59 am

Problem with a simple loop

Postby epeter » Wed Nov 19, 2014 9:12 am

Hi everyone and thanks in advance for your help! I have a quite ridiculous problem with the easiest loop ever.
After running an autoregressive model I am trying to perform a simple operation with the coefficients of the regression. I would like to calculate the long term value using all the AR coefficients i've run (i.e. 10), thus i wrote the following:

Code: Select all

for !p = 2 to 10 table longterm longterm(1,1)= c(1)/(1-c(1+!p)) next
Unfortunately the code doesn't perform the whole operation, in fact it calculates the following:
c(1)/(1-c(11))
While i was expecting:
c(1)/(1-c(11)-c(10)-c(9)-...-c(2))

Hope someone of you can help me.
thank you all!!

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

Re: Problem with a simple loop

Postby EViews Gareth » Wed Nov 19, 2014 9:49 am

Code: Select all

table longterm !sum=0 for !p = 2 to 10 !sum = !sum + c(1+!p) next longterm(1,1)= c(1)/(1-!sum)

epeter
Posts: 16
Joined: Wed May 28, 2014 1:59 am

Re: Problem with a simple loop

Postby epeter » Thu Nov 20, 2014 1:45 am

Thank you Gareth! That's exactly what I was looking for. 8)


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests