<<

Bennett, PJ PSY710 Chapter 3

Y¯u is simply the mean of the group means; di↵erences in the size of the groups (if they exist) are ignored, and so Y¯u is said to be the unweighted mean of the group means.↵ ˆj is simply the di↵erence between the mean of group j and Y¯u.Forthe reduced model, setting the one free parameter, µ,tothegrandaverage,Y¯ ,minimizes the sum of squared residuals.

3.3.1 F formula Next, we need to derive a quantitative measure of the relative goodness-of-fit of the two models. We denote the sum of squared residuals for the best-fitting full and reduced models as EF and ER, respectively. Associated with EF and ER are degrees-of-freedom df = N a and df = N 1, respectively, where N is the total F R number of observations and a is the number of groups. Note that dfR dfF = a 1 is the di↵erence between the number of parameters estimated in the full model (3↵’s and 1 intercept) and the reduced model (1 intercept). The formula for computing the di↵erence between the two models is (E E )/(df df ) F = R F R F (13) EF /dfF Equation 13 can be used to compare all nested linear models. All tests in ANOVA, , and multiple regression can be computed using this formula. Bennett, PJ PSYCH 710 Chapter 4 3.3.2 Null Hypothesis Testing Finally, we are in a position to evaluate the hypothesis of no di↵erence between the goodness-of-fit of the full and reduced models. Note that this comparison is equivalent to evaluating the hypothesis that all of the groups have the same mean; or Notes on Maxwell & Delaney (equivalently) that all ↵j’s areOmnibus zero. More formally, vs. Focussed we are comparing theF hypothesestests

PSYCHPSYCH 710 710 H0: ↵1 = ↵2 = = ↵a =0 H1: ↵ ···=0 j 6 Linear Contrasts 4 Chapter 4 - Individual Comparisons of Means The null hypothesis is that all of the e↵ects are zero, and therefore that all group means are equal. The alternative• A significant hypothesis omnibus is that at F least test one supports e↵ect is nota very zero, general and hypothesis 4.1 Omnibus vs. Focused Tests Week 4 therefore that not all group means- not are all equal. means When are the equal residuals, eij,aredistributed as independent, normal random variables, with mean of zero and a constant variance, For the one-way ANOVAs that we have beenProf. discussing Patrick so Bennett far, a significant F test means that we reject the null hypothesis H0: ↵1 = ↵2 = = ↵a = 0 in favor of the alternative hypothesisthen H1:F in Equation 13 follows- annotF distributionall group effects with (df areR dfzeroF )anddf F degrees of ↵ = 0 (for at least one group, j). So, when··· a 3, a significant omnibus F test does not tell j 6 freedom in the numerator and• Significant denominator, F doesn’t repsectively tell (Figureus how 1).group Under means the null differ us precisely how the group means di↵er from each other. To address this question, and makehypothesis, our therefore, large values of F should be relatively rare (Figure 2). Using inferences more precise, we need to use more focused comparisons of the group means. There is another reason for using focused comparisons. In a sense, the omnibus F test examines • Generality of omnibus F often comes at cost of reduced power all possible patterns of di↵erences among the group means. The advantage of this test is obvious: 4 we don’t need to specify the pattern of e↵ects in advance. However, there is a penalty to this general approach, namely reduced power. As we shall see, asking a focused question can result in a statistical test with much greater power than the omnibus F test. The following example shows that a focused comparison among means can be significant even when the omnibus F test is not significant.

>set.seed(seed=934) >y<-c(rnorm(n=60,mean=100,sd=20),rnorm(n=10,110,sd=20)) Bennett, PJ PSYCH 710 Chapter 4 >g<-factor(rep(seq(1,7,1),each=10),labels="g",ordered=FALSE)

If you examine the line y<-c(rnorm(n=60,...,sd=20));carefully, you will see that it consists of 60 random numbers drawn from a gaussian distribution with a mean of 100, and 10 random numbers drawn from a gaussian distribution with a mean of 110. Our grouping variable, g, will be used to group the y’s into 7 sets of 10 numbers each. Boxplots of the data are shown in Figure 1. Omnibus vs. Focussed F tests >boxplot(y~g) Linear Comparisons OmnibusNow F we test conduct is not significant: a standard ANOVA. Bennett, PJ PSYCH 710 Chapter 4 >lm01<-lm(y~g); 160 Bennett,>anova(lm01); PJ PSYCH 710 Chapter 4 140 >source(url("http://psycserv.mcmaster.ca/bennett/psy710/Rscripts/linear_contrast_v2.R")) Table Bennett, PJ PSYCH 710 Chapter 4 • focussed comparison among group means [1] "loading function linear.comparison" >source(url("http://psycserv.mcmaster.ca/bennett/psy710/Rscripts/linear_contrast_v2.R"))Response: y 120 The sourceDfcommand Sum Sq loaded Mean Sq several F value commands Pr(>F) that can be used to perform a linear comparison among means in a • can be more direct test of hypothesis of interest [1] "loading function linear.comparison" one-wayg63431571.81.7260.13>source(url("http://psycserv.mcmaster.ca/bennett/psy710/Rscripts/linear_contrast_v2.R")) design. Next, I have to specify my contrast weights : 100 TheResidualssource 63command 20873 loaded 331.3 several commands that can be used to perform a linear comparison among means in a >my.weights<-c(-1,-1,-1,-1,-1,-1,6)[1] "loading function linear.comparison" • generally more powerful, but less general, than omnibus F one-way design. Next, I have to specify my contrast weights : 80 We willNotice discuss that the the meaning omnibus of theF contrasttest fails weights to find in a the significant following section. di↵erence Finally, among I use the the groups.linear.comparison Next, we The source command loaded several commands that can be used to perform a linear comparison among means in a Yet>my.weights<-c(-1,-1,-1,-1,-1,-1,6)command,compare a linear group which comparison was 7 to loaded the of other intog7 to R’s groups.g1-g6 workspace is Specifically,significant: by the previous we asksource whethercommand, the mean to perform of group the linear 7 di↵ comparison:ers from theone-way mean design. of the Next, 6 other I have groups. to specify To my docontrast this analysis, weights I: first need to download60 some R commands: We>my.contrast<-linear.comparison(y,g,c.weights=my.weights) will discuss the meaning of the contrast weights in the following section. Finally, I use the linear.comparison >my.weights<-c(-1,-1,-1,-1,-1,-1,6) command, which was loaded into R’s workspace by the previous source command, to perform the● linear comparison: [1] "computing linear comparisons assuming equal variances among groups" We will discuss the meaning of the contrast weights in the following section. Finally,40 I use the linear.comparison >my.contrast<-linear.comparison(y,g,c.weights=my.weights)[1] "C 1: F=7.218, t=2.687, p=0.009, psi=100.218,1 CI=(-2.897,203.332), adj.CI=g1 g2 (25.673,174.762)"g3 g4 g5 g6 g7 command, which was loaded into R’s workspace by the previous source command, to perform the linear comparison: [1]>my.contrast[[1]]$F "computing linear comparisons assuming equal variances among groups" [1]>my.contrast<-linear.comparison(y,g,c.weights=my.weights) "C 1: F=7.218, t=2.687, p=0.009, psi=100.218, CI=(-2.897,203.332), adj.CI= (25.673,174.762)" [1] 7.21771 >my.contrast[[1]]$F[1] "computing linear comparisons assuming equal variances among groups"Figure 1: Boxplots of y data for di↵erent groups, g. >my.contrast[[1]]$p.2tailed[1] "C 1: F=7.218, t=2.687, p=0.009, psi=100.218, CI=(-2.897,203.332), adj.CI= (25.673,174.762)" [1] 7.21771 [1]>my.contrast[[1]]$F 0.00921941 >my.contrast[[1]]$p.2tailed [1]The 7.21771F test for this linear contrast, or linear comparison, is significant, even though the omnibus [1] 0.00921941 F>my.contrast[[1]]$p.2tailedtest was not. The F test for this linear contrast, or linear comparison, is significant, even though the omnibus [1] 0.00921941 F4.1.1test was using not. standard R commands 2 In thisThe sectionF test I for will this showlinear you contrast how to, performor linear thecomparison linear comparison, is significant, with even R’s built-in though commands the omnibus 4.1.1(i.e.,F test without was using not. using standard the linear.comparison R commands command). The first step is to inform R that I want to perform a particular comparison among the various groups represented by the factor g: In this section I will show you how to perform the linear comparison with R’s built-in commands (i.e.,>contrasts(g)<-my.weights4.1.1 without using using standard the linear.comparison R commands command). The first step is to inform R that I want to performNext,In this Iperform section a particular I an will ANOVA. comparison show you Note how among that to I’m performthe using various the groupsaov linearcommand, represented comparison rather by with thethan R’s factor the built-inlmg:command: commands >contrasts(g)<-my.weights>my.aov<-aov(y~g)(i.e., without using the linear.comparison command). The first step is to inform R that I want to Next,Finally,perform I perform I a display particular an the ANOVA.ANOVA comparison Note table among that in a I’m way the using thatvarious thesplits groupsaov thecommand, group represented e↵ect rather into by thethan various factor the pieces:lmg:command: >contrasts(g)<-my.weights >my.aov<-aov(y~g)>summary(my.aov,split=list(g=list(myContrast=1,others=2:6))) Finally,TheNext,split I performI displaysyntax an the is ANOVA. complicated ANOVA Note table because that in a I’m way it is using that a list splitsthe of lists:aov thecommand, It group is used e↵ect to rather inform into than various R to the split pieces:lm acommand:list of >my.aov<-aov(y~g) >summary(my.aov,split=list(g=list(myContrast=1,others=2:6)))terms in the linear model (e.g., g) into lists of pieces. In this case, we’re telling R to split the e↵ects relatedFinally, to I displayfactor g theinto ANOVA two pieces: table the in first a way piece that corresponds splits thegroup to our e linear↵ect into contrast, various and pieces: the second The split syntax is complicated because it is a list of lists: It is used to inform R to split a list of piece>summary(my.aov,split=list(g=list(myContrast=1,others=2:6))) is a combination of five other things that are not of interest. We will discuss what these pieces termsmean in thefollowing linear model sections. (e.g., Forg) into now, lists let’s of examine pieces. In the this output case, of we’re thesummary telling R tocommand: split the e↵ects relatedThe split to factorsyntaxg into is complicated two pieces: because the first it piece is a list corresponds of lists: It to is our used linear to inform contrast, R to and split the a secondlist of piece is a combinationDf Sum of Sq five Meanother Sq Fthings value Pr(>F) that are not of interest. We will discuss what these pieces g634315721.730.1296terms in the linear model (e.g., g) into lists of pieces. In this case, we’re telling R to split the e↵ects meanrelatedg: myContrast in to the factor following 1g into 2391 sections. two pieces: 2391 For thenow, 7.22 first let’s 0.0092 piece examine ** corresponds the output to our of the linear summary contrast, command: and the second pieceg: others is a combinationDf 5 Sum 1039 of Sq five Meanother 208 Sq Fthings value 0.63 0.6794 Pr(>F) that are not of interest. We will discuss what these pieces g634315721.730.1296Residualsmean in the following 63 20873 sections. 331 For now, let’s examine the output of the summary command: ---g: myContrast 1 2391 2391 7.22 0.0092 ** Signif. codes: 0Df*** Sum Sq0.001 Mean** Sq F0.01 value* Pr(>F)0.05 . 0.1 1 g: others 5' 1039' ' 208' 0.63' ' 0.6794 ' ' '' g634315721.730.1296 Residuals 63 20873 331 Noticeg: myContrast that the F 1and 2391p values 2391 listed in 7.22 the 0.0092 ANOVA ** table are the same (to within rounding error) --- asg: those others provided 5 by linear.comparison 1039 208 0.63. 0.6794However, it is important to note that the two methods Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ''1 giveResiduals the same results 63 20873only when 331 there are equal n per group. If the design in unbalanced, then aov --- Noticeyields di that↵erent the valuesF and forp SSvaluescontrast listed, F , and in thep. SoANOVA you should table only are the use sameaov to (to evaluate within linear rounding contrasts error) asforSignif. those balanced codes: provided designs. 0 by'***linear.comparison' 0.001 '**' 0.01 '.*' However,0.05 '.' it0.1 is important''1 to note that the two methods giveNoticeFinally, the that same I the want resultsF toand showonlyp values whenyou how listedthere to areperform in the equal ANOVA an linearper group.table contrast areIfwith the designsame the lm() (to in withinunbalanced,command: rounding then error)aov yieldsas those di↵ providederent values by forlinear.comparison SScontrast, F , and p.. However, So you should it is important only use aov toto note evaluate that the linear two contrasts methods forgive balanced the same designs. results only when there are equal 3n per group. If the design in unbalanced, then aov yieldsFinally, di↵erent I want values to show for SS youcontrast how, F to, andperformp. So a you linear should contrast only with use aov the tolm() evaluatecommand: linear contrasts for balanced designs. Finally, I want to show you how to perform a3 linear contrast with the lm() command:

