11 September, 2022

Course

Topics

Day Topic
1 Intro to Version control (git), reproducible research (rmarkdown) and data wrangling
2 Data visualisation and Frequentist (generalized) linear models (GLM)
3 GLM continued + dealing with heterogeneity and autocorrelation
4 Day 3 continued + Frequentist mixed effects models
5 Frequentist generalized linear mixed effects models (GLMM)
6 More GLMM + Frequentist generalized additive models (GAM + GAMM)
7 GAMM + regression trees
8 Bayesian linear models
9 Bayesian generalized linear/generalized mixed effects
10 Multivariate analyses

Prep

  • Show-us-your-Rs
  • R editors
    • Rstudio
  • Version control / Collaboration
    • git/github
  • Scripts and reproducible research
    • knitr
    • lintr/styler
    • Rmarkdown / R notebook / quarto

R

R studio

R studio

Keybindings: Cntl-Alt-K

Packages

  • extend functionality
  • installing
install.packages("tidyverse")
  • loading
library("dplyr")
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Packages

  • extend functionality
  • installing
  • loading
library("tidyverse")
## ── Attaching packages ──────────────────────────────────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.8     ✔ stringr 1.4.1
## ✔ tidyr   1.2.0     ✔ forcats 0.5.2
## ✔ readr   2.1.2     
## ── Conflicts ─────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()

Packages

  • namespaces
stats::filter()
dplyr::filter()
  • polymorphism
mean
## function (x, ...) 
## UseMethod("mean")
## <bytecode: 0x5629982dead8>
## <environment: namespace:base>
base:::mean.default
## function (x, trim = 0, na.rm = FALSE, ...) 
## {
##     if (!is.numeric(x) && !is.complex(x) && !is.logical(x)) {
##         warning("argument is not numeric or logical: returning NA")
##         return(NA_real_)
##     }
##     if (isTRUE(na.rm)) 
##         x <- x[!is.na(x)]
##     if (!is.numeric(trim) || length(trim) != 1L) 
##         stop("'trim' must be numeric of length one")
##     n <- length(x)
##     if (trim > 0 && n) {
##         if (is.complex(x)) 
##             stop("trimmed means are not defined for complex data")
##         if (anyNA(x)) 
##             return(NA_real_)
##         if (trim >= 0.5) 
##             return(stats::median(x, na.rm = FALSE))
##         lo <- floor(n * trim) + 1
##         hi <- n + 1 - lo
##         x <- sort.int(x, partial = unique(c(lo, hi)))[lo:hi]
##     }
##     .Internal(mean(x))
## }
## <bytecode: 0x56299b582c78>
## <environment: namespace:base>

Reproducible research

Cheat sheets (ref cards)