General Linear Model.docx
《General Linear Model.docx》由会员分享,可在线阅读,更多相关《General Linear Model.docx(11页珍藏版)》请在冰豆网上搜索。
![General Linear Model.docx](https://file1.bdocx.com/fileroot1/2022-12/31/834789b8-777a-4f09-84de-fefaf32a0c44/834789b8-777a-4f09-84de-fefaf32a0c441.gif)
GeneralLinearModel
GeneralLinearModel
4/16/02
Announcements
Background
TheGeneralLinearModel
Therearethreereasonsforcoveringthismaterial.
∙Thismaterialprovidesanintroductiontotheuseof"dummy"variables.
oThesevariablesareveryusefulwheneveryouhaveacategoricalvariable,andareactuallymoreusefulinstandardmultipleregression.
∙Thismaterialemphasizestheimportanceofmodels
oItcauses(conducts,leads)ustothinkabouthowwewanttogoabout(embark)testingmodels,andthealternativeswaysthatwecanlookatproblems.
∙Itmakesitmucheasiertotalkabouttheanalysisofcovariance,andrelatedtechniques,andtotalkaboutunequalsamplesizesandhowwewanttotestthem.
Thistopicstartsoutasamoredifficultwayofdoingwhattheyalreadyknowhowtodo.Butitthengoesontopresentotherstuff(thing)inamuchsimplerwaythanitcouldbepresentedinanyotherway.
Ihavetriedtoremovemuchofthestuffthatdoesn'tfocusonthethreereasonsthatIgaveabove.Iwantstudentstounderstandthegeneralconcepts,andbeabletoseethattheycouldbeapplicableinothersettings.Iamnottryingtoshowpeopleaharderwaytorunananalysisofvariance.
Theapproachtakenhereisbasicallytheapproachthatanystatisticalpackagetakes,whichmayhelpexplainsomeofthesubtletiesofthosepackages.
Amajorsubthemeistoshowthattheanalysisofvariance,theanalysisofcovariance,theanalysisofmultipleregression,andawholebunch(host)ofotherthingsarejustvariationsonacommontheme.
Iwantstudentstounderstandthebasicideaofcoding(dummy)variables,butthespecifics(details)arenotimportant.
Example
IamgoingtouseoneofthesmokingexamplesfromSpilichthatwehaveseeninothercontexts.Thedatafile(Spilich.sav)containsdataonallgroups,butweareonlygoingtolookatthegroupthatwasgivenastandardrecalltask--acognitivetask.
Threebasicgroups.
∙Nonsmokers(peoplewhoneversmoked)
∙Delayedsmokers(Smokerswhohadnothadacigaretteforseveralhours)
∙Activesmokers(Smokerswhosmokedduringthetask.)
Thedependentvariablewasthenumberoferrorsmadeduringtherecalltask.
StandardAnalysisofVariance:
DescriptiveStatistics
Grandmean=38.778
Plot
Plotwitherrorbars(barsrepresent95%CI)
Anova
Itisclearthattherearesignificantdifferencesbetweengroups.IwillevengoaheadandcomparetheNon-smokerswiththecombinedsmokinggroups,andthenthetwosmokinggroupswitheachother.Thisisforcomparisonpurposeslater.
Ididthiswiththeone-wayprocedureandstandardcontrasts.
HerewecanseethatNon-smokersdifferfromsmokers,butthatthetwosmokinggroupsdonotdifferbetweenthemselves.
TheGLMapproach
FirstweneedtocodethedatatoindicateGroups.
∙WealreadyhaveGroupsas1,2,and3,butwearegoingtodoitdifferently.
oThereasonthatwehavetodoitdifferentlyisduetothefactthatourcodingiscompletelyarbitrary.Wecouldhavecodedthemas2,1,and3.Anyregressionagainstgroupmembershipwouldbeentirelydependentontheorderinwhichwecoded--that'sabadthing..
∙WewillsetupdummyvariablesthattelluswhetherasubjectisinGroup1ornot,andwhetherhe/sheisinGroup2ornot.
oIhavecalledthesenewvariablesNonSmokeandDelayed,becausetheyidentifythosewhoareinthosetwogroups.
∙Wedon'tneedtocodeforGroup3,becauseifyou'renotin1or2,youmustbein3.
∙The"filter"variablebelowjustselectedtheCognitivetask,andignoredtheothertwotasks.
Task Group Errors distract filter NonSmoke Delayed
2.00 1.00 27.00 126.00 1 1.00 .00
2.00 1.00 34.00 154.00 1 1.00 .00
2.00 1.00 19.00 113.00 1 1.00 .00
omitted
2.00 2.00 48.00 113.00 1 .00 1.00
2.00 2.00 29.00 100.00 1 .00 1.00
2.00 2.00 34.00 114.00 1 .00 1.00
omitted
2.00 3.00 34.00 108.00 1 -1.00 -1.00
2.00 3.00 65.00 191.00 1 -1.00 -1.00
2.00 3.00 55.00 112.00 1 -1.00 -1.00
omitted
(ExplainwhyIused-1foreachdummyvariableforpeopleinthelastgroup.
Thismakestheinterceptcomeouttobethegrandmean,andexpressestheresultsindistancefromthegrandmean,ratherthandistancefromthemeanofsomearbitrarygroup.
Thisideaisimportant,becauseifwearen'tcarefulitiseasytogetanswerstotellusaboutdeviationsfromsomesinglegroup,andthatusuallyisn'twhatweareafter.
Herewecometothefirstimportantidea.Ihavetakenacategoricalvariablewith3(k)levelsandturneditinto2(k-1) newvariables.Thesetwovariablescarryalltheinformationthatthesinglevariabledid,andaremoreuseful.
RegressionApproachusingDummyVariables
IwillnowsimplypredictErrorsusingNonsmokeandDelayedasmypredictorvariables.Thisisastandardmultipleregression.
LookfirstattheAnovatestfortheregression
F=4.744,p=.014
ThisisexactlythesameresultwegotwhenweranthetraditionalAnova.
Explainwhythisshouldbe.
LooknextattheR2value=.184.Thisisnothingbuteta-squared
GotothetableheadedCoefficients
Thefollowing(uptothenextmajorheading)ismaterialthatIfindimportantandhelpful,butifitaddstoinformationoverload,setitasidefornow.
NotethattheIntercept=38.778.Thisisexactlyequaltothegrandmeanofallthegroups.Interceptequalsgrandmean.
NotethattheslopeforNonsmoke=-9.911.ThisisexactlyequaltothedifferencebetweentheNonsmokemeanandthegrandmean.
NotethattheslopeforDelayed=1.157.ThisisthedifferencebetweentheDelayedmeanandthegrandmean.Slopeequalsdifferencebetweencorrespondingpredictormeanandgrandmean.
WhynothaveaslopeforActive?
?
?
Itwouldberedundant(excessive)--ifweknowthegrandmeanandthedeviationoftheothertwogroups,wecancomputethedeviationofthe3rdgroup.
Thesumofthedeviationsfromthemean=0.So,thedeviationofthethirdgroupis0-(-9.911)-1.156=8.755
IfIhadcodedforActiveandDelayed,andleftoutNonSmoke,Iwouldgetaninterceptof38.778,slopeforactive=8.755,slopeforDelayed=1.157,andcouldcomputeslopeforNonSmoke=-9.911.Thisillustratesthatthechoiceisarbitraryandunimportant.
TestingContrasts
Iforgottodooneadditionalthing,soIwentbackanddidit.IaskedSPSStocompute"deviationcontrasts"whenitrantheAnova.
Deviationcontrastsarecomparisonsofeachmeanwiththegrandmean.(Again,itdoesn'tdoallthree--itleavesoutone,whichinthiscasewasthelastone.)
Outputbelow:
Notethatthetestsandtheprobabilitiesareexactlythesameasthetests(andprobabilities)ontheregressionequation.
Whyshouldthisbe?
Whatisallofthisabout?
IwanttoshowthatAnovaandRegressionarebasicallythesameprocedure.Theonlydifferenceherebetweenthisregressionandstandardmultipleregressionistheuseofdummyvariables.
Therearealotofimportantthingshere,buttheirimportancedoesn'tshowupuntilwemovetomorecomplexanalyses.
GLMandFactorialAnova
Nowthingsgetinteresting.
First,wewilltakethesameexample,butwithallthreetasks,andcreatedummyvariablesforthedifferenttasksaswell.(Again,wecreatedummyvariablesforonlytwoofthetasks.)
Thenwecreateinteractiondummyvariablesbymultiplyingourdummiestogethertocreate4newvariables.
Nonsmoke*Patrec,Nonsmoke*Cogit,Delayed*Patrec,andDelayed*Cognit
TheoverallFactorialAnovafollows:
Regressionapproach
Wewillstartwiththecompletemultipleregressionusingalldummyvariablesaspredictors.Herewearetryingtoexplainvarianceinerrorsasafunctionofeverythingweknowaboutgroups,tasks,andtheirinteractions.
Regression
CommentonSSregressionasbeingequivalentto"Model"inregularAnova(Explainwhy8df.)10-2=8
Commentontheerrorterm.
Thiserrortermisallofthevariancein"errors"thancannotbeexplainedonthebasisofgroups,tasks,ortheirinteractions.Thisisthestandarderrorterminthefactorialanalysisofvariance.
NowstudentsshouldunderstandwhySPSSpresentstheAnovasummarytablethewayitdoes,evenifthatisaconfusingwaytohavechosentopresentit.
RemovingtheInteractionTermsgives:
ThedifferenceintheSSregressionis31744.726-29016.074=2728.652.
ThisistheSSfortheinteractiontermintheAnova.
RemovingtheTaskTerms(afterreplacinginteraction)gives:
IfwesubtractthisSSregressionfromtheSSregressioninfullmodel,weget
31744.726-3083.200=28661.526
ThisistheeffectofTask
Lastly,lookatthemodelwithdummyvariablesforTaskandInteraction,butnodummyvariablesforCondition
Herethedifferencebetweenthefullandreducedmodelsis
31744.726-31390.178=354.548
ThisistheeffectofCondition.
Noticethateachofthisisbasicallywhatwecalledahierarchicalmodelearlier.Thedifferencebetweenthefullmodelandareducedmodeliswhattheextravariable(s)explainoveranabove(controllingfor)theothervariables.
FromhereIgetthefollowingmodels:
Model
SSreg
Difference
SSerror
Effect
Full
31744.726
13587.200
Error
Maineffects
29016.174
2728.652
Interaction
Task.+Interaction
31390.178
354.548
Condition
Cond+Interaction
3083.200
28661.526
Task
Butwearen'tdone.
Yesweareforclass.Ihavelefttherest