Anda di halaman 1dari 15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

HypothesisTestingAnalysisofVariance(ANOVA)
Author:
LisaSullivan,PhD
ProfessorofBiostatistics
BostonUniversitySchoolofPublicHealth

Introduction
Thismodulewillcontinuethediscussionofhypothesistesting,whereaspecificstatementorhypothesisis
generatedaboutapopulationparameter,andsamplestatisticsareusedtoassessthelikelihoodthatthe
hypothesisistrue.Thehypothesisisbasedonavailableinformationandtheinvestigator'sbeliefaboutthe
populationparameters.Thespecifictestconsideredhereiscalledanalysisofvariance(ANOVA)andisa
testofhypothesisthatisappropriatetocomparemeansofacontinuousvariableintwoormore
independentcomparisongroups.Forexample,insomeclinicaltrialstherearemorethantwocomparison
groups.Inaclinicaltrialtoevaluateanewmedicationforasthma,investigatorsmightcomparean
experimentalmedicationtoaplaceboandtoastandardtreatment(i.e.,amedicationcurrentlybeing
used).InanobservationalstudysuchastheFraminghamHeartStudy,itmightbeofinteresttocompare
meanbloodpressureormeancholesterollevelsinpersonswhoareunderweight,normalweight,
overweightandobese.
Thetechniquetotestforadifferenceinmorethantwoindependentmeansisanextensionofthetwo
independentsamplesprocedurediscussedpreviouslywhichapplieswhenthereareexactlytwo
independentcomparisongroups.TheANOVAtechniqueapplieswhentherearetwoormorethantwo
independentgroups.TheANOVAprocedureisusedtocomparethemeansofthecomparisongroupsand
isconductedusingthesamefivestepapproachusedinthescenariosdiscussedinprevioussections.
Becausetherearemorethantwogroups,however,thecomputationoftheteststatisticismoreinvolved.
Theteststatisticmusttakeintoaccountthesamplesizes,samplemeansandsamplestandarddeviations
ineachofthecomparisongroups.
Ifoneisexaminingthemeansobservedamong,saythreegroups,itmightbetemptingtoperformthree
separategrouptogroupcomparisons,butthisapproachisincorrectbecauseeachofthesecomparisons
failstotakeintoaccountthetotaldata,anditincreasesthelikelihoodofincorrectlyconcludingthatthere
arestatisticallysignificatedifferences,sinceeachcomparisonaddstotheprobabilityofatypeIerror.
Analysisofvarianceavoidstheseproblemssbyaskingamoreglobalquestion,i.e.,whetherthereare
significantdifferencesamongthegroups,withoutaddressingdifferencesbetweenanytwogroupsin
http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

1/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

particular(althoughthereareadditionalteststhatcandothisiftheanalysisofvarianceindicatesthat
therearedifferencesamongthegroups).
ThefundamentalstrategyofANOVAistosystematicallyexaminevariabilitywithingroupsbeingcompared
andalsoexaminevariabilityamongthegroupsbeingcompared.

LearningObjectives
Aftercompletingthismodule,thestudentwillbeableto:
1.Performanalysisofvariancebyhand
2.Appropriatelyinterpretresultsofanalysisofvariancetests
3.Distinguishbetweenoneandtwofactoranalysisofvariancetests
4.Identifytheappropriatehypothesistestingprocedurebasedontypeofoutcomevariableand
numberofsamples

TheANOVAApproach
Consideranexamplewithfourindependentgroupsandacontinuousoutcomemeasure.Theindependent
groupsmightbedefinedbyaparticularcharacteristicoftheparticipantssuchasBMI(e.g.,underweight,
normalweight,overweight,obese)orbytheinvestigator(e.g.,randomizingparticipantstooneoffour
competingtreatments,callthemA,B,CandD).Supposethattheoutcomeissystolicbloodpressure,and
wewishtotestwhetherthereisastatisticallysignificantdifferenceinmeansystolicbloodpressures
amongthefourgroups.Thesampledataareorganizedasfollows:

SampleSize

Group1 Group2 Group3 Group4


n1

n2

n3

n4

s1

s2

s3

s4

SampleMean
SampleStandardDeviation

ThehypothesesofinterestinanANOVAareasfollows:
H0:1=2=3...=k
H1:Meansarenotallequal.
wherek=thenumberofindependentcomparisongroups.

