library(tidyr)
library(dplyr)
library(ggplot2)
library(readr)
## theme for ggplot
theme_set(theme_classic())
theme_update(text = element_text(size = 14))Day 9
Freie Universität Berlin @ Theoretical Ecology
pdogs1 <- read_csv("data/08_prairiedogs.csv")
pdogs1 <- pdogs1 %>%
mutate(n.surv = n.tot - n.death,
p.surv = n.surv / n.tot
)
model1 <- glm(cbind(n.surv, n.death) ~ mated*hibernation +
mated*min.weight +
hibernation*min.weight,
family = binomial, data = pdogs1)
model2 <- glm(cbind(n.surv, n.death) ~ mated +
hibernation +
min.weight,
family = binomial, data = pdogs1)Single term deletions
Model:
cbind(n.surv, n.death) ~ mated * hibernation + mated * min.weight +
hibernation * min.weight
Df Deviance AIC LRT Pr(>Chi)
<none> 0.82565 39.744
mated:hibernation 1 1.18134 38.100 0.35569 0.5509
mated:min.weight 1 0.97217 37.891 0.14651 0.7019
hibernation:min.weight 1 1.13001 38.049 0.30436 0.5812
Single term deletions
Model:
cbind(n.surv, n.death) ~ mated + hibernation + min.weight
Df Deviance AIC LRT Pr(>Chi)
<none> 1.6184 34.537
mated 1 1.6781 32.597 0.0597 0.80694
hibernation 1 7.2750 38.194 5.6566 0.01739 *
min.weight 1 7.2963 38.215 5.6779 0.01718 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Type I error / false positive
Rejecting the Null Hypothesis although it is true
?p.adjust
p.adjust()[1] 1.0000000 1.0000000 1.0000000 1.0000000 0.1043412 0.1030768
Single term deletions
Model:
cbind(n.surv, n.death) ~ mated + hibernation + min.weight
Df Deviance AIC LRT Pr(>Chi)
<none> 1.6184 34.537
mated 1 1.6781 32.597 0.0597 0.80694
hibernation 1 7.2750 38.194 5.6566 0.01739 *
min.weight 1 7.2963 38.215 5.6779 0.01718 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
| mated | hibernation | min.weight | n.tot | n.death | n.surv | p.surv |
|---|---|---|---|---|---|---|
| No | Yes | Yes | 60 | 5 | 55 | 0.9166667 |
| Yes | Yes | Yes | 17 | 2 | 15 | 0.8823529 |
| No | No | Yes | 8 | 1 | 7 | 0.8750000 |
| Yes | No | Yes | 2 | 0 | 2 | 1.0000000 |
| No | Yes | No | 187 | 35 | 152 | 0.8128342 |
| Yes | Yes | No | 85 | 13 | 72 | 0.8470588 |
| No | No | No | 51 | 15 | 36 | 0.7058824 |
| Yes | No | No | 23 | 8 | 15 | 0.6521739 |
Multiple tests