Bookmark and Share

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]

Re: st: bug in -xtile-


From   "Dr. Yu Chen" <profyuchen@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: bug in -xtile-
Date   Fri, 1 Feb 2013 09:02:00 -0600

Thank you Nick for the confirmation. I hope this issue will be
corrected in Stata 13.




On Fri, Feb 1, 2013 at 2:44 AM, Nick Cox <njcoxstata@gmail.com> wrote:
>
> Now I agree with you. The code for -xtile- includes the test
>
>                 if `nquanti' > _N + 1 {
>                         di in red "nquantiles() must be less than or " /*
>                         */ "equal to number of observations plus one"
>                         exit 198
>                 }
>
> but a better test would be something like
>
> marksample touse
> qui count if `touse'
>
> if `nquanti' > r(N) + 1 {
>
> The total number of observations _N is not the right number to check
> against.
>
> Nick
>
> On Fri, Feb 1, 2013 at 3:21 AM, Dr. Yu Chen <profyuchen@gmail.com> wrote:
>
> > Nick, if this is -xtile- point of view, then it will not work if I
> > delete observations whose value<5000. See my code below.
> > In other words, in the first example I added an if condition, and in
> > the second example, I deleted those observations. Why is the result
> > different? I think this is an inconsistency in -xtile-.
> >
> > sysuse auto,clear
> > keep in 1/10
> > drop if price<5000
> > xtile decile=price , nq(10)
>
> > On Thu, Jan 31, 2013 at 8:08 PM, Nick Cox <njcoxstata@gmail.com> wrote:
> >> In your example 6 values qualify as < 5000. -xtile- classifies into 10
> >> classes as best it can
> >>
> >> (Here -groups- is from SSC.)
> >>
> >> . groups price decile, sep(0)
> >>
> >>   +----------------------------------+
> >>   | price   decile   Freq.   Percent |
> >>   |----------------------------------|
> >>   | 3,799        1       1     16.67 |
> >>   | 4,082        2       1     16.67 |
> >>   | 4,099        4       1     16.67 |
> >>   | 4,453        6       1     16.67 |
> >>   | 4,749        7       1     16.67 |
> >>   | 4,816        9       1     16.67 |
> >>   +----------------------------------+
> >>
> >> You seem to be saying that they should not be classified if there are
> >> less than 10. That's a point of view, but it is not -xtile-'s point of
> >> view.
> >>
> >> The values are of the new variable are not equally spaced integers,
> >> but they could not be given the request.
> >>
> >> Nick
> >>
> >> On Fri, Feb 1, 2013 at 1:45 AM, Dr. Yu Chen <profyuchen@gmail.com>
> >> wrote:
> >>> I think there is a bug in -xtile-. I ran the code below, and I still
> >>> got deciles, but they are incomplete. I would expect missing values
> >>> because there are not enough observations.
> >>> I use Stata 12.
> >>>
> >>> sysuse auto,clear
> >>> keep in 1/10
> >>> xtile decile=price if price<5000, nq(10)
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index