On Sun, 6 Dec 2015, Riccardo (Jack) Lucchetti wrote:
For example, suppose that you wanted to create series with the
pmean() logic,
but using the median instead of the mean: here's a nice way to do it.
<hansl>
open abdata.gdt
list X = n w k
matrix M = aggregate(X, unit, median)
j = 3
loop foreach i X --quiet
$i_med = replace(unit, M[,1], M[,j++])
endloop
</hansl>
Ah, for future reference: there's a much more efficient way to do the
same: instead of
$i_med = replace(unit, M[,1], M[,j++])
you can use
$i_med2 = pexpand(M[,j++])
which is of course more general but much faster.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------