Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: local variables program


From   "Michael S. Hanson" <[email protected]>
To   [email protected]
Subject   Re: st: local variables program
Date   Mon, 25 Jun 2007 12:33:53 -0400

On Jun 25, 2007, at 9:22 AM, Nachbar, Dirk wrote:

global minRMSE=999999999999999999
	[snip]

  if e(rmse) < $minRMSE {
    global minRMSE = e(rmse)
	[snip]

  }

If I'm not mistaken, you can improve this code slightly by exploiting the fact that Stata sees "missing" (i.e. "global minRMSE = .") as an infinitely large number. Thus, the first time through your loop, e(rmse) < . ("missing") should always evaluate to "true", and then the rest of your code will identify any smaller RMSE values within the loop.

Again, it's clearly not a big deal, but infinity is always greater than any finite large number. So while it is unlikely that your code will fail with "global minRMSE=999999999999999999", I suspect it would never fail with "global minRMSE = ."

Hope this helps.

-- Mike


*
* 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/




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