Announcement

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

  • how to use serrbar for panel data and different treatments

    Dear Stata friends,

    I have a panel dataset coming from a between-subject design experiment where different subjects play for 8 periods in each treatment. I would like to overlay means and standard deviations of my variable of interest against the time variable (period) with lines connecting points that are indicating mean values for each different treatment (so I would like to have 4 lines). This is an example of
    what I want to obtain.
    Click image for larger version

Name:	Senza titolo.png
Views:	1
Size:	31.8 KB
ID:	1446199



    Now, I am trying to use the serrbar command but it seems not allowing me to draw different lines for different treatment (for example serrbar does not allow to use the “by” command for group variables like my dummy variable which is “treatment"). I have also tried to use the addplot option to add other serrbar graphs on the same plot but it does not work). For any useful suggestion I would be very grateful.

    Francesco

  • #2
    Here I add some more info.

    The names of my variables are: mean (for means), sd (for standard deviation) and period (for time). Now, I am trying to use the serrbar command but it seems not allowing me to draw different lines for different treatments (for example serrbar does not allow to use the “by” command for group variables like my dummy variable which is “treatment”).

    serrbar mean sd period, by(treatment)

    I have also tried to use the addplot option to add other serrbar graphs on the same plot only for a proof between the first two treatments but it does not work:

    serrbar mean sd period in 1/8, addplot(serrbar mean sd period in 9/16)

    In addition I also tried this command:

    serrbar mean sd period in 1/8 || serrbar mean sd period in 9/16

    Comment


    • #3
      serrbar doesn't do very much at all. I am supposedly its author but this is no more than StataCorp generosity in respect of community-contributed code, as I just suggested some changes back in Stata 6.

      The addplot() idea won't work because serrbar is not a twoway type.

      serrbar is just a wrapper for a simple idea: to plot intervals showing uncertainty with twoway rcap and points showing estimates with twoway scatter and that is the strategy to follow.

      Comment


      • #4
        OK. Thank you very much Nick.

        Comment

        Working...
        X