```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## {.flexbox .vcenter .bigger}

<font size="10">
Who am I? 
</font>


## My role as course instructor

> - Help you learn the material

> - Help you learn how to ask for help

> - Be a future resource


## {.flexbox .vcenter .bigger}

<font size="10">
Who are you? 
</font>


## Introduce yourself | Tell us via Zoom chat:

1. Your degree program (MS, PhD)

2. Your school/department

3. Your area of study (a phrase or short sentence)


## {.flexbox .vcenter .bigger}

<font size="10">
What is this course about? 
</font>


## Two major goals in ecology:

<font size="6">
1. Infer process from pattern   
</font>


## {.flexbox .vcenter}

<font size="10">
Process $\overset{?}{\Rightarrow}$ Pattern
</font>


## {.flexbox .vcenter}

<font size="10">
Pattern $= f($Process$)$
</font>


## {.flexbox .vcenter}

<font size="10">
Data $= f($Process$)$
</font>


## {.flexbox .vcenter}

<font size="10">
Data = Process + Noise
</font>


## Ecological data often have lots of noise

```{r info_noise_barchart}
dat <- matrix(c(20, 80, 90, 10), 2, 2)
par(mai = c(0.5, 1, 0.5, 0.5))
bp <- barplot(dat, las = 1, col = c("blue", "gray"), border = NA, axes = FALSE,
        ylab = "", names.arg = c("Ecology", "Finance"), cex.names = 1.7)
text(0.7, 10, adj = c(0.5, 0.5), "Process", col = "white", cex = 1.5)
text(0.7, 60, adj = c(0.5, 0.5), "Noise", col = "black", cex = 1.5)
text(1.9, 45, adj = c(0.5, 0.5), "Process", col = "white", cex = 1.5)
text(1.9, 95, adj = c(0.5, 0.5), "Noise", col = "black", cex = 1.5)
```

## {.flexbox .vcenter}

<font size="10">
Our challenge is to separate<br>the signal from the noise
</font>


## Two major goals in ecology:

<font size="6">
1. Infer process from pattern   
</font>

<font size="6">
2. **Make predictions**
</font>


## Ecological forecasting

<font size="6">
How will [some future scenario] affect<br>[some ecosystem service]?
</font>


## General approach

### Question $\rightarrow$ Data $\rightarrow$ Model $\rightarrow$ Inference $\rightarrow$ Prediction


## Forms of linear models

| Errors | Single random process | Multiple random processes |
|:-------|:--------------:|:------------------:|
| Normal | Linear Model (LM) | Linear Mixed Model (LMM) |
| Non-normal | Generalized Linear Model (GLM) | Generalized Linear Mixed Model (GLMM) |


## Forms of linear models
 
```{r model_diagram, fig.height = 5, fig.width = 7, fig.align = 'center'}
par(mai = rep(0, 4), omi = rep(0, 4), bg = NA)

## order: GLM, LM, GLMM, LMM
xx <- c(1, 2, 2, 3) * 10
yy <- c(2, 1, 3, 2) * 10

plot(c(7, 33), c(7, 33), type = "n", xlim = c(7, 33), ylim = c(7, 33),
     xaxt = "n", yaxt = "n", xlab = "", ylab = "",
     bty = "n")
symbols(xx, yy, circle = rep(2, 4), inches = 0.5, add = TRUE,
        lwd = 2, bg = "white")
text(xx, yy, c("GLM", "LM", "GLMM", "LMM"), cex = 1.5)
## from LM to GLM
arrows(xx[2]-2, yy[2]+2, xx[1]+2, yy[1]-2, length = 0.2)
text(15, 14, "multiple forms of errors", pos = 2)
## from LM to LMM
arrows(xx[2]+2, yy[2]+2, xx[4]-2, yy[4]-2, length = 0.2)
text(25, 14, "multiple random processes", pos = 4)
## from GLM to GLMM
arrows(xx[1]+2, yy[1]+2, xx[3]-2, yy[3]-2, length = 0.2)
text(15, 26, "multiple random processes", pos = 2)
## from LMM to GLMM
arrows(xx[4]-2, yy[4]+2, xx[3]+2, yy[3]-2, length = 0.2)
text(25, 26, "multiple forms of errors", pos = 4)
```


## Learning objectives for the course

By the end of the quarter, students should be able to:

* Identify an appropriate statistical model based on the data and specific question

* Understand the assumptions behind a chosen statistical model

* Use **R** to fit a variety of linear models to data

* Evaluate data support for various models and select the most parsimonious model among them

* Use **R Markdown** to combine text, equations, code, tables, and figures into reports


## {.flexbox .vcenter .bigger}

<font size="10">
[__Course information__](https://qerm514.github.io/website)
</font>




