[R] Question concerning pdfs
Rainer M Krug
R.M.Krug at gmail.com
Wed Jan 16 10:34:43 CET 2008
Hi
I have a dataset of absolute growth rates g ranging from close to 0 to
around whatever of which I want to calculate a pdf.
If I use density(g) the pdf will extend to below 0 so I logtransform g
and do d <- density(log(g)).
Now I would like to transform this pdf back, i.e. d$x <-
exp(d$x) but what do I have to do with d$y?
(below is a small example)
Thanks for your help,
Rainer
g <- exp(rnorm(100)) ## Just to generate the example data
d <- density(log(g))
dx <- d$x
dp <- d$y
sum(c(0, (diff(dx))) * dp) ## this is equal to one
plot(dx, dp)
dx2 <- exp(dx)
dp2 <- ??????? ## what should I do here?
plot(dx2, dp2) ## what should I do here?
sum(c(0, (diff(exp(dx2)))) * dp2) ## this should be one
sum( c(0, (diff(dx2))) * ( dp1 / c(1, (diff(exp(dx2)))) * c(0,
(diff(dx1)))) ) ##This is obviously also one, but can I
use this to define my dp2? i.e.
dp2 <- dp1 / c(1, (diff(exp(dx2)))) * c(0, (diff(dx1)))) ###????
More information about the R-help
mailing list