R — the statistical and graphical environment is rapidly emerging as an important set of teaching and research tools for biologists. This book draws upon the popularity and free availability of R to couple the theory and practice of biostatistics into a single treatment, so as to provide a textbook for biologists learning statistics, R, or both. An abridged description of biostatistical principles and analysis sequence keys are combined together with worked examples of the practical use of R into a complete practical guide to designing and analyzing real biological research. Topics covered include: • simple hypothesis testing, graphing • exploratory data analysis and graphical summaries • regression (linear, multi and non-linear) • simple and complex ANOVA and ANCOVA designs (including nested, factorial, blocking, spit-plot and repeated measures) • frequency analysis and generalized linear models. Linear mixed effects modeling is also incorporated extensively throughout as an alternative to traditional modeling techniques. The book is accompanied by a companion website www.wiley.com/go/logan/r with an extensive set of resources comprising all R scripts and data sets used in the book, additional worked examples, the biology package, and other instructional materials and links. Biostatistical Design and Analysis Using R......Page 4 Contents......Page 8 Preface......Page 18 R quick reference card......Page 22 General key to statistical methods......Page 30 1.1 Why R?......Page 32 1.2.2 Unix/Linux......Page 33 1.3 The R environment......Page 34 1.4 Object names......Page 35 1.5 Expressions, Assignment and Arithmetic......Page 36 1.6.1 Cleaning up......Page 37 1.6.3 Current working directory......Page 38 1.7 Getting help......Page 39 1.8 Functions......Page 40 1.9 Precedence......Page 41 1.10 Vectors - variables......Page 42 1.10.1 Regular or patterned sequences......Page 43 1.10.2 Character vectors......Page 44 1.10.3 Factors......Page 46 1.11.1 Matrices......Page 47 1.11.2 Lists......Page 48 1.12.1 Object information......Page 49 1.13 Indexing vectors, matrices and lists......Page 51 1.13.1 Vector indexing......Page 52 1.13.2 Matrix indexing......Page 53 1.13.3 List indexing......Page 54 1.14.1 grep - pattern searching......Page 55 1.14.2 regexpr - position and length of match......Page 56 1.15.1 Sorting......Page 57 1.15.2 Formatting data......Page 58 1.16 Functions that perform other functions repeatedly......Page 59 1.16.1 Along matrix margins......Page 60 1.17 Programming in R......Page 61 1.17.2 Conditional execution – if and ifelse......Page 62 1.17.3 Repeated execution – looping......Page 63 1.17.4 Writing functions......Page 65 1.18 An introduction to the R graphical environment......Page 66 1.18.1 The plot() function......Page 67 1.18.2 Graphical devices......Page 70 1.18.3 Multiple graphics devices......Page 71 1.19.1 Manual package management......Page 73 1.20 Working with scripts......Page 76 1.21 Citing R in publications......Page 77 1.22 Further reading......Page 78 2.1 Constructing data frames......Page 79 2.2 Reviewing a data frame - fix()......Page 80 2.3.1 Import from text file......Page 81 2.3.3 Import from other software......Page 82 2.4 Exporting (writing) data......Page 83 2.5 Saving and loading of R objects......Page 84 2.6.1 Factor levels......Page 85 2.7.1 Subsets of data frames – data frame indexing......Page 87 2.7.2 The %in% matching operator......Page 88 2.7.4 Sorting datasets......Page 89 2.7.6 Reshaping dataframes......Page 90 2.8 Dummy data sets - generating random data......Page 93 3 Introductory statistical principles......Page 96 3.1 Distributions......Page 97 3.1.1 The normal distribution......Page 98 3.2 Scale transformations......Page 99 3.3 Measures of location......Page 100 3.4 Measures of dispersion and variability......Page 101 3.5 Measures of the precision of estimates - standard errors and confidence intervals......Page 102 3.7.1 Least squares (LS)......Page 104 3.7.2 Maximum likelihood (ML)......Page 105 3.9 Further reading......Page 106 4.1 Random sampling......Page 107 4.2.1 Fully randomized treatment allocation......Page 114 4.2.2 Randomized complete block treatment allocation......Page 115 5 Graphical data presentation......Page 116 5.1.1 The type parameter......Page 117 5.1.2 The xlim and ylim parameters......Page 118 5.1.5 The log parameter......Page 119 5.2 Graphical Parameters......Page 120 5.2.1 Plot dimensional and layout parameters......Page 121 5.2.2 Axis characteristics......Page 123 5.2.5 Plotting character parameter - pch......Page 124 5.2.6 Fonts......Page 127 5.2.8 Colors......Page 129 5.3.1 Adding points - points()......Page 130 5.3.2 Adding text within a plot - text()......Page 131 5.3.3 Adding text to plot margins - mtext()......Page 132 5.3.4 Adding a legend - legend()......Page 133 5.3.5 More advanced text formatting......Page 135 5.3.6 Adding axes - axis()......Page 138 5.3.7 Adding lines and shapes within a plot......Page 139 5.4.1 Identifying points - identify()......Page 144 5.5.1 Postscript - poscript() and pdf()......Page 145 5.6 Working with multiple graphical devices......Page 146 5.7.1 Histogram......Page 147 5.7.2 Density functions......Page 148 5.7.3 Q-Q plots......Page 149 5.7.4 Boxplots......Page 150 5.8.1 Scatterplots......Page 151 5.9.2 Boxplots for grouped means......Page 156 5.9.3 Interaction plots - means plots......Page 157 5.9.4 Bargraphs......Page 158 5.10.1 Mosaic plots......Page 159 5.11 Trellis graphics......Page 160 5.11.1 scales() parameters......Page 163 5.12 Further reading......Page 164 6.1 Hypothesis testing......Page 165 6.3 t-tests......Page 167 6.5 Statistical decision and power......Page 168 6.7 Further reading......Page 170 6.8 Key for simple hypothesis testing......Page 171 6.9 Worked examples of real biological data sets......Page 173 7 Introduction to Linear models......Page 182 7.1 Linear models......Page 183 7.2 Linear models in R......Page 185 7.3.1 Linear models with factorial variables......Page 187 7.3.2 Linear model hypothesis testing......Page 193 7.4 Comments about the importance of understanding the structure and parameterization of linear models......Page 195 8 Correlation and simple linear regression......Page 198 8.1 Correlation......Page 199 8.1.4 Robust correlation......Page 200 8.2 Simple linear regression......Page 201 8.2.2 Null hypotheses......Page 202 8.2.3 Assumptions......Page 203 8.2.5 Model I and II regression......Page 204 8.2.7 Robust regression......Page 207 8.2.8 Power and sample size determination......Page 208 8.4 Correlation and regression in R......Page 209 8.5 Further reading......Page 210 8.6 Key for correlation and regression......Page 211 8.7 Worked examples of real biological data sets......Page 215 9.1 Multiple linear regression......Page 239 9.3 Null hypotheses......Page 240 9.4 Assumptions......Page 241 9.5.1 Polynomial regression......Page 242 9.7 Model selection......Page 245 9.7.1 Model averaging......Page 246 9.8 Regression trees......Page 249 9.10 Key and analysis sequence for multiple and complex regression......Page 250 9.11 Worked examples of real biological data sets......Page 255 10.0.1 Fixed versus random factors......Page 285 10.2 Linear model......Page 286 10.3 Analysis of variance......Page 287 10.4 Assumptions......Page 289 10.6 Tests of trends and means comparisons......Page 290 10.8 ANOVA in R......Page 292 10.10 Key for single factor classification (ANOVA)......Page 293 10.11 Worked examples of real biological data sets......Page 296 11 Nested ANOVA......Page 314 11.1 Linear models......Page 315 11.2.2 Factor B - the nested factor......Page 316 11.4 Variance components......Page 317 11.6 Pooling denominator terms......Page 320 11.8 Linear mixed effects models......Page 321 11.10 Power and optimisation of resource allocation......Page 323 11.11.1 Error strata (aov)......Page 324 11.13 Key for nested ANOVA......Page 325 11.14 Worked examples of real biological data sets......Page 329 12 Factorial ANOVA......Page 344 12.2 Null hypotheses......Page 345 12.2.1 Model 1 - fixed effects......Page 346 12.2.2 Model 2 - random effects......Page 347 12.3 Analysis of variance......Page 348 12.3.1 Quasi F-ratios......Page 351 12.5 Planned and unplanned comparisons......Page 352 12.6.1 Missing observations......Page 353 12.6.2 Missing combinations - missing cells......Page 355 12.7 Robust factorial ANOVA......Page 356 12.10 Further reading......Page 358 12.11 Key for factorial ANOVA......Page 359 12.12 Worked examples of real biological data sets......Page 365 13 Unreplicated factorial designs – randomized block and simple repeated measures......Page 391 13.2 Null hypotheses......Page 394 13.3 Analysis of variance......Page 395 13.4 Assumptions......Page 396 13.4.1 Sphericity......Page 397 13.4.2 Block by treatment interactions......Page 399 13.6 Unbalanced un-replicated factorial designs......Page 401 13.10 Further reading......Page 402 13.11 Key for randomized block and simple repeated measures ANOVA......Page 403 13.12 Worked examples of real biological data sets......Page 407 14 Partly nested designs: split plot and complex repeated measures......Page 430 14.1.1 Factor A - the main between block treatment effect......Page 431 14.1.3 Factor C - the main within block treatment effect......Page 432 14.2.2 Two between (α, γ), one within (δ) block effect......Page 433 14.4 Assumptions......Page 434 14.6 Further reading......Page 439 14.7 Key for partly nested ANOVA......Page 440 14.8 Worked examples of real biological data sets......Page 444 15 Analysis of covariance (ANCOVA)......Page 479 15.2 Linear models......Page 481 15.3 Analysis of variance......Page 482 15.4 Assumptions......Page 483 15.4.1 Homogeneity of slopes......Page 484 15.4.2 Similar covariate ranges......Page 485 15.8 Key for ANCOVA......Page 486 15.9 Worked examples of real biological data sets......Page 488 16 Simple Frequency Analysis......Page 497 16.1 The chi-square statistic......Page 498 16.3 Contingency tables......Page 500 16.3.1 Odds ratios......Page 501 16.4 G-tests......Page 503 16.5 Small sample sizes......Page 504 16.7 Power analysis......Page 505 16.10 Key for Analysing frequencies......Page 506 16.11 Worked examples of real biological data sets......Page 508 17 Generalized linear models (GLM)......Page 514 17.2.1 Logistic model......Page 516 17.2.2 Null hypotheses......Page 518 17.2.4 Multiple logistic regression......Page 519 17.3.2 Log-linear Modelling......Page 520 17.4 Assumptions......Page 523 17.5 Generalized additive models (GAM’s) - non-parametric GLM......Page 524 17.6 GLM and R......Page 525 17.8 Key for GLM......Page 526 17.9 Worked examples of real biological data sets......Page 529 Bibliography......Page 562 R index......Page 566 Statistics index......Page 572 Introduction To R -- Data Sets -- Introductory Statistical Principles -- Sampling And Experimental Design With R -- Graphical Data Presentation -- Simple Hypothesis Testing, One And Two Population Tests -- Introduction To Linear Models -- Correlation And Simple Linear Regression -- Multiple And Curvilinear Regression -- Single Factor Classification (anova) -- Nested Anova -- Factorial Anova -- Unreplicated Factorial Designs, Randomized -- Block And Simple Repeated Measures -- Partly Nested Designs : Split Plot And Complex -- Repeated Measures -- Partly Nested Designs : Split Plot And Complex -- Repeated Measures -- Simple Frequency Analysis -- Generalized Linear Models (glm). Murray Logan. Includes Bibliographical References And Indexes. R is the statistical and graphical environment is rapidly emerging as an important set of teaching and research tools for biologists. This book draws upon the popularity and free availability of R to couple the theory and practice of biostatistics into a single treatment, so as to provide a textbook for biologists learning statistics, R, or both. An abridged description of biostatistical principles and analysis sequence keys are combined together with worked examples of the practical use of R into a complete practical guide to designing and analyzing real biological research First book specifically aimed at biologists/ecologists that explains how the new freeware statistical package "R" can be applied to their problems. This software package is becoming increasingly popular as it is powerful and free.