An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090325/f84d416c/attachment-0002.pl>
Density estimation: scale back for calendar time
4 messages · Pradeep Raje, David Winsemius
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
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090326/f3f2099e/attachment-0002.pl>
Pradeep Raje <raje.pradeep <at> gmail.com> writes:
Thanks David for your response.I had done that.
But not shared it.
Problem is not with the computations, but in the interpretation. Assume that x ordinates are 'time' [1:3472], and y are associated parameter values. Now density gives me 512/1024/2048 x-ordinates, of which some (7 to be precise) are negative. What do I make of the non-zero probability at **negative** times?
Obviously you are having problems with interpretation which is why I suggested that you provide a worked example. Since you appear to be resisting that suggestion, let's talk about hypotheticals. Two results of a density estimation will be density(dat)$x and density(dat)$y. The first of these is not a probability and could be negative in any instances where negative numbers were in the domain of the dat object. And it might be negative in situations with postive values where an estimation extended slightly beyond the original dataset. It is the y values that are necessarily positive. The idea that dates associated with a numerical object could be used to label a density plot seems strange. The process of density estimation would scrample the order of the original data so that the densities could be calculated. In a sense the y-axis of the original object will become the new x-axis of the density object. There would be no way to restore that "date" order. It had been my hope that a request for an example would make that more clear. Back to you.
David Winsemius >