1 / 14

Two-Way ANOVA in SAS

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

valtina
Download Presentation

Two-Way ANOVA in SAS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Two-Way ANOVA in SAS Multiple regression with two or more categorical variables as predictors

  2. 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:

  3. 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;

  4. 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?

  5. 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.

  6. Run the Program—Check Your Log If your Log is free of error messages, look at your output.

  7. 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.

  8. ANOVA Table in SAS Output

  9. 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.

  10. 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.

  11. 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:

  12. Plot of mean relief scores and factors

  13. 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).

  14. 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..

More Related