http://r.789695.n4.nabble.com/file/n3567636/ecdfs.jpg ecdfs.jpg http://r.789695.n4.nabble.com/file/n3567636/ecdf_curve.gif ecdf_curve.gif Hello, I have generated a plot of two empirical CDFs (attachment 1). As a result, they are stepwise when plotted. The following code was used:> plot(ecdf(mut), do.points=FALSE, verticals=TRUE, xlim=range(mut, non), > col="red") > plot(ecdf(non), do.points=FALSE, verticals=TRUE, add=TRUE, col="blue")But what I need instead are smooth curves, similar to ones that are generated from a theoretical cdf (attachment 2). I have looked at so many threads; one suggestion to someone else was to use library(fitdistplot) and look for distributions that may fit (e.g. weibull). But I could really use guidance before spending additional time on this. Thank you! -TW -- View this message in context: http://r.789695.n4.nabble.com/Plea-to-the-R-Gods-Theoretical-and-Empirical-CDFs-tp3567636p3567636.html Sent from the R help mailing list archive at Nabble.com.
Patrick Breheny
2011-Jun-02 11:56 UTC
[R] [Plea to the R Gods] Theoretical and Empirical CDFs
On 06/02/2011 02:18 AM, teriri wrote:> I have generated a plot of two empirical CDFs (attachment 1). As a > result, they are stepwise when plotted. > ... > But what I need instead are smooth curves, similar to ones that are > generated from a theoretical cdf (attachment 2).To obtain a smooth curve, you would need to estimate the density, which, from a statistical standpoint, is a vastly different problem. Once you have a density, however, you could integrate it to obtain the cdf: x <- rnorm(10) fit <- density(x) plot(fit$x[-1],diff(fit$x)*cumsum(fit$y)[-1],type="l") ## For comparison: plot(ecdf(x),add=TRUE,do.points=FALSE,verticals=TRUE) Please be aware, however, that density estimation is a complicated topic with an extensive literature. -- Patrick Breheny Assistant Professor Department of Biostatistics Department of Statistics University of Kentucky
David Winsemius
2011-Jun-02 12:53 UTC
[R] [Plea to the R Gods] Theoretical and Empirical CDFs
On Jun 2, 2011, at 2:18 AM, teriri wrote:> http://r.789695.n4.nabble.com/file/n3567636/ecdfs.jpg ecdfs.jpg > http://r.789695.n4.nabble.com/file/n3567636/ecdf_curve.gif > ecdf_curve.gif > > Hello, > > I have generated a plot of two empirical CDFs (attachment 1). As a > result, > they are stepwise when plotted. The following code was used: >> plot(ecdf(mut), do.points=FALSE, verticals=TRUE, xlim=range(mut, >> non), >> col="red") >> plot(ecdf(non), do.points=FALSE, verticals=TRUE, add=TRUE, >> col="blue") > > But what I need instead are smooth curves, similar to ones that are > generated from a theoretical cdf (attachment 2). > > I have looked at so many threads; one suggestion to someone else was > to use > library(fitdistplot) and look for distributions that may fit (e.g. > weibull). > But I could really use guidance before spending additional time on > this.Two threads up in the answer to the question "based on mean and std" you might find Ellison's answer useful. You and teriri at gmail.com in the same class? -- David Winsemius, MD West Hartford, CT
Hello! Haha, I am not doing this for a class...just trying to teach myself a few things or two. Thank you both for the responses. I really appreciate it. -- View this message in context: http://r.789695.n4.nabble.com/Plea-to-the-R-Gods-Theoretical-and-Empirical-CDFs-tp3567636p3569609.html Sent from the R help mailing list archive at Nabble.com.
Look at the logspline package for one approach to doing this. -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of teriri Sent: Thursday, June 02, 2011 12:19 AM To: r-help at r-project.org Subject: [R] [Plea to the R Gods] Theoretical and Empirical CDFs http://r.789695.n4.nabble.com/file/n3567636/ecdfs.jpg ecdfs.jpg http://r.789695.n4.nabble.com/file/n3567636/ecdf_curve.gif ecdf_curve.gif Hello, I have generated a plot of two empirical CDFs (attachment 1). As a result, they are stepwise when plotted. The following code was used:> plot(ecdf(mut), do.points=FALSE, verticals=TRUE, xlim=range(mut, non), > col="red") > plot(ecdf(non), do.points=FALSE, verticals=TRUE, add=TRUE, col="blue")But what I need instead are smooth curves, similar to ones that are generated from a theoretical cdf (attachment 2). I have looked at so many threads; one suggestion to someone else was to use library(fitdistplot) and look for distributions that may fit (e.g. weibull). But I could really use guidance before spending additional time on this. Thank you! -TW -- View this message in context: http://r.789695.n4.nabble.com/Plea-to-the-R-Gods-Theoretical-and-Empirical-CDFs-tp3567636p3567636.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.