Hi,
I have been through the rolling regression forum and the common response thread that deals with pulling "things" out of objects to place elsewhere.
I am trying to run 2 Quandt-Andrews test for every regression in the loop @ .10 trimming and another @.49 trimming. esesentially a double loop within a loop (well i think thats the only way to do it).
I can get the value out of the table and into "Table s" but in the next loop the following saved data overwrites the previous. I want to make it so that it save on line 1,3,5,7,9...... for all .10 trimmings and each subsequent even line (2,4,6....) for .49 trimming.
example in the table
sample 1 120 .10 results
sample 1 120 .49 results
sample 2 121 .10 results
sample 2 121 .49 results
I know i need a variable that cunts the amount of equations ran but because i have one already and the way I have constructed my for loops i am just running in circles.
Thank you
this is what i have:
'run rolling regression
' set window size
!window =120
' set step size
!step =1
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation eq1
'calculate number of rolls
!nrolls = @floor((!length-!window)/!step)
'table to hold each grab from the frozen table
table s
'variable keeping track of how many rolls we've done
!j=0
' move sample !step obs at a time
for !i = 1 to !length-!window+1-!step step !step
!j=!j+1
' set sample to estimation period
smpl @first+!i-1 @first+!i+!window-2
' estimate equation
eq1.ls y c x1 x2
for !c=0 to 5 step 2
!h=!c+1
eq1.ubreak 10 @ c
freeze(tab) eq1.ubreak 10 @ c 'freeze table
s(!h,5)=@val(tab(11,2)) 'deposit contents at (11,2) into table s
s(!h,6)=@val(tab(11,4)) 'deposit contents at (11,2) into table s
tab.copyrange a4 a4 s a!h }
tab.copyrange a5 a5 s b!h } ' these are all non numerical data to be stored in the table and the copyrange function is the easiest way i know how
tab.copyrange a2 a2 s c!h }
tab.copyrange a11 a11 s d!h }
d tab
next
for !k=1 to 5 step 2
!r=!k
eq1.ubreak 49 @ c
freeze(tab1) eq1.ubreak 49 @ c
s(!r,5)=@val(tab1(11,2))
s(!r,6)=@val(tab1(11,4))
tab1.copyrange a4 a4 s a!r
tab1.copyrange a5 a5 s b!r
tab1.copyrange a2 a2 s c!r
tab1.copyrange a11 a11 s d!r
d tab1
next
next
thanks in advance
Double Loop within rolling regression
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Double Loop within rolling regression
It looks like you're using copyrange to copy a single cell? That's over kill. You can just do:
Now with regards to getting the row correct, I'd just use a separate counter outside the loop that counts which row of the table you're on. Every time you add data to the table, you increase it by one.
Code: Select all
s(i,j) = tab(m,n)
Re: Double Loop within rolling regression
I know i need a counter outside but I just cant get it to work. i know its really simple but I keep creating 2 counters and its messing up the table. could you give me some specific(tailored) guidance on the code i have.
I have fixed the copyrange mess thanks.
I have fixed the copyrange mess thanks.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Double Loop within rolling regression
Post what you have after the clean up
Re: Double Loop within rolling regression
Hi there, I have had a similar problem and fixed it by combining a while and a for loop together. The WHILE loop keeps either the row or column constant while the nested FOR loop extracts the information from the other dimension.
hope it helps
A
hope it helps
A
Who is online
Users browsing this forum: No registered users and 2 guests
