220 likes | 811 Views
ANOVA in SAS. Mean Comparison With More Than Two Groups. Introduction. ANOVA (analysis of variance) tests are used to compare the means of multiple groups (as opposed to the t-test, which can only be used for up to two groups).
E N D
ANOVA in SAS Mean Comparison With More Than Two Groups
Introduction ANOVA (analysis of variance) tests are used to compare the means of multiple groups (as opposed to the t-test, which can only be used for up to two groups). An ANOVA tests Ho: all group means are equal vs. Ha: at least one group’s mean is different. The ANOVA results do not tell you which group is different, only whether a difference exists.
ANOVA in SAS Open SAS and use the infile statement to input the data set relief.txt (this is also the first data set of the INFILE tutorial). If you don’t remember how to do this, here is some code that may help: data relief; infile 'C:\Documents and Settings\My Documents\relief.txt'; input group $ time; procprint data = relief; run;
Once you print your data, notice that there are three groups: A, T, M. The data are from an experiment in which subjects were given Aspirin, Tylenol or Motrin for headaches. The time until relief was measured for each subject. The question of interest is: Does time to relief differ for any of the treatments, or are they all the same? In other words: Ho: µA = µT = µM vs. Ha: at least one group mean is different
SAS Code for ANOVA To test our hypothesis, we use the following code in SAS: • “class” tells SAS the classification variable. In general, this is going to be the effect that you are studying. In this case, the effect is “group.” • “model” tells SAS the dependent variable. The general format is “model Y = X” where Y is the dependent variable, and X is the independent variable. In this case, time to relief is dependent on treatment group. • Often a “quit” statement is necessary, because SAS may continue to run a procedure until either another one has been run, or SAS has been told to quit.
The first page of your output says that there were three categories under the variable “Group”: A T M. It also tells you that there are 18 observations (it’s a good idea to double-check these numbers, to make sure no data are missing). Scroll down to the second page.
Interpreting the SAS Output • The “Between SS” is under “Model” and has a value of 2483.44. • The “Within SS” is under “Error” and has a value of 799.50. • The degrees of freedom are listed under “DF.” • The F*= MSB/MSW = 1241.72/53.30 = 23.30. The p-value of this F* is found under “Pr>F” and p < 0.0001.
Conclusions from ANOVA Because the p-value for the test statistic (F*) is less than alpha (0.05), we reject the null hypothesis and conclude that at least two of the groups’ means differ on time to relief. Now the question is: which groups are different? Answering this question requires multiple comparisons, which can affect the Type-I error. To correct for this, we can use the Bonferroni Method. The following code is exactly the same as before, except a line has been added, requesting the Bonferroni correction.
ANOVA Code with Bonferroni Method The fourth statement requests that SAS use the Bonferroni Method when comparing the means of each category within the variable “group.” Your SAS Output will be the same as previously, but it will have an additional page.
Interpreting Output As stated in the SAS Output under the Bonferroni tests, “Means with the same letter are not significantly different.” Because the Aspirin and Tylenol groups have the same letter (A) under the heading “Bon Grouping,” this indicates they are not significantly different in mean time to relief from headache. The Motrin group, however, has a different letter (B) under the “Bon Grouping,” which indicates that the Motrin group differs significantly from both the Aspirin and Tylenol groups. A brief comparison of their means shows that those who took Motrin had significantly quicker time to relief (15 min) than the Aspirin (44 min) or Tylenol (34 min) groups.
Conclusion The code given in this section can be used for all one-way ANOVAs, with slight modification of variable names, etc., to determine whether at least one group differs significantly from the others. The p-value from this test will tell you if at least one group is different.