Inthisexample,thehypothesesare:
H0:1=2=3=4
H1:Themeansarenotallequal.
ThenullhypothesisinANOVAisalwaysthatthereisnodifferenceinmeans.Theresearchoralternative
http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

2/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

hypothesisisalwaysthatthemeansarenotallequalandisusuallywritteninwordsratherthanin
mathematicalsymbols.Theresearchhypothesiscapturesanydifferenceinmeansandincludes,for
example,thesituationwhereallfourmeansareunequal,whereoneisdifferentfromtheotherthree,
wheretwoaredifferent,andsoon.Thealternativehypothesis,asshownabove,captureallpossible
situationsotherthanequalityofallmeansspecifiedinthenullhypothesis.

TestStatisticforANOVA
TheteststatisticfortestingH0:1=2=...=kis:

andthecriticalvalueisfoundinatableofprobabilityvaluesfortheFdistributionwith(degreesof
freedom)df1=k1,df2=Nk.Thetablecanbefoundin"OtherResources"ontheleftsideofthepages.
Intheteststatistic,nj=thesamplesizeinthejthgroup(e.g.,j=1,2,3,and4whenthereare4
comparisongroups),
isthesamplemeaninthejthgroup,and istheoverallmean.krepresentsthe
numberofindependentgroups(inthisexample,k=4),andNrepresentsthetotalnumberofobservations
intheanalysis.NotethatNdoesnotrefertoapopulationsize,butinsteadtothetotalsamplesizeinthe
analysis(thesumofthesamplesizesinthecomparisongroups,e.g.,N=n1+n2+n3+n4).Theteststatistic
iscomplicatedbecauseitincorporatesallofthesampledata.Whileitisnoteasytoseetheextension,the
Fstatisticshownaboveisageneralizationoftheteststatisticusedfortestingtheequalityofexactlytwo
means.
NOTE:TheteststatisticFassumesequalvariabilityinthekpopulations(i.e.,thepopulationvariancesare
equal,ors12=s22=...=sk2).Thismeansthattheoutcomeisequallyvariableineachofthecomparison
populations.Thisassumptionisthesameasthatassumedforappropriateuseoftheteststatistictotest
equalityoftwoindependentmeans.Itispossibletoassessthelikelihoodthattheassumptionofequal
variancesistrueandthetestcanbeconductedinmoststatisticalcomputingpackages.Ifthevariabilityin
thekcomparisongroupsisnotsimilar,thenalternativetechniquesmustbeused.
TheFstatisticiscomputedbytakingtheratioofwhatiscalledthe"betweentreatment"variabilitytothe
"residualorerror"variability.Thisiswherethenameoftheprocedureoriginates.Inanalysisofvariance
wearetestingforadifferenceinmeans(H0:meansareallequalversusH1:meansarenotallequal)by
evaluatingvariabilityinthedata.Thenumeratorcapturesbetweentreatmentvariability(i.e.,differences
amongthesamplemeans)andthedenominatorcontainsanestimateofthevariabilityintheoutcome.
Theteststatisticisameasurethatallowsustoassesswhetherthedifferencesamongthesamplemeans
(numerator)aremorethanwouldbeexpectedbychanceifthenullhypothesisistrue.Recallinthetwo
independentsampletest,theteststatisticwascomputedbytakingtheratioofthedifferenceinsample
means(numerator)tothevariabilityintheoutcome(estimatedbySp).
ThedecisionrulefortheFtestinANOVAissetupinasimilarwaytodecisionrulesweestablishedfort
tests.Thedecisionruleagaindependsonthelevelofsignificanceandthedegreesoffreedom.TheF
statistichastwodegreesoffreedom.Thesearedenoteddf1anddf2,andcalledthenumeratorand
denominatordegreesoffreedom,respectively.Thedegreesoffreedomaredefinedasfollows:
df1=k1anddf2=Nk,
wherekisthenumberofcomparisongroupsandNisthetotalnumberofobservationsintheanalysis.If
thenullhypothesisistrue,thebetweentreatmentvariation(numerator)willnotexceedtheresidualor
errorvariation(denominator)andtheFstatisticwillsmall.Ifthenullhypothesisisfalse,thentheFstatistic
willbelarge.TherejectionregionfortheFtestisalwaysintheupper(righthand)tailofthedistributionas
shownbelow.
RejectionRegionforFTestwitha=0.05,df1=3anddf2=36(k=4,N=40)
http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

