macro FishersV12 D1 D2 N1 N2 #This macro calculates the one-tailed Fisher's method p value for the #two-sample test to compare two population fractions defective. The #user must specify the number of defectives (D1 and D2) and the corresponding #sample sizes (N1 and N2). #This is the V12 version of fishers which uses the binomial approximation #to the hypergeometric distribution. The total number of defectives must be #small compared to the total number of parts inspected for this method to #be valid. #Example calling statement: # mtb> %fishersV12 0 4 20 20 #Rev. 1.1 20Oct01 PGMathews: Modified inital macro (V13) to run under V12 #Copyright (c) Paul G. Mathews 19 October 2001 All rights reserved #Paul Mathews and Rebecca Malnar, Statistical Trainers and Consultants #217 Third Street, Fairport Harbor, OH 44077 #440-350-0911 #pmathews@apk.net #This macro may contain errors and its accuracy is not guaranteed. Use #this macro at your own risk. Mathews and Malnar take no responsibility #for the use or misuse of this macro. mcolumn Sample Bad mconstant N TotDef N1 N2 D1 D2 p1 p2 pvalue p mtitle "Fisher's Method to Compare Two Population Fractions Defective" note notitle let N=N1+N2 let TotDef=D1+D2 let p1=D1/N1 let p2=D2/N2 print N1 D1 p1 note print N2 D2 p2 if TotDef>(N*0.05) #Freund's condition note note Binomial approximation conditions are not met. note You will have to do the calculation manually or with V13. return endif if p1p2 # cdf D2 pvalue; #V13 # hypergeometric N N2 TotDef. #V13 let p=N2/N #V12 cdf D2 pvalue; #V12 binomial TotDef p. #V12 mtitle "Testing hypotheses Ho: p1 = p2 vs. Ha: p1 > p2" endif note This macro uses an approximate method and the p value may not be accurate let pvalue=round(pvalue,3) print pvalue endmacro