Plot main effects of multiple parameters on an outcome (violin/box/jitter)
Source:R/plot_main_effects.R
plot_main_effects.RdCreates a facetted overview plot showing the distribution of an outcome
(e.g., n_overflows) across the tested levels of multiple (varied) parameters.
Parameters are sorted by a simple effect-size proxy: the range of median outcome
values across parameter levels.
Arguments
- df
A data.frame (or tibble) containing the outcome column
yand the parameter columns listed inparams.- y
Character scalar. Name of the outcome column to plot on the y-axis. Defaults to
"n_overflows".- params
Character vector of parameter column names in
dfto consider.- max_levels
Integer. Parameters with more than
max_levelsdistinct values are dropped to keep the plot readable. Defaults to 25.
Details
The function is intended for optimisation / sensitivity grids with many parameters, where a single 2D scatter plot is not informative.
Examples
if (FALSE) { # \dontrun{
library(readr)
library(dplyr)
library(tidyr)
library(ggplot2)
library(forcats)
df <- read_csv("simulation_results_optimisation.csv", show_col_types = FALSE)
params <- c("connected_area", "mulde_area", "mulde_height",
"filter_hydraulicconductivity", "filter_height",
"storage_height", "bottom_hydraulicconductivity", "rain_factor")
p <- plot_main_effects(df, y = "n_overflows", params = params, max_levels = 20)
p
} # }