Skip to content

Commit

Permalink
Add plot of delay distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
athowes committed Jun 25, 2024
1 parent 335d421 commit 40d5887
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions vignettes/approx-inference.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,8 @@ fits <- list(
draws <- purrr::map2(fits, names(fits), function(fit, name) {
extract_lognormal_draws(fit) |>
draws_to_long() |>
filter(parameter %in% c("mean", "sd")) |>
mutate(parameter = recode(parameter, "mean" = "Mean", "sd" = "SD"),
method = as.factor(name))
filter(parameter %in% c("meanlog", "sdlog")) |>
mutate(method = as.factor(name))
})
draws <- bind_rows(draws)
Expand All @@ -157,24 +156,42 @@ draws <- bind_rows(draws)

```{r}
draws |>
filter(parameter == "Mean", method != "Pathfinder") |>
filter(parameter == "meanlog", method != "Pathfinder") |>
ggplot(aes(x = value)) +
geom_histogram(aes(y = ..density..)) +
facet_grid(method ~ parameter) +
theme_minimal() +
labs(x = "", y = "")
draws |>
filter(parameter == "SD", method != "Pathfinder") |>
filter(parameter == "sdlog", method != "Pathfinder") |>
ggplot(aes(x = value)) +
geom_histogram(aes(y= ..density..)) +
geom_histogram(aes(y = ..density..)) +
facet_grid(method ~ parameter) +
theme_minimal() +
labs(x = "", y = "")
```

## Comparison resulting delay distributions

```{r}
pars <- draws |>
group_by(method, parameter) |>
summarise(value = mean(value)) |>
tidyr::pivot_wider(names_from = parameter, values_from = value) |>
filter(!method == "Pathfinder")
purrr::pmap_df(
pars, ~ tibble(
x = seq(0, 25, by = 0.1),

Check warning on line 186 in vignettes/approx-inference.Rmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=vignettes/approx-inference.Rmd,line=186,col=4,[indentation_linter] Hanging indent should be 17 spaces but is 4 spaces.
method = ..1, density = dlnorm(x, ..2, ..3))
) |>

Check warning on line 188 in vignettes/approx-inference.Rmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=vignettes/approx-inference.Rmd,line=188,col=2,[indentation_linter] Indentation should be 0 spaces but is 2 spaces.
ggplot(aes(x = x, y = density, col = method)) +
geom_line() +
theme_minimal() +
labs(x = "", y = "", col = "Method")
```

## Comparison of time taken

How long did each of the methods take?
Expand Down

0 comments on commit 40d5887

Please sign in to comment.