Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: odd behavior in ado file


From   "Katsuhide Isa" <[email protected]>
To   [email protected]
Subject   st: Re: odd behavior in ado file
Date   Sat, 23 Jul 2005 20:40:48 +0900

Thank you for all of your quick responses and advices.
And I'm sorry for my slow reply.

As was correctly pointed out, the line 

f = (`y' - 1)/ln(`1')

should have been

f = (`y' - 1)/ln(`y')

So, though I wrote 'It works well all in all', it was mistaken, 
too:-). I'm sorry to have posted such a careless question.


For your reference, let me explain a little bit the motivation 
behind this posting.

At a glance, a more natural way to code 
  f = (exp(x) - 1)/x
would be:

if `1' == 0 {
   di in gr "f = " 1
}
else {
   local f = (exp(`1') - 1)/`1'
   di in gr "f = " "`f'"
}

But, according to McCullough and Vinod (1999, p.646), 
this 'natural method' tends to return biased results when 
the argument is fairly small(ex. x = 9e-15). They say 

'The reason the natural method fails miserably is because 
the intermediate step of the calculation is imprecise: for 
x ~ 0('nearly zero') the numerator is swamped by rounding and 
cancellation error'.

And they recommend an alternative method, which I posted.

Reference:
McCullough, B. D. and H. D. Vinod,
The Numerical Reliability of Econometric Software,
Journal of Economic Literature,
Jun., 1999, vol 37, num 2, pp.633-665. 

K.I.
*
*   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