[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Data Analytics Corp." <dataanalytics@earthlink.net> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: finding max of several variables |

Date |
Mon, 06 Jul 2009 13:12:38 -0400 |

Thanks for the reference - I'll look for this. Walt Nick Cox wrote:

Such problems have been recently reviewed inSJ-9-1 pr0046 . . . . . . . . . . . . . . . . . . . Speaking Stata: Rowwise (help rowsort, rowranks if installed) . . . . . . . . . . . N. J. Cox Q1/09 SJ 9(1):137--157 shows how to exploit functions, egen functions, and Mata for working rowwise; rowsort and rowranks are introduced The programs -rowsort- and -rowranks- are downloadable from the StataJournal to all, subscribers or not.Regardless of that, the position of the maximum is obtainable from codelike this:gen pos = .gen max = -1tokenize "3 4 7 11 12"forval j = 1/5 {replace pos = `j' if prob``j'' > max & prob``j'' < .replace max = prob``j'' if prob``j'' > max & prob``j'' < .}This isn't subtle about ties.Nickn.j.cox@durham.ac.ukWalter R. Paczkowski, Ph.D.I'm still new to Stata programming, so I hope someone can help with asimple problem. I have five variables that are probabilities estimatedfrom mlogit: prob3, prob4, prob7, prob11, prob12, each with 734 cases.I want to find the max for each case using something likemax(prob3, prob4, prob7, prob11, prob12)but then get the position in this list for that max for each case. Inshort, for case 1, if the max is prob4, I want to get 2; if it's prob11,I want 4; etc. I should have 734 positions of the max in the list. How can this be done? Any help is appreciated. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

-- ________________________ Walter R. Paczkowski, Ph.D. Data Analytics Corp. 44 Hamilton Lane Plainsboro, NJ 08536 ________________________ (V) 609-936-8999 (F) 609-936-3733 dataanalytics@earthlink.net www.dataanalyticscorp.com * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: finding max of several variables***From:*"Data Analytics Corp." <dataanalytics@earthlink.net>

**st: RE: finding max of several variables***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: RE: finding max of several variables** - Next by Date:
**st: do-file halting** - Previous by thread:
**st: RE: finding max of several variables** - Next by thread:
**st: do-file halting** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |