Hello everyone, I would like to know if there is any function to calculate the mode value, or I have to build one to do it. Thanks so much Carlos
Mode value
6 messages · Carlos Morales, stephen sefick, milton ruser +3 more
look here: http://www.nabble.com/how-to-calculate-the-mode-of-a-continuous-variable-td19214243.html#a19214243 On Sat, Sep 6, 2008 at 1:24 PM, Carlos Morales
<carlosmoralesdiego at yahoo.es> wrote:
Hello everyone, I would like to know if there is any function to calculate the mode value, or I have to build one to do it. Thanks so much Carlos
______________________________________________ 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.
Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20080906/680b267a/attachment.pl>
On 09/06/08 17:24, Carlos Morales wrote:
Hello everyone, I would like to know if there is any function to calculate the mode value, or I have to build one to do it.
I just did this the other day. Funny you should ask. It finds the mode of each row of a matrix called Pbest. Pbest.p <- apply(Pbest,1,function(x) x[which.max(as.vector(table(x)))][1]) So to get the mode of a vector v1, the following should work (but I haven't tried it): v1[which.max(as.vector(table(v1)))][1]
Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron
3 days later
Others showed you how to find the mode in a dataset, I just want to point out that if your data is from a continuous distribution (or near continuous), then the mode of the data is more likely to be the result of a quirk of rounding than representative of anything useful. If the data is discrete, then the mode of the data may be meaningful, but looking at the entire table of frequencies, or a plot of them, will give you the mode information along with additional information that may help determine if that mode value is meaningful. If you really want to make inference about the mode of a continuous distribution then you should either use something like fitdistr (from the MASS package) to fit the data to a specific distribution, then use the theory/likelihood of that distribution to find the mode, or use the density function or the logspline package to fit a density to the data (less dependent upon assumptions about the distribution) and look at the mode(s) from those estimates. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org (801) 408-8111
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Carlos Morales Sent: Saturday, September 06, 2008 11:24 AM To: r-help at r-project.org Subject: [R] Mode value Hello everyone, I would like to know if there is any function to calculate the mode value, or I have to build one to do it. Thanks so much Carlos
______________________________________________ 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.