macro ciforp badcount inspectd pi upperCI lowerCI #Accepts D and n info and calculates and plots running 95% CI for p. #Column badcount should contain the number of defectives (D) found #in the samples of size indicated in inspectd (n). The CI limits for #the cumulative observations are calculated using a Poisson (chisquare) #approximation. No check is made to determine if the samples are #sufficiently large to justify the use of the approximation. This #shouldn't affect the validity of the later samples. #Example call: # mtb> %ciforp c1-c5 #To demo the macro try: #Random 100 c1; # Binomial 200 0.03. #set c2 #100(200) #end #%ciforp c1-c5 #by PGMathews 1 Oct 2001 V1.0 for Minitab V13.2 #rev: PGM 26 Jan 02 V1.1 Changed to two sided interval with run chart #rev: PGM 23 Feb 02 V1.2 Fixed mistake in lower CI df #Mathews and Malnar, Statistical Trainers and Consultants #217 Third Street, Fairport Harbor, OH 44077 #440-350-0911 pmathews@apk.net #This macro may give erroneous results. Mathews and Malnar are not responsible for #the use or misuse of this macro. mcolumn badcount inspectd pi upperCI lowerCI mcolumn cumbad cuminsp run fractbad mconstant howmany i dfupper dflower ucritval lcritval note note Macro is running ... note brief 0 let pi=badcount/inspectd #Find the sample fraction defective %runningsum badcount cumbad #running sum of defectives %runningsum inspectd cuminsp #running sum of units inspected let fractbad=cumbad/cuminsp #running fraction defective count badcount howmany #totals do i=1:howmany let dfupper=2*(cumbad(i)+1) let dflower=2*cumbad(i) invcdf 0.975 ucritval; #upper limit for p chisquare dfupper. let upperCI(i)=ucritval/2/cuminsp(i) invcdf 0.025 lcritval; #lower limit for p chisquare dflower. let lowerCI(i)=lcritval/2/cuminsp(i) enddo set run 1:howmany end plot pi*run fractbad*run upperCI*run lowerCI*run; symbol; type 1 0 0 0; size 0.5 1 1 1; connect; type 1 1 1 1; size 1 2 1 1; color 14 1 1 1; minimum 2 0; axis 1; label "Run"; axis 2; label "Fraction Defective"; footnote "Mathews and Malnar, October 2001"; size 0.7; title "95% CI for Cumulative Fraction Defective"; overlay. brief endmacro