macro OneT c1; Test Mu0; Error alpha; Ha tails. #Mathews & Malnar August 20,2000 Rev. 1.0 for Minitab V13.2 #(440) 350-0911 pmathews@apk.net #217 Third Street, Fairport Harbor, OH 44077 #Macro calls MTB system macro onet and then PGM macro. #Mu0 is the hypothesized population mean. #alpha is the type 1 error rate, by default 0.05. #set tails =-1 for left tail test, 1 for right tail, and 0 (default) for two tails. #Example call: # MTB > %OneT c1; # SUBC> Test 5; #test Ho:mu=5 # SUBC> Error 0.05; # SUBC> Ha 0. #two tailed test #Copy these lines to the command prompt and delete the leading #s #%OneT c1; #Test 5; #Error 0.05; #Ha 0. mcolumns c1 mconstant Mu0 tp df tails alpha default Mu0=0 default alpha=0.05 default tails=0 brief OneT c1; #calls MTB system macro for ttest Test Mu0. Let tp = (Mean(c1)-Mu0)/(STDEV(c1)/sqrt(count(c1))) Let tp = round (tp, 2) Let df = count(c1)-1 If abs (tp) < 3.1 Call ttestplot tp alpha df; #calls PGM plotting macro Ha tails. Else Note Your p value is out of range EndIf Endmacro ############################################################## macro ttestplot tp alpha df; Ha tails. #-1/0/+1 for left/two tailed/right #PGMathews 12/4/98 Rev. 1.0 for Minitab V12.1 #Creates a graph of the t distribution with tails shaded. #Shades tail area(s) corresponding to p. Places tick(s) #corresponding to alpha. #Default hypothesis is two tails (Ha: mu.ne.mu0). #Use tails=-1 for one tailed left test (Ha: mumu0). #Example call: # mtb> %ttestplot -2.34 0.05 12; # subc> Ha -1. mcolumns t pdf group mconstant p tp df alpha talpha tails mconstant ltalpha rtalpha halfalph maxpdf mconstant shade notshade mconstant LARLim RARLim default tails=0 brief 0 set t #assigns the z values for plot -3.4:3.4/0.01. end pdf t pdf; #the corresponding probabilities t df. let maxpdf=max(pdf) ############################################################## If tails = -1 #Ha: mumu0 let shade=round((3.4-tp)/0.01) let notshade=681-shade set group notshade(1) shade(0) end cdf tp p; t df. let p=round(1-p,3) invcdf alpha talpha let talpha=round(-talpha,2) let RARLim=talpha+0.3 let LARLim=talpha-1.4 Layout Plot pdf*t; Area group; #the shaded regions Type 1 1; Color 14 0; EType 0 0; Base 0 0; NoLegend; NoFrame 1. Plot pdf * t; #the curve and lines Connect; Tick 1 0 tp talpha; #for x (1) axis TSize 0.8; Angle 90; Offset -0.007 -0.05; Tick 2 0; #for y (2) axis Line -3.4 0 3.4 0; #the baseline Line 0 0 0 maxpdf; #the origin Line talpha 0 talpha maxpdf; #the A/R limit Text RARLim 0.3 "Reject Ho"; Text LARLim 0.3 "Accept Ho"; #Footnote "alpha= , talpha= "; #Footnote "p= , tp= "; Footnote "Mathews and Malnar, December 1998"; Size 0.7; Nolegend. EndLayout. ########################################################### Else #Ha: mu.ne.mu0 let shade=round((3.4-abs(tp))/0.01) let notshade=681-2*shade set group #settings for fill groups shade(0) notshade(1) shade(0) end cdf tp p; t df. let p=round(p,3) #format for plot let halfalph=alpha/2 #let's just do one side invcdf halfalph ltalpha; #the z value t df. let rtalpha=-ltalpha #the right side let ltalpha=round(ltalpha,2) #formatted for plot let rtalpha=round(rtalpha,2) let RARLim=rtalpha+0.3 #plotting positions let LARLim=ltalpha-1.4 #for labels Layout Plot pdf*t; #for the fill regions Area group; #the shaded regions Type 1 1; #solid fill Color 14 0; #gray tails EType 0 0; Base 0 0; #lower limit for fill NoLegend; NoFrame 1. Plot pdf * t; #the curve and lines Connect; Tick 1 0 tp ltalpha -rtalpha; #for x (1) axis TSize 0.8; #small ones Angle 90; #rotated for room Offset -0.007 -0.05; #to line up the characters Tick 2 0; #for y (2) axis Line -3.4 0 3.4 0; #the baseline Line 0 0 0 maxpdf; #the origin Line ltalpha 0 ltalpha maxpdf; #the left A/R limit Line rtalpha 0 rtalpha maxpdf; #the right A/R limit Text LARLim 0.3 "Reject Ho"; #the labels Text RARLim 0.3 "Reject Ho"; Text -0.5 0.3 "Accept Ho"; #Footnote "alpha= , talpha= "; #Footnote "p= , tp= "; Footnote "Mathews and Malnar, December 1998"; Size 0.7; Nolegend. EndLayout. Endif ############################################################ brief endmacro