Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] bivariate empirical cdf

MEYFREDI Jean-Christophe

2005-02-18

Replies:

Dear R users,


 I'm trying to write a small function in order to compute empirical cumulative density function.All seems to work but when I try to plot the function, I always get error messages.
 
 This is the function I use
 
 mecdf<-function(u,v,z) {
 u=sort(u)
 v=sort(v)
 n=length(u)
 nb=0
 
 for (i in seq(1,n)) {
 if (u[i]<z & v[i]<z) {
 nb<-nb+1
 }
 }
 nb=nb/n
 return(nb)
 }
 
 In fact if I try to obtain mecdf(u,v,0.1) or mecdf(u,v,0.2), all is good, but with mecdf(u,v,c(0.1,0.2)), for example, I get errors and wrong results for both mecdf(u,v,0.1) and mecdf(u,v,0.2). I think that it consitutes the key point of my plot difficulty. Can someone help me ?
 
 Best regards
 
 JCM

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.