David Kantor
> > > > I'm looking for a function or a routine in Stata7 which would
> > > > give me the
> > > > highest scalar of a matrix
>
> Both Nick Winter & Nick Cox replied.
>
> I would just add a warning. In Nick Winter's program,
>
> > if `M'[`r',`c']>`val' {
> > scalar `val'=`M'[`r',`c']
>
> will pick up missing values if any are present in `M',
> which is possible in
> Stata 8 (even if your program
> states version 7).
>
> Unless you want to count a missing as a maximal value, that
> condition should be
> if ~mi(`M'[`r',`c']) & (`M'[`r',`c'] > `val | mi(`val') ) {
>
> Why did I throw in that condition mi(`val') ? Because
> `val' is pre-loaded
> with `M'[1,1], so it, too, may be missing, until it is
> replaced when the
> first nonmissing value is encountered.
>
> (Now, given this more robust test, you could pre-load `val'
> with missing,
> rather than `M'[1,1].)
>
> I am not familiar with the -matmax- program by Jeroen
> Weesie, so I don't
> know whether it takes this approach.
The original desire was clearly stated
as code for Stata 7, and I believe that both
Nick Winter's code and Jeroen's Weesie's, which
can be downloaded from his website, are fine
for that question.
As for Stata 8, David has a good point.
A little more can be said.
Jeroen's code also initialises with the [1,1]
element; it doesn't work if that is missing,
but that is a matter of version control (see
-help version-.)
Jeroen's code is not, I think, broken by missing elements
in any other position, and this is because it
works with this rule
maximum so far = max(this element, maximum so far)
and -max()- only returns missing if all its arguments
are missing.
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/