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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: Strange problem with forvalues |

Date |
Fri, 22 Feb 2008 18:09:57 -0000 |

What you are observing is nothing to do with -forvalues- as such. It is a consequence of your attempt to do decimal arithmetic on a computer that uses binary. The keyword here is precision. . search precision points to documentation -- but misses the choicest item of all, namely SJ-6-4 pr0025 . . . . . . . . . . . . . . . . . . . Mata matters: Precision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . W. Gould Q4/06 SJ 6(4):550--560 (no commands) looks at programming implications of the floating-point, base-2 encoding that modern computers use I would re-code as follows: forvalues j= 1/9{ statsby _b, by(year) saving(c:\qreg`j'.dta, replace): qreg y x1 x2 x3 x4, quantile(.`j') Note the last detail: The loop is over the integers 1 to 9. -qreg- will see in turn quantile(.1) quantile(.2) and so forth. Then everyone and everything should be happy. Nick n.j.cox@durham.ac.uk Nuno I'm having an issue with Stata and a small routine I've written. The code is the following: forvalues j=.1(.1).9{ statsby _b, by(year) saving(c:\qreg`j'.dta, replace): qreg y x1 x2 x3 x4, quantile(`j') } The objective run the qreg for the deciles .1-.9 and get save the coefficient estimates in a file. The problem is that, when Stata reaches quantile .8 and .9 it seems to assum that j=.7999999999999 or j=.89999999999. This doesn't happen with the other js. command: qreg y x1 x2 x3 x4, quantile(.7999999999999999) by: year (note: file c:\qreg.7999999999999999.dta not found) Statsby groups ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 ................ (running qreg on estimation sample) command: qreg y x1 x2 x3 x4, quantile(.8999999999999999) by: year (note: file c:\qreg.8999999999999999.dta not found) Statsby groups ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 ................ If I then restart the code with j=.8(.1).9 everyhing runs fine. Any ideas for this to happen? * * 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/

**Follow-Ups**:**st: RE: RE: Strange problem with forvalues***From:*"Nuno" <liststata@gmail.com>

**References**:**st: Strange problem with forvalues***From:*"Nuno" <liststata@gmail.com>

- Prev by Date:
**Re: st: re: Memory, Stata 10, and 32-bit XP** - Next by Date:
**RE: implementation of boschloo's test: very slow execution** - Previous by thread:
**st: Strange problem with forvalues** - Next by thread:
**st: RE: RE: Strange problem with forvalues** - Index(es):

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