3 Bennett, PJ PSYCH 710 Chapter 4 Bennett, PJ PSYCH 710 Chapter 4 Bennett, PJ PSYCH 710 Chapter 4 >source(url("http://psycserv.mcmaster.ca/bennett/psy710/Rscripts/linear_contrast_v2.R")) >source(url("http://psycserv.mcmaster.ca/bennett/psy710/Rscripts/linear_contrast_v2.R")) [1]>source(url("http://psycserv.mcmaster.ca/bennett/psy710/Rscripts/linear_contrast_v2.R")) "loading function linear.comparison" [1] "loading function linear.comparison" TheBennett,[1] "loadingsource PJcommand function loaded linear.comparison" several commands PSYCHthat can 710 be used to perform a linear comparison amongChapter means 4 in a one-wayThe source design.command Next, loaded I have several to specify commands my contrast that can weights be used: to perform a linear comparison among means in a one-wayThe source design.command Next, loaded I have several to specify commands my contrast that can weights be used: to perform a linear comparison among means in a >my.weights<-c(-1,-1,-1,-1,-1,-1,6)one-way design. Next, I have to specify my contrast weights : >source(url("http://psycserv.mcmaster.ca/bennett/psy710/Rscripts/linear_contrast_v2.R"))>my.weights<-c(-1,-1,-1,-1,-1,-1,6) We>my.weights<-c(-1,-1,-1,-1,-1,-1,6) will discuss the meaning of the contrast weights in the following section. Finally, I use the linear.comparison command,[1]We will "loading discuss whichthe function the was meaning meaning loaded linear.comparison" of of the into the contrast R’scontrast workspace weights weights in by thein the the following previous following section.source section. Finally,command, Finally, I use I the use tolinear.comparison performthe linear.comparison the linear comparison: command, which which was was loaded loaded into into R’s R’s workspace workspace by by the the previous previoussourcesourcecommand,command, to perform to perform the linear the linear comparison: comparison: >my.contrast<-linear.comparison(y,g,c.weights=my.weights)The source command loaded several commands that can be used to perform a linear comparison among means in a one-way>my.contrast<-linear.comparison(y,g,c.weights=my.weights) design. Next, I have to specify my contrast weights : [1] "computing linear comparisons assuming equal variances among groups" >my.weights<-c(-1,-1,-1,-1,-1,-1,6)[1] "computing linear comparisons assuming equal variances among groups" [1] "computing"C 1: F=7.218, linear t=2.687, comparisons p=0.009, assuming psi=100.218, equal variances CI=(-2.897,203.332), among groups" adj.CI= (25.673,174.762)" Bennett, PJWe[1] will "C 1: 1:discuss F=7.218, F=7.218, the PSYCH meaning t=2.687, t=2.687, 710 of p=0.009, the p=0.009, contrast psi=100.218, psi=100.218, weights in CI=(-2.897,203.332),the CI=(-2.897,203.332), following section.Chapter Finally, adj.CI= 4 adj.CI= I (25.673,174.762)"use the (25.673,174.762)"linear.comparison >my.contrast[[1]]$Fcommand,>my.contrast[[1]]$F which was loaded into R’s workspace by the previous source command, to perform the linear comparison: >my.contrast[[1]]$F [1]>my.contrast<-linear.comparison(y,g,c.weights=my.weights)[1] 7.21771 7.21771 >#list1stcolumnofweights(printedas1row): [1] 7.21771"computing linear comparisons assuming equal variances among groups" >contrasts(g)[,1]#theyarethesameasbefore>my.contrast[[1]]$p.2tailed>my.contrast[[1]]$p.2tailed [1]>my.contrast[[1]]$p.2tailed "C 1: F=7.218, t=2.687, p=0.009, psi=100.218, CI=(-2.897,203.332), adj.CI= (25.673,174.762)" g1 g2 g3 g4 g5 g6 g7 [1] 0.00921941 [1]>my.contrast[[1]]$F 0.00921941 -1 -1 -1 -1 -1 -1 6 [1] 0.00921941 Bennett, PJ PSYCH 710 Chapter 4 The F test for this linear contrast, or linear comparison, is significant, even though the omnibus [1]Bennett,The 7.21771F PJtest for this linear contrast, or PSYCH linear comparison 710 , is significant, even thoughChapter the4 omnibus >my.lm<-lm(y~g)#constructthelinearF testThe wasF test not. for this linear contrast, or linear comparison, is significant, even though the omnibus >summary(my.lm)#listthecoefficientsandttestsF>my.contrast[[1]]$p.2tailedtest was not. >#list1stcolumnofweights(printedas1row): F test was not. Bennett,>contrasts(g)[,1]#theyarethesameasbefore PJ PSYCH 710 Chapter 4 Call:Bennett, PJ[1]4.1.1>source(url("http://psycserv.mcmaster.ca/bennett/psy710/Rscripts/linear_contrast_v2.R")) 0.00921941 using standard PSYCH R 710 commands Chapter 4 lm(formula = y ~ g) 4.1.1 using standard R commands Bennett,g1 g2 g3 PJ g4 g5 g6 g7 PSYCH 710 Chapter 4 4.1.1In[1] thisThe "loading section usingF test function Istandard for will this show linear.comparison"linearR you commands contrast how to perform, or linear thecomparison linear comparison, is significant, with R’s even built-in though commands the omnibus -1 -1Conducting -1 -1 -1 -1 6 Contrasts with R lm() In(i.e., this without section using I will the linear.comparison show you how tocommand). perform the The linear first step comparison is to inform with R that R’s I built-in want to commands Residuals:>#list1stcolumnofweights(printedas1row):FThetestsource wasConductingcommand not. loaded several commands Contrasts that can be used to with perform a linearR comparisonaov() among means in a (i.e.,Inperform this without section a particular using I will comparison the showlinear.comparison you among how to the perform variouscommand). the groups linear represented comparison The first by stepthe with factor is R’s to built-ing inform: commandsR that I want to This last>my.lm<-lm(y~g)#constructthelinear form of the hypothesis is perhaps the easiest to interpret: the null hypothesis is that the Min>contrasts(g)[,1]#theyarethesameasbefore 1Q Median 3Qone-way Max design. Next, I have to specify my contrast weights : >#list1stcolumnofweights(printedas1row):>summary(my.lm)#listthecoefficientsandttests perform(i.e.,>contrasts(g)<-my.weights without a particular using the comparisonlinear.comparison among thecommand). various groups The first represented step is to inform by the R factor that Ig want: to -43.83 -11.38 -0.39 11.144.1.1 47.32 using standard R commands Bennett, PJmean of>contrasts(g)[,1]#theyarethesameasbefore group PSYCH 7 does 710 not di↵er from the mean of the otherChapter group 4 means. We rejected that null g1 g2 g3 g4 g5 g6 g7 performNext,>my.weights<-c(-1,-1,-1,-1,-1,-1,6) I perform a particular an ANOVA. comparison Note thatamong I’m the using various theCreateaov groupscommand, contrast represented weights rather bythan the the factorlm command:g: Call: >contrasts(g)<-my.weights g1lm(formula g2 g3 g4 = g5 y ~g6 g) g7 -1 -1 -1 -1 -1 -1 6 InWe this willdiscuss section the I willmeaning show of the you contrast how to weights perform in the the following linear section. comparison Finally, with I use R’s the linear.comparison built-in commands hypothesis to accept the alternative Coefficients: >contrasts(g)<-my.weights>my.aov<-aov(y~g) Assign weights to grouping variable -1 -1 -1 -1 -1 -1 6 Next,(i.e.,command, without I perform which using was an loaded the ANOVA.linear.comparison into R’s Note workspace that by I’m thecommand).using previous thesourceaov Thecommand,command, first step to is perform ratherto inform the than linear R that the comparison:lm I wantcommand: to >my.lm<-lm(y~g)#constructthelinearEstimate Std. Error t value Pr(>|t|) Residuals: performNext,Finally, I performI a display particular anthe ANOVA. ANOVA comparison tableNote among in that a way I’m the that using various splits the groups theaov groupcommand, represented e↵ect intorather by various thanthe factor pieces: the lmg:command: >my.lm<-lm(y~g)#constructthelinear1 (Intercept) 96.044 2.176>my.aov<-aov(y~g)>my.contrast<-linear.comparison(y,g,c.weights=my.weights) 44.15 <2e-16 *** Min 1Q Median 3Q Max >summary(my.lm)#listthecoefficientsandttests Perform ANOVA This last form of the hypothesis is perhaps>summary(my.lm)#listthecoefficientsandttests the easiest to interpret:µ7 = the(µ null1 + µ hypothesis2 + µ3 + µ4 is+ thatµ5 + theµ6) g1 2.386 0.888>contrasts(g)<-my.weights>my.aov<-aov(y~g)>summary(my.aov,split=list(g=list(myContrast=1,others=2:6))) 2.69 0.0092 ** -43.83 -11.38 -0.39 11.14 47.32 6 6 Call: Finally,[1] "computing I display linear the comparisons ANOVA table assuming in a wayequal that variances splits among the group groups" e↵ect into various pieces: g2 -6.153 5.756Next,Finally,The split -1.07 I perform I displaysyntax 0.2891 anthe is ANOVA.complicated ANOVA Note table because that in a it I’m way is a using that list of splitsthe lists:aov the Itcommand, is group used to emean↵ informect rather into of R than various to group split the pieces: alm 7listcommand: doesof not di↵er fromCall: the mean of the other group means. We rejected that null g3lm(formula -3.150 = y ~ g) 5.756>summary(my.aov,split=list(g=list(myContrast=1,others=2:6)))[1] "C -0.55 1: F=7.218, 0.5861 t=2.687, p=0.009, psi=100.218, CI=(-2.897,203.332), adj.CI= (25.673,174.762)" lm(formulaCoefficients: = y ~ g) >my.aov<-aov(y~g)terms in the linear model (e.g., g) into lists of pieces. In this case, we’re telling R to split the e↵ects The general form of a linear contrast is g4 0.163 5.756>summary(my.aov,split=list(g=list(myContrast=1,others=2:6)))Write ANOVA 0.03 table, 0.9775 but split results for grouping hypothesis to accept the alternative Estimate Std. Error t value Pr(>|t|) >my.contrast[[1]]$F (Intercept) 96.044 2.176 44.15 <2e-16 *** g5Residuals: 5.502 5.756TheFinally,relatedvariablesplit 0.96 to Iinto factordisplaysyntax separate 0.3428g theinto is lines ANOVA twocomplicated pieces:for different table the because in first contrasts away piece it that corresponds is a splits list of thelists: togroup our It linear is e↵ usedect contrast, into to inform various and the R pieces: second to split a list of Residuals: The split syntax is complicated because it is a list of lists: It is used to inform R to split a list of g1Min 1Q Median 2.386 3Q 0.888 Max 2.69 0.0092 ** Results for our linear contrast g6Min -5.084 1Q Median 5.756 3Qtermspiece[1] 7.21771 Max-0.88is in a combination the 0.3804linear model of five other (e.g., gthings) into that lists are of not pieces. of interest. In this We case, will discuss we’re telling what these R to pieces split the e↵ects 1 H0 : c1µ1 + c2µ2 + + caµa = =0 (2) >summary(my.aov,split=list(g=list(myContrast=1,others=2:6))) µ = (-43.83g2µ + -11.38µ + -6.153µ -0.39+ µ 11.14+ 5.756µ 47.32+ -1.07µ ) 0.2891 --- -43.83 -11.38 -0.39 11.14termsmean 47.32 in in the the following linear model sections. (e.g., Forg) now, into listslet’s examineof pieces. the In output this case, of the we’re summary telling command: R to split the e↵ects 7 g31 2 -3.1503 4 5.7565 -0.556 0.5861 ··· 2 relatedThe>my.contrast[[1]]$p.2tailedsplit to factorsyntaxg isinto complicated two pieces: because the first it is piecea list of corresponds lists: It is used to our to linearinform contrast, R to split and a list theof second 6 6 F = t Signif. codes: 0 '***' 0.001related'**' 0.01 to factor'*' Df0.05g Suminto'. Sq' two0.1 Mean pieces:'' Sq F1 value the first Pr(>F) piece corresponds to our linear contrast, and the second Coefficients:g4 0.163 5.756 0.03 0.9775 Coefficients: pieceterms is in a the combination linear model of (e.g., five otherg) intothings lists of that pieces. are In not this of interest.case, we’re We telling will discuss R to split what the these e↵ects pieces where the weights of the linear contrast are constrained to sum to zero pieceg634315721.730.1296[1] 0.00921941 is a combination of five other things that are not of interest. We will discuss what these pieces g5Estimate 5.502 Std. 5.756Error t value 0.96 Pr(>|t|) 0.3428 Estimate Std. Error t value Pr(>|t|) The general form of a linear contrastg6 is -5.084 5.756 -0.88 0.3804 Residual standard error: 18.2meanrelated ong: 63 myContrast in degrees to the factor following of 1g freedominto 2391 twosections. 2391pieces: For the7.22 now, first 0.0092let’s piece ** examine corresponds theResults tooutput our for linear ofour the linear contrast, summary contrast and command: the second (Intercept) 96.044 2.176 44.15 <2e-16 *** a mean in the following sections. For now, let’s examine the output of the summary command: --- Multiple(Intercept) R-squared: 96.044 0.141,piece 2.176g:The others is Adjusted a 44.15F combinationtest for R-squared: <2e-16 5 this 1039 of ***linear five 0.0594 208other contrast 0.63things, or 0.6794 linear thatcomparison are not of interest., is significant, We will even discuss though what the these omnibus pieces g1 2.386 0.888 2.69 0.0092 ** Df Sum Sq Mean Sq F value Pr(>F) g2Signif. codes: -6.153 0 '***' 0.001 5.756'**' -1.070.01 '* 0.2891' 0.05 '.' 0.1 ''1 F-:g1 1.73 on 2.386 6 and 63meanResiduals 0.888F DF,testin p-value: was the 2.69 not. following 630.13 0.0092Df 20873Sum sections. ** Sq Mean 331 Sq For F now, value let’s Pr(>F) examine the output of the summary command: H0 : c1µ1 + c2µ2 + + caµa = =0 cj =0 (2) (3) g2 -6.153g634315721.730.1296 5.756 -1.07 0.2891 Bennett, PJg3 -3.150 5.756 PSYCH -0.55 0.5861 710 Chapter 4 g634315721.730.1296--- Residual standard··· error: 18.2 on 63 degrees of freedomj=1 Theg3 first coecient, -3.150g1, is theSignif. 5.756 oneg: myContrast that codes: -0.55 corresponds 0 0.5861Df*** 1 Sum 23910.001 toSq our Mean** contrast. 2391 Sq0.01 F value*7.22 Notice0.05 Pr(>F) 0.0092 that. 0.1 the ** t test1 for that g4 0.163 5.756 0.03 0.9775 g: myContrast 1' ' 2391' 2391' 7.22' ' 0.0092' ' ** '' Multiple R-squared: 0.141, Adjusted R-squared:X 0.0594 g4 0.163g634315721.730.1296 5.7564.1.1g: others using 0.03 standard 0.9775 5 1039 R commands 208 0.63 0.6794 where the weights of the linear contrastg5 are constrained 5.502 to 5.756 sum to 0.96 zero 0.3428 coecient yields the same p-valueg: others as our previous 5 1039F test.208 Furthermore, 0.63 0.6794 the values of t and F are Bennett, PJg6F-statistic: 1.73 -5.084 on 6 and 5.756 63 DF, PSYCH -0.88 p-value: 0.3804 0.13710 Chapter 4 g52 2 5.502ResidualsNotice 5.756g: myContrast that 0.96 the F 0.3428 631and 239120873p values 2391 listed 331 in 7.22 the ANOVA 0.0092 ** table are the same (to within rounding error) ˆ related: t =2.69 =7.23 whichIn this is sectionequal to I ourwillvalue show youof F how(to to within perform rounding the linear error). comparison In other with R’s built-in commands and the--- estimation of the comparison, , is g6 -5.084---Residualsas 5.756g: those others -0.88 provided 0.380463 by5 20873linear.comparison 1039 331 208 0.63. However, 0.6794 it is important to note that the two methodsThis last form of theThe hypothesis first coea cient, isg1 perhaps, is the one the that easiest corresponds to to interpret: our contrast.the Notice null thathypothesis the t test for that is that the words, the two-tailed t test in(i.e., this without summary using table the islinear.comparison equivalent to the F command).test in the TheANOVA first steptable is to inform R that I want to Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ''1 --- Signif.Residuals---give the same codes: results 63 0 ' 20873***only' when0.001 331there'**' are0.01 equal'*n' per0.05 group.'.' 0.1If the'' design1 in unbalanced, then aov coecient yieldsc =0 the same p-value as our previous F test.a Furthermore, the values(3) of t and F are ---Signif.perform codes: a particular 0 *** comparison0.001 ** among0.01 the* various0.05 . groups0.1 represented1 by the factor g: mean of group 7 does not2 di↵erj 2 from the mean of the other group means. We rejected that null listedSignif. above. codes: Fortunately, 0 '***'lm0.001yieldsworks'** di even'↵erent0.01 with' values*' unbalanced0.05' for'' SS.' 0.1 designs''', F' ,1 and (i.e.,p'. the' So you values should' ' of t onlyand'' usep willaov beto evaluate linearBennett, contrasts PJrelated:Residualt standard=2.69 PSYCH error:=7.23 18.2 710 which on 63 is degrees equal to of our freedomˆ value of F (to¯ within roundingChapter error). 4 In other Signif. codes: 0 '***' 0.001contrast'**' 0.01 '*' 0.05 '.' 0.1 ''1 This last form of the hypothesisj=1 is perhaps the easiest to= interpret:(cjYj) the null hypothesis is that the (4) very close to those obtained withNoticefor>contrasts(g)<-my.weights balancedlinear.comparison that designs. the F and p). values listed in the ANOVA table are the same (to withinhypothesis rounding error) to acceptwords,Multiple the alternative the R-squared: two-tailed 0.141,t test in this summaryAdjusted R-squared: table is equivalent 0.0594 to the F test in the ANOVA table Notice that the F and p values listed in the ANOVA table are the same (to within rounding error) F-statistic:X 1.73 on 6 and 63 DF, p-value: 0.13 j=1 Residual standard error: 18.2asNoticeNext, thoseFinally, on I 63that perform provided degrees I thewantF an to ofand byANOVA. show freedomlinear.comparisonp values you Note how listed tothat perform in I’m the using.a ANOVA linearHowever, the contrastaov tablecommand, it isare with important the the sameratherlm() (to tocommand: than note within the thatlm roundingcommand: themean two error) of methods group 7 doeslisted not above. di↵ Fortunately,er from thelm works mean even withof the unbalanced otherX designs group (i.e., means. the values We of t and rejectedp will be that null Multiple R-squared: 0.141,as those provided Adjusted R-squared:by linear.comparison 0.0594 . However, it is important to note that the two methods ˆ 1 giveas>my.aov<-aov(y~g) those the providedsame results by linear.comparisononly when there are. However, equal n per it is group. importantIfand the to thedesign note estimation that in unbalanced, the twohypothesis of methods the then comparison,aov to accept Thevery the, isfirst close alternative coe to thosecient, obtainedg1, is the with onelinear.comparison that corresponds to). our contrast. Notice that the t test for that 4.2F-statistic: Complex 1.73 Comparisons on 6 andgive 63 DF, the same p-value: results 0.13only when there are equal nBennett,per PJ group. If the design PSYCH in unbalanced, 710This last then formaov of theChapter hypothesis 4 is perhapsµ the7 = easiest(µ1 + toµ interpret:2 + µ3 + theµ4ˆ+ nullµ5 hypothesis+ µ6) is that the yieldsgive the di↵ sameerent results valuesonly for SSwhencontrast there, F are, and equalp3. Son per you group. shouldIf only thedesign use aov into unbalanced, evaluate linear then contrastsaov In thecoe examplecient yields from the6 the same6 preceding p-value as our section, previous F test.=100 Furthermore,.2. the values of t and F are yieldsFinally,Bennett, di↵ Ierent display PJ values the ANOVA for SS table, F in, and a wayp. thatSo PSYCH you splits should 710 the onlygroup use e↵aovect intoto evaluate variousmean linear pieces: of groupcontrastsChapter 7 4does not di↵er from2 thea mean2 of the other group means. We rejected that null TheThe previous first coe examplescient, usedg1, is aforyields the linear balanced one di contrast↵ thaterent correspondsdesigns. values to test for the SS tocontrast nullcontrast ourhypothesis: contrast., F , and Noticep. So you that should the t test only for use thataov to evaluate linear contrasts 4.2related: Complext =2.69 =7 Comparisons1.23 which is equal to our value of F (to within rounding error). In other for>summary(my.aov,split=list(g=list(myContrast=1,others=2:6))) balanced designs. hypothesis to accept the>my.contrast[[1]]$psi alternativeˆ µ =¯ (µ + µ + µ + µ + µ + µ ) coecient yields the samefor p-value balancedFinally, as our I designs. want previous to showF test. you Furthermore, how to perform the values a linear of contrastt and F are with the lm() command:The general formwords, of a thelinear= two-tailed contrast(7cjYtj)test in1 is this summary2 3 table4 is equivalent5 to6 the F test in(4) the ANOVA table 1(µ1 + µ2 + µ3 + µ4 + µ5 + µ6)+6µ7 =0 listedThe previous above. Fortunately,examples6 6 usedlm aworks linear even contrast with to unbalanced test the null designs hypothesis: (i.e., the values of t and p will be related: t2 =2.692 =7.23The whichFinally,split is equal Isyntax want to tois our complicated show value you you of how howF because(to to to performwithin perform it is arounding a lista linear linear of lists: error).contrast contrast It is In usedwith with other to the the informlm()lm()command: Rcommand: to split a list of [1] 100.218 j=1 >source(url("http://psycserv.mcmaster.ca/bennett/psy710/Rscripts/linear_contrast_v2.R")) very close1 toX those obtained with linear.comparison). words, the two-tailed t testterms in this in summary the linear table model is (e.g., equivalentg) into to lists the ofF pieces.test in In the this ANOVA case, we’re table telling R to split the e↵ects µ7 = (µ1 + µ2 + µ3 + µ1(4µ1++µµ52 + µµ3 6+) µ4 + µ5 + µ6)+6µ7 =0 which is equivalent to the null hypotheses[1] "loading function linear.comparison" 3 The general form of aGeneral linearH0 contrast : c1 µForm1+ is c2µ2 + of +Linearcaµa = =0Contrast (2) listed above. Fortunately, lmrelatedworks to even factor withg into unbalanced two pieces: designs the first(i.e., piece the values3 corresponds3 of t and top ourwill linear be contrast, and the second If there were6 ˆ6 four groups, and we wanted··· to compare group 3 to the mean of groups 1 and 2, then Hypotheses Evaluated by ContrastIn the example from the preceding section,4.2which is Complex equivalent=100.2. to Comparisons the null hypotheses very close to those obtained6pieceµ7 withThe is1(sourcelinear.comparisonµ a1 combination+ commandµ2 + µ3 + loaded ofµ4 five+). severalµother5 + µ commands6things)=0 that that are can not be used of interest. to perform We a will linear discuss comparison what among these means pieces in a The generalwhere the form weights of awe linear would of thecontrast use linear the isH0 contrastfollowing : c1µ1 are+ contrastc2 constrainedµ2 + + c toaµa sum= to=0 zero (2) meanone-way in the design. following Next, I sections. have to specify For now, my contrast let’s examine weights : the output of>my.contrast[[1]]$psi the summary command: The previous examples used a6µ linear7 1( contrastµ1 + µ2 + toµ test3 + µ the4 + nullµ5 + hypothesis:µ6)=0 and, by multiplying both sides of the equation by 1 , ··· >my.weights<-c(-1,-1,-1,-1,-1,-1,6)6 a 1 Df Sum Sq Mean Sq F value Pr(>F) 160 H0and, : byc multiplyingµ + c µ both+ sides+ c ofµ the= equation =0 by , weighted sum of population (2)means equals zero 4.2 Complex Comparisons [1] 100.218 where the weights of the linear1 1 contrast2 2 are1(µa1 constrained+a µ 2 +=(1)µ3 + µµ4 1+6 to+(1)µ5 sum+ µ6µ)+62 toµ zero72=0µ3 +(0)µ4 g634315721.730.1296We1 will discuss the meaning of the contrast weights in the following section. Finally, I use the linear.comparison ··· cj =0 (3) µ7g:command, myContrast(µ1 + whichµ2 + was 1µ3 + loaded 2391µ4 + intoµ 23915 R’s+ µ workspace6)=0 7.22 0.0092 by the previous ** source command, to perform the linear comparison: 1 The previous examples used a linear contrast to test the null hypothesis: 140 which is equivalent to the null hypotheses HO: 6 where the weights of the linear contrast are constrainedµ7 to sum(aµ1 + toµ2 + zeroµ3 + µ4 + µ5 + µ6)=0 g: others 5 1039 208 0.63 0.6794 If there were four groups, and weand wanted our coe to comparecients would group be 3 to c=(1,6j=1 the mean 1, -2, of 0). groups If we 1 wanted and 2, tothen compare group 1 to group 4, the >my.contrast<-linear.comparison(y,g,c.weights=my.weights) 6µ X1(µ + µ + µ + µ + µ + µ )=0 which is equivalent (finally), toResiduals1(µ1 + µ2 + µ 633 + 20873µ4 + µ5 + 331µ6)+6µ7 =0 we would use the following contrastcoecientswhich is would equivalent bea (finally), c=(1, to0,7 0, -1).1 cj If=02 we3 wanted4sum 5of to weights6 compare must equal groups zero 1 and 2 to groups(3) 3 and 4, the Bennett, PJ PSYCH 710 Chapter120 4 ---[1] "computing linear comparisons assuming equal variances among groups" 1 and the estimation ofand, the bycomparison, multiplying both sidesˆ , is of thej=1 equation by 1 , which is equivalent to the nullSignif.[1] hypotheses "C codes: 1: F=7.218, 0 '*** t=2.687,' 0.001 ' p=0.009,**' 0.01 psi=100.218,'*' 0.05 '.' CI=(-2.897,203.332),0.1 ''1 adj.CI= (25.673,174.762)" coecients would be c=(1,cj =0 1, -1,X1 -1). 6 (3) µ7 = (µ1 + µ2 + µ3 + µ4 + µ5 + µ6) (1) µ7 = (µ1 + µ2 + µ3 + µ4 + µ5 + µ6) (1) 6 100 A=(1) linearµ1 +(1) contrastµ2j=1 is2µ evaluated3 +(0)µ146 using our standard F test, which in this case is equal to This last form of the hypothesisNotice>my.contrast[[1]]$F is perhaps that the theF easiestand p tovalues interpret: listed the in nullthe ANOVAhypothesis table is that are the the same (to within rounding error) SScontrast = MSXcontrast ˆ µ (µ +a µ + µ + µ + µ + µ )=0 6µ7 1(µ1 + µ2 + µ3 + µ4 + µ5 + µ6)=0 and the estimation of the comparison, , is7 6 1 2 3 4 5 6 mean of group 7 does not di↵aser[1] those from 7.21771 theprovided mean byof4 thelinear.comparison other group means.. However, We rejected it is that important80 null to note that the two methods ˆ = (cjY¯4j) 2value ofa contrast2 equals weighted sum of group means(4) 1 and our coeand thecients estimation would be of the c=(1, comparison, 1, -2, 0). ˆ , If is we wanted to compare group( )/ 1 to group(c /n ) 4, the hypothesisand, by multiplying to accept the both alternative sidesgive ofthe the same equation results byonly, when there are equal n per group. If the design in unbalanced, then aov which is equivalent (finally), to a j=1 j j H1:>my.contrast[[1]]$p.2tailed6 coecients would be c=(1, 0, 0, -1). If we wanted to compare groupsj=1 1F and= 2 to groups 3 and 4, the (5) 60 X yields di↵erent values for SScontrast, F , and p. So you should only use aov to evaluate linear contrasts a ˆ =1 (cjY¯j) MSW (4) 11 µ7 = (µ1 + µ2 + µ3 + µ4 +Pµ5 + µ6) (1) forµ[1]µ7 balanced7= 0.00921941(µ(1µ+1 designs.+µ2µ+2 +µ3µ+3 +µ4µ+4 µ+5 µ+5µ+6)µ6)=0 coecients would be c=(1, 1, -1, -1). ˆ ¯ 6 6 66 ● In the example from the preceding = section,(cjYj) ˆ =100j=1 .2. (4) 40 when n is equal across groups, Equation 5 simplifies to Finally,The F Itest want for to this showlinear youhow contrast to perform, or linear a linearcomparison contrast, is with significant, theAlm() linear evencommand: though contrast the omnibus is evaluated usingEvaluate our standard comparisonF withj=1test, F: whichX in thisWith caseequal n is per equal group: to whichThe general is equivalent form of (finally), a linear contrastto is g1 g2 g3 g4 g5 g6>my.contrast[[1]]$psig7 X 4 F test was not. ˆ 2 a 2 In the example from the preceding2 a section,2 =100.2. (n )/ (c ) 1 3 ( )/ ˆ (cj /nj) j=1 j df = (1, N-a) H0 : c1µ1 + c2µ2 + + caµa = =0 (2) In the example from the preceding section, j=1=100.2. F = (6) µ7 = (µ1 + µ2···+ µ3 + µ4 + µ5 + µ6) (1) [1] 100.218 F = (5) Figure 1: Boxplots of y data for di↵erent groups,>my.contrast[[1]]$psi g. MS 4.1.1 using6 standard R commands >my.contrast[[1]]$psi MSW W where the weights of the linear contrast are constrained to sum to zero P P In this section I will4 show you how to perform the linear comparison with R’s built-in[1]If commands there 100.218 were four groups, and we wanted to compare group 3 to the mean of groups 1 and 2, then a [1] 100.218 The numerators in Equations 5 and 6 are SScontrast. There is only 1 degree of freedom (i.e., without using the linear.comparison command). The firstwhen step isn tois inform equal R that acrosswe Iwould want groups, to use Equation the following 5 simplifies contrast to perform a particularcj =0 comparison among the various groups represented(3) by the factor g: for each contrast, so SScontrast =MScontrast. The degrees of freedom for the denominator is If there were four groups, and we wanteda to compare group 3 to the mean of groups 1 and 2, then j=1 If there were four groups, and we wanted2 to compare2 group 3 to the mean of groups 1 and 2, then >contrasts(g)<-my.weightsX N a, where(n a is)/ thej number=1(cj ) of groups or, equivalently, the number of parameters in the full model we wouldwe use would the following use the contrast followingF = contrast =(1)µ1 +(1)µ2 2µ3 +(0)µ4 (6) and the estimation of the comparison,Next, Iˆ perform, is an ANOVA. Note that I’m using the aov command, rather than the lm command: (i.e., an interceptMS and a 1 ↵’s). Most of these values are contained in the variable returned by PW >my.aov<-aov(y~g) 2 linear.comparison: a and our coecients would =(1) beµ1 c=(1,+(1) =(1)µ 1,2 -2,µ2µ1 3 0).+(1)+(0) Ifµµ24 we2 wantedµ3 +(0) toµ4 compare group 1 to group 4, the Finally, I displayˆ the¯ ANOVA table in a way that splits the group e↵ectThe into numerators various pieces: in Equations 5 and 6 are SScontrast. There is only 1 degree of freedom = (cjYj) (4) coecients would>my.contrast[[1]]$F be c=(1, 0, 0, -1). If we wanted to compare groups 1 and 2 to groups 3 and 4, the >summary(my.aov,split=list(g=list(myContrast=1,others=2:6)))j=1 for each contrast, so SScontrast =MScontrast. The degrees of freedom for the denominator is X and ourandcoe coe ourcients coe would wouldcients be be c=(1,would c=(1, 1, be1, -2, -1, c=(1, 0). -1). If 1, we -2, wanted 0). If to we compare wanted group to compare1 to group group 4, the 1 to group 4, the N a, wherecoeacientsis the would number be c=(1, of[1] groups 0, 7.21771 0,-1). or, equivalently, If we wanted to the compare number groups of parameters 1 and 2 to in groups the full 3 and model 4, the In the example from the precedingThe section,split ˆsyntax=100. is2. complicated because it is a list of lists: It is used to inform R to splitcoe aAlistcients linearof would contrast be c=(1,is evaluated 0, 0, -1). using If we our wanted standard to compareF test, which groups in 1 this and case 2 to is groups equal to3 and 4, the terms in the linear model (e.g., g) into lists of pieces. In this case,(i.e., we’re antelling interceptcoe R tocients split and the would e↵aects be1 ↵ c=(1,’s). 1, Most -1, -1). of these values are contained in the variable returned by >my.contrast[[1]]$psi coecients would be c=(1, 1, -1, -1). related to factor g into two pieces: the first piece corresponds to ourlinear.comparison linear contrast,A andlinear the: contrast second is evaluated using our standard F test,2 whicha in this2 case is equal to A linear contrast is evaluated using our( standard )/ F(ctest,/nj) which5 in this case is equal to [1] 100.218 piece is a combination of five other things that are not of interest. We will discuss what these pieces F = j=1 j (5) mean in the following sections. For now, let’s examine the output>my.contrast[[1]]$F of the summary command: 2 a 2 If there were four groups, and we wanted to compare group 3 to the mean of groups 1 and 2, then ( )/ j=1(cj /n2j) MSa W 2 F = ( )/ P (c /nj) (5) we would use the following contrast Df Sum Sq Mean Sq F value Pr(>F) j=1 j [1] 7.21771 when n is equal across groups, EquationPMSF W= 5 simplifies to (5) g634315721.730.1296 MSW g: myContrast 1 2391 2391 7.22 0.0092 ** P =(1)µ1 +(1)µ2 2µ3 +(0)µ4 when n is equal across groups, Equation 5 simplifies to g: others 5 1039 208 0.63 0.6794 2 a 2 when n is equal across groups,5 Equation 5 simplifies(n )/ toj=1(cj ) and our coecients would be c=(1,Residuals 1, -2, 0). If 63 we 20873 wanted to 331 compare group 1 to group 4, the 2 F a= 2 (6) --- (n )/ j=1(cj ) coecients would be c=(1, 0, 0, -1). If we wanted to compare groups 1 and 2 to groups 3 and 4, the 2 MSWa 2 Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ''1 F = (n )/ P (c ) (6) coecients would be c=(1, 1, -1, -1). MSW j=1 j The numerators in Equations 5 andPF = 6 are SS . There is only 1 degree of freedom(6) A linear contrast is evaluatedNotice using ourthat standard the F andF test,p values which listed in this in case the is ANOVA equal to table are the same (to within rounding error) MScontrastW The numerators in Equations 5 and 6 are SScontrast. ThereP is only 1 degree of freedom as those provided2 a by linear.comparison2 . However, it is important to note that the twofor methods each contrast, so SScontrast =MScontrast. The degrees of freedom for the denominator is ( )/ j=1(cj /nj) for each contrast, so SS =MS . The degrees of freedom for the denominator is give theF = same results only when there are equal n per group.(5)If the design in unbalanced,N thenThea,aov where numeratorsa iscontrast the in number Equationscontrast of groups 5 and or, 6 areequivalently, SScontrast. theThere number is of only parameters 1 degree in the of full freedom model MSW yields di↵erent valuesP for SScontrast, F , and p. So you should only use aov to evaluateN a linear, where contrasts a is the number of groups or, equivalently, the number of parameters in the full model for(i.e., each an intercept contrast, andsoa SS1contrast↵’s).=MS Mostcontrast of these. valuesThe degrees are contained of freedom in the for variable the denominator returned by is when n is equal across groups, Equationfor balanced 5 simplifies designs. to (i.e., anN intercepta, where and a is1 the↵’s). number Most of these groups values or, equivalently, are contained the in the number variable of returned parameters by in the full model Finally, I want to show you how to perform a linear contrast with the lm() command:linear.comparison : a linear.comparison : (n 2)/ (c2) (i.e., an intercept and a 1 ↵’s). Most of these values are contained in the variable returned by F = j=1 j (6) >my.contrast[[1]]$F>my.contrast[[1]]$F MSPW 3 linear.comparison: [1] 7.21771 The numerators in Equations 5 and 6 are SScontrast. There is only 1 degree of freedom [1] 7.21771>my.contrast[[1]]$F for each contrast, so SScontrast =MScontrast. The degrees of freedom for the denominator is N a, where a is the number of groups or, equivalently, the number of parameters in the full model [1] 7.21771 (i.e., an intercept and a 1 ↵’s). Most of these values are contained in the variable returned by 5 5 linear.comparison: 5 >my.contrast[[1]]$F

