[R] bivariate empirical cdf

MEYFREDI Jean-Christophe jc.meyfredi at edhec.edu
Fri Feb 18 14:34:50 CET 2005


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




More information about the R-help mailing list