macro Ftest Response ID; Error alpha. #Mathews & Malnar #217 Third Street, Fairport Harbor, OH 44077 #(440)350-0911 pmathews@apk.net #Copyright September 2000 #August 20, 2000 Rev. 1.0 for Minitab V12.2 #Rev: 9/18/2000 Changed subcommand defaults #The data are in column Response and the treatment identifiers are in ID. #Macro calls MTB system macro for ftest, then PGM plotting macro. For #Minitab to find the macro you must either: #1) copy this file to your mtbwin\macros subdirectory #2) change the default directory to its location #3) use the full path name to the macro. #Example call: # mtb> %Ftest c1 c2; # subc> Error 0.01. #Copy these lines to the command prompt (without the #): #%Ftest c1 c2; #Error 0.01. mcolumns Response ID c3 c4 mconstant alpha notalpha k3 k4 dfnum dfdenom fp Default alpha = 0.05 brief 1 let notalpha=100*(1-alpha) %Vartest Response ID; #calls MTB system macro for ftest Confidence notalpha. Unstack Response c3 c4; Subscripts ID. Let k3=STDEV(c3) Let k4=STDEV(c4) IF k3>k4 Let fp =(k3/k4)**2 Let dfnum = count(c3)-1 Let dfdenom = count(c4)-1 Else Let fp =(k4/k3)**2 Let dfnum = count(c4)-1 Let dfdenom = count(c3)-1 EndIf let fp=round(fp,2) #print fp alpha dfnum dfdenom If fp < 4.5 Call ftestplot fp alpha dfnum dfdenom. #calls PGM plotting macro Else brief Note F is very large and p is very small. The plot will not be created. EndIf brief endmacro ################################################################# macro ftestplot fp alpha dfnum dfdenom #PGMathews 12/4/98 Rev. 1.0 for Minitab V12.1 #Creates a graph of the f distribution with right tail #shaded. Shades tail area corresponding to p. Places tick #corresponding to alpha. #Hypotheses are Ho: F=1 vs. Ha: F>1. #Example call: # mtb> %ftest 2.34 0.05 8 12 mcolumns f pdf group mconstant p fp alpha falpha dfnum dfdenom pdfmax mconstant shade notshade mconstant LARLim RARLim brief 0 set f #assigns the f values for plot 0:6/0.01. end pdf f pdf; #the corresponding probabilities f dfnum dfdenom. let pdfmax=max(pdf) let shade=round((6.0-fp)/0.01) let notshade=601-shade set group notshade(1) shade(0) end cdf fp p; #find the p value f dfnum dfdenom. let p=round(1-p,3) #round it for plotting let alpha=1-alpha #want the right tail invcdf alpha falpha; #here's the Falpha f dfnum dfdenom. let falpha=round(falpha,2) #round it for plotting let RARLim=falpha+0.3 #labes positions let LARLim=falpha-1.2 Layout Plot pdf*f; #plot the shaded regions Area group; #shaded region definitions Type 1 1; Color 14 0; EType 0 0; Base 0 0; NoLegend; NoFrame 1. Plot pdf * f; #plot the curve and lines Connect; Tick 1 0 1 fp falpha; #for x (1) axis TSize 0.8; Angle 90; Offset -0.007 -0.05; Tick 2 0; #for y (2) axis Line 0 0 6 0; #the baseline Line 1 0 1 pdfmax; #vertical line at F=1 Line falpha 0 falpha 0.4; #the A/R limit Text RARLim 0.3 "Reject Ho"; #the labels Text LARLim 0.3 "Accept Ho"; # Footnote "alpha= , falpha= "; # Footnote "p= , fp= "; Footnote "Mathews and Malnar, September 2000"; Size 0.7; Nolegend. EndLayout. brief endmacro