[R] calculating density from cdf

From: Tamas K Papp <tpapp_at_princeton.edu>
Date: Fri 27 Oct 2006 - 22:00:57 GMT


I have a vector which contains the cdf of a univariate distribution. The support of the rv is [0,1], so eg if the vector has 101 elements, the give the CDF at 0,0.01,...,1. The function is quite smooth. [1]

I would like to calculate (approximate) the density. I tried fitting a splinefun and calling it with deriv=1, but occasionally this is negative. How can I ensure at least positivity?



[1] The cdf points are the result of a dynamic programming problem and is calculated numerically.

R-help@stat.math.ethz.ch 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. Received on Sat Oct 28 08:05:15 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 27 Oct 2006 - 22:30:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.