Stephen Parry Post-hoc Analyses Let A, B, C represent categorical

Post-hocAnalyses
LetA,B,Crepresentcategoricalvariables,XandWrepresentcontinuousvariables.Unless
otherwisespecified,thefollowingcommandswillholdanycontinuousvariableatitsmeanand
willaverageoverfactorvariablesnotlistedinthestatement.
SAS
TheLSMEANScommandinSASisabletoperformpairwisecomparisonsfromvarious
proceduresincludingPROCGLM,MIXED,LOGISTIC,and,GLIMMIX.
LSMEANSA/pdiff=ALL;
PairwisecomparisonsoffactorA
LSMEANSA/pdifflines;
PairwisecomparisonsoffactorA,thelinesoption
producesacompactletterdisplay(cld).
LSMEANSA*B/slice=B;
PairwisecomparisonsoffactorAforeachleveloffactor
B.(GivesFtest).Togett-tests,useESTIMATEand
determineeachcontrast.
LSMEANSA*B*C/slice=B*C;
PairwisecomparisonsoffactorAforallcombinationsofB
andC.(GivesFtest)Togett-tests,useESTIMATEand
determineeachcontrast.
LSMEANSA/atX=5;
PairwisecomparisonsoffactorAwhenXis5
SPSS
IntheSPSSmenus,onlypost-hoctestingonmaineffectscanbedone.Inordertodomore
sophisticatedanalyses,youneedtousethesyntax.TheEMMEANSstatementcanbeexecuted
forgenerallinearmodels(UNIANOVA)generalizedlinearmodels(GENLIN)andlinearmixed
models(MIXED).
/EMMEANS=TABLES(A)
PairwisecomparisonsofallthelevelsoffactorA
/EMMEANS=TABLES(A*B)
PairwisecomparisonsofallthelevelsoffactorAforeach
COMPARE(A)
leveloffactorB
/EMMEANS=TABLES(A*B*C)
PairwisecomparisonsofallthelevelsoffactorAforall
COMPARE(A)
combinationsofBandC. /EMMEANS=TABLES(A)with(X=5) PairwisecomparisonsofallthelevelsoffactorAwhenX
COMPARE
is5
/EMMEANS=TABLES(A*B*C)
PairwisecomparisonsofalllevelsoffactorAforall
with(X=5)COMPARE(A)
combinationsofBandCwhenX=5.
StephenParry
R
InR,thelsmeansfunctionfromthelsmeanspackagecaneasilyandeffectivelyhandlepost-hoc
analyses.Thelsmeansfunctionsupportsaov,lm,andglmmodelsaswellasmodelsestimated
viafunctionsfromthenlme,lme4,survival,andgeepackpackages.Theglhtfunctioninthe
multcomppackagecanalsobeusedtospecifycontrasts.ThemultcompViewpackagecontains
thecldfunction,whichassignscomparisonsdifferentletterswhentheyaresignificantly
different.
lsmeans(model,pairwise~A)
PairwisecomparisonsoffactorA
lsmeans(model,pairwise~A|B)
PairwisecomparisonsoffactorAforeachlevel
offactorB
lsmeans(model,pairwise~A|B*C)
PairwisecomparisonsoffactorAforall
combinationsofBandC. lsmeans(model,pairwise~A|X,
PairwisecomparisonsoffactorAwhenXis1,5,
at=list(X=(c(1,5,10)))
and10
lsmeans(model,pairwise~A|X*W,
PairwisecomparisonsoffactorAwhenXis1,5,
at=list(X=(c(1,5,10),W=c(1,2))
and10andW=2and3
lsm<-lsmeans(model,~A|B)
ThisgivesglobalFtestsforeachlevelofB,
pl<-contrast(lsm,"poly",name="order") comparingthemeansofthelevelsofA.This
test(pl,joint=TRUE,by="B")
matchesJMP’s“testslices”command.
lsmip(model,A~B)
Aninteractionplot,wherethelevelsofBare
plottedonthex-axis,andeachlevelofAis
givenaline.
lsmip(model,A~B|C)
Three-wayinteractionplot,whereforeachlevel
ofC,thelevelsofBareplottedonthex-axis,
andeachlevelofAisgivenaline.
lsmip(model,A~B|C*X,at=list(X=
Four-wayinteractionplot,whereforevery
c(1,5,10)))
combinationofCandX,thelevelsofBare
plottedonthex-axis,andeachlevelofAis
givenaline.
cld(lsmeans(model, ~A)
Cld(compactletterdisplay)liststheLSmans
alongwithgroupingsymbolsforpairwise
contrasts.
StephenParry
STATA
Statahasafewcommandsthatareusefulforpost-estimationpurposes:pwcompare,contrast,
margins,andmarginsplot(forgraphing).Note:Inordertoobtainp-valuesforpairwise
comparisons,youmustspecifythepwcompare(effects)optionforthemarginscommand.
pwcompareA,mcompare(tukey) PairwisecomparisonsoffactorAwithTukeyCorrection.
pveffects
(Setsanycontinuousvariablesto0)
marginsA,pwcompare(effects)
PairwisecomparisonsoffactorAwithBonferroni
mcomp(bonferroni)
correction.Anycontinuousvariableisevaluatedatthe
mean.
contrastA@B
ForeachlevelofB,testsifthemeansofallthelevelsof
Aareequal.(GivesFtest).Toobtainthet-tests,you
needtospecifythecontrast
marginsA,at(B=1)
PairwisecomparisonsofalllevelsofAforthefirstlevel
pwcompare(effects)
ofB.
marginsA#B,at(C=1)
PairwisecomparisonsofalllevelsofA#BatC=”1”.
pwcompare(effects)
marginsA#i(1).B#i(1).C,
PairwisecomparisonsofAwhenbothB=”1”andC=”1”
pwcompare(effects)
contrastA@B#C,effects
MarginalmeansforAoverallcombinationsofBandC.
(GivesFtest)
marginsA,at(X=(5))
PairwisecomparisonsoffactorAwhenX5
pwcompare(effects)
marginsB#A
Aninteractionplot,wherethelevelsofBareplottedon
marginsplot
thex-axis,andeachlevelofAwillbegivenaline.
marginsB#A#C
Three-wayinteractionplot,whereforeachlevelofC,
marginsplot,by(C)
thelevelsofBareplottedonthex-axis,andeachlevel
ofAwillbegivenaline.
marginsA,at(X=(1,4)Y=(3,5))
Three-wayinteractionplot,whereforeachlevelofAhas
marginsplot,by(A)
itsowngraph,thex-axiscontainsthespecifiedvalues
forX,and2linesforwhenY=3andY=5aregraphed.
StephenParry
JMP
Theoptionsorpost-hocanalysisareabitlimitedinJMP.Forinteractionterms,youcanusethe
testslicestoobtainaglobalFtest,andobtainthepairwisecomparisons.TukeyHSDadjustedpvaluescanbeobtainedwhencomparingallpossiblecellsoftheinteractionterm;however,itis
impossibletoapplyamultiplecomparisonsadjustmenttothecontrastsfromslices.
LSMeansDifferencesTukeyHSD PairwisecomparisonsofallthelevelsoffactorAusing
TukeyCorrection
Select“testslices”.
IfA*Bisinthemodel,thisprovidespairwisecomparisons
offactorAforeachlevelofBandviceversa.(GivesF
test).Fort-tests,youneedtomanuallyinsertthe
contrast.
Afterrunningthemodel,goto
MarginalMeansforfactorAwhenXis5
FactorProfiling->Profiler
StephenParry