3/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

Forthescenariodepictedhere,thedecisionruleis:RejectH0ifF>2.87.

TheANOVAProcedure
WewillnextillustratetheANOVAprocedureusingthefivestepapproach.Becausethecomputationofthe
teststatisticisinvolved,thecomputationsareoftenorganizedinanANOVAtable.TheANOVAtable
breaksdownthecomponentsofvariationinthedataintovariationbetweentreatmentsanderroror
residualvariation.StatisticalcomputingpackagesalsoproduceANOVAtablesaspartoftheirstandard
outputforANOVA,andtheANOVAtableissetupasfollows:
Sourceof
Variation

SumsofSquares(SS)

Degreesof
Freedom(df)

Between
Treatments

k1

Error(or
Residual)

Nk

Total

N1

Mean
Squares(MS)

where
X=individualobservation,
=samplemeanofthejthtreatment(orgroup),
=overallsamplemean,
k=thenumberoftreatmentsorindependentcomparisongroups,and
N=totalnumberofobservationsortotalsamplesize.
TheANOVAtableaboveisorganizedasfollows.
http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

4/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

Thefirstcolumnisentitled"SourceofVariation"anddelineatesthebetweentreatmentanderror
orresidualvariation.Thetotalvariationisthesumofthebetweentreatmentanderrorvariation.
Thesecondcolumnisentitled"SumsofSquares(SS)".Thebetweentreatmentsumsofsquares
is

andiscomputedbysummingthesquareddifferencesbetweeneachtreatment(orgroup)mean
andtheoverallmean.Thesquareddifferencesareweightedbythesamplesizespergroup(nj).
Theerrorsumsofsquaresis:

andiscomputedbysummingthesquareddifferencesbetweeneachobservationanditsgroup
mean(i.e.,thesquareddifferencesbetweeneachobservationingroup1andthegroup1mean,
thesquareddifferencesbetweeneachobservationingroup2andthegroup2mean,andso
on).Thedoublesummation(SS)indicatessummationofthesquareddifferenceswithineach
treatmentandthensummationofthesetotalsacrosstreatmentstoproduceasinglevalue.(This
willbeillustratedinthefollowingexamples).Thetotalsumsofsquaresis:

andiscomputedbysummingthesquareddifferencesbetweeneachobservationandtheoverall
samplemean.InanANOVA,dataareorganizedbycomparisonortreatmentgroups.Ifallofthe
datawerepooledintoasinglesample,SSTwouldreflectthenumeratorofthesamplevariance
computedonthepooledortotalsample.SSTdoesnotfigureintotheFstatisticdirectly.
However,SST=SSB+SSE,thusiftwosumsofsquaresareknown,thethirdcanbecomputed
fromtheothertwo.
Thethirdcolumncontainsdegreesoffreedom.Thebetweentreatmentdegreesoffreedomisdf1
=k1.Theerrordegreesoffreedomisdf2=Nk.ThetotaldegreesoffreedomisN1(anditis
alsotruethat(k1)+(Nk)=N1).
Thefourthcolumncontains"MeanSquares(MS)"whicharecomputedbydividingsumsof
squares(SS)bydegreesoffreedom(df),rowbyrow.Specifically,MSB=SSB/(k1)and
MSE=SSE/(Nk).DividingSST/(N1)producesthevarianceofthetotalsample.TheFstatisticisin
therightmostcolumnoftheANOVAtableandiscomputedbytakingtheratioofMSB/MSE.

Example
Aclinicaltrialisruntocompareweightlossprogramsandparticipantsarerandomlyassignedtooneof
thecomparisonprogramsandarecounseledonthedetailsoftheassignedprogram.Participantsfollow
theassignedprogramfor8weeks.Theoutcomeofinterestisweightloss,definedasthedifferencein
weightmeasuredatthestartofthestudy(baseline)andweightmeasuredattheendofthestudy(8
weeks),measuredinpounds.
Threepopularweightlossprogramsareconsidered.Thefirstisalowcaloriediet.Thesecondisalowfat
dietandthethirdisalowcarbohydratediet.Forcomparisonpurposes,afourthgroupisconsideredasa
controlgroup.Participantsinthefourthgrouparetoldthattheyareparticipatinginastudyofhealthy
behaviorswithweightlossonlyonecomponentofinterest.Thecontrolgroupisincludedheretoassess
theplaceboeffect(i.e.,weightlossduetosimplyparticipatinginthestudy).Atotaloftwentypatients
agreetoparticipateinthestudyandarerandomlyassignedtooneofthefourdietgroups.Weightsare
measuredatbaselineandpatientsarecounseledontheproperimplementationoftheassigneddiet(with
theexceptionofthecontrolgroup).After8weeks,eachpatient'sweightisagainmeasuredandthe
differenceinweightsiscomputedbysubtractingthe8weekweightfromthebaselineweight.Positive
differencesindicateweightlossesandnegativedifferencesindicateweightgains.Forinterpretation
http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

5/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

purposes,werefertothedifferencesinweightsasweightlossesandtheobservedweightlossesare
shownbelow.
LowCalorie

LowFat

LowCarbohydrate

Control

Isthereastatisticallysignificantdifferenceinthemeanweightlossamongthefourdiets?Wewillrunthe
ANOVAusingthefivestepapproach.

Step1.Setuphypothesesanddeterminelevelofsignificance
H0:1=2=3=4H1:Meansarenotallequal=0.05
Step2.Selecttheappropriateteststatistic.
TheteststatisticistheFstatisticforANOVA,F=MSB/MSE.
Step3.Setupdecisionrule.
TheappropriatecriticalvaluecanbefoundinatableofprobabilitiesfortheFdistribution(see
"OtherResources").InordertodeterminethecriticalvalueofFweneeddegreesoffreedom,
df1=k1anddf2=Nk.Inthisexample,df1=k1=41=3anddf2=Nk=204=16.Thecriticalvalueis
3.24andthedecisionruleisasfollows:RejectH0ifF>3.24.
Step4.Computetheteststatistic.
ToorganizeourcomputationswecompletetheANOVAtable.Inordertocomputethesumsofsquares
wemustfirstcomputethesamplemeansforeachgroupandtheoverallmeanbasedonthetotalsample.

LowCalorie LowFat LowCarbohydrate Control

Groupmean

6.6

3.0

3.4

1.2

IfwepoolallN=20observations,theoverallmeanis =3.6.
Wecannowcompute

So,inthiscase:

Nextwecompute,

http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

6/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

SSErequirescomputingthesquareddifferencesbetweeneachobservationanditsgroupmean.Wewill
computeSSEinparts.Fortheparticipantsinthelowcaloriediet:
LowCalorie

(X6.6)

(X6.6)2

1.4

2.0

2.4

5.8

0.6

0.4

0.4

0.2

3.6

13.0

21.4

Totals

Thus,

Fortheparticipantsinthelowfatdiet:
LowFat

(X3.0)

(X3.0)2

1.0

1.0

1.0

1.0

0.0

0.0

2.0

4.0

2.0

4.0

10.0

Totals

Thus,

Fortheparticipantsinthelowcarbohydratediet:
LowCarbohydrate

(X3.4)

(X3.4)2

0.4

0.2

1.6

2.6

0.6

0.4

1.4

2.0

0.4

0.2

5.4

Totals

Thus,

Fortheparticipantsinthecontrolgroup:
Control

(X1.2)

(X1.2)2

0.8

0.6

0.8

0.6

http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

7/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

0.8

0.6

2.2

4.8

1.2

1.4

1.8

3.2

10.6

Totals

Thus,

Therefore,

WecannowconstructtheANOVAtable.
Sumsof
Squares

Degreesof
Freedom

Means
Squares

(SS)

(df)

(MS)

Between
Treatmenst

75.8

41=3

Error(or
Residual)

47.4

204=16

Total

123.2

201=19

Sourceof
Variation

75.8/3=25.3 25.3/3.0=8.43
47.4/16=3.0

