When applied to generalized l inear models multilevel models and other extensions of classical regression ANOVA can be e xtended in two di64256erent directions First the Ftest can be used in an asymptotic or approximat e fashion to compare nested mo ID: 29758
Download Pdf The PPT/PDF document "Analysis of variance Andrew Gelman March..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
AnalysisofvarianceAndrewGelmanyMarch22,2006AbstractAnalysisofvariance(ANOVA)isastatisticalprocedureforsummarizingaclassicallinearmodel|adecompositionofsumofsquaresintoacomponentforeachsourceofvariationinthemodel|alongwithanassociatedtest(theF-test)ofthehypothesisthatanygivensourceofvariationinthemodeliszero.Whenappliedtogeneralizedlinearmodels,multilevelmodels,andotherextensionsofclassicalregression,ANOVAcanbeextendedintwodierentdirections.First,theF-testcanbeused(inanasymptoticorapproximatefashion)tocomparenestedmodels,totestthehypothesisthatthesimplerofthemodelsissucienttoexplainthedata.Second,theideaofvariancedecompositioncanbeinterpretedasinferenceforthevariancesofbatchesofparameters(sourcesofvariation)inmultilevelregressions.1IntroductionAnalysisofvariance(ANOVA)representsasetofmodelsthatcanbettodata,andalsoasetofmethodsforsummarizeanexistingttedmodel.WerstconsiderANOVAasitappliestoclassicallinearmodels(thecontextforwhichitwasoriginallydevised;Fisher,1925)andthendiscusshowANOVAhasbeenextendedtogeneralizedlinearmodelsandmultilevelmodels.Analysisofvarianceisparticularlyeectiveforanalyzinghighlystructuredexperimentaldata(inagriculture,multipletreatmentsappliedtodierentbatchesofanimalsorcrops;inpsychology,multi-factorialexperimentsmanipulatingseveralindependentexperimentalconditionsandappliedtogroupsofpeople;industrialexperimentsinwhichmultiplefactorscanbealteredatdierenttimesandindierentlocations).Attheendofthisarticle,wecompareANOVAtosimplelinearregression.2Analysisofvarianceforclassicallinearmodels2.1ANOVAasafamilyofstatisticalmethodsWhenformulatedasastatisticalmodel,analysisofvariancereferstoanadditivedecompositionofdataintoagrandmean,maineects,possibleinteractions,andanerrorterm.Forexample,Gawronetal.(2003)describea\right-simulatorexperimentthatwesummarizeasa58arrayofmeasurementsunder5treatmentconditionsand8dierentairports.Thecorrespondingtwo-wayANOVAmodelisyij=+i+j+ij.Thedataasdescribedherehavenoreplication,andsothetwo-wayinteractionbecomespartoftheerrorterm.1 FortheNewPalgraveDictionaryofEconomics,secondedition.WethankJackNeedleman,MatthewRaerty,DavidPattison,MarcShivers,GregorGorjanc,andseveralanonymouscommentersforhelpfulsuggestionsandtheNationalScienceFoundationfornancialsupport.yDepartmentofStatisticsandDepartmentofPoliticalScience,ColumbiaUniversity,NewYork,gelman@stat.columbia.edu,www.stat.columbia.edu/gelman1If,forexample,eachtreatmentairportconditionwerereplicatedthreetimes,thenthe120datapointscouldbemodeledasyijk=+i+j+\rij+ijk,withtwosetsofmaineects,atwo-wayinteraction,andanerrorterm.1 DegreesofSumofMeanSourcefreedomsquaressquareF-ratiop-value Treatment40.0780.0200.390.816Airport73.9440.56311.130:001Residual281.4170.051Figure1:Classicaltwo-wayanalysisofvariancefordataon5treatmentsand8airportswithnoreplication.Thetreatment-levelvariationisnotstatisticallydistinguishablefromnoise,buttheairporteectsarestatisticallysignicant.ThisandtheotherexamplesinthisarticlecomefromGelman(2005)andGelmanandHill(2006).Thisisalinearmodelwith1+4+7coecients,whichistypicallyidentiedbyconstrainingtheP5i=1i=0andP8j=1j=0.ThecorrespondingANOVAdisplayisshowninFigure1:Foreachsourceofvariation,thedegreesoffreedomrepresentthenumberofeectsatthatlevel,minusthenumberofconstraints(the5treatmenteectssumtozero,the8airporteectssumtozero,andeachrowandcolumnofthe40residualssumstozero).Thetotalsumofsquares|thatis,P5i=1P8j=1(yij y::)2|is0:078+3:944+1:417,whichcanbedecomposedintothesethreetermscorrespondingtovariancedescribedbytreatment,variancedescribedbyairport,andresiduals.Themeansquareforeachrowisthesumofsquaresdividedbydegreesoffreedom.Underthenullhypothesisofzerorowandcolumneects,theirmeansquareswould,inexpectation,simplyequalthemeansquareoftheresiduals.TheF-ratioforeachrow(excludingtheresiduals)isthemeansquare,dividedbytheresidualmeansquare.Thisratioshouldbeapproximately1(inexpectation)ifthecorrespondingeectsarezero;otherwisewewouldgenerallyexpecttheF-ratiotoexceed1.WewouldexpecttheF-ratiotobelessthan1onlyinunusualmodelswithnegativewithin-groupcorrelations(forexample,ifthedatayhavebeenrenormalizedinsomeway,andthishadnotbeenaccountedforinthedataanalysis.)Thep-valuegivesthestatisticalsignicanceoftheF-ratiowithreferencetotheF1;2,where1and2arethenumeratoranddenominatordegreesoffreedom,respectively.(Thus,thetwoF-ratiosinFigure1arebeingcomparedtoF4;28andF7;28distributions,respectively.)Inthisexample,thetreatmentmeansquareislowerthanexpected(anF-ratiooflessthan1),butthedierencefrom1isnotstatisticallysignicant(ap-valueof82%),henceitisreasonabletojudgethisdierenceasexplainablebychance,andconsistentwithzerotreatmenteects.Theairportmeansquare,ismuchhigherthanwouldbeexpectedbychance,withanF-ratiothatishighlystatistically-signicantlylargerthan1;hencewecancondentlyrejectthehypothesisofzeroairporteects.MorecomplicateddesignshavecorrespondinglycomplicatedANOVAmodels,andcomplexitiesarisewithmultipleerrorterms.Wedonotintendtoexplainsuchhierarchicaldesignsandanalyseshere,butwewishtoalertthereadertosuchcomplications.TextbookssuchasSnedecorandCochran(1989)andKirk(1995)provideexamplesofanalysisofvarianceforawiderangeofdesigns.2.2ANOVAtosummarizeamodelthathasalreadybeenttedWehavejustdemonstratedANOVAasamethodofanalyzinghighlystructureddatabydecomposingvarianceintodierentsources,andcomparingtheexplainedvarianceateachleveltowhatwouldbeexpectedbychancealone.Anyclassicalanalysisofvariancecorrespondstoalinearmodel(thatis,aregressionmodel,possiblywithmultipleerrorterms);conversely,ANOVAtoolscanbeusedtosummarizeanexistinglinearmodel.2 Thekeyistheideaof\sourcesofvariation,"eachofwhichcorrespondstoabatchofcoecientsinaregression.Thus,withthemodely=X+,thecolumnsofXcanoftenbebatchedinareasonableway(forexample,fromtheprevioussection,aconstantterm,4treatmentindicators,and7airportindicators),andthemeansquaresandF-teststhenprovideinformationabouttheamountofvarianceexplainedbyeachbatch.SuchmodelscouldbetwithoutanyreferencetoANOVA,butANOVAtoolscouldthenbeusedtomakesomesenseofthettedmodels,andtotesthypothesesaboutbatchesofcoecients.2.3BalancedandunbalanceddataIngeneral,theamountofvarianceexplainedbyabatchofpredictorsinaregressiondependsonwhichothervariableshavealreadybeenincludedinthemodel.Withbalanceddata,however,inwhichallgroupshavethesamenumberofobservations(forexample,eachtreatmentappliedexactlyeighttimes,andeachairportusedforexactlyveobservations),thevariancedecompositiondoesnotdependontheorderinwhichthevariablesareentered.ANOVAisthusparticularlyeasytointerpretwithbalanceddata.Theanalysisofvariancecanalsobeappliedtounbalanceddata,butthenthesumsofsquares,meansquares,andF-ratioswilldependontheorderinwhichthesourcesofvariationareconsidered.3ANOVAformoregeneralmodelsAnalysisofvariancerepresentsawayofsummarizingregressionswithlargenumbersofpredictorsthatcanbearrangedinbatches,andawayoftestinghypothesesaboutbatchesofcoecients.Boththeseideascanbeappliedinsettingsmoregeneralthanlinearmodelswithbalanceddata.3.1FtestsInaclassicalbalanceddesign(asintheexamplesoftheprevioussection),eachF-ratiocomparesaparticularbatchofeectstozero,testingthehypothesisthatthisparticularsourceofvariationisnotnecessarytotthedata.Moregenerally,theFtestcancomparetwonestedmodels,testingthehypothesisthatthesmallermodeltsthedataadequatelyand(sothatthelargermodelisunnecessary).Inalinearmodel,theF-ratiois(SS2 SS1)=(df2 df1) SS1=df1,whereSS1;df1andSS2;df2aretheresidualsumsofsquaresanddegreesoffreedomfromttingthelargerandsmallermodels,respectively.Forgeneralizedlinearmodels,formulasexistusingthedeviance(thelog-likelihoodmultipliedby 2)thatareasymptoticallyequivalenttoF-ratios.Ingeneral,suchmodelsarenotbalanced,andthetestforincludinganotherbatchofcoecientsdependsonwhichothersourcesofvariationhavealreadybeenincludedinthemodel.3.2InferenceforvarianceparametersAdierentsortofgeneralizationinterpretstheANOVAdisplayasinferenceaboutthevarianceofeachbatchofcoecients,whichwecanthinkofastherelativeimportanceofeachsourceofvariationinpredictingthedata.EveninaclassicalbalancedANOVA,thesumsofsquaresandmeansquaresdonotexactlydothis,buttheinformationcontainedthereincanbeusedtoestimatethevariancecomponents(CorneldandTukey,1956,Searle,Casella,andMcCulloch,1992).Bayesiansimulationcanthenbeusedtoobtaincondenceintervalsforthevarianceparameters.Asillustratedbelow,wedisplayinferencesforstandarddeviations(ratherthanvariances)becausethesearemoredirectlyinterpretable.ComparedtotheclassicalANOVAdisplay,ourplotsemphasizetheestimatedvarianceparametersratherthantestingthehypothesisthattheyarezero.3 dfEst. sd of coefficients 0 0.5 1 1.5sex1 ethnicity1 sex * ethnicity1 age3 education3 age * education9 region3 region * state46 0 0.5 1 1.5 dfEst. sd of coefficients 0 0.5 1 1.5sex1 ethnicity1 sex * ethnicity1 age3 education3 age * education9 region3 region * state46 ethnicity * region3 ethnicity * region * state46 0 0.5 1 1.5 Figure2:ANOVAdisplayfortwologisticregressionmodelsoftheprobabilitythatasurveyrespondentpreferstheRepublicancandidateforthe1988U.S.Presidentialelection,basedondatafromsevenCBSNewspolls.Pointestimatesanderrorbarsshowmedianestimates,50%intervals,and95%intervalsofthestandarddeviationofeachbatchofcoecients.Thelargecoecientsforethnicity,region,andstatesuggestthatitmightmakesensetoincludeinteractions,hencetheinclusionofethnicityregionandethnicitystateinteractionsinthesecondmodel.3.3GeneralizedlinearmodelsTheideaofestimatingvarianceparametersappliesdirectlytogeneralizedlinearmodelsaswellasunbalanceddatasets.Allthatisneededisthattheparametersofaregressionmodelarebatchedinto\sourcesofvariation."Figure2illustrateswithamultilevellogisticregressionmodel,predictingvotepreferencegivenasetofdemographicandgeographicvariables.3.4MultilevelmodelsandBayesianinferenceAnalysisofvarianceiscloselytiedtomultilevel(hierarchical)modeling,witheachsourceofvariationintheANOVAtablecorrespondingtoavariancecomponentinamultilevelmodel(seeGelman,2005).Inpractice,thiscanmeanthatweperformANOVAbyttingamultilevelmodel,orthatweuseANOVAideastosummarizemultilevelinferences.MultilevelmodelingisinherentlyBayesianinthatitinvolvesapotentiallylargenumberofparametersthataremodeledwithprobabilitydistributions(see,forexample,Goldstein,1995,KreftandDeLeeuw,1998,SnijdersandBosker,1999).ThedierencesbetweenBayesianandnon-Bayesianmultilevelmodelsaretypicallyminorexceptinsettingswithmanysourcesofvariationandlittleinformationoneach,inwhichcasesomebenetcanbegainedfromafully-Bayesianapproachwhichmodelsthevarianceparameters.4Relatedtopics4.1Finite-populationandsuperpopulationvariancesSofarinthisarticlewehaveconsidered,ateachlevel(thatis,eachsourceofvariation)ofamodel,thestandarddeviationofthecorrespondingsetofcoecients.Wecallthisthenite-populationstandarddeviation.Anotherquantityofpotentialinterestisthestandarddeviationofthehypotheticalsuperpopulationfromwhichtheseparticularcoecientsweredrawn.Thepointestimatesofthesetwovarianceparametersaresimilar|withtheclassicalmethodofmoments,theestimatesareidentical,becausethesuperpopulationvarianceistheexpectedvalueofthenite-populationvariance|buttheywillhavedierentuncertainties.Theinferencesforthenite-populationstandarddeviationsaremoreprecise,astheycorrespondtoeectsforwhichweactuallyhavedata.Figure3illustratesthenite-populationandsuperpopulationinferencesateachlevelofthemodelforthe\right-simulatorexample.Weknowmuchmoreaboutthe5treatmentsand8airportsinourdatasetthanforthegeneralpopulationsoftreatmentsandairports.(Wesimilarlyknowmore4 finite-population s.d.'s 0 0.2 0.4 0.6 0.8sg sd sy 0 0.2 0.4 0.6 0.8 superpopulation s.d.'s 0 0.2 0.4 0.6 0.8sg sd sy 0 0.2 0.4 0.6 0.8 Figure3:Medianestimates,50%intervals,and95%intervalsfor(a)nite-populationand(b)superpopulationstandarddeviationsofthetreatment-level,airport-level,anddata-levelerrorsinthe\right-simulatorexamplefromFigure1.Thetwosortsofstandarddeviationparametershaveessentiallythesameestimates,butthenite-populationquantitiesareestimatedmuchmoreprecisely.(Wefollowthegeneralpracticeinstatisticalnotation,usingGreekandRomanlettersforpopulationandsamplequantities,respectively.) dfEst. sd of coefficients 0 10 20 30 40row4 column4 treatment4 error12 0 10 20 30 40 dfEst. sd of coefficients 0 10 20 30 40row4 row.linear1 row.error3 column4 column.linear1 column.error3 treatment4 treatment.linear1 treatment.error3 error12 0 10 20 30 40 Figure4:ANOVAdisplaysfora55latinsquareexperiment(anexampleofacrossedthree-waystructure):(a)withnogroup-levelpredictors,(b)contrastanalysisincludinglineartrendsforrows,columns,andtreatments.SeealsotheplotsofcoecientestimatesandtrendsinFigure5.aboutthestandarddeviationofthe40particularerrorsinoutdatasetthanabouttheirhypotheticalsuperpopulation,butthedierencesherearenotsolarge,becausethesuperpopulationdistributionisfairlywellestimatedfromthe28degreesoffreedomavailablefromthesedata.)Therehasbeenmuchdiscussionaboutxedandrandomeectsinthestatisticalliterature(seeEisenhart,1947,GreenandTukey,1960,Plackett,1960,Yates,1967,LaMotte,1983,andNelder,1977,1994,forarangeofviewpoints),andunfortunatelytheterminologyusedinthesediscussionsisincoherent(seeGelman,2005,Section6).Ourresolutiontosomeofthesedicultiesistoalwaystamultilevelmodelbuttosummarizeitwiththeappropriateclassofestimand|superpopulationornite-population|dependingonthecontextoftheproblem.Sometimesweareinterestedintheparticulargroupsathand;othertimestheyareasamplefromalargerpopulationofinterest.Achangeoffocusshouldnotrequireachangeinthemodel,onlyachangeintheinferentialsummaries.4.2ContrastanalysisContrastsareawaytostructuringtheeectswithinasourceofvariation.Inamultilevelmodelingcontext,acontrastissimplyagroup-levelcoecient.IntroducingcontrastsintoanANOVAallowsafurtherdecompositionofvariance.Figure4illustratesfora55latinsquareexperiment(thistime,notasplitplot):theleftplotinthegureshowsthestandardANOVA,andtherightplotshowsacontrastanalysisincludinglineartrendsfortherow,column,andtreatmenteects.The5 12345 200250300 row effectsrowy 12345 200250300 column effectscolumny 12345 200250300 treatment effectstreatmenty Figure5:Estimates1standarderrorfortherow,column,andtreatmenteectsforthelatinsquareexperimentsummarizedinFigure4.Thevelevelsofeachfactorareordered,andthelinesdisplaytheestimatedlineartrends.lineartrendsforthecolumnsandtreatmentsarelarge,explainingmostofthevariationateachoftheselevels,butthereisnoevidenceforalineartrendintheroweects.Figure5showstheestimatedeectsandlineartrendsateachlevel(alongwiththerawdatafromthestudy),asestimatedfromamultilevelmodel.Thisplotshowsinadierentwaythatthevariationamongcolumnsandtreatments,butnotamongrows,iswellexplainedbylineartrends.4.3NonexchangeablemodelsInalltheANOVAmodelswehavediscussedsofar,theeectswithinanybatch(sourceofvariation)aremodeledexchangeably,asasetofcoecientswithmean0andsomevariance.Animportantdirectionofgeneralizationistononexchangeablemodels,suchasintimeseries,spatialstructures(BesagandHigdon,1999),correlationsthatariseinparticularapplicationareassuchasgenetics(McCullagh,2005),anddependenceinmulti-waystructures(Aldous,1981,Hodgesetal.,2005).Inthesesettings,boththehypothesis-testingandvariance-estimatingextensionsofANOVAbe-comemoreelaborate.Thecentralideaofclusteringeectsintobatchesremains,however.Inthissense,\analysisofvariance"representsalleortstosummarizetherelativeimportanceofdierentcomponentsofacomplexmodel.5ANOVAcomparedtolinearregressionTheanalysisofvarianceisoftenunderstoodbyeconomistsinrelationtolinearregression(e.g.,Goldberger,1964).Fromtheperspectiveoflinear(orgeneralizedlinear)models,weidentifyANOVAwiththestructuringofcoecientsintobatches,witheachbatchcorrespondingtoa\sourceofvariation"(inANOVAterminology).AsdiscussedbyGelman(2005),therelevantinferencesfromANOVAcanbereproducedusingregression|butnotalwaysleast-squaresregression.Multilevelmodelsareneededforanalyzinghierarchicaldatastructuressuchas\split-plotdesigns,"wherebetween-groupeectsarecomparedtogroup-levelerrors,andwithin-groupeectsarecomparedtodata-levelerrors.Giventhatwecanalreadytregressionmodels,whatdowegainbythinkingaboutANOVA?Tostartwith,thedisplayoftheimportanceofdierentsourcesofvariationisahelpfulexploratorysummary.Forexample,thetwoplotsinFigure2allowustoquicklyunderstandandcomparetwomultilevellogisticregressions,withoutgettingoverwhelmedwithdozensofcoecientestimates.Moregenerally,wethinkoftheanalysisofvarianceasawayofunderstandingandstructur-ingmultilevelmodels|notasanalternativetoregressionbutasatoolforsummarizingcomplexhigh-dimensionalinferences,ascanbeseen,forexample,inFigure3(nite-populationandsuper-populationstandarddeviations)andFigures4{5(group-levelcoecientsandtrends).6 ReferencesAldous,D.J.(1981).Representationsforpartiallyexchangeablearraysofrandomvariables.JournalofMultivariateAnalysis11,581{598.Besag,J.,andHigdon,D.(1999).Bayesiananalysisofagriculturaleldexperiments(withdiscus-sion).JournaloftheRoyalStatisticalSocietyB61,691{746.Cochran,W.G.,andCox,G.M.(1957).ExperimentalDesigns,secondedition.NewYork:Wiley.Corneld,J.,andTukey,J.W.(1956).Averagevaluesofmeansquaresinfactorials.AnnalsofMathematicalStatistics27,907{949.Eisenhart,C.(1947).Theassumptionsunderlyingtheanalysisofvariance.Biometrics3,1{21.Fisher,R.A.(1925).StatisticalMethodsforResearchWorkers.Edinburgh:OliverandBoyd.Gawron,V.J.,Berman,B.A.,Dismukes,R.K.,andPeer,J.H.(2003).Newairlinepilotsmaynotreceivesucienttrainingtocopewithairplaneupsets.FlightSafetyDigest(July{August),19{32.Gelman,A.(2005).Analysisofvariance:whyitismoreimportantthanever(withdiscussion).AnnalsofStatistics33,1{53.Gelman,A.,andHill,J.(2006).AppliedRegressionandMultilevel(Hierarchical)Models.CambridgeUniversityPress.Gelman,A.,Pasarica,C.,andDodhia,R.M.(2002).Let'spracticewhatwepreach:usinggraphsinsteadoftables.TheAmericanStatistician56,121{130.Goldberger,A.S.(1964).EconometricTheory.NewYork:Wiley.Goldstein,H.(1995).MultilevelStatisticalModels,secondedition.London:EdwardArnold.Green,B.F.,andTukey,J.W.(1960).Complexanalysesofvariance:generalproblems.Psychome-trika25127{152.Hodges,J.S.,Cui,Y.,Sargent,D.J.,andCarlin,B.P.(2005).SmoothedANOVA.Technicalreport,DepartmentofBiostatistics,UniversityofMinnesota.Kirk,R.E.(1995).ExperimentalDesign:ProceduresfortheBehavioralSciences,thirdedition.Brooks/Cole.Kreft,I.,andDeLeeuw,J.(1998).IntroducingMultilevelModeling.London:Sage.LaMotte,L.R.(1983).Fixed-,random-,andmixed-eectsmodels.InEncyclopediaofStatisticalSciences,ed.S.Kotz,N.L.Johnson,andC.B.Read,3,137{141.McCullagh,P.(2005).DiscussionofGelman(2005).AnnalsofStatistics33,33{38.Nelder,J.A.(1977).Areformulationoflinearmodels(withdiscussion).JournaloftheRoyalStatisticalSocietyA140,48{76.Nelder,J.A.(1994).Thestatisticsoflinearmodels:backtobasics.StatisticsandComputing4,221{234.Plackett,R.L.(1960).Modelsintheanalysisofvariance(withdiscussion).JournaloftheRoyalStatisticalSocietyB22,195{217.Searle,S.R.,Casella,G.,andMcCulloch,C.E.(1992).VarianceComponents.NewYork:Wiley.Snedecor,G.W.,andCochran,W.G.(1989).StatisticalMethods,eighthedition.IowaStateUniversityPress.Snijders,T.A.B.,andBosker,R.J.(1999).MultilevelAnalysis.London:Sage.Yates,F.(1967).Afreshlookatthebasicprinciplesofthedesignandanalysisofexperiments.ProceedingsoftheFifthBerkeleySymposiumonMathematicalStatisticsandProbability4,777{790.7