Announcement

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

  • Adding error bars to twoway line plot of means

    Hi all. I would like to plot the following graph and include error bars. I have two groups (controls and PD). This code plots what I would like (see attachment: )-- a plot of the mean score for PD and the mean score for controls at each time point where each group has data (i.e., as the control group has some missing time points).

    capture program drop graphData
    program graphData
    preserve
    collapse toe_tapping_R, by(Group timesince)
    graph twoway (line toe_tapping_R timesince if Group=="Control") (line toe_tapping_R timesince if Group=="PD") (scatter toe_tapping_R timesince if Group=="Control") (scatter toe_tapping_R timesince if Group=="PD"), xtitle("Time since baseline visit (years)") ytitle("Group means for task") legend(label(1 "Control") label(2 "PD"))
    restore
    end
    graphData


    However, after looking at other examples, I am quite confused how I might add standard error bars to this graph-- e.g., I could not figure out how to get rcap to work, and if I use marginsplot, this will plot the predicted means from a model I run, not the raw data, correct?

    Best,
    Kathleen
    Attached Files
Working...
X