count positive group items

For questions regarding programming in the EViews programming language.

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

lomfy
Posts: 36
Joined: Mon Jul 18, 2011 11:51 pm

count positive group items

Postby lomfy » Sun Jul 31, 2011 9:53 am

hey there,

i'm trying to program non-parametric tests whether a certain set of observations is significantly different from zero.

in order to program the simple sign test and wilcoxon and corrado rank sign tests, i need to solve the following issue:

suppose i have the following series grouped (in reality they're many more):

rs1 rs2 rs3 rs4
+1 -2 +2 +3
-2 -3 -1 -1
+2 +4 -1 -2
...

can anybody think of a way to count the number of positive items in a row?

what i need to have is a series containing these numbers (concerning all the series in the group) which would look like this for my example:
pos
3
0
2
...

thankful for any advice!

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: count positive group items

Postby EViews Glenn » Mon Aug 01, 2011 9:17 am

The only way I can think is to create a new group with a @recoded version of each series and they count the number of observations in each row. You can do this in a small program without too much effort. Suppose group GRP1 has your series and that there is no group GRP2 in the workfile...

Code: Select all

group grp2 for !i=1 to group01.@count %name = group01.@seriesname(!i) grp2.add @recode({%name}>0, {%name}, na) next series numpos = @robs(grp2) delete grp2
Here, we create a copy of the original group with new series that are based on the old, but with NAs whenever the series value is non-positive. Then we count the number of valid observations.

lomfy
Posts: 36
Joined: Mon Jul 18, 2011 11:51 pm

Re: count positive group items

Postby lomfy » Mon Aug 01, 2011 3:37 pm

hey glenn! marvelous, that worked very well...so i'm done with programming all statistical tests i need thanks to you guys' help!
thanks a lot!!!!! :)


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests