@ngroups function
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
@ngroups function
I tried to use the „@ngroups” function in the following way.
series test_a= @groupid(lfd_nr)
scalar test_b= @ngroups(test_a)
Whereas the series test_a is generated, the scalar test_b is not. I got the following error code:
@NGROUPS is an illegal or reserved name in "SCALAR TEST_B=@NGROUPS(TEST_A)"
Could you give me an indication why it doesn’t work?
Thank you in advance for your efforts.
series test_a= @groupid(lfd_nr)
scalar test_b= @ngroups(test_a)
Whereas the series test_a is generated, the scalar test_b is not. I got the following error code:
@NGROUPS is an illegal or reserved name in "SCALAR TEST_B=@NGROUPS(TEST_A)"
Could you give me an indication why it doesn’t work?
Thank you in advance for your efforts.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: @ngroups function
I guess this is a bug, but more of a documentation bug - that function doesn't actually exist (you'll note it is not documented in the command reference).
You can calculate it easily enough yourself though, simply by taking the max of the groupids:
series grouid = @groupid(x)
scalar ngroups = @max(groupid)
You can calculate it easily enough yourself though, simply by taking the max of the groupids:
series grouid = @groupid(x)
scalar ngroups = @max(groupid)
Re: @ngroups function
Thank you very much.
But note, this sentence is from the user's guide I (Eviews 6 (PDF: page 753, Printed Version: page 749) at the end of the section "by-group statistics":
"There are two related functions of note,
@groupid(arg[, smpl])
returns an integer indexing the group ID for each observation of the series or alpha expression
arg, while:
@ngroups(arg[, smpl])
returns a scalar indicating the number of groups (distinct values) for the series or alpha
expression arg."
But note, this sentence is from the user's guide I (Eviews 6 (PDF: page 753, Printed Version: page 749) at the end of the section "by-group statistics":
"There are two related functions of note,
@groupid(arg[, smpl])
returns an integer indexing the group ID for each observation of the series or alpha expression
arg, while:
@ngroups(arg[, smpl])
returns a scalar indicating the number of groups (distinct values) for the series or alpha
expression arg."
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: @ngroups function
Hence my assertion that it is a documentation bug.
Re: @ngroups function
Thank you once again. In the meantime I have detected another "bug". I tried to use the @groupid function for an alpha series. Unfortunately, it doesn't work. Do you know how to get the number of distinct values for an alpha series?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: @ngroups function
The only way is to do a one-way tabulation.
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: @ngroups function
Possibly, something like
Code: Select all
group g @expand(alphaSeries)
g.@count
d g-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: @ngroups function
Excellent suggestion.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: @ngroups function
Can I play too?
creates a mapped numeric series out of the alphaSeries and then does Gareth's trick. Should be a bit more efficient than doing the expand.
Code: Select all
alphaSeries.makemap x x_map
series groupid = @groupid(x)
scalar ngroups = @max(groupid)
delete groupid x x_mapRe: @ngroups function
Thank you very much! I will try your suggestions.
Re: @ngroups function
Any advice on the best way to do something kinda like @groupid(ser1, ser2), where you are indexing the distinct values of ser1 for each value of ser2? the result might look something like:
ser1 ser2 result
1 1 1
1 3 2
1 3 2
2 5 1
2 5 1
2 20 2
2 5 1
I know I could just define a sample for each value of ser1 and do it that way, but that seems really innefficient.
ser1 ser2 result
1 1 1
1 3 2
1 3 2
2 5 1
2 5 1
2 20 2
2 5 1
I know I could just define a sample for each value of ser1 and do it that way, but that seems really innefficient.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: @ngroups function
I can't think of an easy other than your suggestion, but I'll give it some more thought.
Who is online
Users browsing this forum: No registered users and 2 guests
