This is a hack which uses the output of the density function. rrr <- cumsum(diff(cumsum(denspoints$y))*diff(denspoints$x)) lines(denspoints$x[-512],rrr)
I don't believe this is the best solution, because it is not a direct estimate of the cumulative density function. I think there are methods for a direct estimate, and the name James Ramsay comes to mind. You may want to google his work on estimating strictly monotone functions. Hope that helps, -tgs On Thu, Jul 14, 2011 at 5:03 AM, Jochen1980 <i...@jochen-bauer.net> wrote: > Hi list, > > this is my second try for first post on this list (I tried to post via > email > and nothing appeared in my email-inbox, so now I try to use the > nabble-web-interface) - I hope that you will only have to read one post in > your inbox! Okay, my question ... > > I was able to plot a histogram and add the density()-line to this plot. > I was able to plot a cumulative form of this histogram. > Yet, I was not able to add the density line to this cumulative histogram. > > You can watch a picture of the histograms here: > http://www.jochen-bauer.net/downloads/histo-cumulative-density.png > > Source: > > # Histogramm > histo <- hist( hgd$V1, freq=FALSE ) > > # Dichte-Schätzer-Funktion reinzeichnen > denspoints <- density( hgd$V1 ) > lines( denspoints, col="GREEN", lwd=2 ) > > # Kumulative Verteilung relativer Häufigkeiten > relcum <- cumsum( histo$counts ) / sum(histo$counts) > barplot( relcum, names.arg=round( histo$mids, 2), col="green", > ylab="Wahrscheinlichkeit") > > # Kumulative Dichtefunktion ? > > Thanks in advance - Jochen > > -- > View this message in context: > http://r.789695.n4.nabble.com/Add-a-density-line-to-a-cumulative-histogram-second-try-tp3666969p3666969.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. > [[alternative HTML version deleted]]
______________________________________________ R-help@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.