Announcement

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

  • cibplot can't put bars in prespecified order

    Dear Stata user,

    I use -cibplot- (from SSC, the author is Nick Cox) to produce bar of means with confidence intervals. It is quite convenient, however, it seems that the command does not allow to put bars in prespecified order, just like what we can do in graph bar with option over(, sort(varname | #) ). And I also find that it's ytitle option is a bit of weird, because some setting can be performed using l1title other than ytitle.

    Code:
    webuse fullauto
    cibplot price, by(rep77) ytitle("This" "Is" "A" "TEST") l1title("This" "Is" "A" "TEST")
    cibplot price, by(rep77, sort(1) descending)
    by() does not contain a valid varname
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	158.0 KB
ID:	1769957

  • #2
    cibplot is from SSC. It is not a command I now ever use or recommend or attempt to maintain. See njc_stuff on SSC for its status.

    I am away from base but guess that the by() option does not support suboptions — and never claimed to.

    Sorry, but at this season I can’t provide more support until I return to base.

    Comment


    • #3
      Thank you Nick. I think you should stop work and enjoy yourself for a season.

      Comment


      • #4
        Catching up on this:


        As I guessed, by() was written for cibplot in 2003 only to support a variable name argument. See this opening code segment and the help.


        Code:
        *! NJC 1.0.0 18 August 2003
        program cibplot, sortpreserve rclass  
                version 8.1
                syntax varlist(numeric) [if] [in] [aweight fweight]        ///
                [ , BY(varname) LEVel(integer $S_level) Poisson BINomial   ///
                Exposure(varname) EXAct Jeffreys Wilson Agresti Total      ///
                Total2(str asis) MISSing INCLusive                         ///
                YTItle(str asis) XTItLE(str asis)                          ///
                HORizontal VERTical BARopts(str asis) plot(str asis) * ]
        Hence the command fails if you try to pass sub-options as well. That's as far as you got.

        The syntax would fail for a different reasons. The sub-options you are trying to pass on are options that would work with graph bar, but they would never work with twoway bar.

        In 2024 there are other ways to do it. Here I used myaxis (Stata Journal) and cisets (SSC).

        I don't endorse this kind of dynamite (detonator, plunger) plot myself.You have enough space to shown more detail about the data.


        Code:
        sysuse auto, clear
        
        cisets mean price, over(rep78) saving(myci)
        
        use myci, clear
        
        list
        
        myaxis group2=group, sort(mean point) descending
        
        twoway bar point group2, xla(1/5, valuelabel) barw(0.6) fcolor(none) ///
        || rcap ub lb group2, msize(large) legend(off)  ///
        ytitle(`= varlabel' (USD)) subtitle(Means and 95% confidence intervals)
        Click image for larger version

Name:	chen.png
Views:	1
Size:	44.4 KB
ID:	1770022

        Comment


        • #5
          Thank you very much Nick Cox. I learn your -cibplot- code, and found that it resorts to twoway bar. I recode my over variable with sort order, and take it back to cibplot to get the plot I want. Your combination use of cisets, myaxis, and twoway bar is great, I will use your new method later on.

          Comment


          • #6
            By the way, what do you mean by saying
            I don't endorse this kind of dynamite (detonator, plunger) plot myself.You have enough space to shown more detail about the data.
            Put it concretely, why you don't like bar plot with confidence intervals? And how do I shown more detail about the data? Or you have any other plots to recommend?

            Comment


            • #7
              You can search this forum and the internet more generally for pejorative discussion of dynamite plots, detonator plots and plunger plots. (To my mind they are different names for the same thing.)

              I think the objections fall into two main classes:

              1. They show too little information about the data. For example, the enormously wide confidence interval for repair record 1 is less surprising when you learn that it's based on two measurements.

              2. They often mislead -- whether on purpose or by accident is a secondary issue. Showing point estimates as bars emphasises their magnitude relative to zero, often not the issue of scientific or practical interest. The lower part of each confidence interval is often obscured or even occluded by dark bar colours.

              I would be in favour of any alternative plot that showed the raw data, such as a dot or strip plot or a quantile plot, or came close. A histogram is often good enough.

              In this particular example, I would favour geometric mean or median price.

              See the thread https://www.statalist.org/forums/for...-interval-sets for a sample discussion.

              Comment

              Working...
              X