Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Maarten Buis <maartenlbuis@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Re: STATA mistakes divisions! |

Date |
Thu, 15 Mar 2012 16:43:22 +0100 |

On Thu, Mar 15, 2012 at 3:48 PM, Francesco Vidoli wrote: > But therefore by default, without writing in every division "float", > STATA mistake divisions? > It's not only a visualization problem, we are trying to compare a SAS > OLS regression and results simply do not add up if you calculate the > variables of SAS or STATA ... No, there is no mistake. This is a phenomenon known as precision, and it is a result of the fact that computers cannot store most numbers with infinite precision. Stata (note: not STATA) has some smart defaults on how much precision to use for variables, computations, scalars, etc. In short data is by default stored with less precision (about 7-8 decimal digits) than computations (about 17-18 decimal digits). This is smart as even the 7-8 digits is complete overkill for real world data. Some nice examples of this can be found here: <http://blog.stata.com/2011/06/17/precision-yet-again-part-i/>. However if you want to do computations with variables than you want to overwrite this default, as many tiny rounding errors can start to add up to a large or at least noticeable error. You do so as follows: gen double varname = expression The key part is -double-, that tells you that the variable is supposed to be stored in double precision, i.e. about 18 decimal digits, which corresponds to the precision used by SAS and others. This is also what Stata programs do internally when they are using variables to do computations. Some computations are even done in quad precision (approximately 34 decimal digits). Hope this helps, Maarten -------------------------- Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany http://www.maartenbuis.nl -------------------------- * * 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: Re: STATA mistakes divisions!***From:*Francesco Vidoli <fvidoli@gmail.com>

**Re: st: Re: STATA mistakes divisions!***From:*Austin Nichols <austinnichols@gmail.com>

**Re: st: Re: STATA mistakes divisions!***From:*Francesco Vidoli <fvidoli@gmail.com>

- Prev by Date:
**st: RE: RE: -findname- updated on SSC** - Next by Date:
**Re: st: the use of foreach command in Stata** - Previous by thread:
**Re: st: Re: STATA mistakes divisions!** - Next by thread:
**Re: st: Re: STATA mistakes divisions!** - Index(es):