Step5.Conclusion.
WerejectH0because8.43>3.24.Wehavestatisticallysignificantevidenceat=0.05toshowthatthere
isadifferenceinmeanweightlossamongthefourdiets.
ANOVAisatestthatprovidesaglobalassessmentofastatisticaldifferenceinmorethantwoindependent
means.Inthisexample,wefindthatthereisastatisticallysignificantdifferenceinmeanweightloss
amongthefourdietsconsidered.Inadditiontoreportingtheresultsofthestatisticaltestofhypothesis
(i.e.,thatthereisastatisticallysignificantdifferenceinmeanweightlossesat=0.05),investigatorsshould
alsoreporttheobservedsamplemeanstofacilitateinterpretationoftheresults.Inthisexample,
participantsinthelowcaloriedietlostanaverageof6.6poundsover8weeks,ascomparedto3.0and
3.4poundsinthelowfatandlowcarbohydrategroups,respectively.Participantsinthecontrolgrouplost
anaverageof1.2poundswhichcouldbecalledtheplaceboeffectbecausetheseparticipantswerenot
participatinginanactivearmofthetrialspecificallytargetedforweightloss.Aretheobservedweight
lossesclinicallymeaningful?

AnotherANOVAExample
Calciumisanessentialmineralthatregulatestheheart,isimportantforbloodclottingandforbuilding
healthybones.TheNationalOsteoporosisFoundationrecommendsadailycalciumintakeof10001200
mg/dayforadultmenandwomen.Whilecalciumiscontainedinsomefoods,mostadultsdonotget
enoughcalciumintheirdietsandtakesupplements.Unfortunatelysomeofthesupplementshaveside
effectssuchasgastricdistress,makingthemdifficultforsomepatientstotakeonaregularbasis.
Astudyisdesignedtotestwhetherthereisadifferenceinmeandailycalciumintakeinadultswithnormal
bonedensity,adultswithosteopenia(alowbonedensitywhichmayleadtoosteoporosis)andadultswith
http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

8/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

osteoporosis.Adults60yearsofagewithnormalbonedensity,osteopeniaandosteoporosisareselected
atrandomfromhospitalrecordsandinvitedtoparticipateinthestudy.Eachparticipant'sdailycalcium
intakeismeasuredbasedonreportedfoodintakeandsupplements.Thedataareshownbelow.
NormalBone
Density

Osteopenia Osteoporosis

1200

1000

890

1000

1100

650

980

700

1100

900

800

900

750

500

400

800

700

350

Isthereastatisticallysignificantdifferenceinmeancalciumintakeinpatientswithnormalbonedensityas
comparedtopatientswithosteopeniaandosteoporosis?WewillruntheANOVAusingthefivestep
approach.
Step1.Setuphypothesesanddeterminelevelofsignificance
H0:1=2=3H1:Meansarenotallequal=0.05
Step2.Selecttheappropriateteststatistic.
TheteststatisticistheFstatisticforANOVA,F=MSB/MSE.
Step3.Setupdecisionrule.
InordertodeterminethecriticalvalueofFweneeddegreesoffreedom,df1=k1anddf2=Nk.
Inthisexample,df1=k1=31=2anddf2=Nk=183=15.Thecriticalvalueis3.68andthedecision
ruleisasfollows:RejectH0ifF>3.68.
Step4.Computetheteststatistic.
ToorganizeourcomputationswewillcompletetheANOVAtable.Inordertocomputethesumsof
squareswemustfirstcomputethesamplemeansforeachgroupandtheoverallmean.
NormalBone
Density
n1=6

Osteopenia Osteoporosis
n2=6

n3=6

IfwepoolallN=18observations,theoverallmeanis817.7.

Wecannowcompute:

Substituting:

Finally,
http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

9/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

Next,

SSErequirescomputingthesquareddifferencesbetweeneachobservationanditsgroupmean.Wewill
computeSSEinparts.Fortheparticipantswithnormalbonedensity:
NormalBoneDensity (X938.3) (X938.3)2
1200

261.7

68,486.9

1000

61.7

3,806.9

980

41.7

1,738.9

900

38.3

1,466.9

750

188.3

35,456.9

800

138.3

19,126.9

Total

130,083.4

Thus,

Forparticipantswithosteopenia:
Osteopenia

(X715.0)

(X715.0)2

1000

285.0

81,225.0

1100

385.0

148,225.0

700

15

225.0

800

85.0

7,225.0

500

215.0

46,225.0

700

15

225.0

Total

283,350.0

Thus,
Forparticipantswithosteoporosis:
Osteoporosis

(X715.0)

(X715.0)2

890

90

8,100.0

650

150

22,500.0

1100

300

90,000.0

900

100

10,000.0

400

400

160,000.0

350

450

202,500.0

Total

493,100.0

http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

10/15

5/26/2016

Total

HypothesisTestingAnalysisofVariance(ANOVA)

