Line 135 of xtile.ado appears to contain a typo. The line reads
However, as best I can tell it should read
To see the incorrect behavior, consider
This shows
x1 == x2, but this should not be the case. Using cutpoints and pctile we get the different (and expected) results. I only have access to Stata for Unix, but this is present in 13, 14, and 15.
Code:
args wt x newvar nq altdev
Code:
args wt x newvar nq altdef
Code:
set rmsg on clear set obs 10 gen x = _n xtile x1 = x, nq(7) xtile x2 = x, nq(7) altdef pctile p1 = x, nq(7) pctile p2 = x, nq(7) altdef xtile xp1 = x, c(p1) xtile xp2 = x, c(p2) altdef l
Code:
+------------------------------------------+
| x x1 x2 p1 p2 xp1 xp2 |
|------------------------------------------|
1. | 1 1 1 2 1.571429 1 1 |
2. | 2 1 1 3 3.142857 1 2 |
3. | 3 2 2 5 4.714286 2 2 |
4. | 4 3 3 6 6.285714 3 3 |
5. | 5 3 3 8 7.857143 3 4 |
|------------------------------------------|
6. | 6 4 4 9 9.428572 4 4 |
7. | 7 5 5 . . 5 5 |
8. | 8 5 5 . . 5 6 |
9. | 9 6 6 . . 6 6 |
10. | 10 7 7 . . 7 7 |
+------------------------------------------+

Comment