/* SAS example for Two-Factor Study with Unequal Sample Sizes */ /* We use the growth rate data from Chapter 23 and the example in class. */ DATA growth; INPUT growthratechange gender bone child; CARDS; 1.4 1 1 1 2.4 1 1 2 2.2 1 1 3 2.1 1 2 1 1.7 1 2 2 0.7 1 3 1 1.1 1 3 2 2.4 2 1 1 2.5 2 2 1 1.8 2 2 2 2.0 2 2 3 0.5 2 3 1 0.9 2 3 2 1.3 2 3 3 ; run; PROC GLM data = growth; CLASS gender bone; MODEL growthratechange = gender bone gender*bone; LSMEANS gender bone gender*bone; LSMEANS bone / pdiff CL ADJUST=TUKEY ALPHA = 0.10; RUN; /* When the data are unbalanced (as they are here), the correct SS to */ /* look at in PROC GLM's output are the Type III SS, not Type I. So */ /* The correct F* for the main-effect test for factor A is 0.74 and */ /* the correct F* for the main-effect test for factor B is 12.89. */ /* (Compare to the values obtained at the bottom of page 958 of the */ /* book.) */ /* Our conclusions are: There is no significant interaction between */ /* gender and bone development; there is no significant effect on mean */ /* growth rate change due to gender; there is a significant effect on */ /* mean growth rate change due to bone development. */ /* Using Tukey's procedure (family significance level 0.10), we may */ /* check with of the simultaneous CIs contain zero. We thereby find */ /* that levels 1 and 3 of bone development have significantly different */ /* mean growth rate change; levels 1 and 3 of bone development have */ /* significantly different mean growth rate change; but levels 1 and 2 */ /* of bone development do not have significantly different mean growth */ /* rate change. */ /* Note that with unbalanced data, we must use an LSMEANS statement to */ /* get the correct sample means and Tukey CIs. The MEANS statement */ /* does NOT correctly adjust for the unequal sample sizes. */ /* ******************************************************************** */ /* Analysis with Empty Cells */ /* The following data set is the same as the one above, but deletes the */ /* observation in the (2,1) cell, so that the (2,1) cell is empty. */ DATA growthempty; SET growth; IF gender=2 AND bone=1 THEN DELETE; run; PROC GLM data = growthempty; CLASS gender bone; MODEL growthratechange = gender bone gender*bone / CLPARM; LSMEANS gender bone gender*bone; /* Note NO (2,1) cell sample mean given! */ /* Question: Is mu_12 - mu_22 equal to mu_13 - mu_23? */ /* Contrast of interest: mu_12 - mu_22 - mu_13 + mu_23. */ /* Write this contrast out in terms of the FACTOR EFFECTS. */ /* Treatments are 11, 12, 13, 21, 22, 23 (from "Class Level Information") */ /* But we skip the (2,1) cell when listing coefficients: */ ESTIMATE 'CheckForInteraction' gender*bone 0 1 -1 -1 1; RUN;