defining multiple groups in nested loop with equality tests

For questions regarding programming in the EViews programming language.

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

wicker6m
Posts: 2
Joined: Tue Jul 01, 2014 12:39 am

defining multiple groups in nested loop with equality tests

Postby wicker6m » Tue Jul 01, 2014 7:09 am

Hello I am new to the forum and completely new to Eviews programming. I have two series of data (call them series1 and series2) as well as a series specifying a year (year) and a series specifying an industry (industry). For each year and each industry, I would like to perform an equality test between the median of that specific set of series1 and series2 (10 years times 9 industries = 90 sets). It seems that what I need to do is create a nested for loop that creates two new series for each of these sets, creates a group, and proceeds to run and record an equality test. So something like this (using pseudo-code):

For i = 2004 through 2013
For j = 1 through 10 (referring to the industry)
newseries1 = series1 if year = i AND industry = j
newseries2 = series2 if year = i AND industry = j
newgroup = newseries1 and newseries2
run equality test for medians between newseries1 and newseries2 in newgroup (testbtw function)
record full results of median equality test
End For
End For
.
I can easily assign a number 1 through 90 to each "industry year" if that is simpler than creating a nested for loop. Any comments would be greatly appreciated. Thank you

**EDIT: I should add that I am using Eviews 8**

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

Re: defining multiple groups in nested loop with equality te

Postby EViews Gareth » Tue Jul 01, 2014 9:16 am

Something like:

Code: Select all

group g series1 series2
for !i=2004 to 2013
for !j = 1 to 10
smpl if year=!i and industry=!j
freeze(tab_!i_!j) g.testbtw(med)
next
next
Follow us on Twitter @IHSEViews

wicker6m
Posts: 2
Joined: Tue Jul 01, 2014 12:39 am

Re: defining multiple groups in nested loop with equality te

Postby wicker6m » Tue Jul 01, 2014 10:15 am

This is perfect and exactly what I was looking for. Can't thank you enough.
Is there an additional line of code I can add that could compile all of these output tabs (vertically) into a single output sheet that I can then manually import into excel?

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

Re: defining multiple groups in nested loop with equality te

Postby EViews Gareth » Tue Jul 01, 2014 11:17 am

Code: Select all

spool s
group g series1 series2
for !i=2004 to 2013
for !j = 1 to 10
smpl if year=!i and industry=!j
freeze(tab_!i_!j) g.testbtw(med)
s.append tab_!i_!j
next
next
s.save(t=csv) myfile.csv
Follow us on Twitter @IHSEViews

COM446
Posts: 12
Joined: Wed Jul 08, 2015 2:10 pm

two-sample equality tests

Postby COM446 » Sun Oct 18, 2015 10:20 am

Hi, I have a series x and a classification variable 'hour' with value 1 or 2. How to write a program to test the difference between the mean, median and standard deviation for the two samples. I understand that two-sample tests can be done interactively but I have many series. How to write a program for the tests? Thanks a lot for your help. Howard

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

Re: defining multiple groups in nested loop with equality te

Postby EViews Gareth » Sun Oct 18, 2015 12:15 pm

Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: Google [Bot] and 14 guests