[R] nonparametric densities for bounded distributions

David Winsemius dwinsemius at comcast.net
Sat Mar 10 00:37:57 CET 2012


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



More information about the R-help mailing list