Page 1 of 1

Problem with a simple loop

Posted: Wed Nov 19, 2014 9:12 am
by epeter
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!!

Re: Problem with a simple loop

Posted: Wed Nov 19, 2014 9:49 am
by EViews Gareth

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)

Re: Problem with a simple loop

Posted: Thu Nov 20, 2014 1:45 am
by epeter
Thank you Gareth! That's exactly what I was looking for. 8)