Announcement

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

  • Bar graph not showing correct mean for one variable

    Hi!

    I'm trying to create a bar graph with CI's for a total of 6 variables using catcibar with the following code:

    Code:
    catcibar MDP_A1 MDP_SQ_1int MDP_SQ_2int MDP_SQ_3int MDP_SQ_4int MDP_SQ_5int  if once == 1, over(lastb1) color (eltgreen erose) ytitle("NRS 0-10") xtitle ("MDP Dimension")
    All variables are shown in the bar graph with correct means except MDP_SQ_1int which is shown as having a too low mean value which I can also confirm by running a ttest or mean command. Confusingly, I seem to get the correct values for MDP_SQ_1int if run catcibar with only this variable. Any suggestions on how I could resolve this would be greatly appreciated.

  • #2
    Please see the FAQ Advice especially https://www.statalist.org/forums/help#stata for good practice in asking questions.

    You don't explain catcibar but a Google reveals

    Code:
     
     net install catcibar, from("https://aarondwolf.github.io/catcibar")
    So far, so good, but I can only make guesses in the absence of a data example such as we request.

    I suspect that you have problems with missing values. I would ideally like to see the results of

    Code:
     
     list lastb1 MDP_A1 MDP_SQ_1int MDP_SQ_2int MDP_SQ_3int MDP_SQ_4int MDP_SQ_5int  if once == 1
    if that's not too voluminous and minimally the results of
    Code:
      
     su lastb1 MDP_A1 MDP_SQ_1int MDP_SQ_2int MDP_SQ_3int MDP_SQ_4int MDP_SQ_5int  if once == 1

    Comment


    • #3
      Thank you, I will try to explain the question better next time.
      I discovered that the last variable (MDP_SQ_5int) also gave a slightly wrong mean using catcibar.
      All missing is marked with ".".
      The first option was indeed very voluminous. The results of the second is:
      Variable Obs Mean Std. dev. Min Max
      lastb1 92 1.217391 .4147311 1 2
      MDP_A1 88 4.261364 2.146873 0 8
      MDP_SQ_1int 86 4.011628 2.596351 0 10
      MDP_SQ_2int 81 1.320988 2.096587 0 9
      MDP_SQ_3int 82 .9756098 1.609966 0 8
      MDP_SQ_4int 83 2.168675 2.453565 0 8
      MDP_SQ_5int 89 4.696629 2.785533 0 10

      Comment


      • #4
        There may be other problems -- but you should check out the cw option.


        Code:
        cw                      Calculate means and confidence intervals casewise. Default is to drop all observations where any observations of varlist, over, or
                                        by(varlist) are missing.

        Comment


        • #5
          Thank you so much. Been working on this for hours and this did the trick instantly.

          Comment

          Working...
          X