Skip to content

Commit

Permalink
build_quarto_site(unfreeze = FALSE) for release 1.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jabenninghoff committed May 17, 2024
1 parent 8cd2d3c commit 0265d9a
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 18 deletions.
4 changes: 2 additions & 2 deletions _freeze/analysis/constraints/execute-results/html.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"hash": "3152510323d5e2b19e5f0cb5589617f0",
"hash": "e0a7d75e8fc3ae651fc27f219ce8226c",
"result": {
"engine": "knitr",
"markdown": "---\ntitle: \"Constraints vs Performance\"\nauthor: \"John Benninghoff\"\ndate: '2024-04-30'\ndate-modified: '2024-04-30'\ncategories: notes\norder: 107\noutput:\n html_notebook:\n theme:\n version: 5\n preset: bootstrap\n css: assets/extra.css\n pandoc_args: --shift-heading-level-by=1\n toc: yes\n toc_float:\n collapsed: no\n smooth_scroll: no\n---\n\n\nVisualizations exploring the use of constraints vs performance improvements in risk management.\n\n# Questions/TODO\n\n- [ ] Questions/TODO list here\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(ggplot2)\nlibrary(jbplot)\nlibrary(fs)\nlibrary(tibble)\nlibrary(dplyr)\n```\n:::\n\n\n# Normal Performance\n\nReplicate a version of Figure 9 from the\n[Safety-II White Paper](https://www.england.nhs.uk/signuptosafety/wp-content/uploads/sites/16/2015/10/safety-1-safety-2-whte-papr.pdf),\nwith help from <https://ggplot2tutor.com/tutorials/sampling_distributions>:\n\n\n::: {.cell}\n\n```{.r .cell-code}\nxmin <- -5\nxmax <- 5\n\nsave_png <- function(filename) {\n ggsave(filename = path(\"rendered\", filename), width = 16 * 0.6, height = 9 * 0.6, bg = \"white\")\n}\n\nbackground <- ggplot(data.frame(x = c(xmin, xmax)), aes(x)) +\n scale_x_continuous(breaks = -3:3, minor_breaks = NULL) +\n labs(x = NULL, y = NULL) +\n theme_quo(minor.y = FALSE)\n\nbaseline <- stat_function(fun = dnorm, geom = \"line\")\nbad <- stat_function(fun = dnorm, geom = \"area\", fill = \"red\", xlim = c(xmin, -2))\n\nbackground + bad + baseline\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/background-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"01-baseline-bad.png\")\n```\n:::\n\n\nThe plot above shows \"bad\" outcomes in red. Let's add in \"good\" outcomes (>1) in green:\n\n\n::: {.cell}\n\n```{.r .cell-code}\ngood <- stat_function(fun = dnorm, geom = \"area\", fill = \"green\", xlim = c(1, xmax))\n\nbackground + bad + good + baseline\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/good-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"02-baseline-bad-good.png\")\n```\n:::\n\n\n# Constrained Performance\n\nOne way of reducing \"bad\" outcomes is by constraining performance - reducing the standard\ndeviation.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nconstrained <- stat_function(fun = dnorm, args = list(sd = 0.7), geom = \"line\", color = \"blue\")\ntaller <- scale_y_continuous(limits = c(0, 0.6))\n\nbackground +\n stat_function(\n fun = dnorm, args = list(sd = 0.7), geom = \"area\", fill = \"red\", xlim = c(xmin, -2)\n ) +\n stat_function(\n fun = dnorm, args = list(sd = 0.7), geom = \"area\", fill = \"green\", xlim = c(1, xmax)\n ) +\n constrained +\n taller\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/constrained-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"03-constrained.png\")\n```\n:::\n\n\nPlotting both on the same grid shows the reduction in both \"bad\" and \"good\" outcomes:\n\n\n::: {.cell}\n\n```{.r .cell-code}\nbackground +\n bad +\n good +\n baseline +\n constrained +\n taller\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/overlay-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"04-baseline-constrained.png\")\n```\n:::\n\n\n# Improved Performance\n\nAnother way of reducing bad outcomes is by improving performance - shifting the mean.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nperformance <- stat_function(fun = dnorm, args = list(mean = 1), geom = \"line\", color = \"blue\")\nimproved <- stat_function(\n fun = dnorm, args = list(mean = 1), geom = \"area\", fill = \"green\", xlim = c(1, xmax)\n)\n\nbackground +\n stat_function(\n fun = dnorm, args = list(mean = 1), geom = \"area\", fill = \"red\", xlim = c(xmin, -2)\n ) +\n improved +\n performance\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/performance-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"05-improved.png\")\n```\n:::\n\n\nPlotting both together shows a reduction in \"bad\" and an increase in \"good\" outcomes:\n\n\n::: {.cell}\n\n```{.r .cell-code}\nbackground +\n bad +\n improved +\n baseline +\n performance\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/overlay_perf-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"06-baseline-improved.png\")\n```\n:::\n\n\nComparing all three:\n\n\n::: {.cell}\n\n```{.r .cell-code}\nbackground +\n bad +\n improved +\n baseline +\n constrained +\n performance +\n taller\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/overlay_all-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"07-baseline-constrained-improved.png\")\n```\n:::\n\n\n# Growth of Controls\n\nVisualize an example of the growth of controls using the Cyentia/RiskRecon State of Third-Party Risk\nManagement 2020 and 2024 reports (data from 2023).\n\nSource:\n\n- 2020 data: <https://www.riskrecon.com/state-of-third-party-risk-management-report>\n- 2023 data: <https://www.riskrecon.com/state-of-third-party-risk-management-2024>\n\n\n::: {.cell}\n\n```{.r .cell-code}\nquestionnaire <- tribble(\n ~year, ~questions, ~percent,\n 2020, \">400\", 0.041,\n 2020, \"101-400\", 0.148,\n 2020, \"11-100\", 0.705,\n 2020, \"1-10\", 0.107,\n 2023, \">400\", 0.02,\n 2023, \"101-400\", 0.333,\n 2023, \"11-100\", 0.616,\n 2023, \"1-10\", 0.030\n) |>\n mutate(year = as.factor(year)) |>\n mutate(questions = factor(questions, levels = c(\"1-10\", \"11-100\", \"101-400\", \">400\")))\n\nggplot(questionnaire, aes(questions, percent, fill = year)) +\n geom_col(position = \"dodge\") +\n scale_y_continuous(labels = scales::label_percent()) +\n scale_fill_manual(values = c(\"steelblue2\", \"steelblue4\")) +\n labs(x = NULL, y = NULL, fill = \"Year\", title = \"Third-Party Questionnaire Length by Year\") +\n labs(caption = \"Source: Cyentia/RiskRecon State of Third-Party Risk Management, 2020 and 2024\") +\n theme_quo()\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/questionnaire-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"08-questionnaire-length.png\")\n```\n:::\n\n\n# Transparent Donut\n\nCreate a transparent donut plot showing an 80% reduction.\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# custom function based on ggplot_donut_percent()\ncustom_donut <- function(p, text = \"\", accuracy = NULL, hsize = 4, size = 12, family = \"Lato\") {\n data <- data.frame(group = c(TRUE, FALSE), n = c(p, 1 - p))\n label <- paste0(scales::label_percent(accuracy = accuracy)(p), \"\\n\", text)\n\n ggplot_donut(data, hsize = hsize) +\n guides(fill = \"none\") +\n geom_text(x = 0, label = label, size = size, family = family) +\n scale_fill_grey() +\n theme(plot.background = element_rect(fill = \"transparent\", color = NA))\n}\n\ncustom_donut(0.8, \"reduction\")\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/custom_donut-1.png){width=816}\n:::\n\n```{.r .cell-code}\nggsave(\"rendered/80-percent-safety.png\")\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nSaving 8.5 x 5 in image\n```\n\n\n:::\n\n```{.r .cell-code}\ncustom_donut(0.8, \"reduction?\")\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/custom_donut-2.png){width=816}\n:::\n\n```{.r .cell-code}\nggsave(\"rendered/80-percent-security.png\")\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nSaving 8.5 x 5 in image\n```\n\n\n:::\n:::\n",
"markdown": "---\ntitle: \"Constraints vs Performance\"\nauthor: \"John Benninghoff\"\ndate: '2024-04-30'\ndate-modified: '2024-05-10'\ncategories: notes\norder: 107\noutput:\n html_notebook:\n theme:\n version: 5\n preset: bootstrap\n css: assets/extra.css\n pandoc_args: --shift-heading-level-by=1\n toc: yes\n toc_float:\n collapsed: no\n smooth_scroll: no\n---\n\n\nVisualizations exploring the use of constraints vs performance improvements in risk management.\n\n# Questions/TODO\n\n- [ ] Questions/TODO list here\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(ggplot2)\nlibrary(jbplot)\nlibrary(fs)\nlibrary(tibble)\nlibrary(dplyr)\n```\n:::\n\n\n# Normal Performance\n\nReplicate a version of Figure 9 from the\n[Safety-II White Paper](https://www.england.nhs.uk/signuptosafety/wp-content/uploads/sites/16/2015/10/safety-1-safety-2-whte-papr.pdf),\nwith help from <https://ggplot2tutor.com/tutorials/sampling_distributions>:\n\n\n::: {.cell}\n\n```{.r .cell-code}\nxmin <- -5\nxmax <- 5\n\nsave_png <- function(filename) {\n ggsave(filename = path(\"rendered\", filename), width = 16 * 0.6, height = 9 * 0.6, bg = \"white\")\n}\n\nbackground <- ggplot(data.frame(x = c(xmin, xmax)), aes(x)) +\n scale_x_continuous(breaks = -3:3, minor_breaks = NULL) +\n labs(x = NULL, y = NULL) +\n theme_quo(minor.y = FALSE)\n\nbaseline <- stat_function(fun = dnorm, geom = \"line\")\nbad <- stat_function(fun = dnorm, geom = \"area\", fill = \"red\", xlim = c(xmin, -2))\n\nbackground + bad + baseline\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/background-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"01-baseline-bad.png\")\n```\n:::\n\n\nThe plot above shows \"bad\" outcomes in red. Let's add in \"good\" outcomes (>1) in green:\n\n\n::: {.cell}\n\n```{.r .cell-code}\ngood <- stat_function(fun = dnorm, geom = \"area\", fill = \"green\", xlim = c(1, xmax))\n\nbackground + bad + good + baseline\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/good-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"02-baseline-bad-good.png\")\n```\n:::\n\n\n# Constrained Performance\n\nOne way of reducing \"bad\" outcomes is by constraining performance - reducing the standard\ndeviation.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nconstrained <- stat_function(fun = dnorm, args = list(sd = 0.7), geom = \"line\", color = \"blue\")\ntaller <- scale_y_continuous(limits = c(0, 0.6))\n\nbackground +\n stat_function(\n fun = dnorm, args = list(sd = 0.7), geom = \"area\", fill = \"red\", xlim = c(xmin, -2)\n ) +\n stat_function(\n fun = dnorm, args = list(sd = 0.7), geom = \"area\", fill = \"green\", xlim = c(1, xmax)\n ) +\n constrained +\n taller\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/constrained-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"03-constrained.png\")\n```\n:::\n\n\nPlotting both on the same grid shows the reduction in both \"bad\" and \"good\" outcomes:\n\n\n::: {.cell}\n\n```{.r .cell-code}\nbackground +\n bad +\n good +\n baseline +\n constrained +\n taller\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/overlay-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"04-baseline-constrained.png\")\n```\n:::\n\n\n# Improved Performance\n\nAnother way of reducing bad outcomes is by improving performance - shifting the mean.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nperformance <- stat_function(fun = dnorm, args = list(mean = 1), geom = \"line\", color = \"blue\")\nimproved <- stat_function(\n fun = dnorm, args = list(mean = 1), geom = \"area\", fill = \"green\", xlim = c(1, xmax)\n)\n\nbackground +\n stat_function(\n fun = dnorm, args = list(mean = 1), geom = \"area\", fill = \"red\", xlim = c(xmin, -2)\n ) +\n improved +\n performance\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/performance-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"05-improved.png\")\n```\n:::\n\n\nPlotting both together shows a reduction in \"bad\" and an increase in \"good\" outcomes:\n\n\n::: {.cell}\n\n```{.r .cell-code}\nbackground +\n bad +\n improved +\n baseline +\n performance\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/overlay_perf-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"06-baseline-improved.png\")\n```\n:::\n\n\nComparing all three:\n\n\n::: {.cell}\n\n```{.r .cell-code}\nbackground +\n bad +\n improved +\n baseline +\n constrained +\n performance +\n taller\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/overlay_all-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"07-baseline-constrained-improved.png\")\n```\n:::\n\n\n# Growth of Controls\n\nVisualize an example of the growth of controls using the Cyentia/RiskRecon State of Third-Party Risk\nManagement 2020 and 2024 reports (data from 2023).\n\nSource:\n\n- 2020 data: <https://www.riskrecon.com/state-of-third-party-risk-management-report>\n- 2023 data: <https://www.riskrecon.com/state-of-third-party-risk-management-2024>\n\n\n::: {.cell}\n\n```{.r .cell-code}\nquestionnaire <- tribble(\n ~year, ~questions, ~percent,\n 2020, \">400\", 0.041,\n 2020, \"101-400\", 0.148,\n 2020, \"11-100\", 0.705,\n 2020, \"1-10\", 0.107,\n 2023, \">400\", 0.02,\n 2023, \"101-400\", 0.333,\n 2023, \"11-100\", 0.616,\n 2023, \"1-10\", 0.030\n) |>\n mutate(year = as.factor(year)) |>\n mutate(questions = factor(questions, levels = c(\"1-10\", \"11-100\", \"101-400\", \">400\")))\n\nggplot(questionnaire, aes(questions, percent, fill = year)) +\n geom_col(position = \"dodge\") +\n scale_y_continuous(labels = scales::label_percent()) +\n scale_fill_manual(values = c(\"steelblue2\", \"steelblue4\")) +\n labs(x = NULL, y = NULL, fill = \"Year\", title = \"Third-Party Questionnaire Length by Year\") +\n labs(caption = \"Source: Cyentia/RiskRecon State of Third-Party Risk Management, 2020 and 2024\") +\n theme_quo()\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/questionnaire-1.png){width=816}\n:::\n\n```{.r .cell-code}\nsave_png(\"08-questionnaire-length.png\")\n```\n:::\n\n\n# Transparent Donut\n\nCreate a transparent donut plot showing an 80% reduction.\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# custom function based on ggplot_donut_percent()\ncustom_donut <- function(p, text = \"\", accuracy = NULL, hsize = 4, size = 12, family = \"Lato\") {\n data <- data.frame(group = c(TRUE, FALSE), n = c(p, 1 - p))\n label <- paste0(scales::label_percent(accuracy = accuracy)(p), \"\\n\", text)\n\n ggplot_donut(data, hsize = hsize) +\n guides(fill = \"none\") +\n geom_text(x = 0, label = label, size = size, family = family) +\n scale_fill_grey() +\n theme(plot.background = element_rect(fill = \"transparent\", color = NA))\n}\n\ncustom_donut(0.8, \"reduction\")\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/custom_donut-1.png){width=816}\n:::\n\n```{.r .cell-code}\nggsave(\"rendered/80-percent-safety.png\")\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nSaving 8.5 x 5 in image\n```\n\n\n:::\n\n```{.r .cell-code}\ncustom_donut(0.8, \"reduction?\")\n```\n\n::: {.cell-output-display}\n![](constraints_files/figure-html/custom_donut-2.png){width=816}\n:::\n\n```{.r .cell-code}\nggsave(\"rendered/80-percent-security.png\")\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nSaving 8.5 x 5 in image\n```\n\n\n:::\n:::\n",
"supporting": [
"constraints_files"
],
Expand Down
9 changes: 8 additions & 1 deletion docs/NEWS.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@
<h2 id="toc-title">On this page</h2>

<ul>
<li><a href="#rtraining-1.2.5" id="toc-rtraining-1.2.5" class="nav-link active" data-scroll-target="#rtraining-1.2.5">rtraining 1.2.5</a></li>
<li><a href="#rtraining-1.2.6" id="toc-rtraining-1.2.6" class="nav-link active" data-scroll-target="#rtraining-1.2.6">rtraining 1.2.6</a></li>
<li><a href="#rtraining-1.2.5" id="toc-rtraining-1.2.5" class="nav-link" data-scroll-target="#rtraining-1.2.5">rtraining 1.2.5</a></li>
<li><a href="#rtraining-1.2.4" id="toc-rtraining-1.2.4" class="nav-link" data-scroll-target="#rtraining-1.2.4">rtraining 1.2.4</a></li>
<li><a href="#rtraining-1.2.3" id="toc-rtraining-1.2.3" class="nav-link" data-scroll-target="#rtraining-1.2.3">rtraining 1.2.3</a></li>
<li><a href="#rtraining-1.2.2" id="toc-rtraining-1.2.2" class="nav-link" data-scroll-target="#rtraining-1.2.2">rtraining 1.2.2</a></li>
Expand Down Expand Up @@ -326,6 +327,12 @@ <h2 id="toc-title">On this page</h2>



<section id="rtraining-1.2.6" class="level1">
<h1>rtraining 1.2.6</h1>
<ul>
<li>Minor updates</li>
</ul>
</section>
<section id="rtraining-1.2.5" class="level1">
<h1>rtraining 1.2.5</h1>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/analysis/constraints.html
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ <h1 class="title">Constraints vs Performance</h1>
<div>
<div class="quarto-title-meta-heading">Modified</div>
<div class="quarto-title-meta-contents">
<p class="date-modified">April 30, 2024</p>
<p class="date-modified">May 10, 2024</p>
</div>
</div>

Expand Down
9 changes: 8 additions & 1 deletion docs/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@
<h2 id="toc-title">On this page</h2>

<ul>
<li><a href="#rtraining-1.2.5" id="toc-rtraining-1.2.5" class="nav-link active" data-scroll-target="#rtraining-1.2.5">rtraining 1.2.5</a></li>
<li><a href="#rtraining-1.2.6" id="toc-rtraining-1.2.6" class="nav-link active" data-scroll-target="#rtraining-1.2.6">rtraining 1.2.6</a></li>
<li><a href="#rtraining-1.2.5" id="toc-rtraining-1.2.5" class="nav-link" data-scroll-target="#rtraining-1.2.5">rtraining 1.2.5</a></li>
<li><a href="#rtraining-1.2.4" id="toc-rtraining-1.2.4" class="nav-link" data-scroll-target="#rtraining-1.2.4">rtraining 1.2.4</a></li>
<li><a href="#rtraining-1.2.3" id="toc-rtraining-1.2.3" class="nav-link" data-scroll-target="#rtraining-1.2.3">rtraining 1.2.3</a></li>
<li><a href="#rtraining-1.2.2" id="toc-rtraining-1.2.2" class="nav-link" data-scroll-target="#rtraining-1.2.2">rtraining 1.2.2</a></li>
Expand Down Expand Up @@ -342,6 +343,12 @@ <h1 class="title">Changelog</h1>
</header>


<section id="rtraining-1.2.6" class="level2">
<h2 class="anchored" data-anchor-id="rtraining-1.2.6">rtraining 1.2.6</h2>
<ul>
<li>Minor updates</li>
</ul>
</section>
<section id="rtraining-1.2.5" class="level2">
<h2 class="anchored" data-anchor-id="rtraining-1.2.5">rtraining 1.2.5</h2>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ <h3 class="no-anchor listing-title">
</a>
</div>
</div>
<div class="quarto-post image-right" data-index="7" data-categories="notes" data-listing-date-sort="1714453200000" data-listing-file-modified-sort="1715378385757" data-listing-date-modified-sort="1714453200000" data-listing-reading-time-sort="4" data-listing-word-count-sort="680">
<div class="quarto-post image-right" data-index="7" data-categories="notes" data-listing-date-sort="1714453200000" data-listing-file-modified-sort="1715975236313" data-listing-date-modified-sort="1715317200000" data-listing-reading-time-sort="4" data-listing-word-count-sort="680">
<div class="thumbnail">
<p><a href="./analysis/constraints.html" class="no-external"></a></p><a href="./analysis/constraints.html" class="no-external">
<p class="card-img-top"><img src="analysis/constraints_files/figure-html/background-1.png" class="thumbnail-image card-img"/></p>
Expand Down
Loading

0 comments on commit 0265d9a

Please sign in to comment.