[R] Function from ecdf to ccdf

Gerrit Eichner Gerrit.Eichner at math.uni-giessen.de
Tue Apr 24 14:52:03 CEST 2012


Hello, Alaios,

take a look at the help page of ecdf() where it says that the result of 
ecdf(x) is a 'function (!) of class "ecdf"', not a vector of function 
values.

Take a look at what

> 1- ecdf(onVector)(onVector)

does, and maybe

> myecdfOn <- function( x) { 1- ecdf(x)(x)}

followed by

> myecdfOn( OnVector)

does what you want, and can finally be input to curve().

HtH -- Gerrit


On Tue, 24 Apr 2012, Alaios wrote:

> Dear all, I would like to calculate the complementary cumulative 
> distribution function. As it is known, the ccdf is the 
> 1-ecdf(X)==1-F(x). (From ?ecdf help is shown that ecdf returns a 
> function which is the F(x)
>
>
> I would like to use that function inside my function and after call 
> curve (which accepts function as input). My code looks like that
>
>
>
>
> onVector<-seq(1:100)
> offVector<-seq(101:200)
> myecdfOn<-function(onVector){1-ecdf(onVector)} # This gives the ccdf
>
> curve(myecdfOn,from=1,to=max(c(onVector,offVector)), add=TRUE,lwd=2)
>
>
>
>
>
> Unfortunately fails and I can not really see what is he problem of it.
>
> Could you please help me?
>
> B.R
> Alex
>
> 	[[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.



More information about the R-help mailing list