Announcement

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

  • P Chart

    Hi!

    I would like to create a p chart that recalculates at a designated point. Attaching an image to illustrate. I realize this wasn't created by Stata, but feels like something Stata should be able to.

    Thanks

    Click image for larger version

Name:	pchart.PNG
Views:	1
Size:	111.2 KB
ID:	1774680

  • #2
    There is a reference to 'CL,' which I assume stands for confidence limit. To calculate these limits, you need information about the distribution— in case you don’t have these a priori. Otherwise, to me, the graph appears to be a plot of the maximum, minimum, and mean over some range. You can use twoway to generate such a plot.

    Code:
    clear
    *GENERATE DATASET ASSUMING SOME STRUCTURAL BREAK
    set seed 03202025
    set obs 41
    gen series1 = rnormal(15, 3)
    gen series2= rnormal(10, 3)
    gen series= cond(_n<=24, series1, series2)
    drop series?
    gen which= cond(_n<=24, 1, 2)  
    gen week=_n
    
    *START HERE
    frame put series which, into(new)
    frame new: collapse (min) min= series (max) max=series (mean) mean=series, by(which)
    frlink m:1 which, frame(new)
    frget min max mean, from(new)
    drop new
    frame drop new
     
    *GRAPH
    tw scatter series week || ///
    line max week, lp(dash) lc(red) || ///
    line min week, lp(dash) lc(red) || ///
    line mean week, lc(red) lp(.-.) || ///
    line mean week if which==1 , lc(red) || ///
    line mean week if which==2 , lc(red) leg(off) xlab(1(4)41)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	53.3 KB
ID:	1774687

    Comment

    Working...
    X