Rainer M Krug
2006-Aug-30 10:27 UTC
[R] density() with from, to or cut and comparrison of density()
Hi the function density() does normally integrate to one - I've checked it and it works and I also read the previous threads. But I realised that it does not integrate to one if I use from, to or cut. My scenario: I simulated densities of a plants originating from an sseed source at distance zero. Therefore the density of the plants will be highest close to zero. Is there anything I can do to have this pattern? If I use 'from' or 'cut', the resulting densities do not integrate to one which I need as I want to compare different density curves. Ny second question is concerning the bandwidth. An I correct in saying that if I want to compare different density estimates that the bandwidth should be the same for all of them? Thanks in advance for your help, Rainer -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel: +27 - (0)72 808 2975 (w) Fax: +27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: RKrug at sun.ac.za Rainer at krugs.de
Uwe Ligges
2006-Aug-30 11:01 UTC
[R] density() with from, to or cut and comparrison of density()
Rainer M Krug wrote:> Hi > > the function density() does normally integrate to one - I've checked it > and it works and I also read the previous threads. > But I realised that it does not integrate to one if I use from, to or cut. > > My scenario: I simulated densities of a plants originating from an sseed > source at distance zero. Therefore the density of the plants will be > highest close to zero. Is there anything I can do to have this pattern? > If I use 'from' or 'cut', the resulting densities do not integrate to > one which I need as I want to compare different density curves.The kernel chosen might be not the ideal one for such a restriction. If the density outside the "cut" range is extremely small, you might want to do a dirty transformation so that the values sum up to 1 again.> Ny second question is concerning the bandwidth. An I correct in saying > that if I want to compare different density estimates that the bandwidth > should be the same for all of them?Yes. Uwe Ligges> Thanks in advance for your help, > > Rainer >
Greg Snow
2006-Aug-30 16:08 UTC
[R] density() with from, to or cut and comparrison of density()
You may want to look at the logspline package, it uses a different technique than density does, but it estimates densities and allows you to tell the routine that there is a minimum value and that the density does not extend beyond there. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at intermountainmail.org (801) 408-8111 -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Rainer M Krug Sent: Wednesday, August 30, 2006 4:27 AM To: R help list Subject: [R] density() with from, to or cut and comparrison of density() Hi the function density() does normally integrate to one - I've checked it and it works and I also read the previous threads. But I realised that it does not integrate to one if I use from, to or cut. My scenario: I simulated densities of a plants originating from an sseed source at distance zero. Therefore the density of the plants will be highest close to zero. Is there anything I can do to have this pattern? If I use 'from' or 'cut', the resulting densities do not integrate to one which I need as I want to compare different density curves. Ny second question is concerning the bandwidth. An I correct in saying that if I want to compare different density estimates that the bandwidth should be the same for all of them? Thanks in advance for your help, Rainer -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel: +27 - (0)72 808 2975 (w) Fax: +27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: RKrug at sun.ac.za Rainer at krugs.de ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.