493,100.0

Thus,

WecannowconstructtheANOVAtable.
Sourceof
Variation

SumsofSquares
(SS)

Degreesoffreedom
(df)

MeanSquares
(MS)

Between
Treatments

152,429.6

76,214.8

1.26

ErrororResidual

906,533.4

15

60,435.6

1,058,963.0

17

Total
Step5.Conclusion.

WedonotrejectH0because1.26<3.68.Wedonothavestatisticallysignificantevidenceata=0.05to
showthatthereisadifferenceinmeancalciumintakeinpatientswithnormalbonedensityascompared
toosteopeniaandosterporosis.Arethedifferencesinmeancalciumintakeclinicallymeaningful?Ifso,
whatmightaccountforthelackofstatisticalsignificance?

OneWayANOVAinR
ThevideobelowbyMikeMarindemonstrateshowtoperformanalysisofvarianceinR.Italsocovers
someotherstatisticalissues,buttheinitialpartofthevideowillbeusefultoyou.

TwoFactorANOVA
TheANOVAtestsdescribedabovearecalledonefactorANOVAs.Thereisonetreatmentorgrouping
factorwithk>2levelsandwewishtocomparethemeansacrossthedifferentcategoriesofthisfactor.The
factormightrepresentdifferentdiets,differentclassificationsofriskfordisease(e.g.,osteoporosis),
differentmedicaltreatments,differentagegroups,ordifferentracial/ethnicgroups.Therearesituations
whereitmaybeofinteresttocomparemeansofacontinuousoutcomeacrosstwoormorefactors.For
example,supposeaclinicaltrialisdesignedtocomparefivedifferenttreatmentsforjointpaininpatients
withosteoarthritis.Investigatorsmightalsohypothesizethattherearedifferencesintheoutcomebysex.
ThisisanexampleofatwofactorANOVAwherethefactorsaretreatment(with5levels)andsex(with2
levels).InthetwofactorANOVA,investigatorscanassesswhethertherearedifferencesinmeansdueto
thetreatment,bysexorwhetherthereisadifferenceinoutcomesbythecombinationorinteractionof
treatmentandsex.HigherorderANOVAsareconductedinthesamewayasonefactorANOVAs
presentedhereandthecomputationsareagainorganizedinANOVAtableswithmorerowstodistinguish
thedifferentsourcesofvariation(e.g.,betweentreatments,betweenmenandwomen).Thefollowing
exampleillustratestheapproach.

Example
Considertheclinicaltrialoutlinedaboveinwhichthreecompetingtreatmentsforjointpainarecompared
intermsoftheirmeantimetopainreliefinpatientswithosteoarthritis.Becauseinvestigatorshypothesize
thattheremaybeadifferenceintimetopainreliefinmenversuswomen,theyrandomlyassign15
http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

11/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

participatingmentooneofthethreecompetingtreatmentsandrandomlyassign15participatingwomen
tooneofthethreecompetingtreatments(i.e.,stratifiedrandomization).Participatingmenandwomendo
notknowtowhichtreatmenttheyareassigned.Theyareinstructedtotaketheassignedmedicationwhen
theyexperiencejointpainandtorecordthetime,inminutes,untilthepainsubsides.Thedata(timesto
painrelief)areshownbelowandareorganizedbytheassignedtreatmentandsexoftheparticipant.
TableofTimetoPainReliefbyTreatmentandSex
Treatment

Male

Female

12

21

15

19

16

18

17

24

14

25

14

21

17

20

19

23

20

27

17

25

25

37

27

34

29

36

24

26

22

29

TheanalysisintwofactorANOVAissimilartothatillustratedaboveforonefactorANOVA.The
computationsareagainorganizedinanANOVAtable,butthetotalvariationispartitionedintothatdueto
themaineffectoftreatment,themaineffectofsexandtheinteractioneffect.Theresultsoftheanalysis
areshownbelow(andweregeneratedwithastatisticalcomputingpackageherewefocuson
interpretation).
ANOVATableforTwoFactorANOVA
Sourceof
Variation

Sumsof
Squares

Degreesof
freedom

Mean
Squares

Model

(SS)
967.0

(df)
5

(MS)
193.4

20.7 0.0001

Treatment

651.5

325.7

34.8 0.0001

Sex

313.6

313.6

33.5 0.0001

