Announcement

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

  • "Missing" categories not appearing in catplot

    I am using catplot 3.0.1 by Nick Cox (thanks!) on Stata 19.5. I am failing to convince catplot to include missing categories (i.e. system missing and extended missing values), even with the "missing" option.

    Code:
    sysuse auto, clear
    graph hbar, over(rep78) missing title(hbar) name(hbar) nodraw
    catplot, over(rep78) missing title(catplot) name(catplot) nodraw
    graph combine hbar catplot

    Click image for larger version

Name:	example.png
Views:	1
Size:	57.0 KB
ID:	1782265


    I think the cause might be an early markout that effectively disregards missings before hbar has an opportunity to include them.

    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . marksample touse
    
    . fre `touse'
    
    __000002
    -------------------------------------------------------
              |      Freq.    Percent      Valid       Cum.
    ----------+--------------------------------------------
    Valid   1 |         74     100.00     100.00     100.00
    -------------------------------------------------------
    
    . markout `touse' rep78, strok
    
    . fre `touse'
    
    __000002
    -----------------------------------------------------------
                  |      Freq.    Percent      Valid       Cum.
    --------------+--------------------------------------------
    Valid   0     |          5       6.76       6.76       6.76
            1     |         69      93.24      93.24     100.00
            Total |         74     100.00     100.00           
    -----------------------------------------------------------
    I can devise a workaround (like a temporary mvencode), but is this a bug in catplot or working-as-intended? If the latter, a note in the helpfile might be good.

  • #2
    Good question. catplot is on SSC.

    It's pretty much intentional. catplot as such has no option missing but missing is being passed to graph hbar (in your case) but with no effect because missings have already been marked out, exactly as you say.

    To my mind showing a bar with a bare dot for missing is fairly ugly. If it's what any one wants then as you exempify you can do it otherwise. So, I think the way forward is to add some more explanation to the help file and/or perhaps to trap missing with a warning.

    Comment


    • #3
      To my mind showing a bar with a bare dot for missing is fairly ugly.
      My actual use case is a variable with a variety of labeled extended missing values, e.g. "Doesn't know", "Refused to answer", "Not applicable", "Unintelligible", etc.

      So, I think the way forward is to add some more explanation to the help file and/or perhaps to trap missing with a warning.
      That would be great. I hadn't figured out if there was any possible scenario where "missing" could affect the output, such as in conjunction with a second "over" category, but if it can never make any difference then a trap+warning would be very welcome.

      Comment


      • #4
        On further thought it seemed clear that support for missing values not only should but also could be added. So, thanks as ever to Kit Baum, catplot has been updated on SSC. Version 3.0.2 includes support for a missing option which is native to catplot.

        Thanks again to Nils Enevoldsen for raising the issue.

        Comment

        Working...
        X