[R] Density estimate with bounds

Giovanni Petris GPetris at uark.edu
Thu Nov 5 15:51:28 CET 2009


I think the cleanest solution would be to use kernels whose support is
(included in) (0,1). For example you could use Beta kernels instead of
Normal kernels. Implementing this approach requires a little work,
though -- but not much if you just want a density estimate.

Best,
Giovanni

ps: please do not post the same question multiple times.


> Date: Thu, 05 Nov 2009 10:35:21 +0100
> From: Justine Rochon <Justine.Rochon at klinik.uni-regensburg.de>
> Sender: r-help-bounces at r-project.org
> Precedence: list
> 
> Dear R users,
> 
> I would like to show the estimated density of a (0, 1) uniformly distributed
> random variable. The density curve, however, goes beyond 0 and 1 because of the
> kernel smoothing. 
> 
> Example:
> 
> x = runif(10000)
> plot(density(x))
> 
> Is there a way to estimate the density curve strictly within (0, 1) and still
> use some sort of smoothing?
> 
> Any help would be greatly appreciated.
> 
> Best regards,
> 
> Justine Rochon
> 
> 
> 
> ________________________
> Justine Rochon
> - Biostatistician -
> Center for Clinical Studies
> University Hospital Regensburg 
> Franz-Josef-Strauß-Allee 11
> D-93053 Regensburg
> Phone: ++49-(0)941-944-5626
> Fax: ++49-(0)941-944-5632
> Email: justine.rochon at klinik.uni-regensburg.de
> 
> ______________________________________________
> 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.
> 
> 
> 

-- 

Giovanni Petris  <GPetris at uark.edu>
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/




More information about the R-help mailing list