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

## Goals for today

* Identify features of data that drive analyses

> - Think critically about what the data *could* tell you

> - Start thinking about the distributional forms for data


## General approach

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


## General approach

### <u>Question</u> $\rightarrow$ Data $\rightarrow$ Model $\rightarrow$ Inference $\rightarrow$ Prediction


## Common questions in ecology | At the individual level

### Ideas from the audience?


## Common questions in ecology | At the individual level

### Sex?

### Fecundity?

### Growth? 

### Survival?

### Movement?


## Common questions in ecology | At the population level

### Thoughts from you all?


## Common questions in ecology | At the population level

### Abundance?

### Survival?

### Spatial distribution? 

### Movement/migration?


## General approach

### Question $\rightarrow$ <u>Data</u> $\rightarrow$ Model $\rightarrow$ Inference $\rightarrow$ Prediction


## Ecological data | At the individual level

### Ideas, anyone?


## Ecological data | At the individual level

### 1 Detection $\rightarrow$ presence/absence

### 2+ Detections $\rightarrow$ survival, movement


## Ecological data | At the individual level

### 1 Detection $\rightarrow$ presence/absence

### 2+ Detections $\rightarrow$ survival, movement

<br>

### 1 Measurement $\rightarrow$ fecundity, age, size

### 2+ Measurements $\rightarrow$ growth


## Ecological data | At the population level

### Detections $\rightarrow$ presence/absence

<br>

### Counts $\rightarrow$ density or survival/movement


## Data collection methods

### Can you see where this is going?


## Data collection methods

### Nonexhaustive counts


## &nbsp; {data-background=pelagic_trawl.jpg data-background-size=100%}


## Data collection methods

### Exhaustive counts


## &nbsp; {data-background=weir.JPG data-background-size=cover}


## Data collection methods

### (Non)exhaustive surveys

### Depletions


## &nbsp; {data-background=electrofishing.jpg data-background-size=cover}


## Data collection methods

### (Non)exhaustive surveys

### Depletions

### Capture/Tag/Recapture


## &nbsp; {data-background=sparrow.jpg data-background-size=65%}


## Data types | Discrete values

### Anyone have thoughts here?


## Data types | Discrete values

### Sex

### Age

### Fecundity

### Counts/Census

### Individual survival


## Data types | Continuous

### How about this?


## Data types | Continuous

### Size (length, mass)

### Biomass

### Survival (population)


## A note on continuous variables | Approximating rational numbers with real numbers

### Survival (0.78)

<br>

### Composition (~55% age-4)

<br>

### Density (0.14 per ha)


## A note on continuous variables | Approximating rational numbers with real numbers

### Survival (7 of 9 survived $\approx$ 0.78)

<br>

### Composition (4 age-3, 18 age-4, 11 age-5 $\rightarrow$ ~55% age-4)

<br>

### Density (3 animals in 21 ha plot $\approx$ 0.14 per ha)


## A note on continuous variables | Approximating rational numbers with real numbers

### Which of these give you more confidence?

### A) 3 / 9 $\approx$ 0.33

### B) 300 / 900 $\approx$ 0.33


## {.flexbox .vcenter .bigger}

<font size="14">
<center>The importance of raw data<br>cannot be overstated</center>
</font>

## {.flexbox .vcenter .bigger}

<font size="10">
Distributions of data 
</font>


## Discrete distributions

### Binary (0,1) $\rightarrow$ [Bernoulli](https://en.wikipedia.org/wiki/Bernoulli_distribution)


## Discrete distributions

### Binary (0,1) $\rightarrow$ [Bernoulli](https://en.wikipedia.org/wiki/Bernoulli_distribution)

<br>

Classic "coin toss"

```{r ex_rbern, echo = TRUE}
set.seed(514)
## flip a coin 1000 times
x <- rbinom(n = 1000, size = 1, prob = 0.5)
## count tails (0) and heads (1)
table(x)
```

## Discrete distributions

### Count (non-negative integers) $\rightarrow$ [Poisson](https://en.wikipedia.org/wiki/Poisson_distribution) or [Negative-Binomial](https://en.wikipedia.org/wiki/Negative_binomial_distribution)


## Discrete distributions

### Count (non-negative integers) $\rightarrow$ [Poisson](https://en.wikipedia.org/wiki/Poisson_distribution) or [Negative-Binomial](https://en.wikipedia.org/wiki/Negative_binomial_distribution)

<br>

Number of times birds were resighted 

```{r ex_rpois, echo = TRUE}
set.seed(514)
## 37 banded birds; number of resightings
x <- rpois(n = 37, lambda = 1)
## count up resightings
table(x)
```


