Can anyone recommend a good nonparametric density approach for data bounded (say between 0 and 1)? For example, using the basic Gaussian density approach doesn't generate a very realistic shape (nor should it):> set.seed(1) > dat <- rbeta(100, 1, 2) > plot(density(dat))(note the area outside of 0/1) The data I have may be bimodal or have other odd properties (e.g. point mass at zero). I've tried transforming via the logit, estimating the density then plotting the curve in the original units, but this seems to do poorly in the tails (and I have data are absolute zero and one). Thanks, Max [[alternative HTML version deleted]]
David Winsemius
2012-Mar-09 23:37 UTC
[R] nonparametric densities for bounded distributions
On Mar 9, 2012, at 4:36 PM, Max Kuhn wrote:> Can anyone recommend a good nonparametric density approach for data > bounded > (say between 0 and 1)?I thought the "canonical" answer, at least the one that generally is put forward whe people have difficulty with the stats::spline results was to turn to function 'logspline' in package logspline.> > For example, using the basic Gaussian density approach doesn't > generate a > very realistic shape (nor should it): > >> set.seed(1) >> dat <- rbeta(100, 1, 2) >> plot(density(dat))require(logspline) set.seed(1) dat <- rbeta(100, 1, 2) lsdat <- logspline(dat, lbound=0,ubound=1) plot(lsdat) # yield sharp edges to density.> > (note the area outside of 0/1) > > The data I have may be bimodal or have other odd properties (e.g. > point > mass at zero).Ah, the Dirac function. (Just my physics background showing.) HTH; David.> I've tried transforming via the logit, estimating the > density then plotting the curve in the original units, but this > seems to do > poorly in the tails (and I have data are absolute zero and one). > > Thanks, > > Max > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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.David Winsemius, MD West Hartford, CT
Reasonably Related Threads
- how to generate a normal distribution with mean=1, min=0.2, max=0.8
- oldlogspline probabilities
- Functions in lists or arrays?
- Confidence intervals for Sen slope in zyp-package
- new package benchden 1.0.0 : benchmark densities for nonparametric density estimation