estimating y and x pairs
Posted: Tue Oct 13, 2020 11:59 pm
by Laurel
Code: Select all
'create a workfile
wfcreate q 1990 2010
'create 5 y and 5 x series
for %y y1 y2 y3 y4 y5
series {%y}=nrnd
for %x x1 x2 x3 x4 x5
series {%x}=nrnd
'run pairwise regressions between each series
equation eq_{%y}_{%x}.ls {%y} c {%x}
next
next
Hello! How do I modify the above code so that only the five equation objects with matching y's and x's are created: eq_y1_x1, eq_y2_x2,eq_y3_x3,eq_y4_x4,eq_y5_x5? Thanks!
Re: estimating y and x pairs
Posted: Wed Oct 14, 2020 8:17 am
by EViews Gareth
Code: Select all
'create a workfile
wfcreate q 1990 2010
'create 5 y and 5 x series
for %y y1 y2 y3 y4 y5
series {%y}=nrnd
next
for %x x1 x2 x3 x4 x5
series {%x}=nrnd
next
'run pairwise regressions between each series
for !i = 1 to 5
equation eq_{!i}.ls y{!i} c x{!i}
next
Re: estimating y and x pairs
Posted: Wed Oct 14, 2020 8:39 am
by Laurel
Thank you. But what if the series names are xa, xb, xc, xd, xe and ya, yb, yc, yd, ye?
Re: estimating y and x pairs
Posted: Wed Oct 14, 2020 1:15 pm
by EViews Matt
Hello,
You could loop over the common suffix of the x? and y? series, e.g.
Code: Select all
for %s a b c d e
equation eq_y{%s}_x{%s}.ls y{%s} c x{%s}
next
Similarly named objects let you write terse loops, but can always explicitly list all the names and loop over groups of those elements, e.g.
Code: Select all
for %y %x ya xa yb xb yc xc yd xd ye xe
equation eq_{%y}_{%x}.ls {%y} c {%x}
next