[R] Question on density values obtained from kde2d() from package MASS

Andreas Klein klein82517 at yahoo.de
Thu Nov 24 19:12:19 CET 2011


I am a little bit confused regarding the density values obtained from the function kde2d() from the package MASS because the are not in the intervall [0,1] as I would expect them to be. Here is an example:

x <- c(0.0036,0.0088,0.0042,0.0022,-0.0013,0.0007,0.0028,-0.0028,0.0019,0.0026,-0.0029,-0.0081,-0.0024,0.0090,0.0088,0.0038,0.0022,0.0068,0.0089,-0.0015,-0.0062,0.0066)
y <- c(0.00614,0.00194,0.00264,0.00064,0.00344,0.00314,-0.00006,-0.00066,0.00174,0.00274,-0.00076,0.00024,-0.00236,0.00234,0.00504,0.00114,0.00054,-0.00116,-0.00016,-0.00566,0.00044,0.00404)

tmp <- kde2d(x=x, y=y, n=100)
#3.621288     11989.060924

Do I have to transform them further? Or what scale are they?
Or did I get something wrong regarding the output because in the help file it reads:
"zAn n[1] by n[2] matrix of the estimated density: rows
correspond to the value of x, columns to the value of y."


More information about the R-help mailing list