[1] 7.21771

5 Bennett, PJ PSYCH 710 Chapter 4 Bennett, PJ PSYCH 710 Chapter 4 This last form of the hypothesis is perhaps the easiest to interpret: the null hypothesis is that the meanThis last of group form of7 does the hypothesis not di↵er fromis perhaps the mean the easiest of the to other interpret: group means.the null We hypothesis rejected is that that null the hypothesismean of group to accept 7 does the not alternative di↵er from the mean of the other group means. We rejected that null hypothesis to accept the alternative 1 µ7 = (µ1 + µ2 + µ3 + µ4 + µ5 + µ6) 6 61 µ7 = (µ1 + µ2 + µ3 + µ4 + µ5 + µ6) Bennett, PJ PSYCH 710 Chapter 4 The general form of a linear contrast6 6 is The general form of a linear contrast is H0 : c µ + c µ + + c µ = =0 (2) >my.contrast[[1]]$SS.contrast 1 1 2 2 ··· a a [1] 2391.33 where the weights of the linearH0 contrast : c1µ1 are+ c constrained2µ2 + + c toaµ suma = to=0 zero (2) ··· >my.contrast[[1]]$df1 where the weights of the linear contrast are constraineda to sum to zero [1] 1 cj =0 (3) a Bennett, PJ PSYCH 710 >my.contrast[[1]]$df2Chapter 4 j=1 c =0 (3) X j [1] 63 j=1 and the estimation of the comparison, ˆ , is X Bennett, PJBennett, PJ PSYCH 710 PSYCH 710 Chapter 4 Chapter 4 >my.contrast[[1]]$SS.contrast We can use these quantities to calculate MSW =SScontrast/F =331.3. The p-value was 0.00922, which and the estimation of the comparison, ˆ , is a is less than ↵ = .05, so we reject the two-tailed null hypothesis described by Equation 1. Bennett, PJ PSYCH 710 ˆ ¯ Chapter[1] 2391.33 4 Examination of Equation 5 shows that is divided by a weighted sum of contrast weights. This = a (cjYj) >my.contrast[[1]]$SS.contrast(4) >c1<-c(-1/3,-1/3,-1/3,1);#reversethesignofthe1stcontrastweightsdivision means that the values of SScontrast, F , and p are not altered by multiplying the contrast ˆ j=1 ¯ >my.contrast[[1]]$df1 weights by a constant. In other words, contrast weights of (for example) c=(1, 1, 1, -3), c=(2, 2, 2, =X (cjYj) [1] 2391.33 >contrasts(bp$group)<-cbind(c1,c2,c3)#linkcontraststogroup(4) -6), and c=(1/3, 1/3, 1/3, -1) will all give the same values of SS , F , and p (although the value This last form of the hypothesis is perhaps the easiest to interpret:ˆ thej null=1 hypothesis is that[1] 1 the >bp.lm.02<-lm(blood~group,data=bp)#newanova contrast In the example from the preceding section, =100X .2. >my.contrast[[1]]$df1 of will di↵er; see Equation 4). mean of group 7 does not di↵er from the mean of the other group means. We rejected that null >summary(bp.lm.02)#listcoefficientsandp-values >my.contrast[[1]]$psiIn the example from the preceding section, ˆ =100.2. >my.contrast[[1]]$df2 hypothesis to accept the alternative [1] 1 4.2.1 one-tailed tests [1]>my.contrast[[1]]$psi 100.218 [1] 63 Call: 1 >my.contrast[[1]]$df2lm(formula = blood ~ group, data = bp) How can we evaluate the following hypotheses? If[1] there 100.218µ7 were= ( fourµ1 + groups,µ2 + µ3 and+ µ we4 + wantedµ5 + µ6 to) compare group 3 to theWe mean can use of groups these quantities 1 and 2, thento calculate MS =SS /F =331.3. The p-value was 0.00922, which 6 6 [1] 63 W contrast H0 : µ 1 (µ + µ + µ + µ + µ + µ ) (7) we would use the following contrast 7  6 1 2 3 4 5 6 If there were four groups, and we wanted to compare group 3 to theis less mean than of groups↵ = .05, 1 andso we 2,Residuals: reject then the two-tailed null hypothesis described by Equation 1. 1 We can use these quantities to calculate MS =SS /F =331.3. The p-value was 0.00922,H1 which: µ7 > 6 (µ1 + µ2 + µ3 + µ4 + µ5 + µ6) (8) The general form of a linear contrast is Examination of EquationMin 5 shows that 1Q Median is dividedW 3Q by a weightedcontrast Max sum of contrast weights. This we would use the following contrast =(1)µ +(1)µ 2µ +(0)µ is less than ↵ = .05, so we reject the two-tailed null hypothesis described by Equation 1. 1 2 3 4 division means that the values-11.00 of -5.25SScontrast, 0.00F , and 3.75p are not 17.00 altered by multiplyingA one-tailed the test contrast is appropriate here. One-tailed tests can be done easily with t tests, and therefore H0 : c1µ1 + c2µ2 + + caµa = =0 (2) Examination of Equation 5 shows that is divided by a weightedit would sum of be contrast useful toweights. convert our ThisF statistic (Equation 5) into a t statistic. In fact, it can be shown ··· =(1)µ1 +(1)µ2 2µ3 +(0)µ4 weights by a constant. In other words, contrast weights of (for example) c=(1, 1, 1, -3), c=(2, 2, 2, and our coecients would be c=(1, 1, -2, 0). If we wanted to compare groupdivision 1 to group means 4, thethat the values of SScontrast, F , and p are not alteredthat by multiplying the contrast -6), and c=(1/3, 1/3, 1/3,Coefficients: -1) will all give the same values of SScontrast, F , and p (although the value a where the weights of the linearcoecients contrast would are be constrained c=(1,Bennett, 0, 0, to -1).PJ sum If wetozero wanted to compare groups PSYCH 1 and 2 710 to groups 3 and 4, the Chapter 4 / (c2/n ) and our coecients would be c=(1, 1, -2, 0). If we wanted to compare groupweights 1 to group by a constant.4, the In other words, contrast weights of (for example) c=(1, 1, 1, -3), c=(2, 2, 2, j=1 j j of will di↵er; see Equation 4). Estimate Std. Error t value Pr(>|t|) t = (9) coecients would be c=(1, 1, -1, -1). -6), and c=(1/3, 1/3, 1/3, -1) will all give the same values of SScontrast, F , and p (although the value q coecients would bea c=(1, 0, 0, -1). If we wanted to compare groups 1 and 2 to groups 3 and(Intercept) 4, the 90.000 1.854 48.53 <2e-16 *** PpMSW A linear contrast is evaluated using our standard F test, which in this case isof equal will to di↵er; see Equation 4). coecients would be c=(1,cj =0 1, -1, -1). (3) groupc1 -7.000 3.190 -2.19 0.043follows * a t distribution with N a degrees of freedom. A comparison of Equations 5 and 9 will show General Form of Linear Contrast4.2.1 one-tailed tests 2 j=1 Note that the degrees of freedom (df) correspond to the value in the denominator in Equation 5 that F = t , and therefore t = pF . In other words, it is possible to recover the magnitude of A linear contrast is evaluated using our standard2 a F test,2 which in this case is equal to groupc2One-tailed 0.333 3.018 Linear 0.11 Comparisons 0.913 ± X and so were set to (N )/a =j=1 63.(cj /n Settingj) lower.tail to FALSE tells R that we want to know the t simply by taking the square-root of F . The sign of t can be recovered by noting the sign of ˆ : F = How can we evaluate4.2.1 one-tailed the following(5) tests hypotheses? 2 a 2 groupc3Use 1.500one-tailed t test 2.649 0.57 0.579if ˆ < 0, then t = pF , but if ˆ > 0 then t = pF . In our example, ˆ =100.2, and therefore and the estimation of the comparison, ˆ , is probability of getting( a )t/valueMSW that(c /n is)larger than 2.68; setting lower.tail to TRUE (the default value) P j=1 j j df = (1, N-a) How can we--- evaluate the following hypotheses? p would return theF = probability of getting a value that is less than 2.68.H0 The(5) : probabilityµ 1 (µ +p =0µ +.0046µ + µ + µ + µ ) t = 7.2177 = 2.68. (7) when n is equal across groups,a Equation 5 simplifiesMS toW Signif. codes:7  6 1 0 '***2 ' 30.0014 '**5' 0.016 '*' 0.05Finally,'.' we0.1 can'' evaluate1 the null hypothesis. Our null hypothesis predicts that 0. Therefore, represents the probabilityP of getting our result, or something more extreme, if the1 hypothesis1 that  ˆ = (c Y¯ ) (4) H1 : µ7 >H0(µ : 1 +µµ72 +6µ(µ3 1++µµ42++µµ53++µµ64)+ µ5 + µwhen6) the null hypothesis(8) is true,(7) the largest possible value of in the population is zero, and j j 2 a 2 6  when n is equal across groups,= 0 was Equation true. Suppose, 5 simplifies(n )/ instead, to (c ) we had assumed that was some value less than zero? In1 that observed values of (i.e., ˆ ) that are greater than zero are due only to sampling variation. This j=1 j=1 j df = (1, N-a) Residual standardH1 : µ error:7 > (µ1 8.21+ µ2 + onµ3 16+ µ degrees4 + µ5 + ofµ6) freedom (8) F = (6) 6 is a long-winded way of saying that large, positive values of ˆ are unlikely if the null hypothesis is Bennett, PJXcase, PSYCH the probability 710 of getting2 a a value2 of tAthat one-tailedChapter was4 equal test isto appropriate or greater than here. our One-tailed observed tests value can be done easily with t tests, and therefore (n )MS/ W (cj ) Multiple R-squared: 0.237, Adjusted R-squared: 0.0937 ˆ ˆ would be even lower.F = Therefore,P j=1 the value pit=0 would.0046 be represents usefulA one-tailed to the converthighest test(6) our is appropriateprobabilityF statistic ofhere. (Equation obtaining One-tailed 5) into tests a t canstatistic. be done In easilytrue. fact, Thesewith it can statementst tests, be shown and about therefore can be extended to t (Eq. 9): large, positive values of t are unlikely In the example from the preceding section, =100.2. Value of Psi^2 is divided by weighted sum of squared contrasts weights F-statistic: 1.66 on 3 and 16 DF, p-value: 0.216if the null hypothesis is true. We can calculate the probability of obtaining a value of t that is equal The numerators in Equations 5 and 6 are SSMScontrastW . There is only 1 degree of freedom our result (or something moreP extreme) giventhat that the nullit would hypothesis be useful to convert0 is true. our AdoptingF statistic a (Equation 5) into a t statistic.toIn R, or use greater pt() In command fact, than itour canto observed link be t value shown value to p of value:t =2.68 given the assumption that = 0: >my.contrast[[1]]$psi a Note that thefor degrees each of freedomcontrast, (dfso) correspond SScontrast to=MSThis the normalizationcontrast value in. the The means denominator degrees that multiplying of in freedom Equationweights by for k 5has the no denominatoreffect on is 2 The numerators instandard Equations Type 5 and I error 6 are rate SScontrast (i.e., ↵. =There.01 or . is05) only would 1 lead degreethat us to of reject freedomDoes the this null mean hypothesis that / we in now favourj=1( failcj /n toj) reject the null hypothesis, and that our contrast is no longer sig- [1] 100.218 and so were setN to Na, wherea =a 63.is Settingthe numberlower.tail of groupstothe or, FALSEmagnitude equivalently, tells of the R contrast that the we number(though want it tomay of knowparameters change the sign) and in doesn’t the full model t = / a df( =c 2N-a/n ) >pt(2.68,df=63,lower.tail=FALSE)(9) for each contrast, soof SS thecontrast alternative,=MSalter Fcontrast or >p values0.. The degrees of freedom for the denominatornificant? is The answerq is, no. To see why,j=1 wej needj to re-construct our null and alternative hypothesis. probability of getting(i.e., an a t interceptvalue that and is largera 1than↵’s). 2.68; Most setting of theselower.tail values to TRUE are contained (the default in value) the variable returned by PpMSt =W (9) N a, where a is the number of groups or, equivalently, the number of parameters in the fullWe model predicted that the means ofq thep first three groups[1] will 0.00469164 be greater than the mean of the fourth If there werewould four groups, return the and probability we wanted of gettingto compare a value group that 3 is to less the than mean 2.68. of The groups probability 1 and 2,p then=0.0046 PMSW linear.comparison(i.e., an intercept and: a 1 ↵’s). Most of these values are containedfollows in a thet distribution variable returned withgroup.N by Ifa ourdegrees prediction of freedom. is correct, A comparison then – given of Equations the values 5 of and the 9 weights will show used to construct our linear we would userepresents the following the probability contrast of getting our4.3 result, Unequal or something Variances more extreme, if the hypothesisthat F = thatt2,follows and therefore a t distributiont = p withF .N In othera degrees words, of freedom. it is possible A comparison to recover of Equations the magnitude 5 and of9 will show linear.comparison 2contrast – we would expect <0. Therefore, the null hypothesis for this set of weights is 0, = 0 was true.>my.contrast[[1]]$F Suppose, instead, we: had assumed that was some value less than zero? In that that F = t , and therefore± t = pF . In other words, it is possible to recover the magnitudeˆ of Same results obtained by contrast weights w1 <- c(-1, -1, -1, 3) andt simplyw2 <- c(-1/3, by -1/3, taking -1/3, the 1) 2 square-root of F . The sign of t can be recovered by noting the sign of : =(1)µ +(1)Theµ denominator2µ +(0)µ in Equation 5 is MSW , which is an estimate of e andthat the is derived alternative from± isall my.contrast[[1]]$F 7.21771 of getting a1 value of2 t that3 was equal4 to or greater than our observedif ˆ < value0, thent simplyt = p byF taking, but if the ˆ square-root> 0 then t of=Fp.F The. In sign our of example,t can be ˆ recovered=100.2, by and noting therefore the sign of : groups, not just the ones being compared. When the varianceˆ is homogeneous(t(16) = p across2.19, p groups,=0ˆ.0215, MSW one-tailed).p The important pointˆ here is that the null and alternative would be even lower. Therefore, the value p =0.0046 represents the highest probabilityt of= obtainingp7.2177 =if 2 .68.< 0, then t = F , but if > 0 then t = F . In our example, =100.2, and therefore 6 and our coecients would[1] be 7.21771 c=(1, 1, -2, 0). Ifis we a better wanted estimator to compare of 2 groupthan an 1 estimate to group obtained 4, the from ap subset ofhypotheses the groups. for directional tests of linear contrasts are a↵ected by the sign of the contrast weights. our result (or something more extreme) given that the null hypothesise5 0 is true. AdoptingFinally, a wet = can evaluate7.2177 = the2.68. null hypothesis. Our null hypothesis predicts that 0. Therefore, coecients wouldstandard be c=(1, Type I 0, error 0, -1). rate If (i.e., we↵ wanted= .01 or to.What05) compare would if the groups lead variance us to1 and reject is 2not theto homogeneous? groups null hypothesis 3 and 4, Itin the favourturns out thatFinally,F tests we can of evaluate linear contrasts the null hypothesis. are not Our null hypothesis predicts that 0. Therefore, when the null hypothesis is true, the largest possible value of in the population is zero, and coecients wouldof the be alternative, c=(1, 1, -1,> -1).0. robust to violations of the5 homogeneity of variance assumptions.when the Moreover, null hypothesis it is not is true, the case the largest that possible value of in the population is zero, and observed values of (i.e.,4.6 ˆ ) that Measures are greater of than E↵ zeroect are Size due & only Association to sampling variation. Strength This A linear contrast is evaluated using our standardviolationsF test, of which the assumption in this case have is equal the eto↵ect of simply loweringobserved↵ values: sometimes of (i.e.,↵ will ˆ ) that be increased are greater than zero are due only to sampling variation. This is a long-winded way of saying that large, positive values of ˆ are unlikely if the null hypothesis is and other times it will be decreased. When the groups haveis a long-winded unequalA variances, common way of measuresayingtherefore, that of wethe large, use standardized positive a values di↵erence of ˆ are between unlikely two if the means null is hypothesis Cohen’s d is 4.3 Unequal Variances 2 a 2 true. These statements about ˆ can be extended to t (Eq. 9): large, positive values of t are unlikely ( )/ j=1(cj /nj) 2 true. These statements about ˆ can be extended to t (Eq. 9): large, positive values of t are unlikely F = di↵erent method for estimating2 e (5) The denominator in Equation 5 is MS , which is an estimate of that is derived fromif theall nullaof the hypothesis2 is true. We can calculate the probability of obtainingd =(µ1 aµ value2)/e of t that is equal W MSW e w s if the null hypothesis is true. We can calculate the probability of obtaining a value of t that is equal P 2to or greaterj=1 j j than our observed value of t =2.68 given the assumption that = 0: groups, not just the ones being compared. When the variance is homogeneous acrossˆe groups,= a MSW to or greater than our observed value of (10)t =2.68 given the assumption that = 0: when n is equal across groups, Equation2 5 simplifies to wj which can be estimated from the data by is a better estimator of e than an estimate obtained from a subset of the groups. P j=1 What if the variance is notUnequal homogeneous? ItGroup turns out that VariancesF tests of linear contrasts>pt(2.68,df=63,lower.tail=FALSE) are not >pt(2.68,df=63,lower.tail=FALSE) (n 2)where/ a (c2) P dˆ=(Y¯ Y¯ )/ MS (17) robust to violations of the homogeneity of variancej=1 j assumptions. Moreover, it is not the case2 that 1 2 W F = [1]wj = 0.00469164(6)cj /nj (11) violations of the assumption have the eMS↵ectW of simply lowering ↵: sometimes ↵ will be increased [1] 0.00469164 p P 2 In the case of two or more groups, weCohen’s can defined (for a contrast) standardized di↵erence for a contrast among and other times it will be decreased. WhenUsing the this groups new haveestimate unequal of variances,e , the formula therefore, for F webecomes use a The numerators in Equations 5 and• 6F2 are test SS forcontrast contrasts. There is isnot only robust 1 degree to violation of freedom of equal variance population means as di↵erent method for estimating e a Bennett, PJ PSYCH 710a Chapter 4 a 2 2 for each contrast, so SScontrast =MScontrastassumptions. The degrees w s of freedom for the denominator( )/ isj=1(cj/nj) 2 j=1 j j d =2 / c ˆ = F = a (10) a (12) e j N a, where a is the number of groups or, equivalently,e thea numberw of parameters in the full(c2 model/n )s2 / (c2/n ) | | • when groupsP havej=1 junequal variances, mustj=1 usej differentjPj j=1 j j " j=1 #! (i.e., an intercept and a 1 ↵’s). Most of these values are contained in the variable returned by We can estimate d from6 data by 6 X linear.comparisonwhere : method to calculateP F denominator, whichP ⇥is an estimate⇤ P of The numerator2 degrees of freedom remains 1, but the denominator degrees of freedom no longer is a wj = cj /nj (11) 14 >my.contrast[[1]]$F populationN a .error Instead, variance it is given by the formula d =2 ˆ / MS c (18) 2 W j Using this new estimate of e , the formula for F becomes | | 2 " j=1 #! [1] 7.21771 a 2 2 p X 2 a (c s /n ) ( )/ (cj/nj) j=1 j j j F = j=1 df = (12) When the comparison is(13) between two group means (e.g., c=(-1,1,0,0, )), Equations 17 and 18 are a 2 2 a 2 a 2 2 2 ··· (c /nj)s / (c /nj) h (c s /n ) /(ni 1) j=15 j Pj j=1 j j=1 P j j j j the same. Expresses Psi in terms of the number of standard Your textbook describes several measures of association strength that are based on SS . The P ⇥ ⇤ P deviations of population error distribution contrast The numerator degrees of freedom remainsFortunately, 1, but the denominator we rarely havedegrees to of use freedom EquationsP ⇥ no longer 12 and is 13 to calculate⇤ firstF and is Rdf2 . Instead,which weis defined can as N a. Instead, it is given by the formula alerting use linear.comparison() to do the heavy lifting: 2 2 Ralerting =SScontrast/SSB (19) >source(url("http://psycserv.mcmaster.ca/bennett/psy710/Rscripts/linear_contrast_v2.R"))a 2 2 j=1(cj sj /nj) df = (13) a h 2 2 2 i Recall that SSB is a measure of the variation among group means: [1] "loadingP(cj sj /n functionj) /(nj linear.comparison"1) j=1 a Fortunately, we rarely have to use EquationsP>contrast.unequal.var<-linear.comparison(y,g,c.weights=list(c(-1,-1,-1,-1,-1,-1,6)),var.equal=FALSE)⇥ 12 and 13 to calculate⇤ F and df . Instead, we can SS = n (Y¯ Y¯ )2 B j j u use linear.comparison() to do the heavy lifting: j=1 [1] "computing linear comparisons assuming unequal variances among groups" X [1] "C 1: F=3.772, t=1.942, p=0.080, psi=100.218, CI=(-14.451,214.886), adj.CI= (-14.451,214.886)" ⇥ ⇤ >source(url("http://psycserv.mcmaster.ca/bennett/psy710/Rscripts/linear_contrast_v2.R")) 2 So, Equation 19 expresses SScontrast as a proportion of the “total variation” among groups. Ralerting >contrast.unequal.var[[1]]$psi 2 [1] "loading function linear.comparison" can vary between 0 and 1. As your book notes, another interpretation of Ralerting is that it is the squared correlation between the comparison coecients and the group means when the group n’s are >contrast.unequal.var<-linear.comparison(y,g,c.weights=list(c(-1,-1,-1,-1,-1,-1,6)),var.equal=FALSE) 7 equal. [1] "computing linear comparisons assuming unequal variances among groups" 2 Another measure of association strength is Re↵ectsize : [1] "C 1: F=3.772, t=1.942, p=0.080, psi=100.218, CI=(-14.451,214.886), adj.CI= (-14.451,214.886)" 2 >contrast.unequal.var[[1]]$psi Re↵ectsize =SScontrast/SSTotal (20)

