Presentation is loading. Please wait.

Presentation is loading. Please wait.

Topic 29: Three-Way ANOVA. Outline Three-way ANOVA –Data –Model –Inference.

Similar presentations


Presentation on theme: "Topic 29: Three-Way ANOVA. Outline Three-way ANOVA –Data –Model –Inference."— Presentation transcript:

1 Topic 29: Three-Way ANOVA

2 Outline Three-way ANOVA –Data –Model –Inference

3 Data for three-way ANOVA Y, the response variable Factor A with levels i = 1 to a Factor B with levels j = 1 to b Factor C with levels k = 1 to c Y ijkl is the l th observation in cell (i,j,k), l = 1 to n ijk A balanced design has n ijk =n

4 KNNL Example KNNL p 1005 Y is exercise tolerance, minutes until fatigue on a bicycle test A is gender, a=2 levels: male, female B is percent body fat, b=2 levels: high, low C is smoking history, c=2 levels: light, heavy n=3 persons aged 25-35 per (i,j,k) cell

5 Read and check the data data a1; infile 'c:\...\CH24TA04.txt'; input extol gender fat smoke; proc print data=a1; run;

6 Obs extol gender fat smoke 1 24.1 1 1 1 2 29.2 1 1 1 3 24.6 1 1 1 4 20.0 2 1 1 5 21.9 2 1 1 6 17.6 2 1 1 7 14.6 1 2 1 8 15.3 1 2 1 9 12.3 1 2 1 10 16.1 2 2 1 11 9.3 2 2 1 12 10.8 2 2 1 13 17.6 1 1 2... 24 6.1 2 2 2

7 Define variable for a plot data a1; set a1; if (gender eq 1)*(fat eq 1)*(smoke eq 1) then gfs='1_Mfs'; if (gender eq 1)*(fat eq 2)*(smoke eq 1) then gfs='2_MFs'; if (gender eq 1)*(fat eq 1)*(smoke eq 2) then gfs='3_MfS'; if (gender eq 1)*(fat eq 2)*(smoke eq 2) then gfs='4_MFS'; if (gender eq 2)*(fat eq 1)*(smoke eq 1) then gfs='5_Ffs'; if (gender eq 2)*(fat eq 2)*(smoke eq 1) then gfs='6_FFs'; if (gender eq 2)*(fat eq 1)*(smoke eq 2) then gfs='7_FfS'; if (gender eq 2)*(fat eq 2)*(smoke eq 2) then gfs='8_FFS'; run;

8 Obs extol gender fat smoke gfs 1 24.1 1 1 1 1_Mfs 2 29.2 1 1 1 1_Mfs 3 24.6 1 1 1 1_Mfs 4 17.6 1 1 2 3_MfS 5 18.8 1 1 2 3_MfS 6 23.2 1 1 2 3_MfS 7 14.6 1 2 1 2_MFs 8 15.3 1 2 1 2_MFs 9 12.3 1 2 1 2_MFs 10 14.9 1 2 2 4_MFS 11 20.4 1 2 2 4_MFS 12 12.8 1 2 2 4_MFS

9 Plot the data title1 'Plot of the data'; symbol1 v=circle i=none c=black; proc gplot data=a1; plot extol*gfs/frame; run;

10

11 Find the means proc sort data=a1; by gender fat smoke; proc means data=a1; output out=a2 mean=avextol; by gender fat smoke;

12 Define fat*smoke data a2; set a2; if (fat eq 1)*(smoke eq 1) then fs='1_fs'; if (fat eq 1)*(smoke eq 2) then fs='2_fS'; if (fat eq 2)*(smoke eq 1) then fs='3_Fs'; if (fat eq 2)*(smoke eq 2) then fs='4_FS';

13 Obs gen fat smoke FR avextol fs 1 1 1 1 3 25.97 1_fs 2 2 1 1 3 19.83 1_fs 3 1 1 2 3 19.87 2_fS 4 2 1 2 3 12.13 2_fS 5 1 2 1 3 14.07 3_Fs 6 2 2 1 3 12.07 3_Fs 7 1 2 2 3 16.03 4_FS 8 2 2 2 3 10.20 4_FS

14 Plot the means proc sort data=a2; by fs; title1 'Plot of the means'; symbol1 v='M' i=join c=black; symbol2 v='F' i=join c=black; proc gplot data=a2; plot avextol*fs=gender/frame; run;

15

