Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: bug in -xtile-


From   "Dr. Yu Chen" <[email protected]>
To   [email protected]
Subject   Re: st: bug in -xtile-
Date   Fri, 1 Feb 2013 16:20:38 -0600

Hi, Xiao Yang, thank you so much for your quick response.

Best,

--
Yu Chen, Ph.D.
Assistant Professor of Accounting
A. R. Sanchez, Jr. School of Business, WHTC 218D
Texas A&M International University
5201 University Boulevard
Laredo, Texas 78041-1900
USA
956-326-2513 (office)
956-326-2479 (fax)


On Fri, Feb 1, 2013 at 3:47 PM, Xiao Yang, StataCorp <[email protected]> wrote:
>
> Yu Chen <[email protected]> encountered a bug in the way the -xtile-
> command handles the case of the number of observations being less than the
> requested number of quantiles.  When the -if- condition is specified,
> -xtile-
> produces results.  When the corresponding observations are dropped,
> -xtile-
> reports an error.
>
> > 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.
> >
> > sysuse auto,clear
> > keep in 1/10
> > xtile decile=price if price<5000, nq(10)
> > ...
> >
> > 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)
>
>
> Nick Cox <[email protected]> identified the problem in the -xtile-
> command:
>
> > 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.
>
>
> This is indeed a bug.  We will fix this in a future update.
>
>
> -- Xiao
> [email protected]
> *
> *   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index