Skip to content

Learning Statistics with R

The cover artwork

Since 2011 I (Dan) have been teaching an introductory statistics class for psychology students, using the R statistical package as the primary tool. Because I was a little unhappy with the textbooks available at the time, I started writing my own. The book is still a work in progress, but it has reached a "first draft" stage, at 542 pages. You can download the current version (0.3) from this page. I've also decided to "publish" this version with Lulu, a print-on-demand service, so that students can obtain hard copies at a much lower price than a traditional academic publisher would charge.

This page, like the book itself, is a work in progress. All of the content is here, but I haven't had time to make it look nice yet...

The Book

  • Download the whole book here
  • Purchase a hard copy here (Note that, by default, Lulu will probably assume that you're in the US, and quotes a price in US dollars. If you scroll to the bottom of the page you'll see an option called "International", and a link that will let you switch to the Australian store, and will give you a price in Australian dollars).

Front Matter

Part 1: Background

Part 2: An Introduction to R

  • Section break
  • Chapter 3: Getting started with R. Getting R and Rstudio. Typing commands at the console. Simple calculations. Using functions. Introduction to variables. Numeric, character and logical data. Storing multiple values asa vector.
  • Chapter 4: Additional R concepts. Installing and loading packages. The workspace. Navigating the file system. More complicated data structures: factors, data frames, lists and formulas. A brief discussion of generic functions.

Part 3: Working with Data

  • Section break
  • Chapter 5: Descriptive statistics. Mean, median and mode. Range, interquartile range and standard deviations. Skew and kurtosis. Standard scores. Correlations. Tools for computing these things in R. Brief comments missing data.
  • Chapter 6: Drawing graphs. Discussion of R graphics. Histograms. Stem and leaf plots. Boxplots. Scatterplots. Bar graphs.
  • Chapter 7: Pragmatic matters. Tabulating data. Transforming a variable. Subsetting vectors and data frames. Sorting, transposing and merging data. Reshaping a data frame. Basics of text processing. Reading unusual data files. Basics of variable coercion. Even more data structures. Other miscellaneous topics, including floating point arithmetic.
  • Chapter 8: Basic programming. Scripts. Loops. Conditionals. Writing functions. Implicit loops.

Part 4: Statistical Theory

  • Section break
  • Chapter 9: Introduction to probability. Probability versus statistics. Basics of probability theory. Common distributions: normal, binomial, t, chi-square, F. Bayesian versus frequentist probability.
  • Chapter 10: Estimating population parameters from a sample. Sampling from populations. Estimating population means and standard deviations. Sampling distributions. The central limit theorem. Confidence intervals.
  • Chapter 11: Hypothesis testing. Research hypotheses versus statistical hypotheses. Null versus alternative hypotheses. Type I and Type II errors. Sampling distributions for test statistics. Hypothesis testing as decision making. p-values. Reporting the results of a test. Effect size and power. Controversies and traps in hypothesis testing.

Part 5: Statistical Tools

  • Section break
  • Chapter 12: Categorical data analysis. Chi-square goodness of fit test. Chi-square test of independence. Yate's continuity correction. Effect size with Cramer's V. Assumptions of the tests. Other tests: Fisher exact test and McNemar's test.
  • Chapter 13: Comparing two means. One sample z-test. One sample t-test. Student's independent sample t-test. Welch's independent samples t-test. Paired sample t-test. Effect size with Cohen's d. Checking the normality assumption. Wilcoxon tests for non-normal data.
  • Chapter 14: Comparing several means (one-way ANOVA). Introduction to one-way ANOVA. Doing it in R. Effect size with eta-squared. Simple corrections for multiple comparisons (post hoc tests). Assumptions of one-way ANOVA. Checking homogeneity of variance using Levene tests. Avoiding the homogeneity of variance assumption. Checking and avoiding the normality assumption. Relationship between ANOVA and t-tests.
  • Chapter 15: Linear regression. Introduction to regression. Estimation by least squares. Multiple regression models. Measuring the fit of a regression model. Hypothesis tests for regression models. Standardised regression coefficient. Assumptions of regression models. Basic regression diagnostics. Model selection methods for regression.
  • Chapter 16: Factorial ANOVA. Factorial ANOVA without interactions. Factorial ANOVA with interactions. Effect sizes, estimated marginal means, confidence intervals for effects. Assumption checking. F-tests as model selection. Interpreting ANOVA as a linear model. Specifying contrasts. Post hoc testing via Tukey's HSD. Factorial ANOVA with unbalanced data (Type I, III and III sums of squares)

Wrap Up

The Data Sets

The R Package

The book is associated with the lsr package available on CRAN. I'll post the source code here in the near future

School of Psychology,
North Terrace Campus,
University of Adelaide
SA 5005 AUSTRALIA
Contact

T: +61 8 8303 5265
Email