8 Basic Statistics in R

R is at its core a statistical programming langauge. Much of the increase in popularity of R is a result of the need for statisticians, scientists, economists, and others to develop and implement advanced statistical techniques in a streamlined and straightforward manner. R provides just that, and since it is a full programming language, it offers great flexibility in implementing statistical procedures and fine-tuning them to meet the specific needs of different projects, something that is often hard to do using “point and click” statistical software packages. In this chapter we provide a brief overview of some basic statistical tools in R with a focus on linear modeling techniques commonly used in disciplines ranging from ecology to economics to engineering. We are not attempting to provide a complete overview of statistical modeling in R, or even linear modeling, but rather seek to provide an introduction to some basic statistical tools in R that should get you on your way to doing all of your statistical analyses in R. Here we also take a very applied approach and do not focus on the underlying theory of how R is implementing the different methods we review. Rather, we assume some basic familiarity with statistical analyeses and focus on how we can use R to implement basic statistical tools. We end the chapter by providing a list of some baic functions and R packages for further statistical analyeses.

8.1 Basics of Linear Models

Linear models can be considered the building block of statistics. Many advanced statistical tools are at their simplest forms extensions of linear models to account for additional complexities in data. For example, basic geostatistical models in spatial statitistics are simple extensions of linear models to account for non-independence across two-dimensional space. Generalized linear models are widely used extensions of the basic linear model to accommodate data that cannot reasonably be assumed to follow a normal distribution. Thus, a solid understanding of linear models and how to implement them in R is an essential building block to more complex statistical analyses.

8.2 One-Way Analysis of Variance (ANOVA)

8.3 Two-Way Analyis of Variance (ANOVA)

8.4 Simple Linear Regression

8.5 Multiple Linear Regression

8.6 Regresion Diagnostics and Model Selection

8.7 Basic Linear Mixed Model

8.8 Repeated Measures Design

8.9 Some Other Basic Statistical Tools