Petr Pikal
2004-Nov-12 12:44 UTC
[R] How to get mode (the most frequent value in distribution)?
[This email is either empty or too large to be displayed at this time]
Gregor GORJANC
2004-Nov-12 12:48 UTC
[R] How to get mode (the most frequent value in distribution)?
Hello! I have a continous distribution and would like to get mode (the most frequent value in distribution). I easily found mean, median and other basic thing but not mode function. Can anyone help? I know there my might be problems with multiple modes, but still I think that there should be a mode function in R. Please send mail to R-help list and me, so I can get response faster. Thank you! -- Lep pozdrav / With regards, Gregor GORJANC --------------------------------------------------------------- University of Ljubljana Biotechnical Faculty URI: http://www.bfro.uni-lj.si Zootechnical Department mail: gregor.gorjanc <at> bfro.uni-lj.si Groblje 3 tel: +386 (0)1 72 17 861 SI-1230 Domzale fax: +386 (0)1 72 41 005 Slovenia
Vito Ricci
2004-Nov-12 12:51 UTC
[R] Re: How to get mode (the most frequent value in distribution)?
Hi Gregor, if you have a continous distribution is rather difficult that the same value is repeated many times. In this case I believe you could not find the mode (the most frequent value in distribution) as your distribution is continous, but only the modal class/interval (the interval of the distribution having the most frequency). See this example:> set.seed(13) > x<-rnorm(100) > xcut<-cut(x, breaks=c(-4,-3,-2,-1,0,1,2,3,4)) > table(xcut)xcut (-4,-3] (-3,-2] (-2,-1] (-1,0] (0,1] (1,2] (2,3] (3,4] 0 1 19 33 30 17 0 0> max(table(xcut))[1] 33 the modal class/interval is (-1,0]. I hope I give a little help. Best Vito You wrote: Hello! I have a continous distribution and would like to get mode (the most frequent value in distribution). I easily found mean, median and other basic thing but not mode function. Can anyone help? I know there my might be problems with multiple modes, but still I think that there should be a mode function in R. Please send mail to R-help list and me, so I can get response faster. Thank you! -- Lep pozdrav / With regards, Gregor GORJANC ====Diventare costruttori di soluzioni Became solutions' constructors "The business of the statistician is to catalyze the scientific learning process." George E. P. Box Visitate il portale http://www.modugno.it/ e in particolare la sezione su Palese http://www.modugno.it/archivio/cat_palese.shtml
Gregor GORJANC
2004-Nov-12 17:38 UTC
[R] How to get mode (the most frequent value in distribution)?
Thanks to all! It appears that mode calculation is not easy or simple at all. I understand that it is problematic when you have continous distribution, but there should still be some general function, as for median, mean, ... -- Lep pozdrav / With regards, Gregor GORJANC --------------------------------------------------------------- University of Ljubljana Biotechnical Faculty URI: http://www.bfro.uni-lj.si Zootechnical Department mail: gregor.gorjanc <at> bfro.uni-lj.si Groblje 3 tel: +386 (0)1 72 17 861 SI-1230 Domzale fax: +386 (0)1 72 41 005 Slovenia
Ales Ziberna
2004-Nov-13 11:15 UTC
[R] How to get mode (the most frequent value in distribution)?
Maybe a litle simpler solution: x<-rnorm(50) den<-density(x) #see ?density for more details den$x[which(den$y==max(den$y))] Hope it helps, Ales Ziberna ----- Original Message ----- From: "Gregor GORJANC" <gregor.gorjanc at bfro.uni-lj.si> To: <r-help at stat.math.ethz.ch> Sent: Friday, November 12, 2004 6:38 PM Subject: Re: [R] How to get mode (the most frequent value in distribution)? Thanks to all! It appears that mode calculation is not easy or simple at all. I understand that it is problematic when you have continous distribution, but there should still be some general function, as for median, mean, ... -- Lep pozdrav / With regards, Gregor GORJANC --------------------------------------------------------------- University of Ljubljana Biotechnical Faculty URI: http://www.bfro.uni-lj.si Zootechnical Department mail: gregor.gorjanc <at> bfro.uni-lj.si Groblje 3 tel: +386 (0)1 72 17 861 SI-1230 Domzale fax: +386 (0)1 72 41 005 Slovenia ______________________________________________ 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