## Discrete distributions

### Composition (_D_ categories) $\rightarrow$ [Binomial](https://en.wikipedia.org/wiki/Binomial_distribution) (*D* = 2) or [Multinomial](https://en.wikipedia.org/wiki/Multinomial_distribution) (*D* > 2)


## Discrete distributions

### Composition (_D_ categories) $\rightarrow$ [Binomial](https://en.wikipedia.org/wiki/Binomial_distribution) (*D* = 2) or [Multinomial](https://en.wikipedia.org/wiki/Multinomial_distribution) (*D* > 2)

<br>

Surviving offspring 

```{r ex_rbinom, echo = TRUE}
set.seed(514)
## 1357 tagged smolts; probability of survival is 0.05
x <- rbinom(n = 1357, size = 1, prob = 0.05)
## number of mortalities (0) and survivors (1)
table(x)  # p ~= 0.0593
```


## Continuous distributions

### Real numbers (-$\infty$,$\infty$) $\rightarrow$ [Normal](https://en.wikipedia.org/wiki/Normal_distribution)


## Continuous distributions

### Real numbers (-$\infty$,$\infty$) $\rightarrow$ [Normal](https://en.wikipedia.org/wiki/Normal_distribution)

<br>

Common "bell-shaped curve"

```{r ex_norm, echo = TRUE, eval = FALSE}
## normal distribution (mean = 0, sd = 1)
curve(dnorm(x, mean = 0, sd = sqrt(1)), from = -4, to = 4,
      main = "", xlab = "", ylab = "Density", bty = "n",
      cex.lab = 1.5, cex.axis = 1.2, lwd = 2, col = "#32006e")
```


## Continuous distributions

```{r ex_norm_2, echo = FALSE, fig.dim = c(8, 5), fig.align = "center"}
## normal distribution (mean = 0, sd = 1)
curve(dnorm(x, mean = 0, sd = sqrt(1)), from = -4, to = 4,
      main = "", xlab = "", ylab = "Density", bty = "n",
      cex.lab = 1.5, cex.axis = 1.2, lwd = 2, col = "#32006e")
```


## Continuous distributions

### Density (non-negative real values) $\rightarrow$ [log-Normal](https://en.wikipedia.org/wiki/Log-normal_distribution) or [Gamma](https://en.wikipedia.org/wiki/Gamma_distribution)


## Continuous distributions

### Density (non-negative real values) $\rightarrow$ [log-Normal](https://en.wikipedia.org/wiki/Log-normal_distribution) or [Gamma](https://en.wikipedia.org/wiki/Gamma_distribution)

<br>

```{r ex_lognorm, echo = TRUE, eval = FALSE}
## log-normal distribution (mean = 2, sd = 0.7)
curve(dlnorm(x, meanlog = 2, sdlog = 0.7), from = 0, to = 20,
      main = "", xlab = "", ylab = "Density", bty = "n",
      cex.lab = 1.5, cex.axis = 1.2, lwd = 2,  col = "#32006e")
```


## Continuous distributions

```{r ex_lognorm_2, echo = FALSE, fig.dim = c(8, 5), fig.align = "center"}
## log-normal distribution (mean = 2, sd = 0.7)
curve(dlnorm(x, meanlog = 2, sdlog = 0.7), from = 0, to = 20,
      main = "", xlab = "", ylab = "Density", bty = "n",
      cex.lab = 1.5, cex.axis = 1.2, lwd = 2,  col = "#32006e")
```


## Continuous distributions

### Proportion (simplex$^D$) $\rightarrow$ [Beta](https://en.wikipedia.org/wiki/Beta_distribution) (*D* = 2) or [Dirichlet](https://en.wikipedia.org/wiki/Dirichlet_distribution) (*D* > 2)

<br>

```{r ex_beta, echo = TRUE, eval = FALSE}
## beta distribution (mean = 2/3)
curve(dbeta(x, shape1 = 6, shape2 = 3), from = 0, to = 1,
      main = "", xlab = "", ylab = "Density", bty = "n",
      cex.lab = 1.5, cex.axis = 1.2, lwd = 2,  col = "#32006e")
```


## Continuous distributions

```{r ex_beta_2, echo = FALSE, fig.dim = c(8, 5), fig.align = "center"}
## beta distribution (mean = 2/3)
curve(dbeta(x, shape1 = 6, shape2 = 3), from = 0, to = 1,
      main = "", xlab = "", ylab = "Density", bty = "n",
      cex.lab = 1.5, cex.axis = 1.2, lwd = 2,  col = "#32006e")
```

