Skip to content

Commit

Permalink
do slice max afterwards
Browse files Browse the repository at this point in the history
  • Loading branch information
wlangera committed Dec 4, 2024
1 parent 2e831f7 commit 0ead112
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions source/markdown/test_densiteitsmodellering.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ Hiervoor moeten we echter voor elke gridcel het stratum berekenen.
Alle data is dan nieuw, terwijl we nu gebruik maken van de random intercepts.
We doen dat voorlopig niet, maar dat is zeker mogelijk.

```{r}
```{r, message = FALSE}
# Specify cache path
brms1_pred_path <- file.path(cache_dir, paste0("brms1_pred_df.Rds"))
Expand Down Expand Up @@ -1180,21 +1180,15 @@ if (file.exists(brms1_pred_path)) {
# Calculate summary statistics per location for time period with maximum
# expected breeding pairs
plot_veldleeuwerik_reg_max <- pred_veldleeuwerik_reg %>%
group_by(plotnaam, periode_in_jaar) %>%
mutate(estimate_mean = mean(.epred)) %>%
group_by(plotnaam) %>%
# slice_max not supported by arrow
mutate(max = max(estimate_mean)) %>%
filter(estimate_mean == max) %>%
select(-max) %>%
# quantile not supported by arrow
collect() %>%
group_by(plotnaam) %>%
group_by(plotnaam, periode_in_jaar) %>%
summarise(estimate_mean = mean(.epred),
se = sd(.epred),
q2.5 = quantile(.epred, 0.025),
q97.5 = quantile(.epred, 0.975),
.groups = "drop") %>%
q97.5 = quantile(.epred, 0.975)) %>%
slice_max(order_by = estimate_mean, n = 1) %>%
ungroup() %>%
mutate(cv = se / estimate_mean,
rel_fout = (q97.5 - q2.5) / (2 * estimate_mean),
method = "max") %>%
Expand Down

0 comments on commit 0ead112

Please sign in to comment.