On 17/06/2024 12:54, Sven Schreiber wrote:
Am 17.06.2024 um 12:31 schrieb Riccardo (Jack) Lucchetti:
> On 17/06/2024 11:43, Riccardo (Jack) Lucchetti wrote:
>
>>
>> Possibly. That would require a completely different approach, though.
>> In those cases, I'd think kernel density estimates would be more
>> advisable.
>
> I mean, something like this:
> ...
> loop foreach i L
>
> kd[i] = kdensity(L.$i)
>
Did you see my previous code snippet? kdensity() accepts a list input,
it's pretty straightforward.
Ah cool, I didn't remember. Therefore, the example simplifies to:
<hansl>
function void multi_density(list L)
X = kdensity(L)
X = X[,2:] ~ X[,1]
cnameset(X, varnames(L) + defarray("x"))
gnuplot --matrix=X --with-lines --output=display
end function
open card_krueger94.gdt
list L = 23 24 42 43
multi_density(L)
</hansl>
But still a histogram certainly has its role. The doc for the
relevant
'freq' command mentions that the numerical histogram can be accessed via
$result. I guess that can be used (in a loop) to construct the needed
plot with your gnuplot magic. Right now I don't have time to look into
this further.
Up to a point, I'm afraid: the $result for continuous data gives you the
midpoint, but not the boundaries of the bin. And these can be different
from variable to variable, so that'd be tricky.
(Apart from the other thing that is mentioned in the freq doc, namely
that the aggregate() function can be used. That's certainly true, but it
doesn't give an example of how exactly. A challenge for you!?)
that's easy:
<hansl>
open mroz87.gdt
eval aggregate(const, WE)
</hansl>
-------------------------------------------------------
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
-------------------------------------------------------