<p>Foreword ix</p> <p>Preface xi</p> <p>About the Companion Website xiii</p> <p><b>1 Hypotheses, Variables, Data 1</b></p> <p>1.1 Occam’s Razor 2</p> <p>1.2 Scientific Hypotheses 2</p> <p>1.3 The Choice of a Software 3</p> <p>1.3.1 First Steps in R 3</p> <p>1.4 Variables 5</p> <p>1.4.1 Variable Names and Values 5</p> <p>1.4.2 Types of Variables 10</p> <p>1.4.3 Predictor and Response Variables 11</p> <p>1.5 Data Processing and Data Formats 12</p> <p>1.5.1 The Long vs. the Wide Format 12</p> <p>1.5.2 Choice of Variable, Dataset, and File Names 12</p> <p>1.5.3 Adding, Removing, and Subsetting Variables and Data Frames 14</p> <p>1.5.4 Aggregating Data 17</p> <p>1.5.5 Working with Time and Strings 19</p> <p><b>2 Measuring Variation 23</b></p> <p>2.1 What Is Variation? 23</p> <p>2.2 Treatment vs. Control 23</p> <p>2.3 Systematic and Unsystematic Variation 24</p> <p>2.4 The Signal-to-Noise Ratio 25</p> <p>2.5 Measuring Variation Graphically 26</p> <p>2.6 Measuring Variation Using Metrics 27</p> <p>2.7 The Standard Error 29</p> <p>2.8 Population vs. Sample 31</p> <p><b>3 Distributions and Probabilities 35</b></p> <p>3.1 Probability Distributions 35</p> <p>3.2 Finding the Best Fitting Distribution for Sample Data 37</p> <p>3.2.1 Graphical Tools 37</p> <p>3.2.2 Goodness-of-Fit Tests 39</p> <p>3.3 Quantiles 42</p> <p>3.4 Probabilities 44</p> <p>3.4.1 Density Functions (dnorm, dbinom, .) 44</p> <p>3.4.2 Probability Distribution Functions (pnorm, pbinom, .) 46</p> <p>3.4.3 Quantile Functions (qnorm, qbinom, .) 48</p> <p>3.4.4 Random Sampling Functions (rnorm, rbinom, .) 49</p> <p>3.5 The Normal Distribution 50</p> <p>3.6 Central Limit Theorem 50</p> <p>3.7 Test Statistics 52</p> <p>3.7.1 Null and Alternative Hypotheses 53</p> <p>3.7.2 The Alpha Threshold and Significance Levels 54</p> <p>3.7.3 Type I and Type II Errors 54</p> <p>References 56</p> <p><b>4 Replication and Randomisation 57</b></p> <p>4.1 Replication 57</p> <p>4.2 Statistical Independence 60</p> <p>4.3 Randomisation 61</p> <p>4.4 Randomisation in R 64</p> <p>4.5 Spatial Replication and Randomisation in Observational Studies 65</p> <p><b>5 Two-Sample and One-Sample Tests 67</b></p> <p>5.1 The t-Statistic 67</p> <p>5.2 Two Sample Tests: Comparing Two Groups 67</p> <p>5.2.1 Student’s t-Test 67</p> <p>5.2.1.1 Testing for Normality 68</p> <p>5.2.1.2 What to Write in a Report or Paper and How to Visualise the Results of a t-Test 74</p> <p>5.2.1.3 Two-Tailed vs. One-Tailed t-Tests 75</p> <p>5.2.2 Rank-Based Two-Sample Tests 77</p> <p>5.3 One-Sample Tests 78</p> <p>5.4 Power Analyses and Sample Size Determination 79</p> <p><b>6 Communicating Quantitative Information Using Visuals 83</b></p> <p>6.1 The Fundamentals of Scientific Plotting 84</p> <p>6.2 Scatter Plots 85</p> <p>6.3 Line Plots 87</p> <p>6.4 Box Plots and Bar Plots 89</p> <p>6.5 Multipanel Plots and Plotting Regions 91</p> <p>6.6 Adding Text, Formulae, and Colour 92</p> <p>6.7 Interaction Plots 94</p> <p>6.8 Images, Colour Contour Plots, and 3D Plots 94</p> <p>6.8.1 Adding Images to Plots 94</p> <p>6.8.2 Colour Contour Plots 96</p> <p>References 101</p> <p><b>7 Working with Categorical Data 103</b></p> <p>7.1 Tabling and Visualising Categorical Data 103</p> <p>7.2 Contingency Tables 105</p> <p>7.3 The Chi-squared Test 106</p> <p>7.4 Decision Trees 108</p> <p>7.5 Optimising Decision Trees 111</p> <p>References 113</p> <p><b>8 Working with Continuous Data 115</b></p> <p>8.1 Covariance 115</p> <p>8.2 Correlation Coefficient 116</p> <p>8.3 Transformations 118</p> <p>8.4 Plotting Correlations 120</p> <p>8.5 Correlation Tests 122</p> <p>References 124</p> <p><b>9 Linear Regression 125</b></p> <p>9.1 Basics and Simple Linear Regression 125</p> <p>9.1.1 Making Sense of the summary Output for Regression Models Fitted with lm 128</p> <p>9.1.2 Model Diagnostics 131</p> <p>9.1.3 Model Predictions and Visualisation 135</p> <p>9.1.4 What to Write in a Report or Paper? 137</p> <p>9.1.4.1 Material and Methods 137</p> <p>9.1.4.2 Results 137</p> <p>9.1.5 Dealing with Variance Heterogeneity 137</p> <p>9.2 Multiple Linear Regression 140</p> <p>9.2.1 Multicollinearity in Multiple Regression Models 143</p> <p>9.2.2 Testing Interactions Among Predictors 147</p> <p>9.2.3 Model Selection and Comparison 148</p> <p>9.2.4 Variable Importance 151</p> <p>9.2.5 Visualising Multiple Linear Regression Results 151</p> <p>References 154</p> <p><b>10 One or More Categorical Predictors – Analysis of Variance 155</b></p> <p>10.1 Comparing Groups 155</p> <p>10.2 Comparing Groups Numerically 155</p> <p>10.3 One-way ANOVA Using R 161</p> <p>10.4 Checking for the Model Assumptions 162</p> <p>10.5 Post Hoc Comparisons 162</p> <p>10.6 Two-way ANOVA and Interactions 165</p> <p>10.7 What If the Model Assumptions Are Violated? 166</p> <p>Reference 168</p> <p><b>11 Analysis of Covariance (ANCOVA) 169</b></p> <p>11.1 Interpreting ANCOVA Results 171</p> <p>11.2 Post Hoc Test for ANCOVA 176</p> <p>References 177</p> <p><b>12 Some of What Lies Ahead 179</b></p> <p>12.1 Generalised Linear Models 179</p> <p>12.2 Nonlinear Regression 185</p> <p>12.2.1 Initial Parameter Estimates (Starting Values) 187</p> <p>12.2.2 Nonlinear Model Fitting and Visualisation 187</p> <p>12.3 Generalised Additive Models 189</p> <p>12.4 Modern Approaches to Dealing with Heteroscedasticity 191</p> <p>12.4.1 Variance Modelling Using Generalised Least-squares Estimation 193</p> <p>12.4.2 Robust, Heteroscedasticity-Consistent Covariance Matrix Estimation 195</p> <p>References 198</p> <p>Index 201</p>