Comparing Equations 19 and 20 shows that they have the same numerators but di↵erent denomi- 7 2 nators. Re↵ectsize describes the between-group variability associated with the contrast relative to the total variability among the dependent measures. The third and final measure of association strength does not depend on SSTotal or SSB:

2 Rcontrast =SScontrast /(SScontrast +SSW ) (21)

2 Your textbook describes one advantage that Rcontrast has over the other two measures of association strength. Suppose you are conducting a linear contrast that compares groups B and C to each other, 2 2 and ignores group A. It turns out that the values of Ralerting and Re↵ectsize depend on the mean of 2 group A even though that group is ignored in our contrast. The value of Rcontrast is less dependent on the value of the ignored group A. None of these measures is necessarily better than the other two; they simply convey di↵erent 2 information. You should note that it is possible for Ralerting to be close to its maximum value (i.e., 1) but R2 to be very small. (How could this happen?) ⇡ e↵ectsize 4.7 Orthogonal Contrasts In this section we introduce the notion of orthogonal contrasts. When sample sizes are equal, two contrasts are said to be orthogonal if and only if

a

(c1jc2j)=0 (22) j=1 X

15 Bennett, PJ PSYCH 710 Chapter 4

We can estimate d from data by

a d =2 ˆ / MS c (18) W | j| " j=1 #! p X When the comparison is between two group means (e.g., c=(-1,1,0,0, )), Equations 17 and 18 are the same. ··· Your textbook describes several measures of association strength that are based on SScontrast. The 2 first is Ralerting which is defined as

