Chanchal Kumar
2006-Sep-04 15:59 UTC
[R] Problems with 2-D Kernel Density Estimation using MASS & KernSmooth
Dear R-Users, I am using the two dimensional Kernel density estimation function in "MASS" package (specifically "kde2d") and am having a recurrent problem. The problem is that when my data vectors have less then 30000 entries then the functions gives me the density estimate. But when the vector size increases beyond 30000 then I get an error. I have pasted below my steps and the error message.>Pmin<-2 >Pmax<-14 >Mmin<-100 >Mmax<-10000000 >N<-200>dens<-kde2d(data3[[3]],data3[[4]], h = c(width.SJ(data3[[3]],nb=100,+method="dpi"), width.SJ(data3[[4]], nb=100,method="dpi")), n=N, +lims=c(Pmin,Pmax,log10(Mmin),log10(Mmax))) When data3[[3]] and data3[[4]] are each less then 30000 entries then the function runs fine else it gives me following error message:>Error in SDh(cnt, (2.394/(n * TD))^(1/7), n, d) : NA/NaN/Inf in foreignfunction call (arg 5) I also tried using the "bkde2D" from "KernSmooth" package and am getting the same error for longer vector sizes. I shall be thankful if you could suggest what is going wrong. Alternatively I will be glad to know about other possible ways of fast density estimation on bigger vectors. Thanks in advance! Best Regards, Chanchal ==============================Chanchal Kumar, Ph.D. Candidate Dept. of Proteomics and Signal Transduction Max Planck Institute of Biochemistry Am Klopferspitz 18 82152 D-Martinsried (near Munich) Germany e-mail: chanchal at biochem.mpg.de Phone: (Office) +49 (0) 89 8578 2296 Fax:(Office) +49 (0) 89 8578 2219 http://www.biochem.mpg.de/mann/