macro
#
# Macro: PWILCOXON.MAC
# Version: Minitab 18
# Submitted by: Kelly Aubuchon, July 2009
#
# This macro performs a nonparametric test for paired samples by
# calculating the differences and then performing a one-sample Wilcoxon
# signed rank test. Optional subcommands allow you to specify the
# alternative hypothesis and to change the confidence level. By default,
# Minitab performs the two-sided test with H0: ETA = 0. The default
# confidence level is 95%.
#
# Suppose C1 contains the data for the first sample and C2 contains the
# data for the second sample. Go to Edit > Command Line Editor and type
#
# %pwilcoxon C1 C2
#
# Click on Submit Commands.
#
# There are optional subcommands to specify the alternative hypothesis or
# confidence level. Suppose you would like to perform a test such that
# H1: ETA < 0 and generate the 90% confidence interval. To use the
# subcommands, go to Edit > Command Line Editor and type
#
# %pwilcoxon C1 C2;
# alternative -1;
# confidence 90.
#
# Click on Submit Commands.
#
# Suppose you would like to perform a test such that H0: ETA = 50 and
# H1: ETA > 50. To use the subcommands, go to Edit > Command Line Editor
# and type
#
# %pwilcoxon C1 C2;
# alternative 1;
# null 50.
#
# Click on Submit Commands.
#
###########################################################################
#
# Neither Minitab, LLC nor the author(s) of this MACRO makes any claim
# of or offers any Warranty whatsoever with regard to the accuracy of
# this MACRO or its suitability for use. Minitab, LLC and the author(s)
# of this MACRO each hereby disclaims any Warranty and/or liability with
# respect thereto.
#
###########################################################################
pwilcoxon first second;
alternative k;
null d0;
confidence cl.
mcolumns first second diff
mconstants k d0 cl ft st dt fn sn fnam snam temp dnot tnot
default d0 = 0 k=0 cl=95
mreset
brief 0
noecho
notitle
endmtitle
dtype first ft
dtype second st
dtype d0 dt
if (ft=1 OR ft=2) AND (st=1 OR st=2)
count first fn
count second sn
if fn=sn
if k=-1 OR k=0 OR k=1
if dt=1 OR dt=2
kkname fnam first snam second
kkset tnot "Wilcoxon Signed Rank: " temp ", "
kkcat tnot fnam tnot
kkcat tnot temp tnot
kkcat tnot snam tnot
kkset dnot "Paired test for " temp " - "
kkcat dnot fnam dnot
kkcat dnot temp dnot
kkcat dnot snam dnot
name diff "Difference"
subtract second first diff
mtitle tnot;
notitle.
brief 2
write dnot
wtest d0 diff;
alternative k.
endmtitle
else
mtitle "Nonparametric Test for Paired Samples Macro Error";
notitle.
brief 1
print "* ERROR * Null hypothesis median must be numeric"
print " Macro Exiting"
endmtile
exit
endif
else
mtitle "Nonparametric Test for Paired Samples Macro Error";
notitle.
brief 1
print "* ERROR * Illegal Alternative"
print " Please specify 0, 1, or -1"
print " Macro Exiting"
endmtitle
exit
endif
else
mtitle "Nonparametric Test for Paired Samples Macro Error";
notitle.
brief 1
print "* ERROR * Data columns must be the same length"
print " Macro Exiting"
endmtitle
exit
endif
else
mtitle "Nonparametric Test for Paired Samples";
notitle.
brief 1
print "*Error* Invalid confidence level"
print " Please specify a value between 0.0101 and 99.9"
print " Macro Exiting"
endmtitle
exit
endif
if cl GE 0.0101 and cl LE 99.9
brief 0
mtitle "Nonparametric Test for Paired Samples";
notitle.
brief 2
Winterval cl diff
endmtitle
else
brief 0
mtitle "Nonparametric Test for Paired Samples";
notitle.
brief 1
print "*Error* Invalid confidence level"
print " Please specify a value between 0.0101 and 99.9"
print " Macro Exiting"
endmtitle
endif
endmacro