| Behavioral Research Data Analysis with R | 3 |
|---|
| Preface | 5 |
| Contents | 9 |
| Chapter 1 Introduction | 13 |
| 1.1 An Example R Session | 13 |
| 1.2 A Few Useful Concepts and Commands | 15 |
| 1.2.1 Concepts | 15 |
| 1.2.2 Commands | 16 |
| 1.2.2.1 Working Directory | 16 |
| 1.2.2.2 Getting Help | 17 |
| 1.2.2.3 Installing Packages | 18 |
| 1.2.2.4 Assignment, Logic, and Arithmetic | 18 |
| 1.2.2.5 Loading and Saving | 20 |
| 1.2.2.6 Dealing with Objects | 21 |
| 1.3 Data Objects and Data Types | 21 |
| 1.3.1 Vectors of Character Strings | 22 |
| 1.3.2 Matrices, Lists, and Data Frames | 24 |
| 1.3.2.1 Summaries and Calculations by Row, Column, or Group | 26 |
| 1.4 Functions and Debugging | 27 |
| Chapter 2 Reading and Transforming Data Format | 30 |
| 2.1 Reading and Transforming Data | 30 |
| 2.1.1 Data Layout | 30 |
| 2.1.2 A Simple Questionnaire Example | 30 |
| 2.1.2.1 Extracting Subsets of Data | 31 |
| 2.1.2.2 Finding Means (or Other Things) of Sets of Variables | 32 |
| 2.1.2.3 One Row Per Observation | 32 |
| 2.1.3 Other Ways to Read in Data | 36 |
| 2.1.4 Other Ways to Transform Variables | 37 |
| 2.1.4.1 Contrasts | 37 |
| 2.1.4.2 Averaging Items in a Within-Subject Design | 38 |
| 2.1.4.3 Selecting Cases or Variables | 39 |
| 2.1.4.4 Recoding and Replacing Data | 39 |
| 2.1.4.5 Replacing Characters with Numbers | 41 |
| 2.1.5 Using R to Compute Course Grades | 41 |
| 2.2 Reshape and Merge Data Frames | 42 |
| 2.3 Data Management with a SQL Database | 44 |
| 2.4 SQL Database Considerations | 46 |
| Chapter 3 Statistics for Comparing Means and Proportions | 49 |
| 3.1 Comparing Means of Continuous Variables | 49 |
| 3.2 More on Manual Checking of Data | 52 |
| 3.3 Comparing Sample Proportions | 53 |
| 3.4 Moderating Effect in loglin() | 55 |
| 3.5 Assessing Change of Correlated Proportions | 59 |
| 3.5.1 McNemar Test Across Two Samples | 60 |
| Chapter 4 R Graphics and Trellis Plots | 65 |
| 4.1 Default Behavior of Basic Commands | 65 |
| 4.2 Other Graphics | 66 |
| 4.3 Saving Graphics | 66 |
| 4.4 Multiple Figures on One Screen | 67 |
| 4.5 Other Graphics Tricks | 67 |
| 4.6 Examples of Simple Graphs in Publications | 68 |
| 4.6.1 http://journal.sjdm.org/8827/jdm8827.pdf | 70 |
| 4.6.2 http://journal.sjdm.org/8814/jdm8814.pdf | 73 |
| 4.6.3 http://journal.sjdm.org/8801/jdm8801.pdf | 74 |
| 4.6.4 http://journal.sjdm.org/8319/jdm8319.pdf | 75 |
| 4.6.5 http://journal.sjdm.org/8221/jdm8221.pdf | 76 |
| 4.6.6 http://journal.sjdm.org/8210/jdm8210.pdf | 78 |
| 4.7 Shaded Areas Under a Curve | 79 |
| 4.7.1 Vectors in polygon() | 81 |
| 4.8 Lattice Graphics | 82 |
| 4.8.0.1 Mathematics Achievement and Socioeconomic Status | 82 |
| Chapter 5 Analysis of Variance: Repeated-Measures | 88 |
| 5.1 Example 1: Two Within-Subject Factors | 88 |
| 5.1.1 Unbalanced Designs | 92 |
| 5.2 Example 2: Maxwell and Delaney | 94 |
| 5.3 Example 3: More Than Two Within-Subject Factors | 97 |
| 5.4 Example 4: A Simpler Design with Only One Within-Subject Variable | 98 |
| 5.5 Example 5: One Between, Two Within | 98 |
| 5.6 Other Useful Functions for ANOVA | 100 |
| 5.7 Graphics with Error Bars | 102 |
| 5.8 Another Way to do Error Bars Using plotCI() | 104 |
| 5.8.1 Use Error() for Repeated-Measure ANOVA | 105 |
| 5.8.1.1 Basic ANOVA Table with aov() | 106 |
| 5.8.1.2 Using Error() Within aov() | 107 |
| 5.8.1.3 The Appropriate Error Terms | 107 |
| 5.8.1.4 Sources of the Appropriate Error Terms | 108 |
| 5.8.1.5 Verify the Calculations Manually | 110 |
| 5.8.2 Sphericity | 111 |
| 5.8.2.1 Why Is Sphericity Important? | 111 |
| 5.9 How to Estimate the Greenhouse–Geisser Epsilon? | 112 |
| 5.9.1 Huynh–Feldt Correction | 1 |
| Chapter 6 Linear and Logistic Regression | 117 |
| 6.1 Linear Regression | 117 |
| 6.2 An Application of Linear Regression on Diamond Pricing | 118 |
| 6.2.1 Plotting Data Before Model Fitting | 119 |
| 6.2.2 Checking Model Distributional Assumptions | 122 |
| 6.2.3 Assessing Model Fit | 123 |
| 6.3 Logistic Regression | 126 |
| 6.4 Log–Linear Models | 127 |
| 6.5 Regression in Vector–Matrix Notation | 128 |
| 6.6 Caution on Model Overfit and Classification Errors | 130 |
| Chapter 7 Statistical Power and Sample Size Considerations | 136 |
| 7.1 A Simple Example | 136 |
| 7.2 Basic Concepts on Statistical Power Estimation | 137 |
| 7.3 t-Test with Unequal Sample Sizes | 138 |
| 7.4 Binomial Proportions | 139 |
| 7.5 Power to Declare a Study Feasible | 140 |
| 7.6 Repeated-Measures ANOVA | 140 |
| 7.7 Cluster-Randomized Study Design | 142 |
| Chapter 8 Item Response Theory | 145 |
| 8.1 Overview | 145 |
| 8.2 Rasch Model for Dichotomous Item Responses | 145 |
|