2 Ralerting =SScontrast/SSB (19)

Recall that SSB is a measure of the variation among group means:

a SS = n (Y¯ Y¯ )2 B j j u j=1 X ⇥ ⇤ 2 So, Equation 19 expresses SScontrast as a proportion of the “total variation” among groups. Ralerting 2 can vary between 0 and 1. As your book notes, another interpretation of Ralerting is that it is the squared correlation between the comparison coecients and the group means when the group n’s are equal. Bennett, PJ PSYCH 710 Chapter 4 2 Another measure of association strength is Re↵ectsize : Bennett, PJ PSYCH 710 Chapter 4 2 We can estimate d from data by Re↵ectsize =SScontrast/SSTotal (20)

We can estimate d from data by a Comparing Equations 19 and 20 shows that they have the same numerators but di↵erent denomi- d =2 ˆ / MS c (18) W | j| 2 " j=1 a #! nators. Re↵ectsize describes the between-group variability associated with the contrast relative to the p X d =2 ˆ / MSW cj total(18) variability among the dependent measures. When the comparison is between two group means (e.g., c=(-1,1,0,0,| | )), Equations 17 and 18 are " j=1 #! The third and final measure of association strength does not depend on SSTotal or SSB: the same. p X ··· WhenYour the textbook comparison describes is between several measures two group of association means (e.g., strength c=(-1,1,0,0, that are based)), Equations on SScontrast 17. and The 18 are R2 =SS /(SS +SS ) (21) 2 ··· contrast contrast contrast W firstthe issame.Ralerting which is defined as Bennett, PJ PSYCH 710 Chapter 4 Your textbook describes several measures of association strength that are based on SS . The 2 2 contrastYour textbook describes one advantage that Rcontrast has over the other two measures of association 2 Ralerting =SScontrast/SSB (19) first is Ralerting which is defined as strength. Suppose you are conducting a linear contrast that compares groups B and C to each other, 2 2 RecallWe can that estimate SSB is ad measurefrom data of the by variation among group means: and ignores group A. It turns out that the values of R and R depend on the mean of R2 =SS /SS (19) alerting e↵ectsize alerting contrast B group A even though that group is ignored in our contrast. The value of R2 is less dependent a a contrast ¯ ¯ 2 SSB = ˆ nj(Yj Yu) on the value of the ignored group A. Recall that SSB is a measure of thed variation=2 / amongMSW group means:cj (18) j=1 | | X ⇥ " j=1⇤ #! None of these measures is necessarily better than the other two; they simply convey di↵erent ap X 2 So, Equation 19 expresses SS as a proportion of the¯ “total¯ 2 variation” among groups. R2 information. You should note that it is possible for Ralerting to be close to its maximum value (i.e., When the comparison is betweencontrast twoSS groupB = meansnj(Y (e.g.,j Yu c=(-1,1,0,0,) )), Equationsalerting 17 and 18 are 2 can vary between 0 and 1. As your book notes, another interpretation of R2 is that it is the1) but Re↵ectsize to be very small. (How could this happen?) j=1 ···alerting ⇡ squaredthe same.correlation betweenBennett, the PJcomparison coeXcients⇥ and the group⇤ means PSYCH when 710 the group n’s are Chapter 4 Bennett, PJ PSYCH 710 Chapter 4 equal.Your textbook describes severalAssociation measures of association Strength strength that are based on SScontrast2 . The Orthogonal Contrasts So, Equation 19 expresses SScontrast as a proportion of the “total variation” among groups. Ralerting 2 2 4.7 Orthogonal Contrasts firstAnother is Ralerting measurewhich of association is defined strength as is R : 2 can vary between 0 and 1. As your book notes,e↵ectsize another interpretation of Ralerting is that it is the squared correlation betweenwhere c1 thej and comparisonc2j are the coe coecientscients, and or the weights, group• Proportion means of the of when twoBetween-Groups thecontrasts. groupIn thisnvariation When’s are section accounted sample we sizesfor introduce by arecontrast unequal, the notion of orthogonal contrasts. When sample sizes are equal, two 2 2 where c1j and c2j are the coecients, or weights, of the two contrasts. When sample sizes are unequal, contrasts areRe orthogonal↵ectsizeRalerting=SScontrast=SS if and/contrastSS onlyTotal/ ifSSB • With equal n, equals squared(20) correlation(19) between contrast equal. contrasts are said to be orthogonalcontrasts if are and orthogonalEqual only n: if if and only if Unequal n: 2 weights & group means ComparingAnother Equations measure 19 of andassociation 20 shows strength that they is R havee↵ectsize the: same numeratorsa but di↵erent denomi- Recall that SSB is a measure of the variation among group means: a a nators. R2 describes the between-group variability associated with the contrast relative to the e↵ectsize 2 (c1jc2j/nj)=0 (23) (c c )=0 (c c /n )=0 (22) (23) R =SSa contrast/SSTotal • Proportion of total variation accounted(20) for by contrast 1j 2j 1j 2j j total variability among the dependent measures.e↵ectsize j=1 ¯ ¯ 2 j=1 j=1 The third and final measure of associationSSB = strengthn doesj(Yj notYu depend) X on SS or SS : Total B X X Comparing EquationsSo, 19 when and 20 sample shows sizes that aretheyj=1 equal, have the the same pair numerators of contrasts butc di=(1↵erent, 1, denomi-1, 3) and c =(1, 1, 2, 0) are 2 2 X ⇥ ⇤ • Variation accounted1 for by contrast relative to 2the sum So, when sample sizes are equal, the pair of contrasts c1 =(1, 1, 1, 3) and c2 =(1, 1, 2, 0) are nators. Re↵ectsize describes theRcontrast between-group=SScontrast variability/(SScontrast associated+SSW ) with the contrast relative(21) to the orthogonal because of contrast-variation and within-group2 (error) variation orthogonal because 15 totalSo, Equation variability 19 among expresses the dependentSScontrast as measures. a proportion of the “total variation” among groups. Ralerting 2 (1)(1) + (1)(1) + (1)( 2)2 + ( 3)(0) = 0 Yourcan textbook vary between describes 0 and one 1. advantage As your that bookRcontrast notes,has another over the interpretation other two measures of R of associationis that it is the A set of contrasts(1)(1) is mutually + (1)(1) orthogonal + (1)( 2) + if ( all3)(0) pairs = of 0 contrasts are orthogonal The third and final measure of association strength does not depend on SSTotalalertingor SSB: strength.squared Supposecorrelation you between are conducting the comparison a linear contrast coecients that compares and the groups group meansB and C whento each the other, group n’s are However, c1 =(1, 1, 1, 3) and2 c3 =(1, 1,20, 3) are not orthogonal because However, c1 =(1, 1, 1, 3) and c3 =(1, 1, 0, 3) are not orthogonal because and ignores group A. It turns out2 that the values of Ralerting and Re↵ectsize depend on the mean of Orthogonal contrasts evaluate independent questions about group means equal. Rcontrast =SScontrast /(SScontrast +SSW ) 2 (21) group A even though that group is ignored in our contrast.2 The value of Rcontrast is less dependent Another measure of association strength is Re↵ectsize(1)(1): + (1)(1) + (1)(0) + ( 3)( 3) =0 (1)(1) + (1)(1) + (1)(0) + ( 3)( 3) =0 on the value of the ignored group A. 2 6 6 Your textbook describes one advantage that Rcontrast has over the other two measures of association None of these measures is necessarily2 better than the other two; they simply convey di↵erent strength. Suppose you areA set conductingof contrastsR ae↵ linearectsize is=SS saidcontrast2contrast to be that/ mutuallySS comparesTotal orthogonal groups B and if andC to only each if other, every(20) possible pair of contrastsA set of contrasts is said to be mutually orthogonal if and only if every possible pair of contrasts information. You should note that it is possible for Ralerting2to be close to2 its maximum value (i.e., and ignores2 group Ais. orthogonal.It turns out that For instance the values the of R setalerting of contrastsand Re↵ectsize depend on the mean of is orthogonal. For instance the set of contrasts 1) but Re↵ectsize to be very small. (How could this happen?) 2 ⇡groupComparingA even Equations though that 19 andgroup 20 is shows ignored that in theyour contrast. have the The same value numerators of Rcontrast butis di less↵erent dependent denomi- 2 onnators. the valueR of thedescribes ignored groupthe between-groupA. variability associated with the contrast relative to the 1 =(1)µ1 +(1)µ2 +( 1)µ3 +( 1)µ4 e↵ectsize 1 =(1)µ1 +(1)µ2 +( 1)µ3 +( 1)µ4 4.7total variabilityOrthogonal among Contrasts the dependent measures. None of these measures is necessarily better than the=(1) otherµ two;+( they1)µ simply+(0)µ convey+(0) diµ4↵erent 2 =(1)µ1 +( 1)µ2 +(0)µ3 +(0)µ4 22 1 2 3 Ininformation. thisThe section third You we and introduce should final measure note the notionthat of it association of isorthogonal possible strength forcontrasts.R does Whento not be depend close sample to on sizes its SS maximum areTotal equal,or SS value twoB: (i.e., alerting 3 =(0)µ1 +(0)µ2 +(1)µ3 +( 1)µ4 contrasts1) but areR2 said toto be be orthogonal very small. if and (How only could if this happen?)3 =(0)µ1 +(0)µ2 +(1)µ3 +( 1)µ4 e↵ectsize 2 ⇡ R =SScontrast /(SScontrast +SSW ) (21) contrast a 4.7 Orthogonal Contrasts (c1jc2j2)=0 (22) is (mutually) orthogonal because each pair of contrasts is orthogonal. Your textbook describesis (mutually) one advantage orthogonal that R becausecontrast has each over pair the of other contrasts two measures is orthogonal. of association j=1 The concept of orthogonality is important for the following reason: multiple orthogonal contrasts Instrength. this section Suppose we introduce youThe are conductingconcept the notion ofX a oforthogonality linearorthogonal contrastcontrasts. is that important compares When for groups sample the followingB sizesand C are reason:to equal, each other, twomultiple orthogonal contrasts Complete Set2 of Mutually2 Orthogonal Contrasts of a set of group means provide independent pieces of information about the way the means di↵er. In contrastsand ignores are group said toAof be. a It orthogonal set turns of group out if that and means the only provide values if of independentRalerting and piecesRe↵ectsize of informationdepend on the about mean the of way the means di↵er. In 15 2 other words, orthogonal contrasts provide separate and unique information about group di↵erences. group A even thoughother that words, group orthogonal is ignored in contrasts our contrast. provide The separate value of andRcontrast uniqueis less information dependent about group di↵erences. a Multiple contrasts that are not orthogonal, on the other hand, provide overlapping, correlated, and on the value of theMultiple ignored group contrastsA. thatIf there are not areorthogonal, a groups, onthen the the other largest hand, set provide of mutually overlapping, correlated, and (c1jc2j)=0 (22) partially-redundant information about group di↵erences. This special characteristic of orthogonal None of these measurespartially-redundant is necessarily information better than about the other group two; di↵ theyerences. simply This convey special di↵erent characteristic of orthogonal jorthogonal=1 2 contrasts will have (a-1) contrasts, and: contrasts is represented in the Equation 24, which is true only for orthogonal sets of contrasts: information. You should note that it is possibleX for Ralerting to be close to its maximum value (i.e., 2 contrasts is represented in the Equation 24, which is true only for orthogonal sets of contrasts: 1) but Re↵ectsize to be very small. (How could this happen?) a 1 ⇡ 15 a 1 SScontrast,j =SSB (24) SScontrast,j =SSB (24) j=1 4.7 Orthogonal Contrasts X j=1 In this section we introduce the notion of orthogonal contrasts.X When sample sizes are equal, two Notice that the summation in Equation 24 is over a 1 contrasts. This leads to the second important Notice that the summation in Equation 24 is over a 1 contrasts. This leads to the second importantproperty of orthogonal contrasts: If there are a groups, then the largest possible set of orthogonal contrasts are said to be orthogonal if and onlythe if sum of the (a-1) SScontrasts will equal SSB property of orthogonal contrasts: If there are a groups, then the largest possible set of orthogonalcontrasts will have a 1 elements. I will refer to a set of a 1 orthogonal contrast as constituting a contrasts will have a 1 elements. I will refer to a set of a 1 orthogonal contrast as constitutinga complete orthogonal set. Note that I am not suggesting that there are only a 1 orthogonal (c c )=0 (22) a complete orthogonal set.1j Note2j that I am not suggesting that there are only a 1 orthogonalcontrasts. In fact, there are an infinite number of orthogonal contrasts, and there are an infinite j=1 contrasts. In fact, thereX are an infinite number of orthogonal contrasts, and there are annumber infinite of orthogonal sets of contrasts. However, each complete orthogonal set will contain a 1 number of orthogonal sets of contrasts. However, each complete orthogonal set will containelements.a 1 15 elements. These ideas about orthogonality, and the decomposition of SSB into independent pieces, will be important when we discuss multiple comparisons. These ideas about orthogonality, and the decomposition of SSB into independent pieces, will be important when we discuss multiple comparisons.

16 16