16 Cell means model Y ijkl = μ ijk + ε ijkl –where μ ijk is the theoretical mean or expected value of all observations in cell (i,j,k) –the ε ijkl are iid N(0, σ 2 ) –Y ijkl ~ N(μ ijk, σ 2 ), independent

17 Estimates Estimate μ ijk by the mean of the observations in cell (i,j,k), = (Σ k Y ijkl )/n ijk For each (i,j,k) combination, we can get an estimate of the variance We need to combine these to get an estimate of σ 2

18 Pooled estimate of σ 2 We pool the s ijk 2, giving weights proportional to the df, n ijk -1 The pooled estimate is MSE=s 2 = (Σ (n ijk -1)s ijk 2 ) / (Σ(n ijk -1))

19 Factor effects model Model cell mean as μ ijk = μ + α i + β j + γ k + (αβ) ij + (αγ) ik + (βγ) jk + (αβγ) ijk μ is the overall mean α i, β j, γ k are the main effects of A, B, and C (αβ) ij, (αγ) ik, and (βγ) jk are the two-way interactions (first-order interactions) (αβγ) ijk is the three-way interaction (second-order interaction) Extension of the usual constraints apply

20 ANOVA table Sources of model variation are the three main effects, the three two-way interactions, and the one three-way interaction With balanced data the SS and DF add to the model SS and DF Still have Model + Error = Total Each effect is tested by an F statistic with MSE in the denominator

21 Run proc glm proc glm data=a1; class gender fat smoke; model extol=gender fat smoke gender*fat gender*smoke fat*smoke gender*fat*smoke; means gender*fat*smoke; run;

22 Run proc glm proc glm data=a1; class gender fat smoke; model extol=gender|fat|smoke; means gender*fat*smoke; run; Shorthand way to express model

23 SAS Parameter Estimates Solution option on the model statement gives parameter estimates for the glm parameterization These are as we have seen before; any main effect or interaction with a subscript of a, b, or c is zero These reproduce the cell means in the usual way

24 ANOVA Table SourceDF Sum of SquaresMean SquareF ValuePr > F Model7588.58291784.08327389.010.0002 Error16149.3666679.3354167 Corrected Total23737.949583 Type I and III SS the same here

25 Factor effects output Source DF Type I SSMean SquareF ValuePr > F gender1176.58375176.583750018.920.0005 fat1242.57042242.570416725.980.0001 gender*fat113.65041713.65041671.460.2441 smoke170.38375070.38375007.540.0144 gender*smoke111.0704167 1.190.2923 fat*smoke172.45375072.45375007.760.0132 gender*fat*smoke11.8704167 0.200.6604

26 Analytical Strategy First examine interactions…highest order to lowest order Some options when one or more interactions are significant –Interpret the plot of means –Run analyses for each level of one factor, eg run A*B by C (lsmeans with slice option) –Run as a one-way with abc levels –Define a composite factor by combining two factors, eg AB with ab levels –Use contrasts

27 Analytical Strategy Some options when no interactions are significant –Use a multiple comparison procedure for the main effects –Use contrasts –When needed, rerun without the interactions

28 Example Interpretation Since there appears to be a fat by smoke interaction, let’s run a two-way ANOVA (no interaction) using the fat*smoke variable Note that we could also use the interaction plot to describe the interaction

29 Run glm proc glm data=a1; class gender fs; model extol=gender fs; means gender fs/tukey; run;

30 ANOVA Table SourceDF Sum of SquaresMean SquareF ValuePr > F Model4561.99167140.497916715.17<.0001 Error19175.957929.2609430 Corrected Total23737.94958

31 Factor effects output SourceDFType I SS Mean SquareF ValuePr > F gender1176.58375176.583750019.070.0003 fs3385.40792128.469305613.87<.0001 Both are significant as expected…compare means

32 Means for gender Mean N gender A 18.983 12 1 B 13.558 12 2

33 Tukey comparisons for fs Mean N fs A 22.900 6 1_fs B 16.000 6 2_fS B B 13.117 6 4_FS B B 13.067 6 3_Fs

34 Conclusions Gender difference with males having a roughly 5.5 minute higher exercise tolerance – beneficial to add CI here There was a smoking history by body fat level interaction where those who were low body fat and had a light smoking history had a significantly higher exercise tolerance than the other three groups

35 Last slide Read NKNW Chapter 24 We used program topic29.sas to generate the output for today


Download ppt "Topic 29: Three-Way ANOVA. Outline Three-way ANOVA –Data –Model –Inference."

Similar presentations


Ads by Google