This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Notes on data analysis with R and ANOVA Adam J. Rothman March 23, 2011 Contents 1 Data analysis with R 1 1.1 Loading datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Exploratory data analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 An inference example with the two independent samples ttest 6 2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2 Two independent samples ttests . . . . . . . . . . . . . . . . . . . . . . . . 8 2.2.1 Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.2.2 Two sided alternative . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.2.3 Left sided alternative . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.2.4 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3 Oneway ANOVA 11 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.2 The oneway ANOVA Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.3 Hypothesis testing for ANOVA . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.3.2 Assumptions, Formula, and Interpretation . . . . . . . . . . . . . . . 14 3.3.3 Data example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.3.4 Simultaneous pairwise comparisons . . . . . . . . . . . . . . . . . . . 17 3.4 Chicken example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1 Data analysis with R Datasets usually consist of several characteristics measured for n subjects/units. These characteristics may be numerical or categorical. Definition: numerical characteristic a characteristic that takes on numerical values for which arithmetic operations make sense. (e.g. height, number of children, etc.) 1 Definition: categorical characteristic a characteristic that takes on one of a set of levels/categories. (e.g. the characteristic political party affiliation with levels { democrat, republican, other } . A categorical characteristic is sometimes called a factor. Sometimes the levels of categorical characteristics are coded with numbers. For example, some datasets may code gender with 1 for male and 2 for female. 1.1 Loading datasets If a dataset is available in a text file, it can be loaded with the read.table() command. This command has several arguments, some of which may need to be set to account for how the data is arranged in the text file. To see a description of these arguments, type help(read.table) . The text file we wish to load must be in R s working directory. To change this directory in Windows/Macintosh, use the menu FILE > Change DIR. One could also use getwd() and setwd() to get and set the working directory for R ....
View Full
Document
 Spring '08
 Staff

Click to edit the document details