Creating variables with combinations

For questions regarding programming in the EViews programming language.

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

tV56x
Posts: 6
Joined: Wed Jun 08, 2011 9:34 am

Creating variables with combinations

Postby tV56x » Thu Jul 14, 2011 12:05 am

Hi,
I'm using EV5.

I'm trying to use combinatorial to average series within several groups.
The following is my code, in which I divided the series of a group into
two subgroups and trying to estimate from those, an average in its
series.

The problem is in the attached files. The code is a draft, there are some
lines that does the same, but I'm trying to find out what's the problem
with the combinations. The matrices are just to compare with the groups.

Thanks in advance.

Code: Select all

workfile temp a 1990 2009 'name and date edited ''' %z variable is not defined, so it is not executed matrix(20, 30) m1 matrix(20,30) m1_d_m group g1 'same size as matrix m1 group g{%z}_d_m 'same size as matrix m1_d_m 'variables creation for !i = 1 to 6 for !j = 1 to 5 series y{%z}_{!i}_{!j} = rnd 'two dimension in the series next next 'First set of groups, it goes increasing in its firt dimension !hcol=1 for !hi = 1 to 6 !hj=1 while !hj < 6 g1.add y{%z}_{!hi}_{!hj} 'added to a single group colplace(m1, y{%z}_{!hi}_{!hj}, !hcol) group g_d{!hi}_m g_d{!hi}_m.add y_{!hi}_{!hj} 'added to a first set !hcol=!hcol+1 !hj=!hj+1 wend next 'paso2 would perform an average for elements in g_d1_m until g_d6_m 'creating gw_d1_m until gw_d6_m, respectively. 'in this case, an average is calculated using 6 over 5 (equal to 6) in each g_d*_m to create 'those from gw_d*_m with the same size, but one series excluded. include paso2.prg 'Second set of groups, it goes increasing in its second dimension !gcol=1 for !gi = 1 to 5 !gj=1 while !gj < 7 g{%z}_d_m.add y{%z}_{!gj}_{!gi} 'added to a single group colplace(m1_d_m, y{%z}_{!gj}_{!gi}, !gcol) group g_d_m{!gi} g_d_m{!gi}.add y_{!gj}_{!gi} 'added to a second set !gcol=!gcol+1 !gj=!gj+1 wend next 'paso3 would do the same as paso2, but in this case, 'from g_d_m1 until g_d_m5, should create new groups, gw_d_m1 up to gw_d_m5 'in this case, an average is calculated using 5 over 4 (equal to 5) in each g_d_m* to create 'those from gw_d_m* with the same size, but one series excluded. include paso3.prg
Attachments
paso3.prg
(859 Bytes) Downloaded 489 times
paso2.prg
(748 Bytes) Downloaded 466 times
Last edited by tV56x on Thu Jul 14, 2011 9:07 am, edited 2 times in total.

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

Re: Creating variables with combinations

Postby EViews Gareth » Thu Jul 14, 2011 7:45 am

I'm afraid I don't understand what you're trying to do. Also, without comments, I have no idea what your program is doing.

tV56x
Posts: 6
Joined: Wed Jun 08, 2011 9:34 am

Re: Creating variables with combinations

Postby tV56x » Thu Jul 14, 2011 8:07 am

The first part, up to the first include, creates 5 groups with 6 series in each. The second (using the same initial group, but in its second dimension), creates 6 groups with 5 series, as opposed to the previous.

The content in two files is the same, but it is applied to the first and to the second set of groups, respectively.

Those steps creates, in each case, a group with the same size of the first, but with series that are an average, in this way:

group 1 with 6 variables --> new group 1 with 6 series (with one series left out of the combination to calculate the average). The combination of 6 in 5 elements is 6.
group 2 ...
...

and, likewise,

group 1 with 5 variables --> new group 1 with 5 series (with one series excluded in each average calculation, when combining 5 over 4, is equal to 5).
group 2...
...

The process only does for the group 1 in each case, but not for the rest. The idea is the same in both cases.

Sorry, I forgot to explain a bit more. Comments edited.

Thank you.

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

Re: Creating variables with combinations

Postby EViews Gareth » Thu Jul 14, 2011 9:09 am

Still lost.

It might be easier if you just just talk about the bit that doesn't do what you want it to do. We probably don't need to see/understand the whole program if there is just a single line that isn't working.

If it is case of "the whole program doesn't do what I want it to do", you might be out of luck.

tV56x
Posts: 6
Joined: Wed Jun 08, 2011 9:34 am

Re: Creating variables with combinations

Postby tV56x » Thu Jul 14, 2011 9:27 am

In paso2.prg, I'm not sure when using a counter for each group,
to perform the stepwise average, if this counter isn't working
in the way it creates the series. It does not increase the group
to calculate again the averaged series or calculate many times in the same w* series.

In the group gw1, the same result is repeated, from w_*_1 to w_*_5,
and in the gw1_d_m it puts only one result.

Thank you again.

tV56x
Posts: 6
Joined: Wed Jun 08, 2011 9:34 am

Re: Creating variables with combinations

Postby tV56x » Thu Jul 14, 2011 12:53 pm

This is the simplest case, but in this case, group ws, which contains the averaged series, is two dimensional.
I'd like to create one of 3 dimensions.

Code: Select all

workfile a 1990 2009 group xs group ws for !r =1 to 3 series y{!r} = rnd xs.add y{!r} series w{!r} ws.add w{!r} next matrix(20,3) mat1 !col=1 for !i=1 to xs.@count-1 %iname = xs.@seriesname(!i) for !j=!i+1 to xs.@count %jname = xs.@seriesname(!j) series w{!col} = ({%iname}+{%jname})/xs.@count colplace(mat1,w{!col},!col) !col = !col+1 next next

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

Re: Creating variables with combinations

Postby EViews Gareth » Thu Jul 14, 2011 1:29 pm

I don't know what a 3-dimensional group is.

tV56x
Posts: 6
Joined: Wed Jun 08, 2011 9:34 am

Re: Creating variables with combinations

Postby tV56x » Thu Jul 14, 2011 1:52 pm

Here, xs and ws, are three dimensional. Those, xs*_m and ws*_m, are part of xs and ws, respectively.

Code: Select all

workfile a 1990 2009 group xs group ws for !r = 1 to 3 !s = 1 while !s < 4 series y{!r}_{!s} = rnd xs.add y{!r}_{!s} series w{!r}_{!s} ws.add w{!r}_{!s} group xs{!r}_m xs{!r}_m.add y{!r}_{!s} group ws{!r}_m ws{!r}_m.add w{!r}_{!s} !s=!s+1 wend next


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests