[Gretl-users] on kernel density

Riccardo (Jack) Lucchetti r.lucchetti at univpm.it
Tue Jan 28 09:03:18 EST 2014


On Tue, 28 Jan 2014, Leandro Zipitria wrote:

> Dear Gretl users,
>
> I am trying to run a kernel approximation to a series of data (attached),
> using the command kdensity as show in the manual.
>
> Specifically, the inp is as follows:
>
> matrix d = kdensity(Water)
> gnuplot --matrix=d --with-lines --output=pruba.eps
>
> But, once run the output says that the second column has non finite values.
> Maybe is because values are integers, but I have checked on Stata (sorry, a
> friend of mine, I do not use it), and the kernel density flows without
> problems.
>
> Is this a problem of the data, or I am doing something wrong?

Well, your data are in fact a bit weird: "Water" really is a discrete 
variable, with most cases equal to 0 and a few other values in the 
support. If you set Water as discete, this is what you get from the "freq" 
command:

<output>
Frequency distribution for Water, obs 1-2619

           frequency    rel.     cum.

    0        2190     83.62%   83.62% ******************************
  0.5          15      0.57%   84.19%
  0.6           1      0.04%   84.23%
    1          98      3.74%   87.97% *
  1.1          27      1.03%   89.00%
  1.5         148      5.65%   94.65% **
    2         122      4.66%   99.31% *
  2.2          18      0.69%  100.00%
</output>

So this is decidedly not the kind of data you want to compute the kernel
density of.

Having said this, the fact that "kdensity" produces a string of NAs is in 
fact a bit perplexing, especially considering that if you add some random 
noise, as in

<hansl>
Water2 = Water + 0.01*normal()
</hansl>

then things work like you'd expect them to. I'll have a look as soon as 
possible.


-------------------------------------------------------
   Riccardo (Jack) Lucchetti
   Dipartimento di Scienze Economiche e Sociali (DiSES)

   Università Politecnica delle Marche
   (formerly known as Università di Ancona)

   r.lucchetti at univpm.it
   http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------


More information about the Gretl-users mailing list