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

Re: st: about -mreldif( )-

From (William Gould, Stata)
Subject   Re: st: about -mreldif( )-
Date   Thu, 09 Jun 2005 14:19:47 -0500

Katsuhide Isa <> noted that Stata's (misnamed) 
reldif(X,Y) function returns r, 

                      |X - Y|
                r =  ---------
                      |Y| + 1

and asked about the mathematical justification for this formula.

The formula is simply a mix of the absolute difference,

             r_a   =  |X - Y|

and the relative difference

                      |X - Y|
              r_r =  ---------
In particular, 

           lim  r =  r_a

           lim  r =  r_r

When Y is small, then r is approximately the absolute difference (r is
exactly the absolute difference when Y==0), and when Y is large, then
r is approximately the relative difference.

This function is often used in numerical programming to test whether a 
value has changed much from one iteration to the next, and when one 
does not know whether the paramter will be large or small.

-- Bill
*   For searches and help try:

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