In gretl the function pmean() gives you the time-mean of a specified
series for each unit (repeated for each period), while pxmean() gives
you the cross-sectional mean for each time period (repeated for each
cross-sectional unit). In your example data the answer
{4,4,4,6,6,6,8,8,8} is given by pmean().
Allin Cottrell
On Mon, Apr 6, 2026 at 2:21 PM Ramki S <ramakrishnasalagrama(a)gmail.com> wrote:
>
> I loaded this data into gretl and told that this is time series stacked data. I
wanted to create Y_barj varibale. but the result is different. I expected that 4, 6, 8 are
the means for clusters. Did I do anything wrong here.
>
> unit year y
> 1 1 2
> 1 2 4
> 1 3 6
> 2 1 3
> 2 2 6
> 2 3 9
> 3 1 4
> 3 2 8
> 3 3 12
>
> xm_y
>
> 1:1 3
> 1:2 6
> 1:3 9
> 2:1 3
> 2:2 6
> 2:3 9
> 3:1 3
> 3:2 6
> 3:3 9