200 likes | 1.17k Views
Two-Way ANOVA in SAS. Multiple regression with two or more categorical variables as predictors. Introduction. Two-way ANOVA is Analysis of Variance when you have two variables to test the equality of mean values. Significance Tests in Two-Way ANOVA
E N D
Two-Way ANOVA in SAS Multiple regression with two or more categorical variables as predictors
Introduction • Two-way ANOVA is Analysis of Variance when you have two variables to test the equality of mean values. • Significance Tests in Two-Way ANOVA Ho: Effect=0 vs. Ha: Effect not Zero • There are three hypothesis tests for a TWO-Way ANOVA. • To Test of Main Effect of A: • To Test of Main Effect of B: • To Test the Interaction of A and B:
Two-Way ANOVA in SAS Open SAS and use the infile statement to input the data set dental.txt (this data set can be found in SAS tutorials-Lesson 1). If you don’t remember how to do this, here is some code that may help: data dental; infile 'C:\Documents and Settings\My Documents\dental.txt'; input relief A B; procprint data = dental; run;
This data set is about the effects of acupuncture and codeine on postoperative pain in male dental patients. The factorial of two treatments are considered: codeine or placebo (factor A) and acupuncture at active sites or at inactive sites (factor B). Pain relief scores were recorded two hours after treatment (higher values mean more pain relief). A = 1 is placebo pill A = 2 is codeine B = 1 is placebo (inactive) acupuncture B = 2 is active acupuncture The question of interest is: Are the main effects and interaction significant for factor A and B?
SAS Code for ANOVA To test our hypotheses, we use the following code in SAS: • “class” tells SAS the two classification variables, which are generally going to be the effects that you are studying. In this case, the effects are “A” and “B.” • “model” tells SAS the dependent variable. The general format is “model Y = X1 X2 X1*X2” where Y is the dependent variable, X1 and X2 are independent variables. X1*X2 means the interaction of X1 and X2. • 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.
Run the Program—Check Your Log If your Log is free of error messages, look at your output.
The first page of your output says that there are two values under both of the variables “A” and “B”: 1 or 2. It also tells you that there are 32 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 • For the main effect of factor A, the F*= 10.96. The p-value of this F* is found under “Pr>F” and p =0.0026. • For the main effect of factor B, the F*= 16.03. The p-value of this F* is p =0.0004. • For the A*B interaction, the F*= 0.21. The p-value of this F* is p =0.6476.
Conclusions from Two-way ANOVA • For factor A and B: Because the p-values for the test statistic (F*) are less than alpha (0.05), we reject the null hypotheses and conclude that the main effects of both factor A and B are significant. • For the A*B: The p-value for F* is greater than 0.05. Hence we accept the null hypothesis and conclude that the interaction of A and B is not significant.
Draw a plot of factors and relief We can draw a plot of means of factors (A and B) and the pain relief scores. Here is some SAS code that may help:
Conclusion • Main effect of factor A (placebo or codeine): Codeine makes higher pain relief score than placebo. • Main effect of factor B (inactive acupuncture or active acupuncture): Active acupuncture makes higher pain relief score than inactive site (placebo). • The treatment of factor A (both codeine and placebo) makes more pain relief than the treatment of factor B (active and inactive site of acupuncture).
Conclusion (cont.) • For the interaction of factor A and B: Notice that the two lines are approximately parallel. This is why the interaction of Codeine and active acupuncture is not significant. • The code given in this section can be used for all two-way ANOVAs, with slight modification of variable names, etc..