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
Hi
I changed you function a little bit, so there is no more conflict
in the if condition:
mecdf<-function(u,v,z) {
u=sort(u)
v=sort(v)
n=length(u)
m=length(z)
nb <- numeric(m)
for(j in seq(1,m)) {
nb.temp=0
for (i in seq(1,n)) {
if (u[i]<z[j] & v[i]<z[j]) {
nb.temp<-nb.temp+1
}
}
nb[j]=nb.temp/n
}
return(nb)
}
Attention: I didn't look in detail what you did so you sould
check my changes if it is really what you're looking for !!
Best regards,
Christoph
--------------------------------------------------------------
Christoph Buser <buser at stat.math.ethz.ch>
Seminar fuer Statistik, LEO C11
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-5414 fax: 632-1228
http://stat.ethz.ch/~buser/
--------------------------------------------------------------
MEYFREDI Jean-Christophe writes:
> 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 at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
Can't seem to find a x86_64 RPM for R on any of the DL mirrors. Does one exist? From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk> Date: Fri 22 Oct 2004 - 23:00:41 EST Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:> R does not run under (beta) 64-bit Windows on x86_64 and we have no plans > to port it there, but it does run under 32-bit Windows on that processor. > I am sure it will run on several 64-bit operating systems on Apple > Macintosh's so-called G5 hardware -- I believe we have seen a report that > includes an in-progress version of MacOS 10.4 -- and also several 32-bit > ones.Re. Windows, the issue is that we're using the mingw32 toolkit. If there is ever a mingw64, I'm sure we'd attempt a port almost immediately.> If you want a prebuilt version you are out of luck except for Debian Linux> on Alpha or ia64, from a quick glance.Actually, I've rolled up an x86_64 RPM for SuSE 9.1 which should be en route to CRAN. Detlef Steuer is awaiting delivery of a 64bit machine and plan to maintain the SuSE version in the longer run. It's sitting in http://www.biostat.ku.dk/~pd/R-suse9.1-x86_64 for now. In general, it seems to be quite trivial to take a SPEC or SRPM for the 32 bit version of a distribution and rebuild an RPM for 64 bits. However, you might prefer to install from the source tarball anyway if you want to take advantage of high-performance libraries (some of which can not be redistributed). -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 ______________________________________________ R-devel at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel Tom Colson Center for Earth Observation North Carolina State University Raleigh, NC 27695 (919) 515 3434 (919) 673 8023 tom_colson at ncsu.edu Online Calendar: http://www4.ncsu.edu/~tpcolson