0
$\begingroup$

I am trying out some methods for finding the optimal bandwith for a kernel density estimation in R. Now I stumbled across a post on R-bloggers

If I compute the Silvermann's rule of thumb bandwith for my data I get the following

1.06*sd(kurseu)*length(kurseu)^(-1/5)
[1] 2.171556

Now if I use the cross validation method I get complete different results

J=function(h){
        fdach=Vectorize(function(x)
        density(kurseu,from=x,to=x,n=1,bw=h)$y)
        fdachi=Vectorize(function(i) density(kurseu[-i],from=kurseu[i],to=kurseu[i],n=1,bw=h)$y)
        F=fdachi(1:length(kurseu))
        return(integrate(function(x) fdach(x)^2,-Inf,Inf)$value-2*mean(F))}
optimize(J,interval=c(.1,1))
    $minimum
    [1] 0.6299948

I have no idea why the results are so much different from each other

$\endgroup$
1
$\begingroup$

You should consider that Silvermann's rule of thumb assumes that the underlying density to be modeled is Gaussian, so if the density of your data is not distributed like that it might lead to very poor results.

Have you evaluated the fit that results from these two bandwidths? I'd assume that the one you found via cross-validation will perform better.

$\endgroup$
  • $\begingroup$ there was my mistake. I didn't take into account that the Silvermann bandwith only works for normal distributed data. So the cross validation works for all type of data and also for every kernel used? $\endgroup$ – user2968163 Mar 13 '18 at 14:48
  • $\begingroup$ given that you have data available to use for crossvalidation aswell as that you have a parameter space you want to check and don't mind the computational effort, yes. A rule of thumb like Silvermann's is so attractive, because one can save the time it'd take to evaluate several models on the data, which might be expensive depending on the volume of the data and the parameter space one wants to search. $\endgroup$ – deemel Mar 13 '18 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.