macro
phft cssize inputcol
mcolumns cssize inputcol
mconstants what
note: This is a macro for Posthoc analysis after Friedman test either multigroup comparison or
note: comparison againt a single control .
note: For computational details refer to
note: Nonparametric statistics for behavioural sciences
note: Siegel S and Castellan NJ, 2nd edition, 1988 , McGraw Hill, Inc, New York, page 180-183
note: PLEASE REMEMBER TO ENTER SUM OF RANKS IN THE INPUT COLUMN
Note: What type of post hoc analysis you wish to perform
Note: Type YES & enter for multipgroup comparison. Type NO & enter for single group comparison
yesno what
if what=1
call phftmgc cssize inputcol
elseif what=0
call phftsgc cssize inputcol
endif
call phlabels
endmacro
####MACRO FOR MULTI GROUP COMPARISON
macro
phftmgc cssize inputcol
mcolumns cssize inputcol nsrno ctemp1 ctemp2 ctemp3 cdummy srno dcola dcolb diffcol diffabs ccga ccgb sig05 sig01
mconstants nperiods npminus1 nexttp nexttp1 kremain npplus1 ncomp ktemp1 nsample
mconstants a05 a01 z05 z01 wk1 wk2 crsdif05 crsdif01
#Post hoc analysis after Friedman's test. REf: Nonparametric statistics for behavioural sciences
# Siegel S and Castellan NJ, 2nd edition, 1988, page 180 , McGraw Hill, Inc, New York,
let nsample=cssize(1)
let nperiods=count(inputcol)
let ncomp=(nperiods*(nperiods-1))/2
let npminus1=nperiods-1
set srno
1:ncomp
end
set nsrno
1:nperiods
end
set ctemp1
0
end
#Creating comparable groups column i.e dcola
let nexttp=0
let nexttp1=0
let kremain=0
while nexttp<npminus1
let nexttp=nexttp+1
let nexttp1=nexttp+1
copy inputcol ctemp2;
use nexttp1:nperiods.
stack ctemp1 ctemp2 ctemp3
copy ctemp3 ctemp1
endwhile
copy ctemp3 ctemp3;
omit 1.
let dcola=ctemp3
#creating comparing groups column i.e dcolb
let nexttp=0
let nexttp1=0
let kremain=0
erase ctemp1 ctemp2 ctemp3
set ctemp1
0
end
while nexttp<npminus1
let nexttp=nexttp+1
let nexttp1=nexttp+1
let kremain=nperiods-nexttp
let ktemp1=inputcol(nexttp)
set ctemp2
1(ktemp1:ktemp1/1)kremain
end
stack ctemp1 ctemp2 ctemp3
copy ctemp3 ctemp1
endwhile
copy ctemp3 ctemp3;
omit 1.
let dcolb=ctemp3
#Creating comparable groups number column i.e ccga
let nexttp=0
let nexttp1=0
let kremain=0
erase ctemp1 ctemp2 ctemp3
set ctemp1
0
while nexttp<npminus1
let nexttp=nexttp+1
let nexttp1=nexttp+1
copy nsrno ctemp2;
use nexttp1:nperiods.
stack ctemp1 ctemp2 ctemp3
copy ctemp3 ctemp1
endwhile
copy ctemp3 ctemp3;
omit 1.
let ccga=ctemp3
#creating comparing groups number column i.e ccgb
let nexttp=0
let nexttp1=0
let kremain=0
erase ctemp1 ctemp2 ctemp3
set ctemp1
0
end
while nexttp<npminus1
let nexttp=nexttp+1
let nexttp1=nexttp+1
let kremain=nperiods-nexttp
let ktemp1=nsrno(nexttp)
set ctemp2
1(ktemp1:ktemp1/1)kremain
end
stack ctemp1 ctemp2 ctemp3
copy ctemp3 ctemp1
endwhile
copy ctemp3 ctemp3;
omit 1.
let ccgb=ctemp3
#calculating the z value for 0.05 significance and 0.01 signifiance
let a05=0.05/(ncomp*2)
let a01=0.01/(ncomp*2)
InvCDF a05 z05;
Normal 0.0 1.0.
InvCDF a01 z01;
Normal 0.0 1.0.
let z05=absolute(z05)
let z01=absolute(z01)
#Caculating the critical value for significant difference at 0.05 and 0.01; wk1 wk2 work constants for critical value
let wk1=(nsample*(nperiods*(nperiods+1)))/6
let wk2=wk1**0.5
let crsdif05=z05*wk2
let crsdif01=z01*wk2
#### calculating the difference and determining whether the difference is significant at 0.05, 0.01 level
let diffcol=dcola-dcolb
let diffabs=absolute(diffcol)
let sig05=diffabs>crsdif05
let sig01=diffabs>crsdif01
print inputcol nsrno ccgb ccga dcolb dcola diffcol sig05 sig01
endmacro
###
macro
phlabels
note: Description of columns : Input column i.e rank sums
note: nsrno=Group serial number; ccgb=base group;
ccga=comparative group
note: dcolb=Rank sum of base group; dcola=Rank sum of
comparative group
note: diffcol=Difference in rank sums
note: sig05= 1 implies significance at 0.05 level and 0
implies not signficant
note: sig01= 1 implies significance at 0.01 level and 0
implies not signficant
endmacro
##########MACRO FOR SINGLE GROUP COMPARISON
MACRO
phftsgc cssize inputcol
mcolumns cssize qsrno q05 q01 inputcol srno work2 diffcol dcola dcolb diffabs sig05 sig01 ccga ccgb nsrno
mconstants nexttp nextval nperiods nsample ncomp npminus1 z05 z01 crsdif05 crsdif01 wk1 wk2 compgrp contval a05 a01
let nperiods=count(inputcol)
#Post hoc analysis after Friedman's test. REf: Nonparametric statistics for behavioural sciences
# Siegel S and Castellan NJ, 2nd edition, 1988 , McGraw Hill, Inc, New York,p180
note: PLEASE REMEMBER TO ENTER SUM OF RANKS IN THE INPUT COLUMN
note: What is the comparative group. Enter the number 1 or 2 or 3 etc and press enter key
set work2;
file 'terminal';
nobs 1.
let nextval=1
let nexttp=0
let nsample=cssize(1)
let compgrp=work2(1)
let contval=inputcol(compgrp)
let nperiods=count(inputcol)
let ncomp=nperiods-1
let npminus1=nperiods-1
set srno
1:ncomp
end
set nsrno
1:nperiods
end
set qsrno
1:20
end
set q05
1.96
2.21
2.35
2.44
2.51
2.57
2.61
2.65
2.69
2.72
2.74
2.77
2.79
2.81
2.83
2.846
2.862
2.878
2.894
2.910
end
set q01
2.58
2.79
2.92
3.0
3.06
3.11
3.15
3.19
3.22
3.25
3.27
3.29
3.31
3.33
3.35
3.364
3.378
3.392
3.406
3.420
end
#calculating the z value for 0.05 significance and 0.01 signifiance
# If number of groups for comparison is less than 21, then above table could be used. Else z values based on
#normal distribution could be used
if nperiods le 21
let z05=q05(ncomp)
let z01=q01(ncomp)
else
let a05=0.05/(ncomp*2)
let a01=0.01/(ncomp*2)
InvCDF a05 z05;
Normal 0.0 1.0.
InvCDF a01 z01;
Normal 0.0 1.0.
let z05=absolute(z05)
let z01=absolute(z01)
endif
#wk1 wk2 work constants for critical value
let wk1=(nsample*(nperiods*(nperiods+1)))/6
let wk2=wk1**0.5
let crsdif05=z05*wk2
let crsdif01=z01*wk2
copy inputcol dcola;
omit compgrp.
set dcolb
1(contval:contval/1)npminus1
end
set ccgb
1(compgrp:compgrp/1)ncomp
end
copy nsrno ccga;
omit compgrp.
let diffcol=dcola-dcolb
let diffabs=absolute(diffcol)
let sig05=diffabs>crsdif05
let sig01=diffabs>crsdif01
#output
print inputcol nsrno ccgb ccga dcolb dcola diffcol sig05 sig01
endmacro
###
macro
phlabels
note: Description of columns : Input column i.e rank sums
note: nsrno=Group serial number; ccgb=base group;
ccga=comparative group
note: dcolb=Rank sum of base group; dcola=Rank sum of
comparative group
note: diffcol=Difference in rank sums
note: sig05= 1 implies significance at 0.05 level and 0
implies not signficant
note: sig01= 1 implies significance at 0.01 level and 0
implies not signficant
endmacro