Hi,

Am 18.05.25 um 14:27 schrieb Alecos Papadopoulos:
I want to transform the sample by subtracting from each data point the related group-mean, i.e. the mean value of the same (same by nature) variable across the dimension i=1,...,N

Namely to perform the operation

z_{it} = x_{it} (-) (1/N)*sum_{i=1}^N [x{it}],

i.e.

z_{it} = x_{it} (-) (1/N)*[x_{1t} + x_{2t} + ... + x_{Nt}]

and the same for the "y" variable, and any other variable in the sample.

Ideally, this has to work for both balanced and unbalanced panels., i.e. when the "N" may differ in each t time period.

Sorry, I haven't followed this closely enough. Just some spontaneous reaction: Isn't the pmean() function what you are looking for?

https://gretl.sourceforge.net/gretl-help/funcref.html#pmean

In the PanelTools package you also find the pxmean() function:

https://gretl.sourceforge.net/current_fnfiles/PanelTools.gfn

Best,
Artur