[R] Density estimation when an end may not go to zero?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Mar 7 19:28:30 CET 2005
On Mon, 7 Mar 2005, Spencer Graves wrote:
> All the density estimators I've found in R seem to force the ends to go
> to zero.
Which ones are those?
> What can we do if we don't believe that, e.g., with something that
> might be a uniform distribution or a truncated normal with only observations
> above mu+sigma observed?
> The closest I could come to this was to artificially extend the numbers
> beyond the range, thereby forcing the density estimator to continue outside
> the range of the numbers, then plot only the part that I wanted. The
> following example supposes simulates observations from a truncated normal
> with mean 0, standard deviation 1, and only observations above 1.5 are
> observed and we faked numbers between 1 and 1.5:
> set.seed(1)
> tst <- rnorm(1000)
> tst1 <- tst[tst>1]
> knl <- density(tst1)
> sel <- knl$x>1.5
> plot(knl$x[sel], knl$y[sel], type="l")
> Are there any convenient methods for handling this kind of thing
> currently available in R?
This is covered in MASS, for example. logspline() would be a good choice
here: it allows a finite support.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list