Page 4 of 4
Re: Panel or Pool?
Posted: Tue Jan 07, 2020 10:11 am
by pschneider
Re: Panel or Pool?
Posted: Mon Feb 03, 2025 1:39 pm
by Muhammad Khurram
Really helpful and well explained, thank you team Eviews.
Re: Panel or Pool?
Posted: Thu Aug 21, 2025 10:08 am
by dagfinnrime
Problem generating av variable as share of a different cross-section!
I have a panel where one of the cross-sections is actually the sum of the others. My cross-sections have names but I have made a variable with names replaced with numbers, and the cross-x that is aggregate is number 1.
In panel: I do
volume/@sumsby(volume, @obsid, cxid=1,"29/10/2012 5/06/2015")
Result:
CXID Mean Std. Dev. Obs.
1 1.000000 0.000000 673
2 0.360038 0.169855 672
3 0.028747 0.045342 670
4 0.268701 0.144842 673
5 0.259850 0.168693 673
6 0.083576 0.110940 671
All 0.333829 0.342279 4032
As expected: for CXID=1 the mean=1 and no std.Dev.
I have created a pool-sheet for the same data. I create similar shares from the series:
VOLUME_1/VOLUME_1 VOLUME_2/VOLUME_1 VOLUME_3/VOLUME_1 VOLUME_4/VOLUME_1 VOLUME_5/VOLUME_1 VOLUME_6/VOLUME_1
Mean 1.000000 0.321767 0.021122 0.242661 0.234802 0.061333
Std. Dev. 0.000000 0.128300 0.029529 0.128632 0.150955 0.065457
Observations 673 672 670 673 673 671
Number of observations are the same, and averages and std.dev are ball-park the same, but not exactly the same.
Why not? What am I doing wrong?
* I did the @sumsby also with @date, but I guess that is not as good as @obsid (for reasons I don't really understand)
Thanks in advance,
Dagfinn
Re: Panel or Pool?
Posted: Thu Aug 21, 2025 6:22 pm
by EViews Gareth
Could you provide an example workfile?
Re: Panel or Pool?
Posted: Mon Sep 01, 2025 5:09 am
by dagfinnrime
Hei,
please find attached an example file. Two sheets, Panel and pool. Pool created from panel by unstack in new page. I have 6 categories in the panel, where category 1 is "all". (all is actually slightly larger than sum of group 2-6 because one group is omitted here).
I want to learn each groups share of the total (all).
In panel I create an object from "show volume/@sumsby(volume,@obsid,crossid=1,"29/10/2012 5/06/2015")" and use "Descriptive stats by classification".
In Pool-sheet I simply create a group where all volume-series are divided by the first volume-series.
Look forward to solution :-)
Dagfinn
Re: Panel or Pool?
Posted: Tue Sep 02, 2025 10:14 am
by EViews Gareth
The unbalancedness of the panel means that the @sumsby function isn't quite doing what you think. If you, on the panel page, type:
Code: Select all
smpl @first @first+2
show @sumsby(volume, @obsid, crossid=1)
and then toggle to only show observations for the current sample, you'll notice that the values of that denominator are different across different crossids, based on the number of observations in that cross id.
Re: Panel or Pool?
Posted: Wed Sep 03, 2025 9:50 am
by dagfinnrime
Thanks
so with an unbalanced panel I rather do this in pool/unstacked page, or create a ALL-variable that is same for all cross-sections in the PANEL.
Dagfinn
Re: Panel or Pool?
Posted: Thu Sep 04, 2025 4:33 am
by dagfinnrime
Hi,
How can I create a variable in an unbalanced panel that for every crossid/date equals the value for, e.g., the first crossid on that date?
I can unstack the panel-variable in a new sheet, take the first of these unstacked variables, and copy it back into the panel.
but if my crossids in the panel eg. are names it can be difficult to easily unstack them (because names with space not easily becomes variable names) so it would be easier to just do it within the panel (I have to change the names into eg numbers, and how do I do that easily?)
Dagfinn
Re: Panel or Pool?
Posted: Thu Sep 04, 2025 10:25 am
by EViews Gareth
Create a series equal to what you had before:
Code: Select all
series denom = @sumsby(volume, @obsid, "if crossid=1")
Re: Panel or Pool?
Posted: Fri Sep 05, 2025 1:43 am
by dagfinnrime
Very sorry, but I don't get this!
* I have an unbalanced panel
* the first cross-section is the sum of the others
I want to create a variable that doesn't vary across cross-sections (is the same for each cross section for same date) based on the first cross-section id.
Let this variable be "volume".
The following works:
A)
* Create a new page by frequency and copy volume to this page using source sample and sum.
Code: Select all
copy(smpl="@all if cat2="all"", c=sum) v10_bypartic_cat\VOLUME *_all3 @src @date @dest @date
copy Untitled\VOLUME_ALL3 *
Panel covariance on the panel page reveal that this has same values for all cross-sections at same date.
B)
* Unstack panel-page in new page and copy series for first cross-section back to panel (rename to Volume_all4 first ...)
Code: Select all
pageunstack(namepat=*_?) cat2 date @ volume
VOLUME_ALL.rename volume_all4
pageselect Fix_metrics_all_gbpusd_v10_bypartic_cat
copy Untitled4\VOLUME_ALL4 *
Again, panel covariance show that this is same across all cross sections at same date.
The suggested solution for doing it within the panel doesn't work.
Code: Select all
series volume_all5 = @sumsby(volume, @obsid, "if cat=""all""")
Panel covariance show that this is not the same across all cross-sections, and it's naturally not perfectly correlated with e.g Volume_all4.
I can do procedure A or B, it's not that many lines, but prefer the correct panel version.
Best,
Dagfinn
Re: Panel or Pool?
Posted: Fri Sep 05, 2025 8:07 am
by EViews Gareth
You're right. The @by functions don't work as I expected. I've thought about if for a bit, and can't think of a function that will get what you want in one line :/