## Bug in statsby-functions with panel data

For notifying us of what you believe are bugs or errors in EViews.

Moderators: EViews Gareth, EViews Moderator

mamo
Posts: 173
Joined: Wed Nov 07, 2012 9:11 am

### Bug in statsby-functions with panel data

Dear Eviews team,

I use Eviews 12 March 22 2021 build.

I am wondering about the behaviour of @sumsby in the example code below. I would expect that the optional sample literal in by-group statistics (like @sumsby @meansby, etc,) makes the statistics being computed using the sample literal rather than the pre-selected page sample but it doesn't seem to be the case with panel data.

This behavior can certainly be circumvented by correspondingly preselecting the page sample. Nevertheless, it is a source of unexpected, potentially misleading results and can be considered a bug in view of the documention of the statsby function which says: "By default, EViews will use the workfile sample when computing the descriptive statistics. You may provide the optional sample s as a literal (quoted) sample expression or a named sample."

Best, mamo

Code: Select all

wfcreate a 2001 2010 2
series x=(@trend+1)*10^(crossid-1)
smpl 2001 2001 if crossid=1
' The following line shows "9  1 1" while the expected result should be "9  99 9"
show @sumsby(x, crossid, "2009 2009")  @sumsby(x,"2009 2009")   @sumsby(x,"2009 2009 if crossid=1")

EViews Matt
EViews Developer
Posts: 496
Joined: Thu Apr 25, 2013 7:48 pm

### Re: Bug in statsby-functions with panel data

Hello,

The various statsby functions require at least two series arguments before you may optionally specify a sample. A call such as @sumsby(x,"2009 2009") interprets the second argument as a constant alpha autoseries, not as a sample. If you insert a trivial constant autoseries as the second argument into your example, e.g., show @sumsby(x, crossid, "2009 2009") @sumsby(x, 1, "2009 2009") @sumsby(x, 1, "2009 2009 if crossid=1"), then you'll achieve the results you expect.