Am 18.05.25 um 14:45 schrieb Alecos Papadopoulos:

But the pxmean() function in the PanelTools package does indeed appear to do essentially what I want to do. The documentation states

<<pxmean(const series y)
Compute mean value of y across all units per time period. Missing values are ignored for computing the mean.
Parameters
• y, series, target series
Returns
Series with the mean value value across all units per observation. NA values are completely ignored and are not counted.
>>

...and it appears that it computes my    (1/N)*sum_{i=1}^N [x{it}]    term, including handling the case of an unbalanced panel.


Indeed, looking again at your former definition:
> z_{it} = x_{it} (-) (1/N)*[x_{1t} + x_{2t} + ... + x_{Nt}]

This is what the pxmean() function should do for you.

Here you find a unit-test i wrote for that function. That helps to understand it better, I hope:

https://github.com/atecon/PanelTools/blob/master/tests/run_tests.inp#L249

Best,
Artur