Skip to content

Commit

Permalink
wijziging verkenning figuren flowers + extra analyses aantal soorten …
Browse files Browse the repository at this point in the history
…en aantal individuen
  • Loading branch information
hansvancalster committed Aug 26, 2024
1 parent 24b3fc2 commit 2a9ada9
Showing 1 changed file with 176 additions and 9 deletions.
185 changes: 176 additions & 9 deletions source/data_analysis_spring_2023.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -779,26 +779,107 @@ flowers <- flowers |>
by = join_by(sampling_site_cd == sample_code))
```


```{r}
flowers <- flowers |>
mutate(location_code = str_sub(sampling_site_cd, start = 1L, end = 8L),
maand = str_sub(sampling_site_cd, start = 20L, end = 20L))
```

Aantal soorten bijen ifv aantal bloemen:

```{r}
flowers |>
ggplot(aes(x = number_of_floral_units, y = n_species_ap)) +
geom_point() +
geom_smooth(method = "glm", method.args = list(family = "poisson")) +
scale_x_continuous(trans = "pseudo_log")
geom_smooth(
method = "glm", method.args = list(family = "poisson"), se = FALSE) +
scale_x_continuous(trans = "pseudo_log") +
facet_grid(location_code ~ maand, scales = "free")
```

Aantal individuen van bijen ifv aantal bloemen:

```{r}
flowers <- flowers |>
mutate(location_code = str_sub(sampling_site_cd, start = 1L, end = 8L),
maand = str_sub(sampling_site_cd, start = 20L, end = 20L))
flowers |>
ggplot(aes(x = number_of_floral_units, y = n_ind_ap)) +
geom_point() +
geom_smooth(
method = "glm", method.args = list(family = "poisson"), se = FALSE) +
scale_x_continuous(trans = "pseudo_log") +
facet_grid(location_code ~ maand, scales = "free")
```

Aantal soorten zweefvliegen ifv aantal bloemen:

```{r}
flowers |>
ggplot(aes(x = number_of_floral_units, y = n_species_syr)) +
geom_point() +
geom_smooth(
method = "glm", method.args = list(family = "poisson"), se = FALSE) +
scale_x_continuous(trans = "pseudo_log") +
facet_grid(location_code ~ maand, scales = "free")
```

Aantal individuen van zweefvliegen ifv aantal bloemen:

```{r}
flowers |>
ggplot(aes(x = number_of_floral_units, y = n_ind_syr)) +
geom_point() +
geom_smooth(
method = "glm", method.args = list(family = "poisson"), se = FALSE) +
scale_x_continuous(trans = "pseudo_log") +
facet_grid(location_code ~ maand, scales = "free")
```

```{r}
flowers |>
ggplot(
aes(
x = maand,
y = number_of_floral_units
)
) +
geom_violin() +
ggforce::geom_sina() +
scale_y_continuous(
trans = "pseudo_log",
breaks = c(0, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000))
```

```{r}
flowers |>
ggplot(
aes(
x = n_ind_ap,
y = n_species_ap
)
) +
stat_sum() +
geom_abline()
flowers |>
ggplot(
aes(
x = n_ind_syr,
y = n_species_syr
)
) +
stat_sum() +
geom_abline()
```


```{r}
model1 <- glmmTMB(
n_ind_ap ~ log(number_of_floral_units + 1) + location_code + maand,
ziformula = ~ 1,
n_species_ap ~
log(number_of_floral_units + 1)

Check warning on line 878 in source/data_analysis_spring_2023.Rmd

View workflow job for this annotation

GitHub Actions / check project with checklist

file=source/data_analysis_spring_2023.Rmd,line=878,col=36,[trailing_whitespace_linter] Trailing whitespace is superfluous.
+ maand
+ location_code
,
ziformula = ~ maand,
family = "poisson",
na.action = na.exclude,
data = flowers
Expand All @@ -810,13 +891,27 @@ summary(model1)
```

```{r}
performance::check_overdispersion(model1)
performance::check_model(model1)
```

```{r}
marginaleffects::plot_predictions(
model1, "number_of_floral_units",
vcov = TRUE,
re.form = NA
) +
scale_x_continuous(trans = "pseudo_log")
```


```{r}
model2 <- glmmTMB(
n_species_syr ~ number_of_floral_units + location_code + maand,
ziformula = ~ 1,
n_species_syr ~
log(number_of_floral_units + 1)
+ location_code
+ maand,
ziformula = ~ maand,
family = "poisson",
na.action = na.exclude,
data = flowers
Expand All @@ -828,9 +923,81 @@ summary(model2)
```

```{r}
performance::check_overdispersion(model2)
performance::check_model(model2)
```

```{r}
marginaleffects::plot_predictions(
model2, "number_of_floral_units",
vcov = TRUE,
re.form = NA
) +
scale_x_continuous(trans = "pseudo_log")
```

```{r}
model3 <- glmmTMB(
n_ind_ap ~
log(number_of_floral_units + 1)
+ location_code
+ maand,
ziformula = ~ maand,
family = "nbinom2",
na.action = na.exclude,
data = flowers
)
```

```{r}
summary(model3)
```

```{r}
performance::check_overdispersion(model3)
performance::check_model(model3)
```

```{r}
marginaleffects::plot_predictions(
model3, "number_of_floral_units",
vcov = TRUE,
re.form = NA
) +
scale_x_continuous(trans = "pseudo_log")
```

```{r}
model4 <- glmmTMB(
n_ind_syr ~
+ log(number_of_floral_units + 1)
+ location_code
+ maand,
ziformula = ~ maand,
family = "nbinom2",
na.action = na.exclude,
data = flowers
)
```

```{r}
summary(model4)
```

```{r}
performance::check_overdispersion(model4)
performance::check_model(model4)
```

```{r}
marginaleffects::plot_predictions(
model4, "number_of_floral_units",
vcov = TRUE,
re.form = NA
) +
scale_x_continuous(trans = "pseudo_log")
```

# Kosten

```{r}
Expand Down

0 comments on commit 2a9ada9

Please sign in to comment.