[R] Density estimation: scale back for calendar time

David Winsemius dwinsemius at comcast.net
Wed Mar 25 19:09:43 CET 2009


I am afraid your notion of a "concrete idea" is less concrete than  
what I would need to understand what you are requesting. Your first  
lines of example code should be:

library(<if the density function is not from stats>)
    <sample data construction of x>
density(x, <some set of parameters>)

... since  stats::density() by default would return 512 y estimates,  
even if the length of x were longer.

 > x <- rnorm(3471)
 > plot(density(x))
 > str(density(x))
List of 7
  $ x        : num [1:512] -3.98 -3.96 -3.94 -3.93 -3.91 ...
  $ y        : num [1:512] 7.98e-06

-- 
David Winsemius

On Mar 25, 2009, at 9:30 AM, Pradeep Raje wrote:

> Dear all:Request your indulgence. The econophysics gurus do this  
> stuff all
> the time: all their PDFs are smooth, with neat log x axis.
> 1. The kernel density estimate (KDE) function returns the empirical
> probability density at 2^n points (min: 512). The big question is  
> how do I
> scale back the x-values (say, density$x) to x-values in terms of the
> original dataset?
> 2. To give you a concrete idea, i have a dataset of 3471 obs (x=date  
> index,
> y=parameter values). Now the density estimate d<-density(x) gives be  
> 2048
> x-values. When I plot the PDF, the x axis is obviously d$x,  
> length=2048.
> 3. How can I scale back these 2048 values to get a sense of calendar  
> time
> (original date index)?
> 4. Subsidiary question is: how do i bring in the remaining values
> (3471-2048)?

You seem to have the idea that the original data is "lined up" with  
the density estimates. That is not so.

>
> Thanks very much in advance.
> pradeep
>
> 	[[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
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list