Help- stop the loop

For questions regarding programming in the EViews programming language.

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

junjin
Posts: 3
Joined: Wed Jul 24, 2013 8:16 am

Help- stop the loop

Postby junjin » Wed Jul 24, 2013 9:15 am

Hello Everyone! Could you please help me with the codes below? My problem is that I have set the loop to be stopped when nrtf{!k}=nrtf{!j}. According to my results, nrtf3=nrtf4 but the loop does not stop and continues to produce the nrtf5 nrtf6...nrtf10. I have attached the files in this message.
Thanks you very much for the help.

'start
equation eq01
eq01.ls rt c

series nrt=@recode(rt=na,eq01.@coefs(1),rt)

equation eq02
eq02.ARCH(tdist, backcast=0.7,derive=aa) nrt c

eq02.forecast nrtf1
series nrtf1=@recode(rt=na, nrtf1,rt)

for !i = 3 to 10
!j = !i-2
!k = !i-1
equation eq{!i}
eq{!i}.ARCH(tdist,backcast=0.7,derive=aa) nrtf{!j} c

eq{!i}.forecast nrtf{!k}
series nrtf{!k} = @recode(rt=na,nrtf{!k},rt)

if nrtf{!k}=nrtf{!j}
exitloop
endif

next
Attachments
program.prg
(684 Bytes) Downloaded 223 times
workfile.wf1
(254.05 KiB) Downloaded 155 times

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

Re: Help- stop the loop

Postby EViews Gareth » Wed Jul 24, 2013 9:28 am

You cannot use if conditions on series. I'm not sure what you're trying to do, so can't help you to do it.

junjin
Posts: 3
Joined: Wed Jul 24, 2013 8:16 am

Re: Help- stop the loop

Postby junjin » Wed Jul 24, 2013 11:16 am

You cannot use if conditions on series. I'm not sure what you're trying to do, so can't help you to do it.
Eviews Gareth, thanks a lot for the reply. If the "if condition" cannot be used on series. Could you tell me how to ask a loop to stop when coefficients of the equations are the same. For example:

'start
for !i = 3 to 10
equation eq{!i}
eq{!i}.ARCH(tdist,backcast=0.7,derive=aa) y{!i} c
next
'end

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

Re: Help- stop the loop

Postby EViews Gareth » Wed Jul 24, 2013 11:23 am

Still confused. What does checking whether two series are equal have to do with the coefficients from an equation?

To check whether the coefficients from two equations are equal, you could check the value of the maximum difference between the two sets of coefficients:

Code: Select all

!diff = @max(@abs(eq1.@coef-eq2.@coef))

junjin
Posts: 3
Joined: Wed Jul 24, 2013 8:16 am

Re: Help- stop the loop

Postby junjin » Wed Jul 24, 2013 11:43 am

Still confused. What does checking whether two series are equal have to do with the coefficients from an equation?

To check whether the coefficients from two equations are equal, you could check the value of the maximum difference between the two sets of coefficients:

Code: Select all

!diff = @max(@abs(eq1.@coef-eq2.@coef))


Eviews Gareth, thanks for your quick reply. You are right, I also confuse by myself now. I need to carefully rethinking what I was doing. Anyway, thank you very much for your help.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests