Lab 7 Objectives:In this lab we will use S-Plus for comparing means among populations categorized according to the levels of some factor (grouping variable). To do this, we will use a method called Analysis of Variance (ANOVA or AOV) and will use Exercise 11, Chapter 12 to illustrate the method in S-Plus. We'll perform another ANOVA on Excercise 10 data.Analysis of Variance is a way to test whether the means of two or more populations are equal. In the case of two populations, the procedure results in the same conclusion as the (two-sided) two-sample t-test, even though the test-statistics used are different (an F instead of a t). We've just begun to cover the F-test in lecture and will cover more details. Also, we will cover the 2 sample t-test soon. Below, take a note of the p-values that you get from the outputs of the F-test and the t-test; they should be identical, and if you square your t-statistic you should get the same value as the F-statistic. For more than two groups, the results from an F-test in the ANOVA are not the same as doing several two-sample t-tests. Because the chances of a type I error increase if we do lots of two-way comparisions, the F-test is a better approach for controlling the Type I error rate to test if the groups all have the same mean. In class, we'll talk about one method for controlling the error rate when performing multiple comparisons among means; it's called the Bonferroni correction for multiple comparisons. Read in the data lowbwt (you may already have this data.frame in your workspace). By default, S-plus will read in the data as double precision; in this case we want to treat sex as a factor (categorical grouping variable). Go to the Data menu, and select Change Data Type. Select the column for sex, and then under the New Type field select Factor. Click on OK. Part (a) Carry out a two-sample t-test using sex as a grouping variable and sbp as Variable 1. To do this, go to the Statistics menu and select Compare Samples and then choose Two Samples, and then t Test... Select sbp as Variable 1, and sex as Variable 2. Since sex is a factor, it indicates which group the subject is in, and we need to specify it as a grouping variable. Click the box to indicate that Variable 2 is a Grouping Variable. Specify appropriate entries for the null hypothesis and the alternative. Note: with a grouping variable, the first group has the lowest value of the grouping variable (sex=0). Should you use the "Assume Equal Variances" option? Click OK - the results will be in the Report Window. Part (b) Go to the Statistics menu and select ANOVA, then Fixed Effects. In the popup dialog, we will need to specify a "formula" for the relationship between the outcome or dependent variable "sbp" and the group variable "sex". Select "sbp" for the Dependent variable in the pull down menu. You should see in the formula window "sbp ~ .". Now we need to specify the variables that effect spb based on our alternative hypothesis. In this problem, only sex is under consideration as leading to possible different means for sbp, so select sex as an independent variable. The formula window should look like sbp ~ sex which means that for each level of sex, we will estimate a different mean for sbp. If the variance between the means is large relative to the variance within groups, then we will reject the hypothesis that the means are equal. While you do not need to do any multiple comparison tests for this problem, many of the popular methods (including pairwise comparison of means using the Bonferroni correction) are available under the Compare tab. Click on OK. The results will be in the Report Window.
Repeat part (b) for exercise 10 (dataset cad) You may want to print your results to bring to class if you have questions.
|