New version page

# SMU PHYS 7311 - Two Way Analysis of Variance

Pages: 17
Documents in this Course

15 pages

12 pages

## This preview shows page 1-2-3-4-5-6 out of 17 pages.

View Full Document

End of preview. Want to read all 17 pages?

View Full Document
Unformatted text preview:

IntroductionR ExercisesHomeworkIntroduction R Exercises HomeworkTwo-Way Analysis of Variance: ANOVADr. J. Kyle RobertsSouthern Methodist UniversitySimmons School of Education and Human DevelopmentDepartment of Teaching and LearningIntroduction R Exercises HomeworkIntroduction to Two-Way ANOVA•In a two-way analysis of variance we analyze the dependenceof a continuous response on two, cross-classified factors.•The factors can be experimental factors that are both ofinterest or they can be one experimental factor and oneblocking factor.•A blocking factor is a known source of variability, such as the“subject” or, more generally, the “experimental unit”. Weexpect this factor to account for a substantial portion of thevariability in the response. We wish to control for thisvariability but are not interested in comparing the particularlevels of this factor.•A cross-classified experiment is said to be balanced if everypair of conditions occurs the same number of times. You cancheck with the xtabs function.Introduction R Exercises HomeworkHypothesis Test in Two-Way ANOVA•Recall that the null hypothesis for a one-way ANOVA can bewritten as:H0: Y1= Y2= Y3•For the two-way ANOVA, we have the potential to test threeseparate hypothesis tests: one for each way and one for theinteraction effect. We do not have to test all 3, but if we do,we refer to this as a full factorial ANOVA.•These hypotheses are:H0:MainA: µ1.= µ1.= · · · = µj.H0:MainB: µ.1= µ.2= · · · = µ.kH0:ABInteraction: µ11= µ12= µ21= µ22= · · · = µjk•where j are the “rows” and k are the “columns.”Introduction R Exercises HomeworkHow the Data are Analyzed in a Two-Way•For heuristic purposes, suppose that we have a dataset withtwo independent variables each with two levels.•In a full factorial setting, we would view this data as:Levels of Second IVb1b2MeanLevels of First IV a1¯X11¯X12¯X1.a2¯X21¯X22¯X2.Mean¯X.1¯X.2¯XIntroduction R Exercises HomeworkThe Two-Way ANOVA Summary TableSource SS df MS F p η2Main A kA− 1SSAdfAMSAMSeSSASStMain B kB− 1SSBdfBMSBMSeSSBSStABInter.dfA∗ dfBSSABdfABMSABMSeSSABSStError dft− dfA− dfB− dfABSSedfeTotal n − 1•The statistical significance of F can be obtained bycomputing the F -critical value. Determining statisticalsignificance follows the same pattern for the t test only wehave two sources of df : between and within.•For the two-way ANOVA, the df needed for testing that effectare the df due to that effect and the dferror. Therefore, thedf numerator could be different for each effect.Introduction R Exercises HomeworkTwo-Way ANOVA Practice•Fill in the Missing Values Below. Use pf to compute p.Source SS df MS F p η2Main A 5Main B 4ABinter0.22ErrorTotal 600 752•Fill in the Missing Values Below. Use pf to compute p.Source SS df MS F p η2Main A 0.11Main B 80 40 0.08ABinter22 0.04Error 437TotalIntroduction R Exercises HomeworkPartitioning the Sum of SquaresSSA= nKJXj=1(¯Xj.−¯X)2SSB= nJKXk=1(¯X.k−¯X)2SSAB= nKXk=1JXj=1(¯Xjk−¯Xj.−¯X.k−¯X)2SSError=KXk=1JXj=1nXi=1(Xijk−¯Xjk)2SST otal=KXk=1JXj=1nXi=1(Xijk−¯X)2Introduction R Exercises HomeworkTwo-Way ANOVA Data•Read in a table using read.table which resides on this websiteat http://faculty.smu.edu/kyler/courses/7311/twoway1.txt•Make sure that you include header=T> head(twoway)gender program gre1 2 1 242 2 1 273 2 1 334 2 1 255 2 1 266 2 1 30> str(twoway)’data.frame’: 48 obs. of 3 variables:\$ gender : int 2 2 2 2 2 2 2 2 1 1 ...\$ program: int 1 1 1 1 1 1 1 1 1 1 ...\$ gre : int 24 27 33 25 26 30 22 29 33 26 ...Introduction R Exercises HomeworkStructuring and viewing data> twoway\$gender <- factor(twoway\$gender)> twoway\$program <- factor(twoway\$program)> str(twoway)’data.frame’: 48 obs. of 3 variables:\$ gender : Factor w/ 2 levels "1","2": 2 2 2 2 2 2 2 2 1 1 ...\$ program: Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1 1 1 1 1 ...\$ gre : int 24 27 33 25 26 30 22 29 33 26 ...> table(twoway\$gender, twoway\$program)1 2 31 8 8 82 8 8 8Introduction R Exercises HomeworkProgram vs. Gender> barplot(tapply(twoway\$gre, list(twoway\$program, twoway\$gender),+ mean), beside = T, col = rainbow(3))1 20 5 10 15 20 25 30Introduction R Exercises HomeworkInteraction Plot> interaction.plot(twoway\$gender, twoway\$program, twoway\$gre)27 28 29 30 31 32twoway\$gendermean of twoway\$gre1 2 twoway\$program312Introduction R Exercises HomeworkRunning the Data> m1 <- aov(gre ~ gender + program, twoway)> summary(m1)Df Sum Sq Mean Sq F value Pr(>F)gender 1 38.52 38.521 2.2942 0.1370program 2 60.67 30.333 1.8066 0.1762Residuals 44 738.79 16.791> m2 <- aov(gre ~ gender * program, twoway)> summary(m2)Df Sum Sq Mean Sq F value Pr(>F)gender 1 38.52 38.521 2.5839 0.11544program 2 60.67 30.333 2.0347 0.14340gender:program 2 112.67 56.333 3.7788 0.03097Residuals 42 626.12 14.908Introduction R Exercises HomeworkTesting Assumptions> bartlett.test(gre ~ gender * program, twoway)Bartlett test of homogeneity of variancesdata: gre by gender by programBartlett’s K-squared = 3.865, df = 1, p-value = 0.0493> bartlett.test(gre ~ program * gender, twoway)Bartlett test of homogeneity of variancesdata: gre by program by genderBartlett’s K-squared = 6.5532, df = 2, p-value = 0.03776> fligner.test(gre ~ gender * program, twoway)Fligner-Killeen test of homogeneity of variancesdata: gre by gender by programFligner-Killeen:med chi-squared = 1.6152, df = 1, p-value= 0.2038Introduction R Exercises HomeworkInvestigation of Means> model.tables(m2, "means")Tables of meansGrand mean27.85417gendergender1 226.958 28.750programprogram1 2 327.187 26.938 29.437gender:programprogramgender 1 2 31 27.38 27.12 26.372 27.00 26.75 32.50Introduction R Exercises HomeworkPost Hoc Tests> TukeyHSD(m2)\$"gender:program"diff lwr upr p adj2:1-1:1 -0.375 -6.13810348 5.388103 0.999958751:2-1:1 -0.250 -6.01310348 5.513103 0.999994502:2-1:1 -0.625 -6.38810348 5.138103 0.999491051:3-1:1 -1.000 -6.76310348 4.763103 0.995169342:3-1:1 5.125 -0.63810348 10.888103 0.106545361:2-2:1 0.125 -5.63810348 5.888103 0.999999832:2-2:1 -0.250 -6.01310348 5.513103 0.999994501:3-2:1 -0.625 -6.38810348 5.138103 0.999491052:3-2:1 5.500 -0.26310348 11.263103 0.068989882:2-1:2 -0.375 -6.13810348 5.388103 0.999958751:3-1:2 -0.750 -6.51310348 5.013103 0.998768872:3-1:2 5.375 -0.38810348 11.138103 0.080006761:3-2:2 -0.375 -6.13810348 5.388103 0.999958752:3-2:2 5.750 -0.01310348 11.513103 0.050824042:3-1:3 6.125 0.36189652 11.888103 0.03144884Introduction R

View Full Document
Unlocking...