Treatment*Sex

1.9

0.9

ErrororResidual

224.4

24

9.4

Total

1191.4

29

0.1

P
Value

0.9054

Thereare4statisticaltestsintheANOVAtableabove.Thefirsttestisanoveralltesttoassesswhether
thereisadifferenceamongthe6cellmeans(cellsaredefinedbytreatmentandsex).TheFstatisticis
20.7andishighlystatisticallysignificantwithp=0.0001.Whentheoveralltestissignificant,focusthen
turnstothefactorsthatmaybedrivingthesignificance(inthisexample,treatment,sexortheinteraction
betweenthetwo).Thenextthreestatisticaltestsassessthesignificanceofthemaineffectoftreatment,
themaineffectofsexandtheinteractioneffect.Inthisexample,thereisahighlysignificantmaineffectof
http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

12/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

treatment(p=0.0001)andahighlysignificantmaineffectofsex(p=0.0001).Theinteractionbetweenthe
twodoesnotreachstatisticalsignificance(p=0.91).Thetablebelowcontainsthemeantimestopainrelief
ineachofthetreatmentsformenandwomen(Notethateachsamplemeaniscomputedonthe5
observationsmeasuredunderthatexperimentalcondition).
MeanTimetoPainReliefbyTreatmentandGender
Treatment

Male

Female

14.8

21.4

17.4

23.2

25.4

32.4

TreatmentAappearstobethemostefficacioustreatmentforbothmenandwomen.Themeantimesto
reliefarelowerinTreatmentAforbothmenandwomenandhighestinTreatmentCforbothmenand
women.Acrossalltreatments,womenreportlongertimestopainrelief(Seebelow).

Noticethatthereisthesamepatternoftimetopainreliefacrosstreatmentsinbothmenandwomen
(treatmenteffect).Thereisalsoasexeffectspecifically,timetopainreliefislongerinwomeninevery
treatment.
Supposethatthesameclinicaltrialisreplicatedinasecondclinicalsiteandthefollowingdataare
observed.
TableTimetoPainReliefbyTreatmentandSexClinicalSite2
Treatment

Male

Female

22

21

25

19

26

18

27

24

24

25

14

21

17

20

19

23

20

27

http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

13/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

20

27

17

25

15

37

17

34

19

36

14

26

12

29

TheANOVAtableforthedatameasuredinclinicalsite2isshownbelow.
TableSummaryofTwoFactorANOVAClinicalSite2
Sourceof
Variation

Sumsof
Squares

Degreesof
freedom

Mean
Squares

PValue

(SS)

(df)

(MS)

Model

907.0

181.4

19.4 0.0001

Treatment

71.5

35.7

3.8

Sex

313.6

313.6

33.5 0.0001

Treatment*Sex

521.9

260.9

27.9 0.0001

ErrororResidual

224.4

24

9.4

Total

1131.4

29

0.0362

Noticethattheoveralltestissignificant(F=19.4,p=0.0001),thereisasignificanttreatmenteffect,sex
effectandahighlysignificantinteractioneffect.Thetablebelowcontainsthemeantimestoreliefineach
ofthetreatmentsformenandwomen.
TableMeanTimetoPainReliefbyTreatmentandGenderClinicalSite2
Treatment

Male

Female

24.8

21.4

17.4

23.2

15.4

32.4

Noticethatnowthedifferencesinmeantimetopainreliefamongthetreatmentsdependonsex.Among
men,themeantimetopainreliefishighestinTreatmentAandlowestinTreatmentC.Amongwomen,
thereverseistrue.Thisisaninteractioneffect(seebelow).

http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

14/15

5/26/2016

HypothesisTestingAnalysisofVariance(ANOVA)

Noticeabovethatthetreatmenteffectvariesdependingonsex.Thus,wecannotsummarizeanoverall
treatmenteffect(inmen,treatmentCisbest,inwomen,treatmentAisbest).
Wheninteractioneffectsarepresent,someinvestigatorsdonotexaminemaineffects(i.e.,donottestfor
treatmenteffectbecausetheeffectoftreatmentdependsonsex).Thisissueiscomplexandisdiscussed
inmoredetailinalatermodule.

http://sphweb.bumc.bu.edu/otlt/MPHModules/BS/BS704_HypothesisTestingANOVA/BS704_HypothesisTestingAnova_print.html

15/15