R workshop

Introduction to R and GLM/GAMs workshop

by Aaron Greenville and Mathew Crowther

This two-day workshop is designed to remove the mystery behind R, passing on tips for best practice techniques that we have picked up on our journey with R and lastly, to get you started with GLM/M and GAM/Ms. There are many ways to use R and here we wish to show you our workflow, which seems to work for us.

Please bring your own laptop or share one with a friend. This workshop is designed to be very hands-on. If you do not have access to a laptop, then please let us know and we will see if we can organise something for you.

Assumed knowledge is basic statistics.

Before the workshop you will need:

Download and install:

  1. R
  2. RStudio for desktop
  3. Git
  4. Exercises

Optional: GLM and GAMs Workshop slides, Model Selection and PseudoR² slides.

Acknowledgements: This workshop draws on material from Software Carpentry (If you see one of their course advertised, then do it!) and Zuur A.F. (2009). Mixed effects models and extensions in ecology with R. Springer, New York ; London.

Outline [pdf]

Basics

  1. Exercise 1: Set up R, Rstudio, github – installing packages, loading packages, a trick for uni proxy settings.
  2. Data structures – vectors, lists, matrix, data frame, factors and sub-setting (using $ to call columns, how to use dataframes, vectors, selecting rows, columns or cells)
  3. Getting data into R and setting working directory.
  4. basic data checks – head(), using RStudio, plots ()
  5. Using and misusing attach()
  6. Using help

Version control

  1. Why do it?
  2. Exercise 2: RStudio and Github.

Writing functions

  1. Exercise 3: introduction

Organising a project

  1. Best practice for organising a project.
  2. Exercise 4

GLM and GLMM

  1. Basics of a linear model
  2. What is a GLM and GLMM
  3. Exercise 5: Frog road kill (poisson, quasi-poisson and neg bin)
  4. Exercise 6: GLMM with temporal confounding – Hawaii bird abundance
  5. Exercise 7: binomial GLM rats

GAM and GAMM

  1. What is a GAM and GAMM
  2. Exercise 8: GAM- Roadkill
  3. Exercise 9: GAMM with spatial confounding – Roadkill

Model selection

  1. Introduction to Information Theory
  2. Exercise 10: GLM Model selection and model averaging – Roadkill

Pseudo R2

  1. How do you know your top model/s are any good?
  2. Exercise 11: GLM Pseudo R2

Steps in choosing the appropriate analysis

More resources

  1. Recommended books: anything from the UseR series, any books by Zuur et al.
  2. Search engines: Google and rseek.org
  3. Software Carpentry
  4. Quick intro to R
  5. Organizing your project
  6. R-bloggers interpreting residual plots
  7. UCLA data analysis examples
  8. Git hub demo website