Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Xtile command not working as expected

    I was hoping someone could help with the following query - the xtile command is not dividing my continous variable into four equal groups, which is what I assume it would do according to the help file.

    I type;

    xtile quartvar=var, nq(4)

    And it results in my sample being split into groups of 39.84%, 13.95%, 26.10% and 20.11%

    I tested it by looking tertiles

    xtile tertvar=var, nq(3)

    And it results in the sample being split into groups of 39.84%, 34.50% and 25.65%


    The variable is heavily left skewed, with the majority of the sample having a value of 0/1, which I'm wondering has something to do with it? But I had assumed even if the case of non-normal distribution, it would still generate 4 (or 3) equal groups as this is the definition of a quantile/tertile.


    If anyone could help me troubleshoot this issue (and explain where I am going wrong), I would be hugely grateful.

  • #2
    The definition is one of principle, setting aside the small print that you may have a number of observations not a multiple of 3, 4 or whatever.

    In practice xtile will never allocate observations with the same value to different quantile bins, so ties may often mightily frustrate the ideal of equal frequencies.

    Much more at https://www.stata-journal.com/articl...article=dm0095 Section 6.

    https://www.stata-journal.com/articl...article=pr0054 Section 4.

    There is no good solution to this, and indeed it casts much doubt on the utility of such binning.

    Detail: I guess you mean right-skewed.
    Last edited by Nick Cox; 17 Feb 2022, 10:45.

    Comment

    Working...
    X