Announcement

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

  • ciplot, two plots in same graph

    Dear all,

    I have used ciplot to look at the point estimates and confidence intervals. The code I have used is as follows:
    Code:
    ciplot Y if Intervention==1, by(month)  ///
    name(name1)
    
    ciplot Yif Intervention==0, by(month) ///
    name(name2)
    
    graph combine name1 name2
    This produces two figures next to each other. I would like to have to the plots in the same figure. Is this possible?

    What I essentially want, is to plot the mean and confidence interval on three different points in time for two groups; if there is another code that works better, any tip would be appreciated.

    Best,
    Lillian Myrtveit

  • #2
    ciplot is from SSC, as you are asked to explain (FAQ Advice #12).

    The help says this

    (note added August 2011)

    For fuller flexibility, consider using statsby first and then standard graphics commands (Cox 2010).

    Cox, N.J. 2010. Speaking Stata: The statsby strategy. Stata Journal 10: 143-151.
    and I can only endorse that advice you should have already read.


    FAQ Advice #12 also asks for a data example, but you don't give one. Failing that, here is something you can run.

    Code:
    sysuse auto, clear 
    
    gen rep782 = inlist(rep78, 4, 5) 
    label def rep782 0 "{&le} 3"  1 "4 or 5"
    label val rep782 rep782 
    local ytitle : var label mpg 
    
    statsby , by(foreign rep782) clear: ci means mpg 
    
    list 
    
    twoway rspike lb ub foreign, by(rep782, legend(off) note("") subtitle(Repair record)) ///
    || scatter mean foreign , xla(0 1, val) ytitle("`ytitle'") xsc(r(-0.2 1.2)) yla(, ang(h))
    Click image for larger version

Name:	ciplot_alt.png
Views:	1
Size:	28.4 KB
ID:	1449972


    Flexibility means, among many other choices, freedom to use rcap rather than rspike..

    Comment

    Working...
    X