[R] Kernel Density Estimation at manually specified points

Carsten Harlaß carsten_harlass at web.de
Mon Jun 27 02:02:21 CEST 2011


Hello,

my name is Carsten. This ist my first post to R-help mailing list.

I estimate densities with the function "density" out of the package
"stats".

A simplified example:

	
	#generation of test data
	n=10
	z = rnorm(n)
	
	#density estimation
	f=density(z,kernel="epanechnikov",n=n)

	#evaluation
	print(f$y[5])

Here I can only evaluate the estimation at given points. These points
are determined by the parameter n. By default they are equidistant
distributed on the interesting interval.

But I need to evaluate the estimation (the estimated densitiy function)
at manually specified points. For example I want to compute f(z[i]).
This means I am interested in the estimated density at a the observation
z[i].

Does anyone know how I can compute this? I think this is an ordinary
task so I would be surprised if R can not manage this. But even after a
long search I have found nothing.

Thanks in advance

Carsten Harlaß

--
Carsten Harlaß
Aachen University of Applied Sciences
Campus Jülich
E-Mail: carsten_harlass at web.de



More information about the R-help mailing list