-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathframework.Rmd
194 lines (111 loc) · 3.78 KB
/
framework.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
---
title: 'GLM as a unified framework for data analysis'
author: 'Francisco Rodríguez-Sánchez'
institute: 'https://frodriguezsanchez.net'
aspectratio: 43 # use 169 for wide format
fontsize: 12pt
output:
binb::metropolis:
keep_tex: no
incremental: yes
fig_caption: no
pandoc_args: ['--lua-filter=hideslide.lua']
urlcolor: blue
linkcolor: blue
header-includes:
- \definecolor{shadecolor}{RGB}{230,230,230}
- \setbeamercolor{frametitle}{bg=gray}
---
```{r knitr_setup, include=FALSE, cache=FALSE}
library('knitr')
### Chunk options ###
## Text results
opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE, size = 'tiny')
## Code decoration
opts_chunk$set(tidy = FALSE, comment = NA, highlight = TRUE, prompt = FALSE, crop = TRUE)
# ## Cache
# opts_chunk$set(cache = TRUE, cache.path = 'knitr_output/cache/')
# ## Plots
# opts_chunk$set(fig.path = 'knitr_output/figures/')
opts_chunk$set(fig.align = 'center', out.width = '90%')
### Hooks ###
## Crop plot margins
knit_hooks$set(crop = hook_pdfcrop)
## Reduce font size
## use tinycode = TRUE as chunk option to reduce code font size
# see http://stackoverflow.com/a/39961605
knit_hooks$set(tinycode = function(before, options, envir) {
if (before) return(paste0('\n \\', options$size, '\n\n'))
else return('\n\n \\normalsize \n')
})
```
## How I was taught statistics
```{r out.width='100%'}
include_graphics('images/tests_diagram.png')
```
## So many questions
- **Why** should we really use analysis Y over Z?
- What if my data are **not Normal**?
- What if they are **not independent**?
- Why am I getting **different p-values** with different tests?
- What even is a **p-value**?
- How can I take **different factors** into account?
- Can I make **predictions**?
## A unified framework
```{r out.width='100%'}
include_graphics('images/flowchart.png')
```
---
## Linear regression
\Large $$y = a + bx$$
```{r out.width='60%'}
include_graphics('images/framework_xquant.png')
```
## Is predictor X qualitative?
\Large $$y = a + bx_2$$
```{r out.width='30%'}
include_graphics('images/framework_xqual.png')
```
## More than 2 groups?
\Large $$y = a + bx_2 + cx_3$$
```{r out.width='30%'}
include_graphics('images/framework_xqual2.png')
```
## My data (residuals) are not Normal
\Large $$y = f(a + bx)$$
```{r out.width='30%'}
include_graphics('images/framework_logit.png')
```
## My data are structured (space, time, phylogeny)
\Large $$y = f(a + bx + \eta)$$
## Relationships are not linear
\Large $$y = a + f(x)$$
```{r out.width='30%'}
include_graphics('images/framework_gam.png')
```
---
\Large
t-tests
ANOVA
regression
...
are special cases of GLM
---
\Large
With GLM we can analyse
many different types of data
using many predictors
(quantitative & qualitative)
---
\large
**Unified, coherent framework** for data analysis with many extensions:
- **GLMM** (mixed models): accomodate data structure & variation (space, time, phylogeny)
- **GAMM** (generalised additive models): non-linear relationships
- **Model-based multivariate** statistics
- **Bayesian** modelling
---
The Generalised Linear Model (GLM) is a particularly reasonable vantage point on statistical analyses, as **many tests and procedures are special cases** of the GLM. The downside of that (and any other) vantage point is that **we first have to climb it**. There are the morass of unfamiliar terminology, the scree slopes of probability and the cliffs of distributions. **The vista, however, is magnificent**. From the GLM, t-test, ANOVA and regression neatly arrange themselves into regular patterns, and we can see the paths
leading towards the horizon: to time series analyses, Bayesian statistics, spatial statistics and
so forth.
\footnotesize
[Dormann 2020](https://www.springer.com/gp/book/9783030550196)