|
|
<!DOCTYPE html>
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
|
|
|
|
|
<meta charset="utf-8">
|
|
|
<meta name="generator" content="quarto-1.5.57">
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
|
|
|
|
|
<meta name="author" content="Will King">
|
|
|
|
|
|
<title>The Effects of Recruitment status on completion of clinical trials</title>
|
|
|
<style>
|
|
|
code{white-space: pre-wrap;}
|
|
|
span.smallcaps{font-variant: small-caps;}
|
|
|
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
|
|
div.column{flex: auto; overflow-x: auto;}
|
|
|
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|
|
ul.task-list{list-style: none;}
|
|
|
ul.task-list li input[type="checkbox"] {
|
|
|
width: 0.8em;
|
|
|
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
|
|
|
vertical-align: middle;
|
|
|
}
|
|
|
/* CSS for syntax highlighting */
|
|
|
pre > code.sourceCode { white-space: pre; position: relative; }
|
|
|
pre > code.sourceCode > span { line-height: 1.25; }
|
|
|
pre > code.sourceCode > span:empty { height: 1.2em; }
|
|
|
.sourceCode { overflow: visible; }
|
|
|
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
|
|
div.sourceCode { margin: 1em 0; }
|
|
|
pre.sourceCode { margin: 0; }
|
|
|
@media screen {
|
|
|
div.sourceCode { overflow: auto; }
|
|
|
}
|
|
|
@media print {
|
|
|
pre > code.sourceCode { white-space: pre-wrap; }
|
|
|
pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; }
|
|
|
}
|
|
|
pre.numberSource code
|
|
|
{ counter-reset: source-line 0; }
|
|
|
pre.numberSource code > span
|
|
|
{ position: relative; left: -4em; counter-increment: source-line; }
|
|
|
pre.numberSource code > span > a:first-child::before
|
|
|
{ content: counter(source-line);
|
|
|
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
|
|
border: none; display: inline-block;
|
|
|
-webkit-touch-callout: none; -webkit-user-select: none;
|
|
|
-khtml-user-select: none; -moz-user-select: none;
|
|
|
-ms-user-select: none; user-select: none;
|
|
|
padding: 0 4px; width: 4em;
|
|
|
}
|
|
|
pre.numberSource { margin-left: 3em; padding-left: 4px; }
|
|
|
div.sourceCode
|
|
|
{ }
|
|
|
@media screen {
|
|
|
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
|
|
}
|
|
|
</style>
|
|
|
|
|
|
|
|
|
<script src="EffectsOfEnrollmentDelay_rebased_files/libs/clipboard/clipboard.min.js"></script>
|
|
|
<script src="EffectsOfEnrollmentDelay_rebased_files/libs/quarto-html/quarto.js"></script>
|
|
|
<script src="EffectsOfEnrollmentDelay_rebased_files/libs/quarto-html/popper.min.js"></script>
|
|
|
<script src="EffectsOfEnrollmentDelay_rebased_files/libs/quarto-html/tippy.umd.min.js"></script>
|
|
|
<script src="EffectsOfEnrollmentDelay_rebased_files/libs/quarto-html/anchor.min.js"></script>
|
|
|
<link href="EffectsOfEnrollmentDelay_rebased_files/libs/quarto-html/tippy.css" rel="stylesheet">
|
|
|
<link href="EffectsOfEnrollmentDelay_rebased_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
|
|
<script src="EffectsOfEnrollmentDelay_rebased_files/libs/bootstrap/bootstrap.min.js"></script>
|
|
|
<link href="EffectsOfEnrollmentDelay_rebased_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
|
|
<link href="EffectsOfEnrollmentDelay_rebased_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
<body class="fullcontent">
|
|
|
|
|
|
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
|
|
|
|
|
|
<main class="content" id="quarto-document-content">
|
|
|
|
|
|
<header id="title-block-header" class="quarto-title-block default">
|
|
|
<div class="quarto-title">
|
|
|
<h1 class="title">The Effects of Recruitment status on completion of clinical trials</h1>
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="quarto-title-meta">
|
|
|
|
|
|
<div>
|
|
|
<div class="quarto-title-meta-heading">Author</div>
|
|
|
<div class="quarto-title-meta-contents">
|
|
|
<p>Will King </p>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
<section id="setup" class="level1">
|
|
|
<h1>Setup</h1>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(knitr)</span>
|
|
|
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(bayesplot)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>This is bayesplot version 1.11.1</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>- Online documentation and vignettes at mc-stan.org/bayesplot</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>- bayesplot theme set to bayesplot::theme_default()</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code> * Does _not_ affect other ggplot2 plots</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code> * See ?bayesplot_theme_set for details on theme setting</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">available_mcmc</span>(<span class="at">pattern =</span> <span class="st">"_nuts_"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>bayesplot MCMC module:
|
|
|
(matching pattern '_nuts_')
|
|
|
mcmc_nuts_acceptance
|
|
|
mcmc_nuts_divergence
|
|
|
mcmc_nuts_energy
|
|
|
mcmc_nuts_stepsize
|
|
|
mcmc_nuts_treedepth</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggplot2)</span>
|
|
|
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(patchwork)</span>
|
|
|
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tidyverse)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
|
|
|
✔ dplyr 1.1.4 ✔ readr 2.1.5
|
|
|
✔ forcats 1.0.0 ✔ stringr 1.5.1
|
|
|
✔ lubridate 1.9.4 ✔ tibble 3.2.1
|
|
|
✔ purrr 1.0.2 ✔ tidyr 1.3.1</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
|
|
|
✖ dplyr::filter() masks stats::filter()
|
|
|
✖ dplyr::lag() masks stats::lag()
|
|
|
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(rstan)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Loading required package: StanHeaders
|
|
|
|
|
|
rstan version 2.32.6 (Stan version 2.32.2)
|
|
|
|
|
|
For execution on a local, multicore CPU with excess RAM we recommend calling
|
|
|
options(mc.cores = parallel::detectCores()).
|
|
|
To avoid recompilation of unchanged Stan programs, we recommend calling
|
|
|
rstan_options(auto_write = TRUE)
|
|
|
For within-chain threading using `reduce_sum()` or `map_rect()` Stan functions,
|
|
|
change `threads_per_chain` option:
|
|
|
rstan_options(threads_per_chain = 1)
|
|
|
|
|
|
|
|
|
Attaching package: 'rstan'
|
|
|
|
|
|
The following object is masked from 'package:tidyr':
|
|
|
|
|
|
extract</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb14"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tidyr)</span>
|
|
|
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ghibli)</span>
|
|
|
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(xtable)</span>
|
|
|
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a><span class="co">#Resources: https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started</span></span>
|
|
|
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a><span class="co">#save unchanged models instead of recompiling</span></span>
|
|
|
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="fu">rstan_options</span>(<span class="at">auto_write =</span> <span class="cn">TRUE</span>)</span>
|
|
|
<span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a><span class="co">#allow for multithreaded sampling</span></span>
|
|
|
<span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a><span class="fu">options</span>(<span class="at">mc.cores =</span> parallel<span class="sc">::</span><span class="fu">detectCores</span>())</span>
|
|
|
<span id="cb14-10"><a href="#cb14-10" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb14-11"><a href="#cb14-11" aria-hidden="true" tabindex="-1"></a><span class="co">#test installation, shouldn't get any errors</span></span>
|
|
|
<span id="cb14-12"><a href="#cb14-12" aria-hidden="true" tabindex="-1"></a><span class="co">#example(stan_model, package = "rstan", run.dontrun = TRUE)</span></span>
|
|
|
<span id="cb14-13"><a href="#cb14-13" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb14-14"><a href="#cb14-14" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb14-15"><a href="#cb14-15" aria-hidden="true" tabindex="-1"></a>image_root <span class="ot"><-</span> <span class="st">"./output/withdiff/EffectsOfEnrollmentDelay"</span></span>
|
|
|
<span id="cb14-16"><a href="#cb14-16" aria-hidden="true" tabindex="-1"></a>image_dist_diff_analysis <span class="ot"><-</span> <span class="fu">paste0</span>(image_root,<span class="st">"/dist_diff_analysis"</span>)</span>
|
|
|
<span id="cb14-17"><a href="#cb14-17" aria-hidden="true" tabindex="-1"></a>image_trial_details <span class="ot"><-</span><span class="fu">paste0</span>(image_root,<span class="st">"/trials_details"</span>)</span>
|
|
|
<span id="cb14-18"><a href="#cb14-18" aria-hidden="true" tabindex="-1"></a>image_parameters_by_groups <span class="ot"><-</span><span class="fu">paste0</span>(image_root,<span class="st">"/betas/parameters_by_group"</span>)</span>
|
|
|
<span id="cb14-19"><a href="#cb14-19" aria-hidden="true" tabindex="-1"></a>image_parameters_across_groups <span class="ot"><-</span><span class="fu">paste0</span>(image_root,<span class="st">"/betas/parameter_across_groups"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb15"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="do">################ Pull data from database ######################</span></span>
|
|
|
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(RPostgreSQL)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Loading required package: DBI</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a>host <span class="ot"><-</span> <span class="st">'aact_db-restored-2025-01-07'</span></span>
|
|
|
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a>driver <span class="ot"><-</span> <span class="fu">dbDriver</span>(<span class="st">"PostgreSQL"</span>)</span>
|
|
|
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a>get_data <span class="ot"><-</span> <span class="cf">function</span>(driver) {</span>
|
|
|
<span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-7"><a href="#cb17-7" aria-hidden="true" tabindex="-1"></a>con <span class="ot"><-</span> <span class="fu">dbConnect</span>(</span>
|
|
|
<span id="cb17-8"><a href="#cb17-8" aria-hidden="true" tabindex="-1"></a> driver,</span>
|
|
|
<span id="cb17-9"><a href="#cb17-9" aria-hidden="true" tabindex="-1"></a> <span class="at">user=</span><span class="st">'root'</span>,</span>
|
|
|
<span id="cb17-10"><a href="#cb17-10" aria-hidden="true" tabindex="-1"></a> <span class="at">password=</span><span class="st">'root'</span>,</span>
|
|
|
<span id="cb17-11"><a href="#cb17-11" aria-hidden="true" tabindex="-1"></a> <span class="at">dbname=</span><span class="st">'aact_db'</span>,</span>
|
|
|
<span id="cb17-12"><a href="#cb17-12" aria-hidden="true" tabindex="-1"></a> <span class="at">host=</span>host</span>
|
|
|
<span id="cb17-13"><a href="#cb17-13" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb17-14"><a href="#cb17-14" aria-hidden="true" tabindex="-1"></a><span class="fu">on.exit</span>(<span class="fu">dbDisconnect</span>(con))</span>
|
|
|
<span id="cb17-15"><a href="#cb17-15" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-16"><a href="#cb17-16" aria-hidden="true" tabindex="-1"></a>query <span class="ot"><-</span> <span class="fu">dbSendQuery</span>(</span>
|
|
|
<span id="cb17-17"><a href="#cb17-17" aria-hidden="true" tabindex="-1"></a> con,</span>
|
|
|
<span id="cb17-18"><a href="#cb17-18" aria-hidden="true" tabindex="-1"></a><span class="co"># "select * from formatted_data_with_planned_enrollment;"</span></span>
|
|
|
<span id="cb17-19"><a href="#cb17-19" aria-hidden="true" tabindex="-1"></a><span class="st">"</span></span>
|
|
|
<span id="cb17-20"><a href="#cb17-20" aria-hidden="true" tabindex="-1"></a><span class="st">select </span></span>
|
|
|
<span id="cb17-21"><a href="#cb17-21" aria-hidden="true" tabindex="-1"></a><span class="st"> fdqpe.nct_id</span></span>
|
|
|
<span id="cb17-22"><a href="#cb17-22" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.start_date</span></span>
|
|
|
<span id="cb17-23"><a href="#cb17-23" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.current_enrollment</span></span>
|
|
|
<span id="cb17-24"><a href="#cb17-24" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.enrollment_category</span></span>
|
|
|
<span id="cb17-25"><a href="#cb17-25" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.current_status </span></span>
|
|
|
<span id="cb17-26"><a href="#cb17-26" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.earliest_date_observed </span></span>
|
|
|
<span id="cb17-27"><a href="#cb17-27" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.elapsed_duration</span></span>
|
|
|
<span id="cb17-28"><a href="#cb17-28" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.n_brands as identical_brands</span></span>
|
|
|
<span id="cb17-29"><a href="#cb17-29" aria-hidden="true" tabindex="-1"></a><span class="st"> ,ntbtu.brand_name_counts </span></span>
|
|
|
<span id="cb17-30"><a href="#cb17-30" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.category_id</span></span>
|
|
|
<span id="cb17-31"><a href="#cb17-31" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.final_status</span></span>
|
|
|
<span id="cb17-32"><a href="#cb17-32" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.h_sdi_val</span></span>
|
|
|
<span id="cb17-33"><a href="#cb17-33" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.h_sdi_u95</span></span>
|
|
|
<span id="cb17-34"><a href="#cb17-34" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.h_sdi_l95</span></span>
|
|
|
<span id="cb17-35"><a href="#cb17-35" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.hm_sdi_val</span></span>
|
|
|
<span id="cb17-36"><a href="#cb17-36" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.hm_sdi_u95</span></span>
|
|
|
<span id="cb17-37"><a href="#cb17-37" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.hm_sdi_l95</span></span>
|
|
|
<span id="cb17-38"><a href="#cb17-38" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.m_sdi_val</span></span>
|
|
|
<span id="cb17-39"><a href="#cb17-39" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.m_sdi_u95</span></span>
|
|
|
<span id="cb17-40"><a href="#cb17-40" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.m_sdi_l95</span></span>
|
|
|
<span id="cb17-41"><a href="#cb17-41" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.lm_sdi_val</span></span>
|
|
|
<span id="cb17-42"><a href="#cb17-42" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.lm_sdi_u95</span></span>
|
|
|
<span id="cb17-43"><a href="#cb17-43" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.lm_sdi_l95</span></span>
|
|
|
<span id="cb17-44"><a href="#cb17-44" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.l_sdi_val</span></span>
|
|
|
<span id="cb17-45"><a href="#cb17-45" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.l_sdi_u95</span></span>
|
|
|
<span id="cb17-46"><a href="#cb17-46" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.l_sdi_l95</span></span>
|
|
|
<span id="cb17-47"><a href="#cb17-47" aria-hidden="true" tabindex="-1"></a><span class="st">from formatted_data_with_planned_enrollment fdqpe</span></span>
|
|
|
<span id="cb17-48"><a href="#cb17-48" aria-hidden="true" tabindex="-1"></a><span class="st"> join </span><span class="sc">\"</span><span class="st">Formularies</span><span class="sc">\"</span><span class="st">.nct_to_brand_counts_through_uspdc ntbtu</span></span>
|
|
|
<span id="cb17-49"><a href="#cb17-49" aria-hidden="true" tabindex="-1"></a><span class="st"> on fdqpe.nct_id = ntbtu.nct_id </span></span>
|
|
|
<span id="cb17-50"><a href="#cb17-50" aria-hidden="true" tabindex="-1"></a><span class="st">order by fdqpe.nct_id, fdqpe.earliest_date_observed </span></span>
|
|
|
<span id="cb17-51"><a href="#cb17-51" aria-hidden="true" tabindex="-1"></a><span class="st">;</span></span>
|
|
|
<span id="cb17-52"><a href="#cb17-52" aria-hidden="true" tabindex="-1"></a><span class="st">"</span></span>
|
|
|
<span id="cb17-53"><a href="#cb17-53" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb17-54"><a href="#cb17-54" aria-hidden="true" tabindex="-1"></a>df <span class="ot"><-</span> <span class="fu">fetch</span>(query, <span class="at">n =</span> <span class="sc">-</span><span class="dv">1</span>)</span>
|
|
|
<span id="cb17-55"><a href="#cb17-55" aria-hidden="true" tabindex="-1"></a>df <span class="ot"><-</span> <span class="fu">na.omit</span>(df)</span>
|
|
|
<span id="cb17-56"><a href="#cb17-56" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-57"><a href="#cb17-57" aria-hidden="true" tabindex="-1"></a>query2 <span class="ot"><-</span><span class="fu">dbSendQuery</span>(con,<span class="st">"select count(*) from </span><span class="sc">\"</span><span class="st">DiseaseBurden</span><span class="sc">\"</span><span class="st">.icd10_categories ic where </span><span class="sc">\"</span><span class="st">level</span><span class="sc">\"</span><span class="st">=1;"</span>)</span>
|
|
|
<span id="cb17-58"><a href="#cb17-58" aria-hidden="true" tabindex="-1"></a>n_categories <span class="ot"><-</span> <span class="fu">fetch</span>(query2, <span class="at">n =</span> <span class="sc">-</span><span class="dv">1</span>)</span>
|
|
|
<span id="cb17-59"><a href="#cb17-59" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-60"><a href="#cb17-60" aria-hidden="true" tabindex="-1"></a><span class="fu">return</span>(<span class="fu">list</span>(<span class="at">data=</span>df,<span class="at">ncat=</span>n_categories))</span>
|
|
|
<span id="cb17-61"><a href="#cb17-61" aria-hidden="true" tabindex="-1"></a>}</span>
|
|
|
<span id="cb17-62"><a href="#cb17-62" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-63"><a href="#cb17-63" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-64"><a href="#cb17-64" aria-hidden="true" tabindex="-1"></a>get_counterfact_base <span class="ot"><-</span> <span class="cf">function</span>(driver) {</span>
|
|
|
<span id="cb17-65"><a href="#cb17-65" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-66"><a href="#cb17-66" aria-hidden="true" tabindex="-1"></a>con <span class="ot"><-</span> <span class="fu">dbConnect</span>(</span>
|
|
|
<span id="cb17-67"><a href="#cb17-67" aria-hidden="true" tabindex="-1"></a> driver,</span>
|
|
|
<span id="cb17-68"><a href="#cb17-68" aria-hidden="true" tabindex="-1"></a> <span class="at">user=</span><span class="st">'root'</span>,</span>
|
|
|
<span id="cb17-69"><a href="#cb17-69" aria-hidden="true" tabindex="-1"></a> <span class="at">password=</span><span class="st">'root'</span>,</span>
|
|
|
<span id="cb17-70"><a href="#cb17-70" aria-hidden="true" tabindex="-1"></a> <span class="at">dbname=</span><span class="st">'aact_db'</span>,</span>
|
|
|
<span id="cb17-71"><a href="#cb17-71" aria-hidden="true" tabindex="-1"></a> <span class="at">host=</span>host</span>
|
|
|
<span id="cb17-72"><a href="#cb17-72" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb17-73"><a href="#cb17-73" aria-hidden="true" tabindex="-1"></a><span class="fu">on.exit</span>(<span class="fu">dbDisconnect</span>(con))</span>
|
|
|
<span id="cb17-74"><a href="#cb17-74" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-75"><a href="#cb17-75" aria-hidden="true" tabindex="-1"></a>query <span class="ot"><-</span> <span class="fu">dbSendQuery</span>(</span>
|
|
|
<span id="cb17-76"><a href="#cb17-76" aria-hidden="true" tabindex="-1"></a> con,</span>
|
|
|
<span id="cb17-77"><a href="#cb17-77" aria-hidden="true" tabindex="-1"></a> <span class="st">"</span></span>
|
|
|
<span id="cb17-78"><a href="#cb17-78" aria-hidden="true" tabindex="-1"></a><span class="st"> with cte as (</span></span>
|
|
|
<span id="cb17-79"><a href="#cb17-79" aria-hidden="true" tabindex="-1"></a><span class="st"> --get last recruiting state</span></span>
|
|
|
<span id="cb17-80"><a href="#cb17-80" aria-hidden="true" tabindex="-1"></a><span class="st"> select fd.nct_id, max(fd.earliest_date_observed),min(fd2.earliest_date_observed) as tmstmp</span></span>
|
|
|
<span id="cb17-81"><a href="#cb17-81" aria-hidden="true" tabindex="-1"></a><span class="st"> from formatted_data fd </span></span>
|
|
|
<span id="cb17-82"><a href="#cb17-82" aria-hidden="true" tabindex="-1"></a><span class="st"> join formatted_data fd2 </span></span>
|
|
|
<span id="cb17-83"><a href="#cb17-83" aria-hidden="true" tabindex="-1"></a><span class="st"> on fd.nct_id=fd2.nct_id and fd.earliest_date_observed < fd2.earliest_date_observed </span></span>
|
|
|
<span id="cb17-84"><a href="#cb17-84" aria-hidden="true" tabindex="-1"></a><span class="st"> where fd.current_status = 'Recruiting'</span></span>
|
|
|
<span id="cb17-85"><a href="#cb17-85" aria-hidden="true" tabindex="-1"></a><span class="st"> and fd2.current_status = 'Active, not recruiting'</span></span>
|
|
|
<span id="cb17-86"><a href="#cb17-86" aria-hidden="true" tabindex="-1"></a><span class="st"> group by fd.nct_id </span></span>
|
|
|
<span id="cb17-87"><a href="#cb17-87" aria-hidden="true" tabindex="-1"></a><span class="st"> )</span></span>
|
|
|
<span id="cb17-88"><a href="#cb17-88" aria-hidden="true" tabindex="-1"></a><span class="st"> select </span></span>
|
|
|
<span id="cb17-89"><a href="#cb17-89" aria-hidden="true" tabindex="-1"></a><span class="st"> fdqpe.nct_id</span></span>
|
|
|
<span id="cb17-90"><a href="#cb17-90" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.start_date</span></span>
|
|
|
<span id="cb17-91"><a href="#cb17-91" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.current_enrollment</span></span>
|
|
|
<span id="cb17-92"><a href="#cb17-92" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.enrollment_category</span></span>
|
|
|
<span id="cb17-93"><a href="#cb17-93" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.current_status </span></span>
|
|
|
<span id="cb17-94"><a href="#cb17-94" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.earliest_date_observed </span></span>
|
|
|
<span id="cb17-95"><a href="#cb17-95" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.elapsed_duration</span></span>
|
|
|
<span id="cb17-96"><a href="#cb17-96" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.n_brands as identical_brands</span></span>
|
|
|
<span id="cb17-97"><a href="#cb17-97" aria-hidden="true" tabindex="-1"></a><span class="st"> ,ntbtu.brand_name_counts </span></span>
|
|
|
<span id="cb17-98"><a href="#cb17-98" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.category_id</span></span>
|
|
|
<span id="cb17-99"><a href="#cb17-99" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.final_status</span></span>
|
|
|
<span id="cb17-100"><a href="#cb17-100" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.h_sdi_val</span></span>
|
|
|
<span id="cb17-101"><a href="#cb17-101" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.h_sdi_u95</span></span>
|
|
|
<span id="cb17-102"><a href="#cb17-102" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.h_sdi_l95</span></span>
|
|
|
<span id="cb17-103"><a href="#cb17-103" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.hm_sdi_val</span></span>
|
|
|
<span id="cb17-104"><a href="#cb17-104" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.hm_sdi_u95</span></span>
|
|
|
<span id="cb17-105"><a href="#cb17-105" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.hm_sdi_l95</span></span>
|
|
|
<span id="cb17-106"><a href="#cb17-106" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.m_sdi_val</span></span>
|
|
|
<span id="cb17-107"><a href="#cb17-107" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.m_sdi_u95</span></span>
|
|
|
<span id="cb17-108"><a href="#cb17-108" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.m_sdi_l95</span></span>
|
|
|
<span id="cb17-109"><a href="#cb17-109" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.lm_sdi_val</span></span>
|
|
|
<span id="cb17-110"><a href="#cb17-110" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.lm_sdi_u95</span></span>
|
|
|
<span id="cb17-111"><a href="#cb17-111" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.lm_sdi_l95</span></span>
|
|
|
<span id="cb17-112"><a href="#cb17-112" aria-hidden="true" tabindex="-1"></a><span class="st"> ,fdqpe.l_sdi_val</span></span>
|
|
|
<span id="cb17-113"><a href="#cb17-113" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.l_sdi_u95</span></span>
|
|
|
<span id="cb17-114"><a href="#cb17-114" aria-hidden="true" tabindex="-1"></a><span class="st"> --,fdqpe.l_sdi_l95</span></span>
|
|
|
<span id="cb17-115"><a href="#cb17-115" aria-hidden="true" tabindex="-1"></a><span class="st"> from formatted_data_with_planned_enrollment fdqpe</span></span>
|
|
|
<span id="cb17-116"><a href="#cb17-116" aria-hidden="true" tabindex="-1"></a><span class="st"> join </span><span class="sc">\"</span><span class="st">Formularies</span><span class="sc">\"</span><span class="st">.nct_to_brand_counts_through_uspdc ntbtu</span></span>
|
|
|
<span id="cb17-117"><a href="#cb17-117" aria-hidden="true" tabindex="-1"></a><span class="st"> on fdqpe.nct_id = ntbtu.nct_id </span></span>
|
|
|
<span id="cb17-118"><a href="#cb17-118" aria-hidden="true" tabindex="-1"></a><span class="st"> join cte </span></span>
|
|
|
<span id="cb17-119"><a href="#cb17-119" aria-hidden="true" tabindex="-1"></a><span class="st"> on fdqpe.nct_id = cte.nct_id </span></span>
|
|
|
<span id="cb17-120"><a href="#cb17-120" aria-hidden="true" tabindex="-1"></a><span class="st"> and fdqpe.earliest_date_observed = cte.tmstmp</span></span>
|
|
|
<span id="cb17-121"><a href="#cb17-121" aria-hidden="true" tabindex="-1"></a><span class="st"> order by fdqpe.nct_id, fdqpe.earliest_date_observed </span></span>
|
|
|
<span id="cb17-122"><a href="#cb17-122" aria-hidden="true" tabindex="-1"></a><span class="st"> ;</span></span>
|
|
|
<span id="cb17-123"><a href="#cb17-123" aria-hidden="true" tabindex="-1"></a><span class="st"> "</span></span>
|
|
|
<span id="cb17-124"><a href="#cb17-124" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb17-125"><a href="#cb17-125" aria-hidden="true" tabindex="-1"></a>df <span class="ot"><-</span> <span class="fu">fetch</span>(query, <span class="at">n =</span> <span class="sc">-</span><span class="dv">1</span>)</span>
|
|
|
<span id="cb17-126"><a href="#cb17-126" aria-hidden="true" tabindex="-1"></a>df <span class="ot"><-</span> <span class="fu">na.omit</span>(df)</span>
|
|
|
<span id="cb17-127"><a href="#cb17-127" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-128"><a href="#cb17-128" aria-hidden="true" tabindex="-1"></a>query2 <span class="ot"><-</span><span class="fu">dbSendQuery</span>(con,<span class="st">"select count(*) from </span><span class="sc">\"</span><span class="st">DiseaseBurden</span><span class="sc">\"</span><span class="st">.icd10_categories ic where </span><span class="sc">\"</span><span class="st">level</span><span class="sc">\"</span><span class="st">=1;"</span>)</span>
|
|
|
<span id="cb17-129"><a href="#cb17-129" aria-hidden="true" tabindex="-1"></a>n_categories <span class="ot"><-</span> <span class="fu">fetch</span>(query2, <span class="at">n =</span> <span class="sc">-</span><span class="dv">1</span>)</span>
|
|
|
<span id="cb17-130"><a href="#cb17-130" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-131"><a href="#cb17-131" aria-hidden="true" tabindex="-1"></a><span class="fu">return</span>(<span class="fu">list</span>(<span class="at">data=</span>df,<span class="at">ncat=</span>n_categories))</span>
|
|
|
<span id="cb17-132"><a href="#cb17-132" aria-hidden="true" tabindex="-1"></a>}</span>
|
|
|
<span id="cb17-133"><a href="#cb17-133" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-134"><a href="#cb17-134" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-135"><a href="#cb17-135" aria-hidden="true" tabindex="-1"></a>d <span class="ot"><-</span> <span class="fu">get_data</span>(driver)</span>
|
|
|
<span id="cb17-136"><a href="#cb17-136" aria-hidden="true" tabindex="-1"></a>df <span class="ot"><-</span> d<span class="sc">$</span>data</span>
|
|
|
<span id="cb17-137"><a href="#cb17-137" aria-hidden="true" tabindex="-1"></a>n_categories <span class="ot"><-</span> d<span class="sc">$</span>ncat</span>
|
|
|
<span id="cb17-138"><a href="#cb17-138" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-139"><a href="#cb17-139" aria-hidden="true" tabindex="-1"></a>cf <span class="ot"><-</span> <span class="fu">get_counterfact_base</span>(driver)</span>
|
|
|
<span id="cb17-140"><a href="#cb17-140" aria-hidden="true" tabindex="-1"></a>df_counterfact_base <span class="ot"><-</span> cf<span class="sc">$</span>data</span>
|
|
|
<span id="cb17-141"><a href="#cb17-141" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-142"><a href="#cb17-142" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-143"><a href="#cb17-143" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-144"><a href="#cb17-144" aria-hidden="true" tabindex="-1"></a><span class="do">################ Format Data ###########################</span></span>
|
|
|
<span id="cb17-145"><a href="#cb17-145" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-146"><a href="#cb17-146" aria-hidden="true" tabindex="-1"></a>data_formatter <span class="ot"><-</span> <span class="cf">function</span>(df) {</span>
|
|
|
<span id="cb17-147"><a href="#cb17-147" aria-hidden="true" tabindex="-1"></a>categories <span class="ot"><-</span> df[<span class="st">"category_id"</span>]</span>
|
|
|
<span id="cb17-148"><a href="#cb17-148" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-149"><a href="#cb17-149" aria-hidden="true" tabindex="-1"></a>x <span class="ot"><-</span> df[<span class="st">"elapsed_duration"</span>]</span>
|
|
|
<span id="cb17-150"><a href="#cb17-150" aria-hidden="true" tabindex="-1"></a>x[<span class="st">"identical_brands"</span>] <span class="ot"><-</span> <span class="fu">asinh</span>(df<span class="sc">$</span>identical_brands)</span>
|
|
|
<span id="cb17-151"><a href="#cb17-151" aria-hidden="true" tabindex="-1"></a>x[<span class="st">"brand_name_counts"</span>] <span class="ot"><-</span> <span class="fu">asinh</span>(df<span class="sc">$</span>brand_name_count)</span>
|
|
|
<span id="cb17-152"><a href="#cb17-152" aria-hidden="true" tabindex="-1"></a>x[<span class="st">"h_sdi_val"</span>] <span class="ot"><-</span> <span class="fu">asinh</span>(df<span class="sc">$</span>h_sdi_val)</span>
|
|
|
<span id="cb17-153"><a href="#cb17-153" aria-hidden="true" tabindex="-1"></a>x[<span class="st">"hm_sdi_val"</span>] <span class="ot"><-</span> <span class="fu">asinh</span>(df<span class="sc">$</span>hm_sdi_val)</span>
|
|
|
<span id="cb17-154"><a href="#cb17-154" aria-hidden="true" tabindex="-1"></a>x[<span class="st">"m_sdi_val"</span>] <span class="ot"><-</span> <span class="fu">asinh</span>(df<span class="sc">$</span>m_sdi_val)</span>
|
|
|
<span id="cb17-155"><a href="#cb17-155" aria-hidden="true" tabindex="-1"></a>x[<span class="st">"lm_sdi_val"</span>] <span class="ot"><-</span> <span class="fu">asinh</span>(df<span class="sc">$</span>lm_sdi_val)</span>
|
|
|
<span id="cb17-156"><a href="#cb17-156" aria-hidden="true" tabindex="-1"></a>x[<span class="st">"l_sdi_val"</span>] <span class="ot"><-</span> <span class="fu">asinh</span>(df<span class="sc">$</span>l_sdi_val)</span>
|
|
|
<span id="cb17-157"><a href="#cb17-157" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-158"><a href="#cb17-158" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-159"><a href="#cb17-159" aria-hidden="true" tabindex="-1"></a><span class="co">#Setup fixed effects</span></span>
|
|
|
<span id="cb17-160"><a href="#cb17-160" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-161"><a href="#cb17-161" aria-hidden="true" tabindex="-1"></a>x[<span class="st">"status_NYR"</span>] <span class="ot"><-</span> <span class="fu">ifelse</span>(df[<span class="st">"current_status"</span>]<span class="sc">==</span><span class="st">"Not yet recruiting"</span>,<span class="dv">1</span>,<span class="dv">0</span>)</span>
|
|
|
<span id="cb17-162"><a href="#cb17-162" aria-hidden="true" tabindex="-1"></a>x[<span class="st">"status_EBI"</span>] <span class="ot"><-</span> <span class="fu">ifelse</span>(df[<span class="st">"current_status"</span>]<span class="sc">==</span><span class="st">"Enrolling by invitation"</span>,<span class="dv">1</span>,<span class="dv">0</span>)</span>
|
|
|
<span id="cb17-163"><a href="#cb17-163" aria-hidden="true" tabindex="-1"></a>x[<span class="st">"status_Rec"</span>] <span class="ot"><-</span> <span class="fu">ifelse</span>(df[<span class="st">"current_status"</span>]<span class="sc">==</span><span class="st">"Recruiting"</span>,<span class="dv">1</span>,<span class="dv">0</span>) </span>
|
|
|
<span id="cb17-164"><a href="#cb17-164" aria-hidden="true" tabindex="-1"></a>x[<span class="st">"status_ANR"</span>] <span class="ot"><-</span> <span class="fu">ifelse</span>(df[<span class="st">"current_status"</span>]<span class="sc">==</span><span class="st">"Active, not recruiting"</span>,<span class="dv">1</span>,<span class="dv">0</span>)</span>
|
|
|
<span id="cb17-165"><a href="#cb17-165" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-166"><a href="#cb17-166" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-167"><a href="#cb17-167" aria-hidden="true" tabindex="-1"></a>y <span class="ot"><-</span> <span class="fu">ifelse</span>(df[<span class="st">"final_status"</span>]<span class="sc">==</span><span class="st">"Terminated"</span>,<span class="dv">1</span>,<span class="dv">0</span>)</span>
|
|
|
<span id="cb17-168"><a href="#cb17-168" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-169"><a href="#cb17-169" aria-hidden="true" tabindex="-1"></a><span class="co">#get category list</span></span>
|
|
|
<span id="cb17-170"><a href="#cb17-170" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-171"><a href="#cb17-171" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-172"><a href="#cb17-172" aria-hidden="true" tabindex="-1"></a><span class="fu">return</span>(<span class="fu">list</span>(<span class="at">x=</span>x,<span class="at">y=</span>y))</span>
|
|
|
<span id="cb17-173"><a href="#cb17-173" aria-hidden="true" tabindex="-1"></a>}</span>
|
|
|
<span id="cb17-174"><a href="#cb17-174" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-175"><a href="#cb17-175" aria-hidden="true" tabindex="-1"></a>train <span class="ot"><-</span> <span class="fu">data_formatter</span>(df)</span>
|
|
|
<span id="cb17-176"><a href="#cb17-176" aria-hidden="true" tabindex="-1"></a>counterfact_base <span class="ot"><-</span> <span class="fu">data_formatter</span>(df_counterfact_base)</span>
|
|
|
<span id="cb17-177"><a href="#cb17-177" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-178"><a href="#cb17-178" aria-hidden="true" tabindex="-1"></a>categories <span class="ot"><-</span> df<span class="sc">$</span>category_id</span>
|
|
|
<span id="cb17-179"><a href="#cb17-179" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-180"><a href="#cb17-180" aria-hidden="true" tabindex="-1"></a>x <span class="ot"><-</span> train<span class="sc">$</span>x</span>
|
|
|
<span id="cb17-181"><a href="#cb17-181" aria-hidden="true" tabindex="-1"></a>y <span class="ot"><-</span> train<span class="sc">$</span>y</span>
|
|
|
<span id="cb17-182"><a href="#cb17-182" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb17-183"><a href="#cb17-183" aria-hidden="true" tabindex="-1"></a>x_cf_base <span class="ot"><-</span> counterfact_base<span class="sc">$</span>x</span>
|
|
|
<span id="cb17-184"><a href="#cb17-184" aria-hidden="true" tabindex="-1"></a>y_cf_base <span class="ot"><-</span> counterfact_base<span class="sc">$</span>y</span>
|
|
|
<span id="cb17-185"><a href="#cb17-185" aria-hidden="true" tabindex="-1"></a>cf_categories <span class="ot"><-</span> df_counterfact_base<span class="sc">$</span>category_id</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
</section>
|
|
|
<section id="fit-model" class="level1">
|
|
|
<h1>Fit Model</h1>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb18"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="do">################################# FIT MODEL #########################################</span></span>
|
|
|
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a>inherited_cols <span class="ot"><-</span> <span class="fu">c</span>(</span>
|
|
|
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a> <span class="st">"elapsed_duration"</span></span>
|
|
|
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a> ,<span class="st">"identical_brands"</span></span>
|
|
|
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a> ,<span class="st">"brand_name_counts"</span></span>
|
|
|
<span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a> ,<span class="st">"h_sdi_val"</span></span>
|
|
|
<span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a> ,<span class="st">"hm_sdi_val"</span></span>
|
|
|
<span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a> ,<span class="st">"m_sdi_val"</span></span>
|
|
|
<span id="cb18-9"><a href="#cb18-9" aria-hidden="true" tabindex="-1"></a> ,<span class="st">"lm_sdi_val"</span></span>
|
|
|
<span id="cb18-10"><a href="#cb18-10" aria-hidden="true" tabindex="-1"></a> ,<span class="st">"l_sdi_val"</span></span>
|
|
|
<span id="cb18-11"><a href="#cb18-11" aria-hidden="true" tabindex="-1"></a> ,<span class="st">"status_NYR"</span></span>
|
|
|
<span id="cb18-12"><a href="#cb18-12" aria-hidden="true" tabindex="-1"></a> ,<span class="st">"status_EBI"</span></span>
|
|
|
<span id="cb18-13"><a href="#cb18-13" aria-hidden="true" tabindex="-1"></a> ,<span class="st">"status_Rec"</span></span>
|
|
|
<span id="cb18-14"><a href="#cb18-14" aria-hidden="true" tabindex="-1"></a> ,<span class="st">"status_ANR"</span></span>
|
|
|
<span id="cb18-15"><a href="#cb18-15" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb19"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a>beta_list <span class="ot"><-</span> <span class="fu">list</span>(</span>
|
|
|
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a> <span class="at">groups =</span> <span class="fu">c</span>(</span>
|
|
|
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">1</span><span class="st">`</span><span class="ot">=</span><span class="st">"Infections & Parasites"</span>,</span>
|
|
|
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">2</span><span class="st">`</span><span class="ot">=</span><span class="st">"Neoplasms"</span>,</span>
|
|
|
<span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">3</span><span class="st">`</span><span class="ot">=</span><span class="st">"Blood & Immune system"</span>,</span>
|
|
|
<span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">4</span><span class="st">`</span><span class="ot">=</span><span class="st">"Endocrine, Nutritional, and Metabolic"</span>,</span>
|
|
|
<span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">5</span><span class="st">`</span><span class="ot">=</span><span class="st">"Mental & Behavioral"</span>,</span>
|
|
|
<span id="cb19-8"><a href="#cb19-8" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">6</span><span class="st">`</span><span class="ot">=</span><span class="st">"Nervous System"</span>,</span>
|
|
|
<span id="cb19-9"><a href="#cb19-9" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">7</span><span class="st">`</span><span class="ot">=</span><span class="st">"Eye and Adnexa"</span>,</span>
|
|
|
<span id="cb19-10"><a href="#cb19-10" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">8</span><span class="st">`</span><span class="ot">=</span><span class="st">"Ear and Mastoid"</span>,</span>
|
|
|
<span id="cb19-11"><a href="#cb19-11" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">9</span><span class="st">`</span><span class="ot">=</span><span class="st">"Circulatory"</span>,</span>
|
|
|
<span id="cb19-12"><a href="#cb19-12" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">10</span><span class="st">`</span><span class="ot">=</span><span class="st">"Respiratory"</span>,</span>
|
|
|
<span id="cb19-13"><a href="#cb19-13" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">11</span><span class="st">`</span><span class="ot">=</span><span class="st">"Digestive"</span>,</span>
|
|
|
<span id="cb19-14"><a href="#cb19-14" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">12</span><span class="st">`</span><span class="ot">=</span><span class="st">"Skin & Subcutaneaous tissue"</span>,</span>
|
|
|
<span id="cb19-15"><a href="#cb19-15" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">13</span><span class="st">`</span><span class="ot">=</span><span class="st">"Musculoskeletal"</span>,</span>
|
|
|
<span id="cb19-16"><a href="#cb19-16" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">14</span><span class="st">`</span><span class="ot">=</span><span class="st">"Genitourinary"</span>,</span>
|
|
|
<span id="cb19-17"><a href="#cb19-17" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">15</span><span class="st">`</span><span class="ot">=</span><span class="st">"Pregancy, Childbirth, & Puerperium"</span>,</span>
|
|
|
<span id="cb19-18"><a href="#cb19-18" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">16</span><span class="st">`</span><span class="ot">=</span><span class="st">"Perinatal Period"</span>,</span>
|
|
|
<span id="cb19-19"><a href="#cb19-19" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">17</span><span class="st">`</span><span class="ot">=</span><span class="st">"Congential"</span>,</span>
|
|
|
<span id="cb19-20"><a href="#cb19-20" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">18</span><span class="st">`</span><span class="ot">=</span><span class="st">"Symptoms, Signs etc."</span>,</span>
|
|
|
<span id="cb19-21"><a href="#cb19-21" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">19</span><span class="st">`</span><span class="ot">=</span><span class="st">"Injury etc."</span>,</span>
|
|
|
<span id="cb19-22"><a href="#cb19-22" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">20</span><span class="st">`</span><span class="ot">=</span><span class="st">"External Causes"</span>,</span>
|
|
|
<span id="cb19-23"><a href="#cb19-23" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">21</span><span class="st">`</span><span class="ot">=</span><span class="st">"Contact with Healthcare"</span>,</span>
|
|
|
<span id="cb19-24"><a href="#cb19-24" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">22</span><span class="st">`</span><span class="ot">=</span><span class="st">"Special Purposes"</span></span>
|
|
|
<span id="cb19-25"><a href="#cb19-25" aria-hidden="true" tabindex="-1"></a> ),</span>
|
|
|
<span id="cb19-26"><a href="#cb19-26" aria-hidden="true" tabindex="-1"></a> <span class="at">parameters =</span> <span class="fu">c</span>(</span>
|
|
|
<span id="cb19-27"><a href="#cb19-27" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">1</span><span class="st">`</span><span class="ot">=</span><span class="st">"Elapsed Duration"</span>,</span>
|
|
|
<span id="cb19-28"><a href="#cb19-28" aria-hidden="true" tabindex="-1"></a> <span class="co"># brands</span></span>
|
|
|
<span id="cb19-29"><a href="#cb19-29" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">2</span><span class="st">`</span><span class="ot">=</span><span class="st">"asinh(Generic Brands)"</span>,</span>
|
|
|
<span id="cb19-30"><a href="#cb19-30" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">3</span><span class="st">`</span><span class="ot">=</span><span class="st">"asinh(Competitors USPDC)"</span>,</span>
|
|
|
<span id="cb19-31"><a href="#cb19-31" aria-hidden="true" tabindex="-1"></a> <span class="co"># population</span></span>
|
|
|
<span id="cb19-32"><a href="#cb19-32" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">4</span><span class="st">`</span><span class="ot">=</span><span class="st">"asinh(High SDI)"</span>,</span>
|
|
|
<span id="cb19-33"><a href="#cb19-33" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">5</span><span class="st">`</span><span class="ot">=</span><span class="st">"asinh(High-Medium SDI)"</span>,</span>
|
|
|
<span id="cb19-34"><a href="#cb19-34" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">6</span><span class="st">`</span><span class="ot">=</span><span class="st">"asinh(Medium SDI)"</span>,</span>
|
|
|
<span id="cb19-35"><a href="#cb19-35" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">7</span><span class="st">`</span><span class="ot">=</span><span class="st">"asinh(Low-Medium SDI)"</span>,</span>
|
|
|
<span id="cb19-36"><a href="#cb19-36" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">8</span><span class="st">`</span><span class="ot">=</span><span class="st">"asinh(Low SDI)"</span>,</span>
|
|
|
<span id="cb19-37"><a href="#cb19-37" aria-hidden="true" tabindex="-1"></a> <span class="co">#Status</span></span>
|
|
|
<span id="cb19-38"><a href="#cb19-38" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">9</span><span class="st">`</span><span class="ot">=</span><span class="st">"status_NYR"</span>,</span>
|
|
|
<span id="cb19-39"><a href="#cb19-39" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">10</span><span class="st">`</span><span class="ot">=</span><span class="st">"status_EBI"</span>,</span>
|
|
|
<span id="cb19-40"><a href="#cb19-40" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">11</span><span class="st">`</span><span class="ot">=</span><span class="st">"status_Rec"</span>,</span>
|
|
|
<span id="cb19-41"><a href="#cb19-41" aria-hidden="true" tabindex="-1"></a> <span class="st">`</span><span class="at">12</span><span class="st">`</span><span class="ot">=</span><span class="st">"status_ANR"</span></span>
|
|
|
<span id="cb19-42"><a href="#cb19-42" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb19-43"><a href="#cb19-43" aria-hidden="true" tabindex="-1"></a>)</span>
|
|
|
<span id="cb19-44"><a href="#cb19-44" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb19-45"><a href="#cb19-45" aria-hidden="true" tabindex="-1"></a>get_parameters <span class="ot"><-</span> <span class="cf">function</span>(stem,class_list) {</span>
|
|
|
<span id="cb19-46"><a href="#cb19-46" aria-hidden="true" tabindex="-1"></a> <span class="co">#get categories and lengths</span></span>
|
|
|
<span id="cb19-47"><a href="#cb19-47" aria-hidden="true" tabindex="-1"></a> named <span class="ot"><-</span> <span class="fu">names</span>(class_list)</span>
|
|
|
<span id="cb19-48"><a href="#cb19-48" aria-hidden="true" tabindex="-1"></a> lengths <span class="ot"><-</span> <span class="fu">sapply</span>(named, (<span class="cf">function</span> (x) <span class="fu">length</span>(class_list[[x]])))</span>
|
|
|
<span id="cb19-49"><a href="#cb19-49" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb19-50"><a href="#cb19-50" aria-hidden="true" tabindex="-1"></a> <span class="co">#describe the grid needed</span></span>
|
|
|
<span id="cb19-51"><a href="#cb19-51" aria-hidden="true" tabindex="-1"></a> iter_list <span class="ot"><-</span> <span class="fu">sapply</span>(named, (<span class="cf">function</span> (x) <span class="dv">1</span><span class="sc">:</span>lengths[x]))</span>
|
|
|
<span id="cb19-52"><a href="#cb19-52" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb19-53"><a href="#cb19-53" aria-hidden="true" tabindex="-1"></a> <span class="co">#generate the list of parameters</span></span>
|
|
|
<span id="cb19-54"><a href="#cb19-54" aria-hidden="true" tabindex="-1"></a> pardf <span class="ot"><-</span> <span class="fu">generate_parameter_df</span>(stem, iter_list)</span>
|
|
|
<span id="cb19-55"><a href="#cb19-55" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb19-56"><a href="#cb19-56" aria-hidden="true" tabindex="-1"></a> <span class="co">#add columns with appropriate human-readable names</span></span>
|
|
|
<span id="cb19-57"><a href="#cb19-57" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> (name <span class="cf">in</span> named) {</span>
|
|
|
<span id="cb19-58"><a href="#cb19-58" aria-hidden="true" tabindex="-1"></a> pardf[<span class="fu">paste</span>(name,<span class="st">"_hr"</span>,<span class="at">sep=</span><span class="st">""</span>)] <span class="ot"><-</span> <span class="fu">as.factor</span>(</span>
|
|
|
<span id="cb19-59"><a href="#cb19-59" aria-hidden="true" tabindex="-1"></a> <span class="fu">sapply</span>(pardf[name], (<span class="cf">function</span> (i) class_list[[name]][i]))</span>
|
|
|
<span id="cb19-60"><a href="#cb19-60" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb19-61"><a href="#cb19-61" aria-hidden="true" tabindex="-1"></a> }</span>
|
|
|
<span id="cb19-62"><a href="#cb19-62" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb19-63"><a href="#cb19-63" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(pardf) </span>
|
|
|
<span id="cb19-64"><a href="#cb19-64" aria-hidden="true" tabindex="-1"></a>}</span>
|
|
|
<span id="cb19-65"><a href="#cb19-65" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb19-66"><a href="#cb19-66" aria-hidden="true" tabindex="-1"></a>generate_parameter_df <span class="ot"><-</span> <span class="cf">function</span>(stem, iter_list) {</span>
|
|
|
<span id="cb19-67"><a href="#cb19-67" aria-hidden="true" tabindex="-1"></a> grid <span class="ot"><-</span> <span class="fu">expand.grid</span>(iter_list)</span>
|
|
|
<span id="cb19-68"><a href="#cb19-68" aria-hidden="true" tabindex="-1"></a> grid[<span class="st">"param_name"</span>] <span class="ot"><-</span> grid <span class="sc">%>%</span> <span class="fu">unite</span>(x,<span class="fu">colnames</span>(grid),<span class="at">sep=</span><span class="st">","</span>)</span>
|
|
|
<span id="cb19-69"><a href="#cb19-69" aria-hidden="true" tabindex="-1"></a> grid[<span class="st">"param_name"</span>] <span class="ot"><-</span> <span class="fu">paste</span>(stem,<span class="st">"["</span>,grid<span class="sc">$</span>param_name,<span class="st">"]"</span>,<span class="at">sep=</span><span class="st">""</span>)</span>
|
|
|
<span id="cb19-70"><a href="#cb19-70" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(grid)</span>
|
|
|
<span id="cb19-71"><a href="#cb19-71" aria-hidden="true" tabindex="-1"></a>}</span>
|
|
|
<span id="cb19-72"><a href="#cb19-72" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb19-73"><a href="#cb19-73" aria-hidden="true" tabindex="-1"></a>group_mcmc_areas <span class="ot"><-</span> <span class="cf">function</span>(</span>
|
|
|
<span id="cb19-74"><a href="#cb19-74" aria-hidden="true" tabindex="-1"></a> stem,<span class="co"># = "beta"</span></span>
|
|
|
<span id="cb19-75"><a href="#cb19-75" aria-hidden="true" tabindex="-1"></a> class_list,<span class="co"># = beta_list</span></span>
|
|
|
<span id="cb19-76"><a href="#cb19-76" aria-hidden="true" tabindex="-1"></a> stanfit,<span class="co"># = fit</span></span>
|
|
|
<span id="cb19-77"><a href="#cb19-77" aria-hidden="true" tabindex="-1"></a> group_id,<span class="co"># = 2</span></span>
|
|
|
<span id="cb19-78"><a href="#cb19-78" aria-hidden="true" tabindex="-1"></a> <span class="at">rename=</span><span class="cn">TRUE</span>,</span>
|
|
|
<span id="cb19-79"><a href="#cb19-79" aria-hidden="true" tabindex="-1"></a> <span class="at">filter=</span><span class="cn">NULL</span></span>
|
|
|
<span id="cb19-80"><a href="#cb19-80" aria-hidden="true" tabindex="-1"></a> ) {</span>
|
|
|
<span id="cb19-81"><a href="#cb19-81" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb19-82"><a href="#cb19-82" aria-hidden="true" tabindex="-1"></a> <span class="co">#get all parameter names</span></span>
|
|
|
<span id="cb19-83"><a href="#cb19-83" aria-hidden="true" tabindex="-1"></a> params <span class="ot"><-</span> <span class="fu">get_parameters</span>(stem,class_list)</span>
|
|
|
<span id="cb19-84"><a href="#cb19-84" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb19-85"><a href="#cb19-85" aria-hidden="true" tabindex="-1"></a> <span class="co">#filter down to parameters of interest</span></span>
|
|
|
<span id="cb19-86"><a href="#cb19-86" aria-hidden="true" tabindex="-1"></a> params <span class="ot"><-</span> <span class="fu">filter</span>(params,groups <span class="sc">==</span> group_id)</span>
|
|
|
<span id="cb19-87"><a href="#cb19-87" aria-hidden="true" tabindex="-1"></a> <span class="co">#Get dataframe with only the rows of interest</span></span>
|
|
|
<span id="cb19-88"><a href="#cb19-88" aria-hidden="true" tabindex="-1"></a> filtdata <span class="ot"><-</span> <span class="fu">as.data.frame</span>(stanfit)[params<span class="sc">$</span>param_name]</span>
|
|
|
<span id="cb19-89"><a href="#cb19-89" aria-hidden="true" tabindex="-1"></a> <span class="co">#rename columns</span></span>
|
|
|
<span id="cb19-90"><a href="#cb19-90" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> (rename) <span class="fu">dimnames</span>(filtdata)[[<span class="dv">2</span>]] <span class="ot"><-</span> params<span class="sc">$</span>parameters_hr</span>
|
|
|
<span id="cb19-91"><a href="#cb19-91" aria-hidden="true" tabindex="-1"></a> <span class="co">#get group name for title</span></span>
|
|
|
<span id="cb19-92"><a href="#cb19-92" aria-hidden="true" tabindex="-1"></a> group_name <span class="ot"><-</span> class_list<span class="sc">$</span>groups[group_id]</span>
|
|
|
<span id="cb19-93"><a href="#cb19-93" aria-hidden="true" tabindex="-1"></a> <span class="co">#create area plot with appropriate title</span></span>
|
|
|
<span id="cb19-94"><a href="#cb19-94" aria-hidden="true" tabindex="-1"></a> p <span class="ot"><-</span> <span class="fu">mcmc_areas</span>(filtdata,<span class="at">prob =</span> <span class="fl">0.8</span>, <span class="at">prob_outer =</span> <span class="fl">0.95</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb19-95"><a href="#cb19-95" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggtitle</span>(<span class="fu">paste</span>(<span class="st">"Parameter distributions for ICD-10 class:"</span>,group_name)) <span class="sc">+</span></span>
|
|
|
<span id="cb19-96"><a href="#cb19-96" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="at">xintercept=</span><span class="fu">seq</span>(<span class="sc">-</span><span class="dv">2</span>,<span class="dv">2</span>,<span class="fl">0.5</span>),<span class="at">color=</span><span class="st">"grey"</span>,<span class="at">alpha=</span><span class="fl">0.750</span>) </span>
|
|
|
<span id="cb19-97"><a href="#cb19-97" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb19-98"><a href="#cb19-98" aria-hidden="true" tabindex="-1"></a> d <span class="ot"><-</span> <span class="fu">pivot_longer</span>(filtdata, <span class="fu">everything</span>()) <span class="sc">|></span> </span>
|
|
|
<span id="cb19-99"><a href="#cb19-99" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(name) <span class="sc">|></span> </span>
|
|
|
<span id="cb19-100"><a href="#cb19-100" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarize</span>(</span>
|
|
|
<span id="cb19-101"><a href="#cb19-101" aria-hidden="true" tabindex="-1"></a> <span class="at">mean=</span><span class="fu">mean</span>(value)</span>
|
|
|
<span id="cb19-102"><a href="#cb19-102" aria-hidden="true" tabindex="-1"></a> ,<span class="at">q025 =</span> <span class="fu">quantile</span>(value,<span class="at">probs =</span> <span class="fl">0.025</span>)</span>
|
|
|
<span id="cb19-103"><a href="#cb19-103" aria-hidden="true" tabindex="-1"></a> ,<span class="at">q975 =</span> <span class="fu">quantile</span>(value,<span class="at">probs =</span> <span class="fl">0.975</span>)</span>
|
|
|
<span id="cb19-104"><a href="#cb19-104" aria-hidden="true" tabindex="-1"></a> ,<span class="at">q05 =</span> <span class="fu">quantile</span>(value,<span class="at">probs =</span> <span class="fl">0.05</span>)</span>
|
|
|
<span id="cb19-105"><a href="#cb19-105" aria-hidden="true" tabindex="-1"></a> ,<span class="at">q95 =</span> <span class="fu">quantile</span>(value,<span class="at">probs =</span> <span class="fl">0.95</span>)</span>
|
|
|
<span id="cb19-106"><a href="#cb19-106" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb19-107"><a href="#cb19-107" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(<span class="fu">list</span>(<span class="at">plot=</span>p,<span class="at">quantiles=</span>d,<span class="at">name=</span>group_name))</span>
|
|
|
<span id="cb19-108"><a href="#cb19-108" aria-hidden="true" tabindex="-1"></a>}</span>
|
|
|
<span id="cb19-109"><a href="#cb19-109" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb19-110"><a href="#cb19-110" aria-hidden="true" tabindex="-1"></a>parameter_mcmc_areas <span class="ot"><-</span> <span class="cf">function</span>(</span>
|
|
|
<span id="cb19-111"><a href="#cb19-111" aria-hidden="true" tabindex="-1"></a> stem,<span class="co"># = "beta"</span></span>
|
|
|
<span id="cb19-112"><a href="#cb19-112" aria-hidden="true" tabindex="-1"></a> class_list,<span class="co"># = beta_list</span></span>
|
|
|
<span id="cb19-113"><a href="#cb19-113" aria-hidden="true" tabindex="-1"></a> stanfit,<span class="co"># = fit</span></span>
|
|
|
<span id="cb19-114"><a href="#cb19-114" aria-hidden="true" tabindex="-1"></a> parameter_id,<span class="co"># = 2</span></span>
|
|
|
<span id="cb19-115"><a href="#cb19-115" aria-hidden="true" tabindex="-1"></a> <span class="at">rename=</span><span class="cn">TRUE</span></span>
|
|
|
<span id="cb19-116"><a href="#cb19-116" aria-hidden="true" tabindex="-1"></a> ) {</span>
|
|
|
<span id="cb19-117"><a href="#cb19-117" aria-hidden="true" tabindex="-1"></a> <span class="co">#get all parameter names</span></span>
|
|
|
<span id="cb19-118"><a href="#cb19-118" aria-hidden="true" tabindex="-1"></a> params <span class="ot"><-</span> <span class="fu">get_parameters</span>(stem,class_list)</span>
|
|
|
<span id="cb19-119"><a href="#cb19-119" aria-hidden="true" tabindex="-1"></a> <span class="co">#filter down to parameters of interest</span></span>
|
|
|
<span id="cb19-120"><a href="#cb19-120" aria-hidden="true" tabindex="-1"></a> params <span class="ot"><-</span> <span class="fu">filter</span>(params,parameters <span class="sc">==</span> parameter_id)</span>
|
|
|
<span id="cb19-121"><a href="#cb19-121" aria-hidden="true" tabindex="-1"></a> <span class="co">#Get dataframe with only the rows of interest</span></span>
|
|
|
<span id="cb19-122"><a href="#cb19-122" aria-hidden="true" tabindex="-1"></a> filtdata <span class="ot"><-</span> <span class="fu">as.data.frame</span>(stanfit)[params<span class="sc">$</span>param_name]</span>
|
|
|
<span id="cb19-123"><a href="#cb19-123" aria-hidden="true" tabindex="-1"></a> <span class="co">#rename columns</span></span>
|
|
|
<span id="cb19-124"><a href="#cb19-124" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> (rename) <span class="fu">dimnames</span>(filtdata)[[<span class="dv">2</span>]] <span class="ot"><-</span> params<span class="sc">$</span>groups_hr</span>
|
|
|
<span id="cb19-125"><a href="#cb19-125" aria-hidden="true" tabindex="-1"></a> <span class="co">#get group name for title</span></span>
|
|
|
<span id="cb19-126"><a href="#cb19-126" aria-hidden="true" tabindex="-1"></a> parameter_name <span class="ot"><-</span> class_list<span class="sc">$</span>parameters[parameter_id]</span>
|
|
|
<span id="cb19-127"><a href="#cb19-127" aria-hidden="true" tabindex="-1"></a> <span class="co">#create area plot with appropriate title</span></span>
|
|
|
<span id="cb19-128"><a href="#cb19-128" aria-hidden="true" tabindex="-1"></a> p <span class="ot"><-</span> <span class="fu">mcmc_areas</span>(filtdata,<span class="at">prob =</span> <span class="fl">0.8</span>, <span class="at">prob_outer =</span> <span class="fl">0.95</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb19-129"><a href="#cb19-129" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggtitle</span>(parameter_name,<span class="st">"Parameter Distribution"</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb19-130"><a href="#cb19-130" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="at">xintercept=</span><span class="fu">seq</span>(<span class="sc">-</span><span class="dv">2</span>,<span class="dv">2</span>,<span class="fl">0.5</span>),<span class="at">color=</span><span class="st">"grey"</span>,<span class="at">alpha=</span><span class="fl">0.750</span>) </span>
|
|
|
<span id="cb19-131"><a href="#cb19-131" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb19-132"><a href="#cb19-132" aria-hidden="true" tabindex="-1"></a> d <span class="ot"><-</span> <span class="fu">pivot_longer</span>(filtdata, <span class="fu">everything</span>()) <span class="sc">|></span> </span>
|
|
|
<span id="cb19-133"><a href="#cb19-133" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(name) <span class="sc">|></span> </span>
|
|
|
<span id="cb19-134"><a href="#cb19-134" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarize</span>(</span>
|
|
|
<span id="cb19-135"><a href="#cb19-135" aria-hidden="true" tabindex="-1"></a> <span class="at">mean=</span><span class="fu">mean</span>(value)</span>
|
|
|
<span id="cb19-136"><a href="#cb19-136" aria-hidden="true" tabindex="-1"></a> ,<span class="at">q025 =</span> <span class="fu">quantile</span>(value,<span class="at">probs =</span> <span class="fl">0.025</span>)</span>
|
|
|
<span id="cb19-137"><a href="#cb19-137" aria-hidden="true" tabindex="-1"></a> ,<span class="at">q975 =</span> <span class="fu">quantile</span>(value,<span class="at">probs =</span> <span class="fl">0.975</span>)</span>
|
|
|
<span id="cb19-138"><a href="#cb19-138" aria-hidden="true" tabindex="-1"></a> ,<span class="at">q05 =</span> <span class="fu">quantile</span>(value,<span class="at">probs =</span> <span class="fl">0.05</span>)</span>
|
|
|
<span id="cb19-139"><a href="#cb19-139" aria-hidden="true" tabindex="-1"></a> ,<span class="at">q95 =</span> <span class="fu">quantile</span>(value,<span class="at">probs =</span> <span class="fl">0.95</span>)</span>
|
|
|
<span id="cb19-140"><a href="#cb19-140" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb19-141"><a href="#cb19-141" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(<span class="fu">list</span>(<span class="at">plot=</span>p,<span class="at">quantiles=</span>d,<span class="at">name=</span>parameter_name))</span>
|
|
|
<span id="cb19-142"><a href="#cb19-142" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
<p>Plan: select all snapshots that are the first to have closed enrollment (Rec -> ANR when comparing across snapshots), and then</p>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb20"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="co">#delay intervention</span></span>
|
|
|
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a>intervention_enrollment <span class="ot"><-</span> x_cf_base[<span class="fu">c</span>(inherited_cols)]</span>
|
|
|
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a><span class="co">#TOFIX: ^^^ This ordering of columns is</span></span>
|
|
|
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a>intervention_enrollment[<span class="st">"status_ANR"</span>] <span class="ot"><-</span> <span class="dv">0</span></span>
|
|
|
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a>intervention_enrollment[<span class="st">"status_Rec"</span>] <span class="ot"><-</span> <span class="dv">1</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb21"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a>counterfact_delay <span class="ot"><-</span> <span class="fu">list</span>(</span>
|
|
|
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a> <span class="at">D =</span> <span class="fu">ncol</span>(x),<span class="co">#</span></span>
|
|
|
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a> <span class="at">N =</span> <span class="fu">nrow</span>(x),</span>
|
|
|
<span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a> <span class="at">L =</span> n_categories<span class="sc">$</span>count,</span>
|
|
|
<span id="cb21-5"><a href="#cb21-5" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="fu">as.vector</span>(y),</span>
|
|
|
<span id="cb21-6"><a href="#cb21-6" aria-hidden="true" tabindex="-1"></a> <span class="at">ll =</span> <span class="fu">as.vector</span>(categories),</span>
|
|
|
<span id="cb21-7"><a href="#cb21-7" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">as.matrix</span>(x),</span>
|
|
|
<span id="cb21-8"><a href="#cb21-8" aria-hidden="true" tabindex="-1"></a> <span class="at">mu_mean =</span> <span class="dv">0</span>,</span>
|
|
|
<span id="cb21-9"><a href="#cb21-9" aria-hidden="true" tabindex="-1"></a> <span class="at">mu_stdev =</span> <span class="fl">0.05</span>,</span>
|
|
|
<span id="cb21-10"><a href="#cb21-10" aria-hidden="true" tabindex="-1"></a> <span class="at">sigma_shape =</span> <span class="dv">4</span>,</span>
|
|
|
<span id="cb21-11"><a href="#cb21-11" aria-hidden="true" tabindex="-1"></a> <span class="at">sigma_rate =</span> <span class="dv">20</span>,</span>
|
|
|
<span id="cb21-12"><a href="#cb21-12" aria-hidden="true" tabindex="-1"></a> <span class="at">Nx =</span> <span class="fu">nrow</span>(x_cf_base),</span>
|
|
|
<span id="cb21-13"><a href="#cb21-13" aria-hidden="true" tabindex="-1"></a> <span class="at">llx =</span> <span class="fu">as.vector</span>(cf_categories),</span>
|
|
|
<span id="cb21-14"><a href="#cb21-14" aria-hidden="true" tabindex="-1"></a> <span class="at">counterfact_x_tilde =</span> <span class="fu">as.matrix</span>(intervention_enrollment),</span>
|
|
|
<span id="cb21-15"><a href="#cb21-15" aria-hidden="true" tabindex="-1"></a> <span class="at">counterfact_x =</span> <span class="fu">as.matrix</span>(x_cf_base),</span>
|
|
|
<span id="cb21-16"><a href="#cb21-16" aria-hidden="true" tabindex="-1"></a> <span class="at">status_indexes =</span> <span class="fu">c</span>(<span class="dv">11</span>,<span class="dv">12</span>) <span class="co">#subtract anr from recruiting to get movement from anr to recruiting</span></span>
|
|
|
<span id="cb21-17"><a href="#cb21-17" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb22"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a>fit <span class="ot"><-</span> <span class="fu">stan</span>(</span>
|
|
|
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a> <span class="at">file=</span><span class="st">'Hierarchal_Logistic.stan'</span>, </span>
|
|
|
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a> <span class="at">data =</span> counterfact_delay,</span>
|
|
|
<span id="cb22-4"><a href="#cb22-4" aria-hidden="true" tabindex="-1"></a> <span class="at">chains =</span> <span class="dv">4</span>,</span>
|
|
|
<span id="cb22-5"><a href="#cb22-5" aria-hidden="true" tabindex="-1"></a> <span class="at">iter =</span> <span class="dv">5000</span>,</span>
|
|
|
<span id="cb22-6"><a href="#cb22-6" aria-hidden="true" tabindex="-1"></a> <span class="at">seed =</span> <span class="dv">11021585</span></span>
|
|
|
<span id="cb22-7"><a href="#cb22-7" aria-hidden="true" tabindex="-1"></a> )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
|
|
|
Running the chains for more iterations may help. See
|
|
|
https://mc-stan.org/misc/warnings.html#bulk-ess</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<section id="calculate-relative-difference-in-parameters-between-recruiting-and-active-not-recruiting-states" class="level2">
|
|
|
<h2 class="anchored" data-anchor-id="calculate-relative-difference-in-parameters-between-recruiting-and-active-not-recruiting-states">Calculate relative difference in parameters between recruiting and active not recruiting states</h2>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb24"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a>filt_data <span class="ot"><-</span> <span class="fu">as.data.frame</span>(<span class="fu">extract</span>(fit,<span class="at">pars=</span><span class="st">"status_diff"</span>))</span>
|
|
|
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a><span class="fu">dimnames</span>(filt_data)[[<span class="dv">2</span>]] <span class="ot"><-</span> beta_list<span class="sc">$</span>groups</span>
|
|
|
<span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a><span class="fu">mcmc_areas</span>(filt_data,<span class="at">prob =</span> <span class="fl">0.8</span>, <span class="at">prob_outer =</span> <span class="fl">0.95</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb24-4"><a href="#cb24-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggtitle</span>(<span class="st">"Relative fixed effects across groups"</span>, <span class="at">subtitle =</span><span class="st">"moving from `Active, not recruiting` to `Recruiting`"</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb24-5"><a href="#cb24-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="at">xintercept=</span><span class="fu">seq</span>(<span class="sc">-</span><span class="dv">2</span>,<span class="dv">2</span>,<span class="fl">0.5</span>),<span class="at">color=</span><span class="st">"grey"</span>,<span class="at">alpha=</span><span class="fl">0.750</span>) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 3 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-8-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<p>I’ve got an issue here, because this should be a movement from ANR -> recruiting but that is suggesting that</p>
|
|
|
</section>
|
|
|
<section id="explore-data" class="level2">
|
|
|
<h2 class="anchored" data-anchor-id="explore-data">Explore data</h2>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb26"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="co">#get number of trials and snapshots in each category</span></span>
|
|
|
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a>group_trials_by_category <span class="ot"><-</span> <span class="fu">as.data.frame</span>(<span class="fu">aggregate</span>(category_id <span class="sc">~</span> nct_id, df, max))</span>
|
|
|
<span id="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a>group_trials_by_category <span class="ot"><-</span> <span class="fu">as.data.frame</span>(group_trials_by_category)</span>
|
|
|
<span id="cb26-4"><a href="#cb26-4" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb26-5"><a href="#cb26-5" aria-hidden="true" tabindex="-1"></a>category_count <span class="ot"><-</span> group_trials_by_category <span class="sc">|></span> <span class="fu">group_by</span>(category_id) <span class="sc">|></span> <span class="fu">count</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb27"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a><span class="do">################################# DATA EXPLORATION ############################</span></span>
|
|
|
<span id="cb27-2"><a href="#cb27-2" aria-hidden="true" tabindex="-1"></a>driver <span class="ot"><-</span> <span class="fu">dbDriver</span>(<span class="st">"PostgreSQL"</span>)</span>
|
|
|
<span id="cb27-3"><a href="#cb27-3" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb27-4"><a href="#cb27-4" aria-hidden="true" tabindex="-1"></a>con <span class="ot"><-</span> <span class="fu">dbConnect</span>(</span>
|
|
|
<span id="cb27-5"><a href="#cb27-5" aria-hidden="true" tabindex="-1"></a> driver,</span>
|
|
|
<span id="cb27-6"><a href="#cb27-6" aria-hidden="true" tabindex="-1"></a> <span class="at">user=</span><span class="st">'root'</span>,</span>
|
|
|
<span id="cb27-7"><a href="#cb27-7" aria-hidden="true" tabindex="-1"></a> <span class="at">password=</span><span class="st">'root'</span>,</span>
|
|
|
<span id="cb27-8"><a href="#cb27-8" aria-hidden="true" tabindex="-1"></a> <span class="at">dbname=</span><span class="st">'aact_db'</span>,</span>
|
|
|
<span id="cb27-9"><a href="#cb27-9" aria-hidden="true" tabindex="-1"></a> <span class="at">host=</span>host</span>
|
|
|
<span id="cb27-10"><a href="#cb27-10" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb27-11"><a href="#cb27-11" aria-hidden="true" tabindex="-1"></a><span class="co">#Plot histogram of count of snapshots</span></span>
|
|
|
<span id="cb27-12"><a href="#cb27-12" aria-hidden="true" tabindex="-1"></a>df3 <span class="ot"><-</span> <span class="fu">dbGetQuery</span>(</span>
|
|
|
<span id="cb27-13"><a href="#cb27-13" aria-hidden="true" tabindex="-1"></a> con,</span>
|
|
|
<span id="cb27-14"><a href="#cb27-14" aria-hidden="true" tabindex="-1"></a> <span class="st">"select nct_id,final_status,count(*) from formatted_data_with_planned_enrollment fdwpe </span></span>
|
|
|
<span id="cb27-15"><a href="#cb27-15" aria-hidden="true" tabindex="-1"></a><span class="st"> group by nct_id,final_status ;"</span></span>
|
|
|
<span id="cb27-16"><a href="#cb27-16" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb27-17"><a href="#cb27-17" aria-hidden="true" tabindex="-1"></a><span class="co">#df3 <- fetch(query3, n = -1)</span></span>
|
|
|
<span id="cb27-18"><a href="#cb27-18" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb27-19"><a href="#cb27-19" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(<span class="at">data=</span>df3, <span class="fu">aes</span>(<span class="at">x=</span>count, <span class="at">fill=</span>final_status)) <span class="sc">+</span> </span>
|
|
|
<span id="cb27-20"><a href="#cb27-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_histogram</span>(<span class="at">binwidth=</span><span class="dv">1</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb27-21"><a href="#cb27-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggtitle</span>(<span class="st">"Histogram of snapshots per trial (matched trials)"</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb27-22"><a href="#cb27-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">xlab</span>(<span class="st">"Snapshots per trial"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-10-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb28"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_trial_details,<span class="st">"/HistSnapshots.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb30"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a><span class="co">#Plot duration for terminated vs completed</span></span>
|
|
|
<span id="cb30-2"><a href="#cb30-2" aria-hidden="true" tabindex="-1"></a>df4 <span class="ot"><-</span> <span class="fu">dbGetQuery</span>(</span>
|
|
|
<span id="cb30-3"><a href="#cb30-3" aria-hidden="true" tabindex="-1"></a> con,</span>
|
|
|
<span id="cb30-4"><a href="#cb30-4" aria-hidden="true" tabindex="-1"></a> <span class="st">"</span></span>
|
|
|
<span id="cb30-5"><a href="#cb30-5" aria-hidden="true" tabindex="-1"></a><span class="st"> select </span></span>
|
|
|
<span id="cb30-6"><a href="#cb30-6" aria-hidden="true" tabindex="-1"></a><span class="st"> nct_id, </span></span>
|
|
|
<span id="cb30-7"><a href="#cb30-7" aria-hidden="true" tabindex="-1"></a><span class="st"> start_date , </span></span>
|
|
|
<span id="cb30-8"><a href="#cb30-8" aria-hidden="true" tabindex="-1"></a><span class="st"> primary_completion_date, </span></span>
|
|
|
<span id="cb30-9"><a href="#cb30-9" aria-hidden="true" tabindex="-1"></a><span class="st"> overall_status ,</span></span>
|
|
|
<span id="cb30-10"><a href="#cb30-10" aria-hidden="true" tabindex="-1"></a><span class="st"> primary_completion_date - start_date as duration</span></span>
|
|
|
<span id="cb30-11"><a href="#cb30-11" aria-hidden="true" tabindex="-1"></a><span class="st"> from ctgov.studies s </span></span>
|
|
|
<span id="cb30-12"><a href="#cb30-12" aria-hidden="true" tabindex="-1"></a><span class="st"> where nct_id in (select distinct nct_id from http.download_status ds)</span></span>
|
|
|
<span id="cb30-13"><a href="#cb30-13" aria-hidden="true" tabindex="-1"></a><span class="st"> ;"</span></span>
|
|
|
<span id="cb30-14"><a href="#cb30-14" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb30-15"><a href="#cb30-15" aria-hidden="true" tabindex="-1"></a><span class="co">#df4 <- fetch(query4, n = -1)</span></span>
|
|
|
<span id="cb30-16"><a href="#cb30-16" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb30-17"><a href="#cb30-17" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(<span class="at">data=</span>df4, <span class="fu">aes</span>(<span class="at">x=</span>duration,<span class="at">fill=</span>overall_status)) <span class="sc">+</span></span>
|
|
|
<span id="cb30-18"><a href="#cb30-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_histogram</span>()<span class="sc">+</span></span>
|
|
|
<span id="cb30-19"><a href="#cb30-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggtitle</span>(<span class="st">"Histogram of trial durations"</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb30-20"><a href="#cb30-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">xlab</span>(<span class="st">"duration"</span>)<span class="sc">+</span></span>
|
|
|
<span id="cb30-21"><a href="#cb30-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">facet_wrap</span>(<span class="sc">~</span>overall_status)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-10-2.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb32"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1"><a href="#cb32-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_trial_details,<span class="st">"/HistTrialDurations_Faceted.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image
|
|
|
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb34"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a>df5 <span class="ot"><-</span> <span class="fu">dbGetQuery</span>(</span>
|
|
|
<span id="cb34-2"><a href="#cb34-2" aria-hidden="true" tabindex="-1"></a> con,</span>
|
|
|
<span id="cb34-3"><a href="#cb34-3" aria-hidden="true" tabindex="-1"></a> <span class="st">"</span></span>
|
|
|
<span id="cb34-4"><a href="#cb34-4" aria-hidden="true" tabindex="-1"></a><span class="st"> with cte1 as (</span></span>
|
|
|
<span id="cb34-5"><a href="#cb34-5" aria-hidden="true" tabindex="-1"></a><span class="st"> select </span></span>
|
|
|
<span id="cb34-6"><a href="#cb34-6" aria-hidden="true" tabindex="-1"></a><span class="st"> nct_id, </span></span>
|
|
|
<span id="cb34-7"><a href="#cb34-7" aria-hidden="true" tabindex="-1"></a><span class="st"> start_date , </span></span>
|
|
|
<span id="cb34-8"><a href="#cb34-8" aria-hidden="true" tabindex="-1"></a><span class="st"> primary_completion_date, </span></span>
|
|
|
<span id="cb34-9"><a href="#cb34-9" aria-hidden="true" tabindex="-1"></a><span class="st"> overall_status ,</span></span>
|
|
|
<span id="cb34-10"><a href="#cb34-10" aria-hidden="true" tabindex="-1"></a><span class="st"> primary_completion_date - start_date as duration</span></span>
|
|
|
<span id="cb34-11"><a href="#cb34-11" aria-hidden="true" tabindex="-1"></a><span class="st"> from ctgov.studies s </span></span>
|
|
|
<span id="cb34-12"><a href="#cb34-12" aria-hidden="true" tabindex="-1"></a><span class="st"> where nct_id in (select distinct nct_id from http.download_status ds)</span></span>
|
|
|
<span id="cb34-13"><a href="#cb34-13" aria-hidden="true" tabindex="-1"></a><span class="st"> ), cte2 as (</span></span>
|
|
|
<span id="cb34-14"><a href="#cb34-14" aria-hidden="true" tabindex="-1"></a><span class="st"> select nct_id,count(*) as snapshot_count from formatted_data_with_planned_enrollment fdwpe</span></span>
|
|
|
<span id="cb34-15"><a href="#cb34-15" aria-hidden="true" tabindex="-1"></a><span class="st"> group by nct_id</span></span>
|
|
|
<span id="cb34-16"><a href="#cb34-16" aria-hidden="true" tabindex="-1"></a><span class="st"> )</span></span>
|
|
|
<span id="cb34-17"><a href="#cb34-17" aria-hidden="true" tabindex="-1"></a><span class="st"> select a.nct_id, a.overall_status, a.duration,b.snapshot_count</span></span>
|
|
|
<span id="cb34-18"><a href="#cb34-18" aria-hidden="true" tabindex="-1"></a><span class="st"> from cte1 as a</span></span>
|
|
|
<span id="cb34-19"><a href="#cb34-19" aria-hidden="true" tabindex="-1"></a><span class="st"> join cte2 as b </span></span>
|
|
|
<span id="cb34-20"><a href="#cb34-20" aria-hidden="true" tabindex="-1"></a><span class="st"> on a.nct_id=b.nct_id</span></span>
|
|
|
<span id="cb34-21"><a href="#cb34-21" aria-hidden="true" tabindex="-1"></a><span class="st"> ;"</span></span>
|
|
|
<span id="cb34-22"><a href="#cb34-22" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb34-23"><a href="#cb34-23" aria-hidden="true" tabindex="-1"></a>df5<span class="sc">$</span>overall_status <span class="ot"><-</span> <span class="fu">as.factor</span>(df5<span class="sc">$</span>overall_status)</span>
|
|
|
<span id="cb34-24"><a href="#cb34-24" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb34-25"><a href="#cb34-25" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(<span class="at">data=</span>df5, <span class="fu">aes</span>(<span class="at">x=</span>duration,<span class="at">y=</span>snapshot_count,<span class="at">color=</span>overall_status)) <span class="sc">+</span></span>
|
|
|
<span id="cb34-26"><a href="#cb34-26" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_jitter</span>() <span class="sc">+</span></span>
|
|
|
<span id="cb34-27"><a href="#cb34-27" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggtitle</span>(<span class="st">"Comparison of duration, status, and snapshot_count"</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb34-28"><a href="#cb34-28" aria-hidden="true" tabindex="-1"></a> <span class="fu">xlab</span>(<span class="st">"duration"</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb34-29"><a href="#cb34-29" aria-hidden="true" tabindex="-1"></a> <span class="fu">ylab</span>(<span class="st">"snapshot count"</span>) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-10-3.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb35"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_trial_details,<span class="st">"/SnapshotsVsDurationVsTermination.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb37"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb37-1"><a href="#cb37-1" aria-hidden="true" tabindex="-1"></a><span class="fu">dbDisconnect</span>(con)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] TRUE</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb39"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb39-1"><a href="#cb39-1" aria-hidden="true" tabindex="-1"></a><span class="co">#get number of trials and snapshots in each category</span></span>
|
|
|
<span id="cb39-2"><a href="#cb39-2" aria-hidden="true" tabindex="-1"></a>group_trials_by_category <span class="ot"><-</span> <span class="fu">as.data.frame</span>(<span class="fu">aggregate</span>(category_id <span class="sc">~</span> nct_id, df, max))</span>
|
|
|
<span id="cb39-3"><a href="#cb39-3" aria-hidden="true" tabindex="-1"></a>group_trials_by_category <span class="ot"><-</span> <span class="fu">as.data.frame</span>(group_trials_by_category)</span>
|
|
|
<span id="cb39-4"><a href="#cb39-4" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb39-5"><a href="#cb39-5" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(<span class="at">data =</span> group_trials_by_category, <span class="fu">aes</span>(<span class="at">x=</span>category_id)) <span class="sc">+</span></span>
|
|
|
<span id="cb39-6"><a href="#cb39-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_bar</span>(<span class="at">binwidth=</span><span class="dv">1</span>,<span class="at">color=</span><span class="st">"black"</span>,<span class="at">fill=</span><span class="st">"lightblue"</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb39-7"><a href="#cb39-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_x_continuous</span>(<span class="at">breaks=</span>scales<span class="sc">::</span><span class="fu">pretty_breaks</span>(<span class="at">n=</span><span class="dv">22</span>)) <span class="sc">+</span> </span>
|
|
|
<span id="cb39-8"><a href="#cb39-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb39-9"><a href="#cb39-9" aria-hidden="true" tabindex="-1"></a> <span class="at">title=</span><span class="st">"bar chart of trial categories"</span></span>
|
|
|
<span id="cb39-10"><a href="#cb39-10" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x=</span><span class="st">"Category ID"</span></span>
|
|
|
<span id="cb39-11"><a href="#cb39-11" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y=</span><span class="st">"Count"</span></span>
|
|
|
<span id="cb39-12"><a href="#cb39-12" aria-hidden="true" tabindex="-1"></a> )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning in geom_bar(binwidth = 1, color = "black", fill = "lightblue"):
|
|
|
Ignoring unknown parameters: `binwidth`</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-10-4.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb41"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb41-1"><a href="#cb41-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_trial_details,<span class="st">"/CategoryCounts.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb43"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb43-1"><a href="#cb43-1" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(df5)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code> nct_id overall_status duration snapshot_count
|
|
|
Length:162 Completed :134 Min. : 61.0 Min. : 1.000
|
|
|
Class :character Terminated: 28 1st Qu.: 618.5 1st Qu.: 4.000
|
|
|
Mode :character Median :1022.5 Median : 6.000
|
|
|
Mean :1202.4 Mean : 8.315
|
|
|
3rd Qu.:1637.0 3rd Qu.:11.000
|
|
|
Max. :3332.0 Max. :48.000 </code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb45"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb45-1"><a href="#cb45-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cor</span>(df5<span class="sc">$</span>duration,df5<span class="sc">$</span>snapshot_count)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 0.3356006</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb47"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb47-1"><a href="#cb47-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sum</span>(df5<span class="sc">$</span>snapshot_count)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 1347</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
</section>
|
|
|
<section id="fit-results" class="level2">
|
|
|
<h2 class="anchored" data-anchor-id="fit-results">Fit Results</h2>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb49"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb49-1"><a href="#cb49-1" aria-hidden="true" tabindex="-1"></a><span class="do">################################# ANALYZE #####################################</span></span>
|
|
|
<span id="cb49-2"><a href="#cb49-2" aria-hidden="true" tabindex="-1"></a><span class="co">#print(fit)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
</section>
|
|
|
</section>
|
|
|
<section id="parameter-distributions" class="level1">
|
|
|
<h1>Parameter Distributions</h1>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb50"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb50-1"><a href="#cb50-1" aria-hidden="true" tabindex="-1"></a><span class="co">#g1 <- group_mcmc_areas("beta",beta_list,fit,1)</span></span>
|
|
|
<span id="cb50-2"><a href="#cb50-2" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb50-3"><a href="#cb50-3" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb50-4"><a href="#cb50-4" aria-hidden="true" tabindex="-1"></a>gx <span class="ot"><-</span> <span class="fu">c</span>()</span>
|
|
|
<span id="cb50-5"><a href="#cb50-5" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb50-6"><a href="#cb50-6" aria-hidden="true" tabindex="-1"></a><span class="co">#grab parameters for every category with more than 8 observations</span></span>
|
|
|
<span id="cb50-7"><a href="#cb50-7" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> category_count<span class="sc">$</span>category_id[category_count<span class="sc">$</span>n <span class="sc">>=</span> <span class="dv">0</span>]) {</span>
|
|
|
<span id="cb50-8"><a href="#cb50-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span>(i)</span>
|
|
|
<span id="cb50-9"><a href="#cb50-9" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb50-10"><a href="#cb50-10" aria-hidden="true" tabindex="-1"></a> <span class="co">#Print parameter distributions</span></span>
|
|
|
<span id="cb50-11"><a href="#cb50-11" aria-hidden="true" tabindex="-1"></a> gi <span class="ot"><-</span> <span class="fu">group_mcmc_areas</span>(<span class="st">"beta"</span>,beta_list,fit,i) <span class="co">#add way to filter groups</span></span>
|
|
|
<span id="cb50-12"><a href="#cb50-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggsave</span>(</span>
|
|
|
<span id="cb50-13"><a href="#cb50-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">paste0</span>(image_parameters_by_groups,<span class="st">"/group_"</span>,i,<span class="st">"_"</span>,gi<span class="sc">$</span>name,<span class="st">".png"</span>)</span>
|
|
|
<span id="cb50-14"><a href="#cb50-14" aria-hidden="true" tabindex="-1"></a> ,<span class="at">plot=</span>gi<span class="sc">$</span>plot</span>
|
|
|
<span id="cb50-15"><a href="#cb50-15" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb50-16"><a href="#cb50-16" aria-hidden="true" tabindex="-1"></a> gx <span class="ot"><-</span> <span class="fu">c</span>(gx,gi)</span>
|
|
|
<span id="cb50-17"><a href="#cb50-17" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb50-18"><a href="#cb50-18" aria-hidden="true" tabindex="-1"></a> <span class="co">#Get Quantiles and means for parameters</span></span>
|
|
|
<span id="cb50-19"><a href="#cb50-19" aria-hidden="true" tabindex="-1"></a><span class="co"># table <- xtable(gi$quantiles,</span></span>
|
|
|
<span id="cb50-20"><a href="#cb50-20" aria-hidden="true" tabindex="-1"></a><span class="co"># floating=FALSE</span></span>
|
|
|
<span id="cb50-21"><a href="#cb50-21" aria-hidden="true" tabindex="-1"></a><span class="co"># ,latex.environments = NULL</span></span>
|
|
|
<span id="cb50-22"><a href="#cb50-22" aria-hidden="true" tabindex="-1"></a><span class="co"># ,booktabs = TRUE</span></span>
|
|
|
<span id="cb50-23"><a href="#cb50-23" aria-hidden="true" tabindex="-1"></a><span class="co"># ,zap=getOption("digits")</span></span>
|
|
|
<span id="cb50-24"><a href="#cb50-24" aria-hidden="true" tabindex="-1"></a><span class="co"># )</span></span>
|
|
|
<span id="cb50-25"><a href="#cb50-25" aria-hidden="true" tabindex="-1"></a><span class="co"># write_lines(table,paste0("./latex_output/DirectEffects/group_",gi$name,".tex"))</span></span>
|
|
|
<span id="cb50-26"><a href="#cb50-26" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 1</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 3 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 2</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 2 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 3</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 2 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 4</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 2 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 5</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 1 row containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 6</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 2 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 7</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 3 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 9</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 3 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 10</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 3 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 11</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 2 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 12</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 1 row containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 13</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 14</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 3 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 17</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 2 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>[1] 18</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 2 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb95"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb95-1"><a href="#cb95-1" aria-hidden="true" tabindex="-1"></a>px <span class="ot"><-</span> <span class="fu">c</span>()</span>
|
|
|
<span id="cb95-2"><a href="#cb95-2" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb95-3"><a href="#cb95-3" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb95-4"><a href="#cb95-4" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>,<span class="dv">3</span>,<span class="dv">9</span>,<span class="dv">10</span>,<span class="dv">11</span>,<span class="dv">12</span>)) {</span>
|
|
|
<span id="cb95-5"><a href="#cb95-5" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb95-6"><a href="#cb95-6" aria-hidden="true" tabindex="-1"></a> <span class="co">#Print parameter distributions</span></span>
|
|
|
<span id="cb95-7"><a href="#cb95-7" aria-hidden="true" tabindex="-1"></a> pi <span class="ot"><-</span> <span class="fu">parameter_mcmc_areas</span>(<span class="st">"beta"</span>,beta_list,fit,i) <span class="co">#add way to filter groups</span></span>
|
|
|
<span id="cb95-8"><a href="#cb95-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggsave</span>(</span>
|
|
|
<span id="cb95-9"><a href="#cb95-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">paste0</span>(image_parameters_across_groups,<span class="st">"/parameters_"</span>,i,<span class="st">"_"</span>,pi<span class="sc">$</span>name,<span class="st">".png"</span>)</span>
|
|
|
<span id="cb95-10"><a href="#cb95-10" aria-hidden="true" tabindex="-1"></a> ,<span class="at">plot=</span>pi<span class="sc">$</span>plot</span>
|
|
|
<span id="cb95-11"><a href="#cb95-11" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb95-12"><a href="#cb95-12" aria-hidden="true" tabindex="-1"></a> px <span class="ot"><-</span> <span class="fu">c</span>(px,pi)</span>
|
|
|
<span id="cb95-13"><a href="#cb95-13" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb95-14"><a href="#cb95-14" aria-hidden="true" tabindex="-1"></a> <span class="co">#Get Quantiles and means for parameters</span></span>
|
|
|
<span id="cb95-15"><a href="#cb95-15" aria-hidden="true" tabindex="-1"></a><span class="co"># table <- xtable(pi$quantiles,</span></span>
|
|
|
<span id="cb95-16"><a href="#cb95-16" aria-hidden="true" tabindex="-1"></a><span class="co"># floating=FALSE</span></span>
|
|
|
<span id="cb95-17"><a href="#cb95-17" aria-hidden="true" tabindex="-1"></a><span class="co"># ,latex.environments = NULL</span></span>
|
|
|
<span id="cb95-18"><a href="#cb95-18" aria-hidden="true" tabindex="-1"></a><span class="co"># ,booktabs = TRUE</span></span>
|
|
|
<span id="cb95-19"><a href="#cb95-19" aria-hidden="true" tabindex="-1"></a><span class="co"># ,zap=getOption("digits")</span></span>
|
|
|
<span id="cb95-20"><a href="#cb95-20" aria-hidden="true" tabindex="-1"></a><span class="co"># )</span></span>
|
|
|
<span id="cb95-21"><a href="#cb95-21" aria-hidden="true" tabindex="-1"></a><span class="co"># write_lines(table,paste0("./latex_output/DirectEffects/parameters_",i,"_",pi$name,".tex"))</span></span>
|
|
|
<span id="cb95-22"><a href="#cb95-22" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb95-23"><a href="#cb95-23" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 6 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image
|
|
|
Saving 7 x 5 in image
|
|
|
Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 3 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 6 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 5 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 5 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<p>Note these have 95% outer CI and 80% inner (shaded)</p>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb106"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb106-1"><a href="#cb106-1" aria-hidden="true" tabindex="-1"></a><span class="co">#get the generic and uspdc parameters</span></span>
|
|
|
<span id="cb106-2"><a href="#cb106-2" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(px[<span class="dv">4</span>]<span class="sc">$</span>plot <span class="sc">+</span> px[<span class="dv">7</span>]<span class="sc">$</span>plot)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-14-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb107"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb107-1"><a href="#cb107-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_parameters_across_groups,<span class="st">"2+3_generic_and_uspdc.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb109"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb109-1"><a href="#cb109-1" aria-hidden="true" tabindex="-1"></a><span class="co">#get the parameters associated with duration</span></span>
|
|
|
<span id="cb109-2"><a href="#cb109-2" aria-hidden="true" tabindex="-1"></a>px[<span class="dv">16</span>]<span class="sc">$</span>plot <span class="sc">+</span> px[<span class="dv">19</span>]<span class="sc">$</span>plot</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 5 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).
|
|
|
Removed 5 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-14-2.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb111"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb111-1"><a href="#cb111-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_parameters_across_groups,<span class="st">"11+12_statusREC_and_statusANR.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Warning: Removed 5 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).
|
|
|
Removed 5 rows containing missing values or values outside the scale range
|
|
|
(`geom_vline()`).</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
</section>
|
|
|
<section id="counterfactuals" class="level1">
|
|
|
<h1>Counterfactuals</h1>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb114"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb114-1"><a href="#cb114-1" aria-hidden="true" tabindex="-1"></a>generated_ib <span class="ot"><-</span> <span class="fu">gqs</span>(</span>
|
|
|
<span id="cb114-2"><a href="#cb114-2" aria-hidden="true" tabindex="-1"></a> fit<span class="sc">@</span>stanmodel,</span>
|
|
|
<span id="cb114-3"><a href="#cb114-3" aria-hidden="true" tabindex="-1"></a> <span class="at">data=</span>counterfact_delay,</span>
|
|
|
<span id="cb114-4"><a href="#cb114-4" aria-hidden="true" tabindex="-1"></a> <span class="at">draws=</span><span class="fu">as.matrix</span>(fit),</span>
|
|
|
<span id="cb114-5"><a href="#cb114-5" aria-hidden="true" tabindex="-1"></a> <span class="at">seed=</span><span class="dv">11021585</span></span>
|
|
|
<span id="cb114-6"><a href="#cb114-6" aria-hidden="true" tabindex="-1"></a> )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
<section id="get-priors" class="level3">
|
|
|
<h3 class="anchored" data-anchor-id="get-priors">Get priors</h3>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb115"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb115-1"><a href="#cb115-1" aria-hidden="true" tabindex="-1"></a>df_ib_p <span class="ot"><-</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb115-2"><a href="#cb115-2" aria-hidden="true" tabindex="-1"></a> <span class="at">p_prior=</span><span class="fu">as.vector</span>(<span class="fu">extract</span>(generated_ib, <span class="at">pars=</span><span class="st">"p_prior"</span>)<span class="sc">$</span>p_prior)</span>
|
|
|
<span id="cb115-3"><a href="#cb115-3" aria-hidden="true" tabindex="-1"></a> ,<span class="at">p_predicted =</span> <span class="fu">as.vector</span>(<span class="fu">extract</span>(generated_ib, <span class="at">pars=</span><span class="st">"p_predicted"</span>)<span class="sc">$</span>p_predicted)</span>
|
|
|
<span id="cb115-4"><a href="#cb115-4" aria-hidden="true" tabindex="-1"></a>)</span>
|
|
|
<span id="cb115-5"><a href="#cb115-5" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb115-6"><a href="#cb115-6" aria-hidden="true" tabindex="-1"></a>df_ib_prior <span class="ot"><-</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb115-7"><a href="#cb115-7" aria-hidden="true" tabindex="-1"></a> <span class="at">mu_prior =</span> <span class="fu">as.vector</span>(<span class="fu">extract</span>(generated_ib, <span class="at">pars=</span><span class="st">"mu_prior"</span>)<span class="sc">$</span>mu_prior)</span>
|
|
|
<span id="cb115-8"><a href="#cb115-8" aria-hidden="true" tabindex="-1"></a> ,<span class="at">sigma_prior =</span> <span class="fu">as.vector</span>(<span class="fu">extract</span>(generated_ib, <span class="at">pars=</span><span class="st">"sigma_prior"</span>)<span class="sc">$</span>sigma_prior)</span>
|
|
|
<span id="cb115-9"><a href="#cb115-9" aria-hidden="true" tabindex="-1"></a>)</span>
|
|
|
<span id="cb115-10"><a href="#cb115-10" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb115-11"><a href="#cb115-11" aria-hidden="true" tabindex="-1"></a><span class="co">#p_prior</span></span>
|
|
|
<span id="cb115-12"><a href="#cb115-12" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(df_ib_p, <span class="fu">aes</span>(<span class="at">x=</span>p_prior)) <span class="sc">+</span></span>
|
|
|
<span id="cb115-13"><a href="#cb115-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>() <span class="sc">+</span> </span>
|
|
|
<span id="cb115-14"><a href="#cb115-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb115-15"><a href="#cb115-15" aria-hidden="true" tabindex="-1"></a> <span class="at">title=</span><span class="st">"implied prior distribution p"</span></span>
|
|
|
<span id="cb115-16"><a href="#cb115-16" aria-hidden="true" tabindex="-1"></a> ,<span class="at">subtitle=</span><span class="st">""</span></span>
|
|
|
<span id="cb115-17"><a href="#cb115-17" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x=</span><span class="st">"probability domain 'p'"</span></span>
|
|
|
<span id="cb115-18"><a href="#cb115-18" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y=</span><span class="st">"probability density"</span></span>
|
|
|
<span id="cb115-19"><a href="#cb115-19" aria-hidden="true" tabindex="-1"></a> )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-16-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb116"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb116-1"><a href="#cb116-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"/prior_p.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb118"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb118-1"><a href="#cb118-1" aria-hidden="true" tabindex="-1"></a><span class="co">#p_posterior</span></span>
|
|
|
<span id="cb118-2"><a href="#cb118-2" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(df_ib_p, <span class="fu">aes</span>(<span class="at">x=</span>p_predicted)) <span class="sc">+</span></span>
|
|
|
<span id="cb118-3"><a href="#cb118-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>() <span class="sc">+</span> </span>
|
|
|
<span id="cb118-4"><a href="#cb118-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb118-5"><a href="#cb118-5" aria-hidden="true" tabindex="-1"></a> <span class="at">title=</span><span class="st">"implied posterior distribution p"</span></span>
|
|
|
<span id="cb118-6"><a href="#cb118-6" aria-hidden="true" tabindex="-1"></a> ,<span class="at">subtitle=</span><span class="st">""</span></span>
|
|
|
<span id="cb118-7"><a href="#cb118-7" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x=</span><span class="st">"probability domain 'p'"</span></span>
|
|
|
<span id="cb118-8"><a href="#cb118-8" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y=</span><span class="st">"Probability Density"</span></span>
|
|
|
<span id="cb118-9"><a href="#cb118-9" aria-hidden="true" tabindex="-1"></a> )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-16-2.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb119"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb119-1"><a href="#cb119-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"/posterior_p.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb121"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb121-1"><a href="#cb121-1" aria-hidden="true" tabindex="-1"></a><span class="co">#mu_prior</span></span>
|
|
|
<span id="cb121-2"><a href="#cb121-2" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(df_ib_prior) <span class="sc">+</span></span>
|
|
|
<span id="cb121-3"><a href="#cb121-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>(<span class="fu">aes</span>(<span class="at">x=</span>mu_prior)) <span class="sc">+</span> </span>
|
|
|
<span id="cb121-4"><a href="#cb121-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb121-5"><a href="#cb121-5" aria-hidden="true" tabindex="-1"></a> <span class="at">title=</span><span class="st">"Prior - Mu"</span></span>
|
|
|
<span id="cb121-6"><a href="#cb121-6" aria-hidden="true" tabindex="-1"></a> ,<span class="at">subtitle=</span><span class="st">"same prior for all Mu values"</span></span>
|
|
|
<span id="cb121-7"><a href="#cb121-7" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x=</span><span class="st">"Mu"</span></span>
|
|
|
<span id="cb121-8"><a href="#cb121-8" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y=</span><span class="st">"Probability"</span></span>
|
|
|
<span id="cb121-9"><a href="#cb121-9" aria-hidden="true" tabindex="-1"></a> )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-16-3.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb122"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb122-1"><a href="#cb122-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"/prior_mu.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb124"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb124-1"><a href="#cb124-1" aria-hidden="true" tabindex="-1"></a><span class="co">#sigma_posterior</span></span>
|
|
|
<span id="cb124-2"><a href="#cb124-2" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(df_ib_prior) <span class="sc">+</span></span>
|
|
|
<span id="cb124-3"><a href="#cb124-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>(<span class="fu">aes</span>(<span class="at">x=</span>sigma_prior)) <span class="sc">+</span> </span>
|
|
|
<span id="cb124-4"><a href="#cb124-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb124-5"><a href="#cb124-5" aria-hidden="true" tabindex="-1"></a> <span class="at">title=</span><span class="st">"Prior - Sigma"</span></span>
|
|
|
<span id="cb124-6"><a href="#cb124-6" aria-hidden="true" tabindex="-1"></a> ,<span class="at">subtitle=</span><span class="st">"same prior for all Sigma values"</span></span>
|
|
|
<span id="cb124-7"><a href="#cb124-7" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x=</span><span class="st">"Sigma"</span></span>
|
|
|
<span id="cb124-8"><a href="#cb124-8" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y=</span><span class="st">"Probability"</span></span>
|
|
|
<span id="cb124-9"><a href="#cb124-9" aria-hidden="true" tabindex="-1"></a> )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-16-4.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb125"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb125-1"><a href="#cb125-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"/prior_sigma.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb127"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb127-1"><a href="#cb127-1" aria-hidden="true" tabindex="-1"></a><span class="fu">check_hmc_diagnostics</span>(fit)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>
|
|
|
Divergences:</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>0 of 10000 iterations ended with a divergence.</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>
|
|
|
Tree depth:</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>0 of 10000 iterations saturated the maximum tree depth of 10.</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code>
|
|
|
Energy:</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>E-BFMI indicated no pathological behavior.</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
</section>
|
|
|
<section id="intervention-delay-close-of-enrollment" class="level3">
|
|
|
<h3 class="anchored" data-anchor-id="intervention-delay-close-of-enrollment">Intervention: Delay close of enrollment</h3>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb134"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb134-1"><a href="#cb134-1" aria-hidden="true" tabindex="-1"></a>counterfact_predicted_ib <span class="ot"><-</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb134-2"><a href="#cb134-2" aria-hidden="true" tabindex="-1"></a> <span class="at">p_predicted_default =</span> <span class="fu">as.vector</span>(<span class="fu">extract</span>(generated_ib, <span class="at">pars=</span><span class="st">"p_predicted_default"</span>)<span class="sc">$</span>p_predicted_default)</span>
|
|
|
<span id="cb134-3"><a href="#cb134-3" aria-hidden="true" tabindex="-1"></a> ,<span class="at">p_predicted_intervention =</span> <span class="fu">as.vector</span>(<span class="fu">extract</span>(generated_ib, <span class="at">pars=</span><span class="st">"p_predicted_intervention"</span>)<span class="sc">$</span>p_predicted_intervention)</span>
|
|
|
<span id="cb134-4"><a href="#cb134-4" aria-hidden="true" tabindex="-1"></a> ,<span class="at">predicted_difference =</span> <span class="fu">as.vector</span>(<span class="fu">extract</span>(generated_ib, <span class="at">pars=</span><span class="st">"predicted_difference"</span>)<span class="sc">$</span>predicted_difference)</span>
|
|
|
<span id="cb134-5"><a href="#cb134-5" aria-hidden="true" tabindex="-1"></a>)</span>
|
|
|
<span id="cb134-6"><a href="#cb134-6" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb134-7"><a href="#cb134-7" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb134-8"><a href="#cb134-8" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(counterfact_predicted_ib, <span class="fu">aes</span>(<span class="at">x=</span>p_predicted_default)) <span class="sc">+</span></span>
|
|
|
<span id="cb134-9"><a href="#cb134-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>() <span class="sc">+</span> </span>
|
|
|
<span id="cb134-10"><a href="#cb134-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb134-11"><a href="#cb134-11" aria-hidden="true" tabindex="-1"></a> <span class="at">title=</span><span class="st">"Predicted Distribution of 'p'"</span></span>
|
|
|
<span id="cb134-12"><a href="#cb134-12" aria-hidden="true" tabindex="-1"></a> ,<span class="at">subtitle=</span><span class="st">"Intervention: None"</span></span>
|
|
|
<span id="cb134-13"><a href="#cb134-13" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x=</span><span class="st">"Probability Domain 'p'"</span></span>
|
|
|
<span id="cb134-14"><a href="#cb134-14" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y=</span><span class="st">"Probability Density"</span></span>
|
|
|
<span id="cb134-15"><a href="#cb134-15" aria-hidden="true" tabindex="-1"></a> )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-18-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb135"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb135-1"><a href="#cb135-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"p_no_intervention.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb137"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb137-1"><a href="#cb137-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(counterfact_predicted_ib, <span class="fu">aes</span>(<span class="at">x=</span>p_predicted_intervention)) <span class="sc">+</span></span>
|
|
|
<span id="cb137-2"><a href="#cb137-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>() <span class="sc">+</span> </span>
|
|
|
<span id="cb137-3"><a href="#cb137-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb137-4"><a href="#cb137-4" aria-hidden="true" tabindex="-1"></a> <span class="at">title=</span><span class="st">"Predicted Distribution of 'p'"</span></span>
|
|
|
<span id="cb137-5"><a href="#cb137-5" aria-hidden="true" tabindex="-1"></a> ,<span class="at">subtitle=</span><span class="st">"Intervention: Delay close of enrollment"</span></span>
|
|
|
<span id="cb137-6"><a href="#cb137-6" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x=</span><span class="st">"Probability Domain 'p'"</span></span>
|
|
|
<span id="cb137-7"><a href="#cb137-7" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y=</span><span class="st">"Probability Density"</span></span>
|
|
|
<span id="cb137-8"><a href="#cb137-8" aria-hidden="true" tabindex="-1"></a> )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-18-2.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb138"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb138-1"><a href="#cb138-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"/p_delay_intervention.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb140"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb140-1"><a href="#cb140-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(counterfact_predicted_ib, <span class="fu">aes</span>(<span class="at">x=</span>predicted_difference)) <span class="sc">+</span></span>
|
|
|
<span id="cb140-2"><a href="#cb140-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>() <span class="sc">+</span> </span>
|
|
|
<span id="cb140-3"><a href="#cb140-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb140-4"><a href="#cb140-4" aria-hidden="true" tabindex="-1"></a> <span class="at">title=</span><span class="st">"Predicted Distribution of differences 'p'"</span></span>
|
|
|
<span id="cb140-5"><a href="#cb140-5" aria-hidden="true" tabindex="-1"></a> ,<span class="at">subtitle=</span><span class="st">"Intervention: Delay close of enrollment"</span></span>
|
|
|
<span id="cb140-6"><a href="#cb140-6" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x=</span><span class="st">"Difference in 'p' under treatment"</span></span>
|
|
|
<span id="cb140-7"><a href="#cb140-7" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y=</span><span class="st">"Probability Density"</span></span>
|
|
|
<span id="cb140-8"><a href="#cb140-8" aria-hidden="true" tabindex="-1"></a> )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-18-3.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb141"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb141-1"><a href="#cb141-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"/p_delay_intervention_distdiff_1.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb143"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb143-1"><a href="#cb143-1" aria-hidden="true" tabindex="-1"></a>get_category_count <span class="ot"><-</span> <span class="cf">function</span>(tbl, id) {</span>
|
|
|
<span id="cb143-2"><a href="#cb143-2" aria-hidden="true" tabindex="-1"></a> result <span class="ot"><-</span> tbl<span class="sc">$</span>n[tbl<span class="sc">$</span>category_id <span class="sc">==</span> id]</span>
|
|
|
<span id="cb143-3"><a href="#cb143-3" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span>(<span class="fu">length</span>(result) <span class="sc">==</span> <span class="dv">0</span>) <span class="dv">0</span> <span class="cf">else</span> result</span>
|
|
|
<span id="cb143-4"><a href="#cb143-4" aria-hidden="true" tabindex="-1"></a>}</span>
|
|
|
<span id="cb143-5"><a href="#cb143-5" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb143-6"><a href="#cb143-6" aria-hidden="true" tabindex="-1"></a>category_names <span class="ot"><-</span> <span class="fu">sapply</span>(<span class="dv">1</span><span class="sc">:</span><span class="fu">length</span>(beta_list<span class="sc">$</span>groups), </span>
|
|
|
<span id="cb143-7"><a href="#cb143-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">function</span>(i) <span class="fu">sprintf</span>(<span class="st">"ICD-10 #%d: %s (n=%d)"</span>, </span>
|
|
|
<span id="cb143-8"><a href="#cb143-8" aria-hidden="true" tabindex="-1"></a> i, </span>
|
|
|
<span id="cb143-9"><a href="#cb143-9" aria-hidden="true" tabindex="-1"></a> beta_list<span class="sc">$</span>groups[i],</span>
|
|
|
<span id="cb143-10"><a href="#cb143-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">get_category_count</span>(category_count, i)))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb144"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb144-1"><a href="#cb144-1" aria-hidden="true" tabindex="-1"></a>pddf_ib <span class="ot"><-</span> <span class="fu">data.frame</span>(<span class="fu">extract</span>(generated_ib, <span class="at">pars=</span><span class="st">"predicted_difference"</span>)<span class="sc">$</span>predicted_difference) <span class="sc">|></span></span>
|
|
|
<span id="cb144-2"><a href="#cb144-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_longer</span>(X1<span class="sc">:</span>X168) <span class="co">#CHANGE_NOTE: moved from X169 to X168</span></span>
|
|
|
<span id="cb144-3"><a href="#cb144-3" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb144-4"><a href="#cb144-4" aria-hidden="true" tabindex="-1"></a>pddf_ib[<span class="st">"entry_idx"</span>] <span class="ot"><-</span> <span class="fu">as.numeric</span>(<span class="fu">gsub</span>(<span class="st">"</span><span class="sc">\\</span><span class="st">D"</span>,<span class="st">""</span>,pddf_ib<span class="sc">$</span>name))</span>
|
|
|
<span id="cb144-5"><a href="#cb144-5" aria-hidden="true" tabindex="-1"></a>pddf_ib[<span class="st">"category"</span>] <span class="ot"><-</span> <span class="fu">sapply</span>(pddf_ib<span class="sc">$</span>entry_idx, <span class="cf">function</span>(i) df<span class="sc">$</span>category_id[i])</span>
|
|
|
<span id="cb144-6"><a href="#cb144-6" aria-hidden="true" tabindex="-1"></a>pddf_ib[<span class="st">"category_name"</span>] <span class="ot"><-</span> <span class="fu">sapply</span>(</span>
|
|
|
<span id="cb144-7"><a href="#cb144-7" aria-hidden="true" tabindex="-1"></a> pddf_ib<span class="sc">$</span>category, </span>
|
|
|
<span id="cb144-8"><a href="#cb144-8" aria-hidden="true" tabindex="-1"></a> <span class="cf">function</span>(i) category_names[i]</span>
|
|
|
<span id="cb144-9"><a href="#cb144-9" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb144-10"><a href="#cb144-10" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb144-11"><a href="#cb144-11" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb144-12"><a href="#cb144-12" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb144-13"><a href="#cb144-13" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(pddf_ib, <span class="fu">aes</span>(<span class="at">x=</span>value,)) <span class="sc">+</span></span>
|
|
|
<span id="cb144-14"><a href="#cb144-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>(<span class="at">adjust=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">5</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb144-15"><a href="#cb144-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb144-16"><a href="#cb144-16" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"Distribution of predicted differences"</span></span>
|
|
|
<span id="cb144-17"><a href="#cb144-17" aria-hidden="true" tabindex="-1"></a> ,<span class="at">subtitle =</span> <span class="st">"Intervention: Delay close of enrollment"</span></span>
|
|
|
<span id="cb144-18"><a href="#cb144-18" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x =</span> <span class="st">"Difference in probability due to intervention"</span></span>
|
|
|
<span id="cb144-19"><a href="#cb144-19" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y =</span> <span class="st">"Probability Density"</span></span>
|
|
|
<span id="cb144-20"><a href="#cb144-20" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span> </span>
|
|
|
<span id="cb144-21"><a href="#cb144-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="fu">aes</span>(<span class="at">xintercept =</span> <span class="dv">0</span>), <span class="at">color =</span> <span class="st">"skyblue"</span>, <span class="at">linetype=</span><span class="st">"dashed"</span>) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-20-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb145"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb145-1"><a href="#cb145-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"/p_delay_intervention_distdiff_styled.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb147"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb147-1"><a href="#cb147-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(pddf_ib, <span class="fu">aes</span>(<span class="at">x=</span>value,)) <span class="sc">+</span></span>
|
|
|
<span id="cb147-2"><a href="#cb147-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>(<span class="at">adjust=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">5</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb147-3"><a href="#cb147-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">facet_wrap</span>(</span>
|
|
|
<span id="cb147-4"><a href="#cb147-4" aria-hidden="true" tabindex="-1"></a> <span class="sc">~</span><span class="fu">factor</span>(</span>
|
|
|
<span id="cb147-5"><a href="#cb147-5" aria-hidden="true" tabindex="-1"></a> category_name, </span>
|
|
|
<span id="cb147-6"><a href="#cb147-6" aria-hidden="true" tabindex="-1"></a> <span class="at">levels=</span>category_names</span>
|
|
|
<span id="cb147-7"><a href="#cb147-7" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb147-8"><a href="#cb147-8" aria-hidden="true" tabindex="-1"></a> , <span class="at">labeller =</span> <span class="fu">label_wrap_gen</span>(<span class="at">multi_line =</span> <span class="cn">TRUE</span>)</span>
|
|
|
<span id="cb147-9"><a href="#cb147-9" aria-hidden="true" tabindex="-1"></a> , <span class="at">ncol=</span><span class="dv">4</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb147-10"><a href="#cb147-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb147-11"><a href="#cb147-11" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"Distribution of predicted differences | By Group"</span></span>
|
|
|
<span id="cb147-12"><a href="#cb147-12" aria-hidden="true" tabindex="-1"></a> ,<span class="at">subtitle =</span> <span class="st">"Intervention: Delay close of enrollment"</span></span>
|
|
|
<span id="cb147-13"><a href="#cb147-13" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x =</span> <span class="st">"Difference in probability due to intervention"</span></span>
|
|
|
<span id="cb147-14"><a href="#cb147-14" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y =</span> <span class="st">"Probability Density"</span></span>
|
|
|
<span id="cb147-15"><a href="#cb147-15" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span> </span>
|
|
|
<span id="cb147-16"><a href="#cb147-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="fu">aes</span>(<span class="at">xintercept =</span> <span class="dv">0</span>), <span class="at">color =</span> <span class="st">"skyblue"</span>, <span class="at">linetype=</span><span class="st">"dashed"</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb147-17"><a href="#cb147-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">strip.text.x =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">8</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-20-2.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb148"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb148-1"><a href="#cb148-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"/p_delay_intervention_distdiff_by_group.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb150"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb150-1"><a href="#cb150-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(pddf_ib, <span class="fu">aes</span>(<span class="at">x=</span>value,)) <span class="sc">+</span></span>
|
|
|
<span id="cb150-2"><a href="#cb150-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_histogram</span>(<span class="at">bins=</span><span class="dv">300</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb150-3"><a href="#cb150-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">facet_wrap</span>(</span>
|
|
|
<span id="cb150-4"><a href="#cb150-4" aria-hidden="true" tabindex="-1"></a> <span class="sc">~</span><span class="fu">factor</span>(</span>
|
|
|
<span id="cb150-5"><a href="#cb150-5" aria-hidden="true" tabindex="-1"></a> category_name, </span>
|
|
|
<span id="cb150-6"><a href="#cb150-6" aria-hidden="true" tabindex="-1"></a> <span class="at">levels=</span>category_names</span>
|
|
|
<span id="cb150-7"><a href="#cb150-7" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb150-8"><a href="#cb150-8" aria-hidden="true" tabindex="-1"></a> , <span class="at">labeller =</span> <span class="fu">label_wrap_gen</span>(<span class="at">multi_line =</span> <span class="cn">TRUE</span>)</span>
|
|
|
<span id="cb150-9"><a href="#cb150-9" aria-hidden="true" tabindex="-1"></a> , <span class="at">ncol=</span><span class="dv">4</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb150-10"><a href="#cb150-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb150-11"><a href="#cb150-11" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"Histogram of predicted differences | By Group"</span></span>
|
|
|
<span id="cb150-12"><a href="#cb150-12" aria-hidden="true" tabindex="-1"></a> ,<span class="at">subtitle =</span> <span class="st">"Intervention: Delay close of enrollment"</span></span>
|
|
|
<span id="cb150-13"><a href="#cb150-13" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x =</span> <span class="st">"Difference in probability due to intervention"</span></span>
|
|
|
<span id="cb150-14"><a href="#cb150-14" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y =</span> <span class="st">"Predicted counts"</span></span>
|
|
|
<span id="cb150-15"><a href="#cb150-15" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span> </span>
|
|
|
<span id="cb150-16"><a href="#cb150-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="fu">aes</span>(<span class="at">xintercept =</span> <span class="dv">0</span>), <span class="at">color =</span> <span class="st">"skyblue"</span>, <span class="at">linetype=</span><span class="st">"dashed"</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb150-17"><a href="#cb150-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">strip.text.x =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">8</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-20-3.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb151"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb151-1"><a href="#cb151-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"p_delay_intervention_histdiff_by_group.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb153"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb153-1"><a href="#cb153-1" aria-hidden="true" tabindex="-1"></a>p3 <span class="ot"><-</span> <span class="fu">ggplot</span>(pddf_ib, <span class="fu">aes</span>(<span class="at">x=</span>value,)) <span class="sc">+</span></span>
|
|
|
<span id="cb153-2"><a href="#cb153-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_histogram</span>(<span class="at">bins=</span><span class="dv">500</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb153-3"><a href="#cb153-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb153-4"><a href="#cb153-4" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"Distribution of predicted differences"</span></span>
|
|
|
<span id="cb153-5"><a href="#cb153-5" aria-hidden="true" tabindex="-1"></a> ,<span class="at">subtitle =</span> <span class="st">"Intervention: Delay close of enrollment"</span></span>
|
|
|
<span id="cb153-6"><a href="#cb153-6" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x =</span> <span class="st">"Difference in probability due to intervention"</span></span>
|
|
|
<span id="cb153-7"><a href="#cb153-7" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y =</span> <span class="st">"Probability Density"</span></span>
|
|
|
<span id="cb153-8"><a href="#cb153-8" aria-hidden="true" tabindex="-1"></a> ,<span class="at">caption =</span> <span class="st">"Vertical marks: 5/10/25/50/75/90/95th percentiles. Dot shows mean."</span></span>
|
|
|
<span id="cb153-9"><a href="#cb153-9" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span> </span>
|
|
|
<span id="cb153-10"><a href="#cb153-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="fu">aes</span>(<span class="at">xintercept =</span> <span class="dv">0</span>), <span class="at">color =</span> <span class="st">"skyblue"</span>, <span class="at">linetype=</span><span class="st">"dashed"</span>) </span>
|
|
|
<span id="cb153-11"><a href="#cb153-11" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb153-12"><a href="#cb153-12" aria-hidden="true" tabindex="-1"></a>density_hight <span class="ot"><-</span> <span class="fu">max</span>(<span class="fu">density</span>(pddf_ib<span class="sc">$</span>value)<span class="sc">$</span>y)</span>
|
|
|
<span id="cb153-13"><a href="#cb153-13" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb153-14"><a href="#cb153-14" aria-hidden="true" tabindex="-1"></a>stats <span class="ot"><-</span> <span class="fu">list</span>(</span>
|
|
|
<span id="cb153-15"><a href="#cb153-15" aria-hidden="true" tabindex="-1"></a> <span class="at">p5 =</span> <span class="fu">quantile</span>(pddf_ib<span class="sc">$</span>value, <span class="fl">0.05</span>),</span>
|
|
|
<span id="cb153-16"><a href="#cb153-16" aria-hidden="true" tabindex="-1"></a> <span class="at">p10 =</span> <span class="fu">quantile</span>(pddf_ib<span class="sc">$</span>value, <span class="fl">0.10</span>),</span>
|
|
|
<span id="cb153-17"><a href="#cb153-17" aria-hidden="true" tabindex="-1"></a> <span class="at">q1 =</span> <span class="fu">quantile</span>(pddf_ib<span class="sc">$</span>value, <span class="fl">0.25</span>),</span>
|
|
|
<span id="cb153-18"><a href="#cb153-18" aria-hidden="true" tabindex="-1"></a> <span class="at">med =</span> <span class="fu">median</span>(pddf_ib<span class="sc">$</span>value),</span>
|
|
|
<span id="cb153-19"><a href="#cb153-19" aria-hidden="true" tabindex="-1"></a> <span class="at">mean =</span> <span class="fu">mean</span>(pddf_ib<span class="sc">$</span>value),</span>
|
|
|
<span id="cb153-20"><a href="#cb153-20" aria-hidden="true" tabindex="-1"></a> <span class="at">q3 =</span> <span class="fu">quantile</span>(pddf_ib<span class="sc">$</span>value, <span class="fl">0.75</span>),</span>
|
|
|
<span id="cb153-21"><a href="#cb153-21" aria-hidden="true" tabindex="-1"></a> <span class="at">p90 =</span> <span class="fu">quantile</span>(pddf_ib<span class="sc">$</span>value, <span class="fl">0.90</span>),</span>
|
|
|
<span id="cb153-22"><a href="#cb153-22" aria-hidden="true" tabindex="-1"></a> <span class="at">p95 =</span> <span class="fu">quantile</span>(pddf_ib<span class="sc">$</span>value, <span class="fl">0.95</span>),</span>
|
|
|
<span id="cb153-23"><a href="#cb153-23" aria-hidden="true" tabindex="-1"></a> <span class="at">max_height =</span> <span class="fu">max</span>(<span class="fu">ggplot_build</span>(p3)<span class="sc">$</span>data[[<span class="dv">1</span>]]<span class="sc">$</span>count),</span>
|
|
|
<span id="cb153-24"><a href="#cb153-24" aria-hidden="true" tabindex="-1"></a> <span class="at">y_offset =</span> <span class="sc">-</span><span class="fu">max</span>(<span class="fu">ggplot_build</span>(p3)<span class="sc">$</span>data[[<span class="dv">1</span>]]<span class="sc">$</span>count) <span class="sc">*</span> <span class="fl">0.05</span>,</span>
|
|
|
<span id="cb153-25"><a href="#cb153-25" aria-hidden="true" tabindex="-1"></a> <span class="at">y_offset_density =</span> <span class="sc">-</span>density_hight <span class="sc">*</span> <span class="fl">0.15</span></span>
|
|
|
<span id="cb153-26"><a href="#cb153-26" aria-hidden="true" tabindex="-1"></a>)</span>
|
|
|
<span id="cb153-27"><a href="#cb153-27" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb153-28"><a href="#cb153-28" aria-hidden="true" tabindex="-1"></a>p3 <span class="sc">+</span> </span>
|
|
|
<span id="cb153-29"><a href="#cb153-29" aria-hidden="true" tabindex="-1"></a> <span class="co"># Box</span></span>
|
|
|
<span id="cb153-30"><a href="#cb153-30" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb153-31"><a href="#cb153-31" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">c</span>(stats<span class="sc">$</span>q1, stats<span class="sc">$</span>q3, stats<span class="sc">$</span>med),</span>
|
|
|
<span id="cb153-32"><a href="#cb153-32" aria-hidden="true" tabindex="-1"></a> <span class="at">xend =</span> <span class="fu">c</span>(stats<span class="sc">$</span>q1, stats<span class="sc">$</span>q3, stats<span class="sc">$</span>med),</span>
|
|
|
<span id="cb153-33"><a href="#cb153-33" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>y_offset, <span class="dv">3</span>), </span>
|
|
|
<span id="cb153-34"><a href="#cb153-34" aria-hidden="true" tabindex="-1"></a> <span class="at">yend =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>y_offset <span class="sc">*</span> <span class="dv">2</span>, <span class="dv">3</span>)</span>
|
|
|
<span id="cb153-35"><a href="#cb153-35" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">xend =</span> xend, <span class="at">y =</span> y, <span class="at">yend =</span> yend)) <span class="sc">+</span></span>
|
|
|
<span id="cb153-36"><a href="#cb153-36" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb153-37"><a href="#cb153-37" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>q1, <span class="dv">2</span>),</span>
|
|
|
<span id="cb153-38"><a href="#cb153-38" aria-hidden="true" tabindex="-1"></a> <span class="at">xend =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>q3, <span class="dv">2</span>),</span>
|
|
|
<span id="cb153-39"><a href="#cb153-39" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="fu">c</span>(stats<span class="sc">$</span>y_offset, stats<span class="sc">$</span>y_offset <span class="sc">*</span> <span class="dv">2</span>),</span>
|
|
|
<span id="cb153-40"><a href="#cb153-40" aria-hidden="true" tabindex="-1"></a> <span class="at">yend =</span> <span class="fu">c</span>(stats<span class="sc">$</span>y_offset, stats<span class="sc">$</span>y_offset <span class="sc">*</span> <span class="dv">2</span>)</span>
|
|
|
<span id="cb153-41"><a href="#cb153-41" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">xend =</span> xend, <span class="at">y =</span> y, <span class="at">yend =</span> yend)) <span class="sc">+</span></span>
|
|
|
<span id="cb153-42"><a href="#cb153-42" aria-hidden="true" tabindex="-1"></a> <span class="co"># Inner whiskers (Q1->P10, Q3->P90)</span></span>
|
|
|
<span id="cb153-43"><a href="#cb153-43" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb153-44"><a href="#cb153-44" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">c</span>(stats<span class="sc">$</span>q1, stats<span class="sc">$</span>q3),</span>
|
|
|
<span id="cb153-45"><a href="#cb153-45" aria-hidden="true" tabindex="-1"></a> <span class="at">xend =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p10, stats<span class="sc">$</span>p90),</span>
|
|
|
<span id="cb153-46"><a href="#cb153-46" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>y_offset <span class="sc">*</span> <span class="fl">1.5</span>, <span class="dv">2</span>),</span>
|
|
|
<span id="cb153-47"><a href="#cb153-47" aria-hidden="true" tabindex="-1"></a> <span class="at">yend =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>y_offset <span class="sc">*</span> <span class="fl">1.5</span>, <span class="dv">2</span>)</span>
|
|
|
<span id="cb153-48"><a href="#cb153-48" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">xend =</span> xend, <span class="at">y =</span> y, <span class="at">yend =</span> yend)) <span class="sc">+</span></span>
|
|
|
<span id="cb153-49"><a href="#cb153-49" aria-hidden="true" tabindex="-1"></a> <span class="co"># Crossbars at P10/P90</span></span>
|
|
|
<span id="cb153-50"><a href="#cb153-50" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb153-51"><a href="#cb153-51" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p10, stats<span class="sc">$</span>p90),</span>
|
|
|
<span id="cb153-52"><a href="#cb153-52" aria-hidden="true" tabindex="-1"></a> <span class="at">xend =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p10, stats<span class="sc">$</span>p90),</span>
|
|
|
<span id="cb153-53"><a href="#cb153-53" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> stats<span class="sc">$</span>y_offset <span class="sc">*</span> <span class="fl">1.3</span>,</span>
|
|
|
<span id="cb153-54"><a href="#cb153-54" aria-hidden="true" tabindex="-1"></a> <span class="at">yend =</span> stats<span class="sc">$</span>y_offset <span class="sc">*</span> <span class="fl">1.7</span></span>
|
|
|
<span id="cb153-55"><a href="#cb153-55" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">xend =</span> xend, <span class="at">y =</span> y, <span class="at">yend =</span> yend)) <span class="sc">+</span></span>
|
|
|
<span id="cb153-56"><a href="#cb153-56" aria-hidden="true" tabindex="-1"></a> <span class="co"># Outer whiskers (P10->P5, P90->P95)</span></span>
|
|
|
<span id="cb153-57"><a href="#cb153-57" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb153-58"><a href="#cb153-58" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p10, stats<span class="sc">$</span>p90),</span>
|
|
|
<span id="cb153-59"><a href="#cb153-59" aria-hidden="true" tabindex="-1"></a> <span class="at">xend =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p5, stats<span class="sc">$</span>p95),</span>
|
|
|
<span id="cb153-60"><a href="#cb153-60" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>y_offset <span class="sc">*</span> <span class="fl">1.5</span>, <span class="dv">2</span>),</span>
|
|
|
<span id="cb153-61"><a href="#cb153-61" aria-hidden="true" tabindex="-1"></a> <span class="at">yend =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>y_offset <span class="sc">*</span> <span class="fl">1.5</span>, <span class="dv">2</span>)</span>
|
|
|
<span id="cb153-62"><a href="#cb153-62" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">xend =</span> xend, <span class="at">y =</span> y, <span class="at">yend =</span> yend)) <span class="sc">+</span></span>
|
|
|
<span id="cb153-63"><a href="#cb153-63" aria-hidden="true" tabindex="-1"></a> <span class="co"># Crossbars at P5/P95</span></span>
|
|
|
<span id="cb153-64"><a href="#cb153-64" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb153-65"><a href="#cb153-65" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p5, stats<span class="sc">$</span>p95),</span>
|
|
|
<span id="cb153-66"><a href="#cb153-66" aria-hidden="true" tabindex="-1"></a> <span class="at">xend =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p5, stats<span class="sc">$</span>p95),</span>
|
|
|
<span id="cb153-67"><a href="#cb153-67" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> stats<span class="sc">$</span>y_offset <span class="sc">*</span> <span class="fl">1.3</span>,</span>
|
|
|
<span id="cb153-68"><a href="#cb153-68" aria-hidden="true" tabindex="-1"></a> <span class="at">yend =</span> stats<span class="sc">$</span>y_offset <span class="sc">*</span> <span class="fl">1.7</span></span>
|
|
|
<span id="cb153-69"><a href="#cb153-69" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">xend =</span> xend, <span class="at">y =</span> y, <span class="at">yend =</span> yend)) <span class="sc">+</span></span>
|
|
|
<span id="cb153-70"><a href="#cb153-70" aria-hidden="true" tabindex="-1"></a> <span class="co"># Mean dot</span></span>
|
|
|
<span id="cb153-71"><a href="#cb153-71" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_point</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb153-72"><a href="#cb153-72" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> stats<span class="sc">$</span>mean,</span>
|
|
|
<span id="cb153-73"><a href="#cb153-73" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> stats<span class="sc">$</span>y_offset <span class="sc">*</span> <span class="fl">1.5</span></span>
|
|
|
<span id="cb153-74"><a href="#cb153-74" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">y =</span> y))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-21-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb154"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb154-1"><a href="#cb154-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"/p_delay_intervention_histdiff_boxplot.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb156"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb156-1"><a href="#cb156-1" aria-hidden="true" tabindex="-1"></a>p4 <span class="ot"><-</span> <span class="fu">ggplot</span>(pddf_ib, <span class="fu">aes</span>(<span class="at">x =</span> value)) <span class="sc">+</span></span>
|
|
|
<span id="cb156-2"><a href="#cb156-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>() <span class="sc">+</span></span>
|
|
|
<span id="cb156-3"><a href="#cb156-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb156-4"><a href="#cb156-4" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"Distribution of predicted differences"</span></span>
|
|
|
<span id="cb156-5"><a href="#cb156-5" aria-hidden="true" tabindex="-1"></a> ,<span class="at">subtitle =</span> <span class="st">"Intervention: Delay close of enrollment"</span></span>
|
|
|
<span id="cb156-6"><a href="#cb156-6" aria-hidden="true" tabindex="-1"></a> ,<span class="at">x =</span> <span class="st">"Difference in probability due to intervention"</span></span>
|
|
|
<span id="cb156-7"><a href="#cb156-7" aria-hidden="true" tabindex="-1"></a> ,<span class="at">y =</span> <span class="st">"Probability Density"</span></span>
|
|
|
<span id="cb156-8"><a href="#cb156-8" aria-hidden="true" tabindex="-1"></a> ,<span class="at">caption =</span> <span class="st">"Vertical marks: 5/10/25/50/75/90/95th percentiles. Dot shows mean."</span></span>
|
|
|
<span id="cb156-9"><a href="#cb156-9" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span> </span>
|
|
|
<span id="cb156-10"><a href="#cb156-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="fu">aes</span>(<span class="at">xintercept =</span> <span class="dv">0</span>), <span class="at">color =</span> <span class="st">"skyblue"</span>, <span class="at">linetype=</span><span class="st">"dashed"</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb156-11"><a href="#cb156-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb156-12"><a href="#cb156-12" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">c</span>(stats<span class="sc">$</span>q1, stats<span class="sc">$</span>q3, stats<span class="sc">$</span>med),</span>
|
|
|
<span id="cb156-13"><a href="#cb156-13" aria-hidden="true" tabindex="-1"></a> <span class="at">xend =</span> <span class="fu">c</span>(stats<span class="sc">$</span>q1, stats<span class="sc">$</span>q3, stats<span class="sc">$</span>med),</span>
|
|
|
<span id="cb156-14"><a href="#cb156-14" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>y_offset_density, <span class="dv">3</span>), </span>
|
|
|
<span id="cb156-15"><a href="#cb156-15" aria-hidden="true" tabindex="-1"></a> <span class="at">yend =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>y_offset_density <span class="sc">*</span> <span class="dv">2</span>, <span class="dv">3</span>)</span>
|
|
|
<span id="cb156-16"><a href="#cb156-16" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">xend =</span> xend, <span class="at">y =</span> y, <span class="at">yend =</span> yend)) <span class="sc">+</span></span>
|
|
|
<span id="cb156-17"><a href="#cb156-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb156-18"><a href="#cb156-18" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>q1, <span class="dv">2</span>),</span>
|
|
|
<span id="cb156-19"><a href="#cb156-19" aria-hidden="true" tabindex="-1"></a> <span class="at">xend =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>q3, <span class="dv">2</span>),</span>
|
|
|
<span id="cb156-20"><a href="#cb156-20" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="fu">c</span>(stats<span class="sc">$</span>y_offset_density, stats<span class="sc">$</span>y_offset_density <span class="sc">*</span> <span class="dv">2</span>),</span>
|
|
|
<span id="cb156-21"><a href="#cb156-21" aria-hidden="true" tabindex="-1"></a> <span class="at">yend =</span> <span class="fu">c</span>(stats<span class="sc">$</span>y_offset_density, stats<span class="sc">$</span>y_offset_density <span class="sc">*</span> <span class="dv">2</span>)</span>
|
|
|
<span id="cb156-22"><a href="#cb156-22" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">xend =</span> xend, <span class="at">y =</span> y, <span class="at">yend =</span> yend)) <span class="sc">+</span></span>
|
|
|
<span id="cb156-23"><a href="#cb156-23" aria-hidden="true" tabindex="-1"></a> <span class="co"># Inner whiskers (Q1->P10, Q3->P90)</span></span>
|
|
|
<span id="cb156-24"><a href="#cb156-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb156-25"><a href="#cb156-25" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">c</span>(stats<span class="sc">$</span>q1, stats<span class="sc">$</span>q3),</span>
|
|
|
<span id="cb156-26"><a href="#cb156-26" aria-hidden="true" tabindex="-1"></a> <span class="at">xend =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p10, stats<span class="sc">$</span>p90),</span>
|
|
|
<span id="cb156-27"><a href="#cb156-27" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>y_offset_density <span class="sc">*</span> <span class="fl">1.5</span>, <span class="dv">2</span>),</span>
|
|
|
<span id="cb156-28"><a href="#cb156-28" aria-hidden="true" tabindex="-1"></a> <span class="at">yend =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>y_offset_density <span class="sc">*</span> <span class="fl">1.5</span>, <span class="dv">2</span>)</span>
|
|
|
<span id="cb156-29"><a href="#cb156-29" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">xend =</span> xend, <span class="at">y =</span> y, <span class="at">yend =</span> yend)) <span class="sc">+</span></span>
|
|
|
<span id="cb156-30"><a href="#cb156-30" aria-hidden="true" tabindex="-1"></a> <span class="co"># Crossbars at P10/P90</span></span>
|
|
|
<span id="cb156-31"><a href="#cb156-31" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb156-32"><a href="#cb156-32" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p10, stats<span class="sc">$</span>p90),</span>
|
|
|
<span id="cb156-33"><a href="#cb156-33" aria-hidden="true" tabindex="-1"></a> <span class="at">xend =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p10, stats<span class="sc">$</span>p90),</span>
|
|
|
<span id="cb156-34"><a href="#cb156-34" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> stats<span class="sc">$</span>y_offset_density <span class="sc">*</span> <span class="fl">1.3</span>,</span>
|
|
|
<span id="cb156-35"><a href="#cb156-35" aria-hidden="true" tabindex="-1"></a> <span class="at">yend =</span> stats<span class="sc">$</span>y_offset_density <span class="sc">*</span> <span class="fl">1.7</span></span>
|
|
|
<span id="cb156-36"><a href="#cb156-36" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">xend =</span> xend, <span class="at">y =</span> y, <span class="at">yend =</span> yend)) <span class="sc">+</span></span>
|
|
|
<span id="cb156-37"><a href="#cb156-37" aria-hidden="true" tabindex="-1"></a> <span class="co"># Outer whiskers (P10->P5, P90->P95)</span></span>
|
|
|
<span id="cb156-38"><a href="#cb156-38" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb156-39"><a href="#cb156-39" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p10, stats<span class="sc">$</span>p90),</span>
|
|
|
<span id="cb156-40"><a href="#cb156-40" aria-hidden="true" tabindex="-1"></a> <span class="at">xend =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p5, stats<span class="sc">$</span>p95),</span>
|
|
|
<span id="cb156-41"><a href="#cb156-41" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>y_offset_density <span class="sc">*</span> <span class="fl">1.5</span>, <span class="dv">2</span>),</span>
|
|
|
<span id="cb156-42"><a href="#cb156-42" aria-hidden="true" tabindex="-1"></a> <span class="at">yend =</span> <span class="fu">rep</span>(stats<span class="sc">$</span>y_offset_density <span class="sc">*</span> <span class="fl">1.5</span>, <span class="dv">2</span>)</span>
|
|
|
<span id="cb156-43"><a href="#cb156-43" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">xend =</span> xend, <span class="at">y =</span> y, <span class="at">yend =</span> yend)) <span class="sc">+</span></span>
|
|
|
<span id="cb156-44"><a href="#cb156-44" aria-hidden="true" tabindex="-1"></a> <span class="co"># Crossbars at P5/P95</span></span>
|
|
|
<span id="cb156-45"><a href="#cb156-45" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_segment</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb156-46"><a href="#cb156-46" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p5, stats<span class="sc">$</span>p95),</span>
|
|
|
<span id="cb156-47"><a href="#cb156-47" aria-hidden="true" tabindex="-1"></a> <span class="at">xend =</span> <span class="fu">c</span>(stats<span class="sc">$</span>p5, stats<span class="sc">$</span>p95),</span>
|
|
|
<span id="cb156-48"><a href="#cb156-48" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> stats<span class="sc">$</span>y_offset_density <span class="sc">*</span> <span class="fl">1.3</span>,</span>
|
|
|
<span id="cb156-49"><a href="#cb156-49" aria-hidden="true" tabindex="-1"></a> <span class="at">yend =</span> stats<span class="sc">$</span>y_offset_density <span class="sc">*</span> <span class="fl">1.7</span></span>
|
|
|
<span id="cb156-50"><a href="#cb156-50" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">xend =</span> xend, <span class="at">y =</span> y, <span class="at">yend =</span> yend)) <span class="sc">+</span></span>
|
|
|
<span id="cb156-51"><a href="#cb156-51" aria-hidden="true" tabindex="-1"></a> <span class="co"># Mean dot</span></span>
|
|
|
<span id="cb156-52"><a href="#cb156-52" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_point</span>(<span class="at">data =</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb156-53"><a href="#cb156-53" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> stats<span class="sc">$</span>mean,</span>
|
|
|
<span id="cb156-54"><a href="#cb156-54" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> stats<span class="sc">$</span>y_offset_density <span class="sc">*</span> <span class="fl">1.5</span></span>
|
|
|
<span id="cb156-55"><a href="#cb156-55" aria-hidden="true" tabindex="-1"></a> ), <span class="fu">aes</span>(<span class="at">x =</span> x, <span class="at">y =</span> y))</span>
|
|
|
<span id="cb156-56"><a href="#cb156-56" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"/p_delay_intervention_distdiff_boxplot.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb158"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb158-1"><a href="#cb158-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(pddf_ib, <span class="fu">aes</span>(<span class="at">x=</span>value)) <span class="sc">+</span></span>
|
|
|
<span id="cb158-2"><a href="#cb158-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">stat_ecdf</span>(<span class="at">geom=</span><span class="st">'step'</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb158-3"><a href="#cb158-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
|
|
|
<span id="cb158-4"><a href="#cb158-4" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"Cumulative distribution of predicted differences"</span>,</span>
|
|
|
<span id="cb158-5"><a href="#cb158-5" aria-hidden="true" tabindex="-1"></a> <span class="at">subtitle =</span> <span class="st">"Intervention: Delay close of enrollment"</span>,</span>
|
|
|
<span id="cb158-6"><a href="#cb158-6" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="st">"Difference in probability of termination due to intervention"</span>,</span>
|
|
|
<span id="cb158-7"><a href="#cb158-7" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="st">"Cumulative Proportion"</span></span>
|
|
|
<span id="cb158-8"><a href="#cb158-8" aria-hidden="true" tabindex="-1"></a> ) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-22-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb159"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb159-1"><a href="#cb159-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_dist_diff_analysis,<span class="st">"/p_delay_intervention_cumulative_distdiff.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<p>Get the % of differences in the spike around zero</p>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb161"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb161-1"><a href="#cb161-1" aria-hidden="true" tabindex="-1"></a><span class="co"># get values around and above/below spike</span></span>
|
|
|
<span id="cb161-2"><a href="#cb161-2" aria-hidden="true" tabindex="-1"></a>width <span class="ot"><-</span> <span class="fl">0.02</span></span>
|
|
|
<span id="cb161-3"><a href="#cb161-3" aria-hidden="true" tabindex="-1"></a>spike_band_centered_zero <span class="ot"><-</span> <span class="fu">mean</span>( pddf_ib<span class="sc">$</span>value <span class="sc">>=</span> <span class="sc">-</span>width<span class="sc">/</span><span class="dv">2</span> <span class="sc">&</span> pddf_ib<span class="sc">$</span>value <span class="sc"><=</span> width<span class="sc">/</span><span class="dv">2</span>)</span>
|
|
|
<span id="cb161-4"><a href="#cb161-4" aria-hidden="true" tabindex="-1"></a>above_spike_band <span class="ot"><-</span> <span class="fu">mean</span>( pddf_ib<span class="sc">$</span>value <span class="sc">>=</span> width<span class="sc">/</span><span class="dv">2</span>)</span>
|
|
|
<span id="cb161-5"><a href="#cb161-5" aria-hidden="true" tabindex="-1"></a>below_spike_band <span class="ot"><-</span> <span class="fu">mean</span>( pddf_ib<span class="sc">$</span>value <span class="sc"><=</span> <span class="sc">-</span>width<span class="sc">/</span><span class="dv">2</span>)</span>
|
|
|
<span id="cb161-6"><a href="#cb161-6" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb161-7"><a href="#cb161-7" aria-hidden="true" tabindex="-1"></a><span class="co"># get mass above and mass below zero</span></span>
|
|
|
<span id="cb161-8"><a href="#cb161-8" aria-hidden="true" tabindex="-1"></a>mass_below_zero <span class="ot"><-</span> <span class="fu">mean</span>( pddf_ib<span class="sc">$</span>value <span class="sc"><=</span> <span class="dv">0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
<p>Looking at the spike around zero, we find that 39.193869% of the probability mass is contained within the band from [-1,1]. Additionally, there was 51.937619% of the probability above that – representing those with a general increase in the probability of termination – and 8.8685119% of the probability mass below the band – representing a decrease in the probability of termination.</p>
|
|
|
<p>On average, if you keep the trial open instead of closing it, 0.2488518% of trials will see a decrease in the probability of termination, but, due to the high increase in probability of termination given termination was increased, the mean probability of termination increases by 0.0249444.</p>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb162"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb162-1"><a href="#cb162-1" aria-hidden="true" tabindex="-1"></a><span class="co"># 5%-iles</span></span>
|
|
|
<span id="cb162-2"><a href="#cb162-2" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb162-3"><a href="#cb162-3" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(pddf_ib<span class="sc">$</span>value)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stdout">
|
|
|
<pre><code> Min. 1st Qu. Median Mean 3rd Qu. Max.
|
|
|
-0.42755 0.00000 0.01164 0.02494 0.04213 0.54813 </code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb164"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb164-1"><a href="#cb164-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Create your quantiles</span></span>
|
|
|
<span id="cb164-2"><a href="#cb164-2" aria-hidden="true" tabindex="-1"></a>quants <span class="ot"><-</span> <span class="fu">quantile</span>(pddf_ib<span class="sc">$</span>value, <span class="at">probs =</span> <span class="fu">seq</span>(<span class="dv">0</span>,<span class="dv">1</span>,<span class="fl">0.05</span>), <span class="at">type=</span><span class="dv">4</span>)</span>
|
|
|
<span id="cb164-3"><a href="#cb164-3" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb164-4"><a href="#cb164-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Convert to a data frame</span></span>
|
|
|
<span id="cb164-5"><a href="#cb164-5" aria-hidden="true" tabindex="-1"></a>quant_df <span class="ot"><-</span> <span class="fu">data.frame</span>(</span>
|
|
|
<span id="cb164-6"><a href="#cb164-6" aria-hidden="true" tabindex="-1"></a> <span class="at">Percentile =</span> <span class="fu">names</span>(quants),</span>
|
|
|
<span id="cb164-7"><a href="#cb164-7" aria-hidden="true" tabindex="-1"></a> <span class="at">Value =</span> quants</span>
|
|
|
<span id="cb164-8"><a href="#cb164-8" aria-hidden="true" tabindex="-1"></a>)</span>
|
|
|
<span id="cb164-9"><a href="#cb164-9" aria-hidden="true" tabindex="-1"></a><span class="fu">kable</span>(quant_df)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<table class="caption-top table table-sm table-striped small">
|
|
|
<thead>
|
|
|
<tr class="header">
|
|
|
<th style="text-align: left;"></th>
|
|
|
<th style="text-align: left;">Percentile</th>
|
|
|
<th style="text-align: right;">Value</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
<tbody>
|
|
|
<tr class="odd">
|
|
|
<td style="text-align: left;">0%</td>
|
|
|
<td style="text-align: left;">0%</td>
|
|
|
<td style="text-align: right;">-0.4275511</td>
|
|
|
</tr>
|
|
|
<tr class="even">
|
|
|
<td style="text-align: left;">5%</td>
|
|
|
<td style="text-align: left;">5%</td>
|
|
|
<td style="text-align: right;">-0.0213008</td>
|
|
|
</tr>
|
|
|
<tr class="odd">
|
|
|
<td style="text-align: left;">10%</td>
|
|
|
<td style="text-align: left;">10%</td>
|
|
|
<td style="text-align: right;">-0.0079768</td>
|
|
|
</tr>
|
|
|
<tr class="even">
|
|
|
<td style="text-align: left;">15%</td>
|
|
|
<td style="text-align: left;">15%</td>
|
|
|
<td style="text-align: right;">-0.0021932</td>
|
|
|
</tr>
|
|
|
<tr class="odd">
|
|
|
<td style="text-align: left;">20%</td>
|
|
|
<td style="text-align: left;">20%</td>
|
|
|
<td style="text-align: right;">-0.0001065</td>
|
|
|
</tr>
|
|
|
<tr class="even">
|
|
|
<td style="text-align: left;">25%</td>
|
|
|
<td style="text-align: left;">25%</td>
|
|
|
<td style="text-align: right;">0.0000000</td>
|
|
|
</tr>
|
|
|
<tr class="odd">
|
|
|
<td style="text-align: left;">30%</td>
|
|
|
<td style="text-align: left;">30%</td>
|
|
|
<td style="text-align: right;">0.0000535</td>
|
|
|
</tr>
|
|
|
<tr class="even">
|
|
|
<td style="text-align: left;">35%</td>
|
|
|
<td style="text-align: left;">35%</td>
|
|
|
<td style="text-align: right;">0.0012179</td>
|
|
|
</tr>
|
|
|
<tr class="odd">
|
|
|
<td style="text-align: left;">40%</td>
|
|
|
<td style="text-align: left;">40%</td>
|
|
|
<td style="text-align: right;">0.0040158</td>
|
|
|
</tr>
|
|
|
<tr class="even">
|
|
|
<td style="text-align: left;">45%</td>
|
|
|
<td style="text-align: left;">45%</td>
|
|
|
<td style="text-align: right;">0.0075646</td>
|
|
|
</tr>
|
|
|
<tr class="odd">
|
|
|
<td style="text-align: left;">50%</td>
|
|
|
<td style="text-align: left;">50%</td>
|
|
|
<td style="text-align: right;">0.0116358</td>
|
|
|
</tr>
|
|
|
<tr class="even">
|
|
|
<td style="text-align: left;">55%</td>
|
|
|
<td style="text-align: left;">55%</td>
|
|
|
<td style="text-align: right;">0.0162235</td>
|
|
|
</tr>
|
|
|
<tr class="odd">
|
|
|
<td style="text-align: left;">60%</td>
|
|
|
<td style="text-align: left;">60%</td>
|
|
|
<td style="text-align: right;">0.0214039</td>
|
|
|
</tr>
|
|
|
<tr class="even">
|
|
|
<td style="text-align: left;">65%</td>
|
|
|
<td style="text-align: left;">65%</td>
|
|
|
<td style="text-align: right;">0.0272582</td>
|
|
|
</tr>
|
|
|
<tr class="odd">
|
|
|
<td style="text-align: left;">70%</td>
|
|
|
<td style="text-align: left;">70%</td>
|
|
|
<td style="text-align: right;">0.0340562</td>
|
|
|
</tr>
|
|
|
<tr class="even">
|
|
|
<td style="text-align: left;">75%</td>
|
|
|
<td style="text-align: left;">75%</td>
|
|
|
<td style="text-align: right;">0.0421259</td>
|
|
|
</tr>
|
|
|
<tr class="odd">
|
|
|
<td style="text-align: left;">80%</td>
|
|
|
<td style="text-align: left;">80%</td>
|
|
|
<td style="text-align: right;">0.0519438</td>
|
|
|
</tr>
|
|
|
<tr class="even">
|
|
|
<td style="text-align: left;">85%</td>
|
|
|
<td style="text-align: left;">85%</td>
|
|
|
<td style="text-align: right;">0.0645430</td>
|
|
|
</tr>
|
|
|
<tr class="odd">
|
|
|
<td style="text-align: left;">90%</td>
|
|
|
<td style="text-align: left;">90%</td>
|
|
|
<td style="text-align: right;">0.0819636</td>
|
|
|
</tr>
|
|
|
<tr class="even">
|
|
|
<td style="text-align: left;">95%</td>
|
|
|
<td style="text-align: left;">95%</td>
|
|
|
<td style="text-align: right;">0.1102529</td>
|
|
|
</tr>
|
|
|
<tr class="odd">
|
|
|
<td style="text-align: left;">100%</td>
|
|
|
<td style="text-align: left;">100%</td>
|
|
|
<td style="text-align: right;">0.5481257</td>
|
|
|
</tr>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
</div>
|
|
|
</div>
|
|
|
<p>There seems to be some trials that are highly suceptable to this enrollment delay. Specifically, there were some</p>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb165"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb165-1"><a href="#cb165-1" aria-hidden="true" tabindex="-1"></a>n <span class="ot">=</span> <span class="fu">length</span>(counterfact_predicted_ib<span class="sc">$</span>p_predicted_intervention)</span>
|
|
|
<span id="cb165-2"><a href="#cb165-2" aria-hidden="true" tabindex="-1"></a>k <span class="ot">=</span> <span class="dv">100</span></span>
|
|
|
<span id="cb165-3"><a href="#cb165-3" aria-hidden="true" tabindex="-1"></a>simulated_terminations_intervention <span class="ot"><-</span> <span class="fu">mean</span>(<span class="fu">rbinom</span>(n,k,<span class="fu">as.vector</span>(counterfact_predicted_ib<span class="sc">$</span>p_predicted_intervention)))</span>
|
|
|
<span id="cb165-4"><a href="#cb165-4" aria-hidden="true" tabindex="-1"></a>simulated_terminations_base <span class="ot"><-</span><span class="fu">mean</span>(<span class="fu">rbinom</span>(n,k,<span class="fu">as.vector</span>(counterfact_predicted_ib<span class="sc">$</span>p_predicted_default)))</span>
|
|
|
<span id="cb165-5"><a href="#cb165-5" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb165-6"><a href="#cb165-6" aria-hidden="true" tabindex="-1"></a>simulated_percentages <span class="ot"><-</span> (simulated_terminations_intervention <span class="sc">-</span> simulated_terminations_base)<span class="sc">/</span>k</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
<p>The simulation above shows that this results in a percentage-point increase of about 2.4922006.</p>
|
|
|
</section>
|
|
|
</section>
|
|
|
<section id="diagnostics" class="level1">
|
|
|
<h1>Diagnostics</h1>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb166"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb166-1"><a href="#cb166-1" aria-hidden="true" tabindex="-1"></a><span class="co">#trace plots</span></span>
|
|
|
<span id="cb166-2"><a href="#cb166-2" aria-hidden="true" tabindex="-1"></a>image_diagnostics <span class="ot"><-</span> <span class="fu">paste0</span>(image_root,<span class="st">"/diagnostics"</span>)</span>
|
|
|
<span id="cb166-3"><a href="#cb166-3" aria-hidden="true" tabindex="-1"></a></span>
|
|
|
<span id="cb166-4"><a href="#cb166-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(fit, <span class="at">pars=</span><span class="fu">c</span>(<span class="st">"mu"</span>), <span class="at">plotfun=</span><span class="st">"trace"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-26-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb167"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb167-1"><a href="#cb167-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_diagnostics,<span class="st">"/trace_plot_mu.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb169"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb169-1"><a href="#cb169-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>) {</span>
|
|
|
<span id="cb169-2"><a href="#cb169-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span>(</span>
|
|
|
<span id="cb169-3"><a href="#cb169-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">mcmc_rank_overlay</span>(</span>
|
|
|
<span id="cb169-4"><a href="#cb169-4" aria-hidden="true" tabindex="-1"></a> fit, </span>
|
|
|
<span id="cb169-5"><a href="#cb169-5" aria-hidden="true" tabindex="-1"></a> <span class="at">pars=</span><span class="fu">c</span>(</span>
|
|
|
<span id="cb169-6"><a href="#cb169-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">paste0</span>(<span class="st">"mu["</span>,<span class="dv">4</span><span class="sc">*</span>i<span class="dv">-3</span>,<span class="st">"]"</span>),</span>
|
|
|
<span id="cb169-7"><a href="#cb169-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">paste0</span>(<span class="st">"mu["</span>,<span class="dv">4</span><span class="sc">*</span>i<span class="dv">-2</span>,<span class="st">"]"</span>),</span>
|
|
|
<span id="cb169-8"><a href="#cb169-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">paste0</span>(<span class="st">"mu["</span>,<span class="dv">4</span><span class="sc">*</span>i<span class="dv">-1</span>,<span class="st">"]"</span>),</span>
|
|
|
<span id="cb169-9"><a href="#cb169-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">paste0</span>(<span class="st">"mu["</span>,<span class="dv">4</span><span class="sc">*</span>i,<span class="st">"]"</span>)</span>
|
|
|
<span id="cb169-10"><a href="#cb169-10" aria-hidden="true" tabindex="-1"></a> ), </span>
|
|
|
<span id="cb169-11"><a href="#cb169-11" aria-hidden="true" tabindex="-1"></a> <span class="at">n_bins=</span><span class="dv">100</span></span>
|
|
|
<span id="cb169-12"><a href="#cb169-12" aria-hidden="true" tabindex="-1"></a> )<span class="sc">+</span> <span class="fu">legend_move</span>(<span class="st">"top"</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb169-13"><a href="#cb169-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_colour_ghibli_d</span>(<span class="st">"KikiMedium"</span>)</span>
|
|
|
<span id="cb169-14"><a href="#cb169-14" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb169-15"><a href="#cb169-15" aria-hidden="true" tabindex="-1"></a> mu_range <span class="ot"><-</span> <span class="fu">paste0</span>(<span class="dv">4</span><span class="sc">*</span>i<span class="dv">-3</span>,<span class="st">"-"</span>,<span class="dv">4</span><span class="sc">*</span>i)</span>
|
|
|
<span id="cb169-16"><a href="#cb169-16" aria-hidden="true" tabindex="-1"></a> filename <span class="ot"><-</span> <span class="fu">paste0</span>(image_diagnostics,<span class="st">"/trace_rank_plot_mu_"</span>,mu_range,<span class="st">".png"</span>)</span>
|
|
|
<span id="cb169-17"><a href="#cb169-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggsave</span>(filename)</span>
|
|
|
<span id="cb169-18"><a href="#cb169-18" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Scale for colour is already present.
|
|
|
Adding another scale for colour, which will replace the existing scale.</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-26-2.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image
|
|
|
Scale for colour is already present.
|
|
|
Adding another scale for colour, which will replace the existing scale.</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-26-3.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image
|
|
|
Scale for colour is already present.
|
|
|
Adding another scale for colour, which will replace the existing scale.</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-26-4.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb174"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb174-1"><a href="#cb174-1" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(fit, <span class="at">pars=</span><span class="fu">c</span>(<span class="st">"sigma"</span>), <span class="at">plotfun=</span><span class="st">"trace"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-27-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb175"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb175-1"><a href="#cb175-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_diagnostics,<span class="st">"/traceplot_sigma.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb177"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb177-1"><a href="#cb177-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>) {</span>
|
|
|
<span id="cb177-2"><a href="#cb177-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span>(</span>
|
|
|
<span id="cb177-3"><a href="#cb177-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">mcmc_rank_overlay</span>(</span>
|
|
|
<span id="cb177-4"><a href="#cb177-4" aria-hidden="true" tabindex="-1"></a> fit, </span>
|
|
|
<span id="cb177-5"><a href="#cb177-5" aria-hidden="true" tabindex="-1"></a> <span class="at">pars=</span><span class="fu">c</span>(</span>
|
|
|
<span id="cb177-6"><a href="#cb177-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">paste0</span>(<span class="st">"sigma["</span>,<span class="dv">4</span><span class="sc">*</span>i<span class="dv">-3</span>,<span class="st">"]"</span>),</span>
|
|
|
<span id="cb177-7"><a href="#cb177-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">paste0</span>(<span class="st">"sigma["</span>,<span class="dv">4</span><span class="sc">*</span>i<span class="dv">-2</span>,<span class="st">"]"</span>),</span>
|
|
|
<span id="cb177-8"><a href="#cb177-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">paste0</span>(<span class="st">"sigma["</span>,<span class="dv">4</span><span class="sc">*</span>i<span class="dv">-1</span>,<span class="st">"]"</span>),</span>
|
|
|
<span id="cb177-9"><a href="#cb177-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">paste0</span>(<span class="st">"sigma["</span>,<span class="dv">4</span><span class="sc">*</span>i,<span class="st">"]"</span>)</span>
|
|
|
<span id="cb177-10"><a href="#cb177-10" aria-hidden="true" tabindex="-1"></a> ), </span>
|
|
|
<span id="cb177-11"><a href="#cb177-11" aria-hidden="true" tabindex="-1"></a> <span class="at">n_bins=</span><span class="dv">100</span></span>
|
|
|
<span id="cb177-12"><a href="#cb177-12" aria-hidden="true" tabindex="-1"></a> )<span class="sc">+</span> <span class="fu">legend_move</span>(<span class="st">"top"</span>) <span class="sc">+</span></span>
|
|
|
<span id="cb177-13"><a href="#cb177-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_colour_ghibli_d</span>(<span class="st">"KikiMedium"</span>)</span>
|
|
|
<span id="cb177-14"><a href="#cb177-14" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb177-15"><a href="#cb177-15" aria-hidden="true" tabindex="-1"></a> sigma_range <span class="ot"><-</span> <span class="fu">paste0</span>(<span class="dv">4</span><span class="sc">*</span>i<span class="dv">-3</span>,<span class="st">"-"</span>,<span class="dv">4</span><span class="sc">*</span>i)</span>
|
|
|
<span id="cb177-16"><a href="#cb177-16" aria-hidden="true" tabindex="-1"></a> filename <span class="ot"><-</span> <span class="fu">paste0</span>(image_diagnostics,<span class="st">"/trace_rank_plot_sigma_"</span>,sigma_range,<span class="st">".png"</span>)</span>
|
|
|
<span id="cb177-17"><a href="#cb177-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggsave</span>(filename)</span>
|
|
|
<span id="cb177-18"><a href="#cb177-18" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Scale for colour is already present.
|
|
|
Adding another scale for colour, which will replace the existing scale.</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-27-2.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image
|
|
|
Scale for colour is already present.
|
|
|
Adding another scale for colour, which will replace the existing scale.</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-27-3.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image
|
|
|
Scale for colour is already present.
|
|
|
Adding another scale for colour, which will replace the existing scale.</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-27-4.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb182"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb182-1"><a href="#cb182-1" aria-hidden="true" tabindex="-1"></a><span class="co">#other diagnostics</span></span>
|
|
|
<span id="cb182-2"><a href="#cb182-2" aria-hidden="true" tabindex="-1"></a>logpost <span class="ot"><-</span> <span class="fu">log_posterior</span>(fit)</span>
|
|
|
<span id="cb182-3"><a href="#cb182-3" aria-hidden="true" tabindex="-1"></a>nuts_prmts <span class="ot"><-</span> <span class="fu">nuts_params</span>(fit)</span>
|
|
|
<span id="cb182-4"><a href="#cb182-4" aria-hidden="true" tabindex="-1"></a>posterior <span class="ot"><-</span> <span class="fu">as.array</span>(fit)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb183"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb183-1"><a href="#cb183-1" aria-hidden="true" tabindex="-1"></a><span class="fu">color_scheme_set</span>(<span class="st">"darkgray"</span>)</span>
|
|
|
<span id="cb183-2"><a href="#cb183-2" aria-hidden="true" tabindex="-1"></a>div_style <span class="ot"><-</span> <span class="fu">parcoord_style_np</span>(<span class="at">div_color =</span> <span class="st">"green"</span>, <span class="at">div_size =</span> <span class="fl">0.05</span>, <span class="at">div_alpha =</span> <span class="fl">0.4</span>)</span>
|
|
|
<span id="cb183-3"><a href="#cb183-3" aria-hidden="true" tabindex="-1"></a><span class="fu">mcmc_parcoord</span>(posterior, <span class="at">regex_pars =</span> <span class="st">"mu"</span>, <span class="at">np=</span>nuts_prmts, <span class="at">np_style =</span> div_style, <span class="at">alpha =</span> <span class="fl">0.05</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-29-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb184"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb184-1"><a href="#cb184-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_diagnostics,<span class="st">"/parcoord_mu.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb186"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb186-1"><a href="#cb186-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>) {</span>
|
|
|
<span id="cb186-2"><a href="#cb186-2" aria-hidden="true" tabindex="-1"></a> mus <span class="ot">=</span> <span class="fu">sapply</span>(<span class="dv">3</span><span class="sc">:</span><span class="dv">0</span>, <span class="cf">function</span>(j) <span class="fu">paste0</span>(<span class="st">"mu["</span>,<span class="dv">4</span><span class="sc">*</span>i<span class="sc">-</span>j ,<span class="st">"]"</span>))</span>
|
|
|
<span id="cb186-3"><a href="#cb186-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span>(</span>
|
|
|
<span id="cb186-4"><a href="#cb186-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">mcmc_pairs</span>(</span>
|
|
|
<span id="cb186-5"><a href="#cb186-5" aria-hidden="true" tabindex="-1"></a> posterior,</span>
|
|
|
<span id="cb186-6"><a href="#cb186-6" aria-hidden="true" tabindex="-1"></a> <span class="at">np =</span> nuts_prmts,</span>
|
|
|
<span id="cb186-7"><a href="#cb186-7" aria-hidden="true" tabindex="-1"></a> <span class="at">pars=</span><span class="fu">c</span>(</span>
|
|
|
<span id="cb186-8"><a href="#cb186-8" aria-hidden="true" tabindex="-1"></a> mus,</span>
|
|
|
<span id="cb186-9"><a href="#cb186-9" aria-hidden="true" tabindex="-1"></a> <span class="st">"lp__"</span></span>
|
|
|
<span id="cb186-10"><a href="#cb186-10" aria-hidden="true" tabindex="-1"></a> ),</span>
|
|
|
<span id="cb186-11"><a href="#cb186-11" aria-hidden="true" tabindex="-1"></a> <span class="at">off_diag_args =</span> <span class="fu">list</span>(<span class="at">size =</span> <span class="fl">0.75</span>)</span>
|
|
|
<span id="cb186-12"><a href="#cb186-12" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb186-13"><a href="#cb186-13" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb186-14"><a href="#cb186-14" aria-hidden="true" tabindex="-1"></a> mu_range <span class="ot"><-</span> <span class="fu">paste0</span>(<span class="dv">4</span><span class="sc">*</span>i<span class="dv">-3</span>,<span class="st">"-"</span>,<span class="dv">4</span><span class="sc">*</span>i)</span>
|
|
|
<span id="cb186-15"><a href="#cb186-15" aria-hidden="true" tabindex="-1"></a> filename <span class="ot"><-</span> <span class="fu">paste0</span>(image_diagnostics,<span class="st">"/correlation_plot_mu_"</span>,mu_range,<span class="st">".png"</span>)</span>
|
|
|
<span id="cb186-16"><a href="#cb186-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggsave</span>(filename)</span>
|
|
|
<span id="cb186-17"><a href="#cb186-17" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-30-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-30-2.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-30-3.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb190"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb190-1"><a href="#cb190-1" aria-hidden="true" tabindex="-1"></a><span class="fu">mcmc_parcoord</span>(posterior,<span class="at">regex_pars =</span> <span class="st">"sigma"</span>, <span class="at">np=</span>nuts_prmts, <span class="at">alpha=</span><span class="fl">0.05</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-31-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="sourceCode cell-code" id="cb191"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb191-1"><a href="#cb191-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="fu">paste0</span>(image_diagnostics,<span class="st">"/parcoord_sigma.png"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb193"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb193-1"><a href="#cb193-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>) {</span>
|
|
|
<span id="cb193-2"><a href="#cb193-2" aria-hidden="true" tabindex="-1"></a> params <span class="ot">=</span> <span class="fu">sapply</span>(<span class="dv">3</span><span class="sc">:</span><span class="dv">0</span>, <span class="cf">function</span>(j) <span class="fu">paste0</span>(<span class="st">"sigma["</span>,<span class="dv">4</span><span class="sc">*</span>i<span class="sc">-</span>j ,<span class="st">"]"</span>))</span>
|
|
|
<span id="cb193-3"><a href="#cb193-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span>(</span>
|
|
|
<span id="cb193-4"><a href="#cb193-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">mcmc_pairs</span>(</span>
|
|
|
<span id="cb193-5"><a href="#cb193-5" aria-hidden="true" tabindex="-1"></a> posterior,</span>
|
|
|
<span id="cb193-6"><a href="#cb193-6" aria-hidden="true" tabindex="-1"></a> <span class="at">np =</span> nuts_prmts,</span>
|
|
|
<span id="cb193-7"><a href="#cb193-7" aria-hidden="true" tabindex="-1"></a> <span class="at">pars=</span><span class="fu">c</span>(</span>
|
|
|
<span id="cb193-8"><a href="#cb193-8" aria-hidden="true" tabindex="-1"></a> params,</span>
|
|
|
<span id="cb193-9"><a href="#cb193-9" aria-hidden="true" tabindex="-1"></a> <span class="st">"lp__"</span></span>
|
|
|
<span id="cb193-10"><a href="#cb193-10" aria-hidden="true" tabindex="-1"></a> ),</span>
|
|
|
<span id="cb193-11"><a href="#cb193-11" aria-hidden="true" tabindex="-1"></a> <span class="at">off_diag_args =</span> <span class="fu">list</span>(<span class="at">size =</span> <span class="fl">0.75</span>)</span>
|
|
|
<span id="cb193-12"><a href="#cb193-12" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb193-13"><a href="#cb193-13" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb193-14"><a href="#cb193-14" aria-hidden="true" tabindex="-1"></a> sigma_range <span class="ot"><-</span> <span class="fu">paste0</span>(<span class="dv">4</span><span class="sc">*</span>i<span class="dv">-3</span>,<span class="st">"-"</span>,<span class="dv">4</span><span class="sc">*</span>i)</span>
|
|
|
<span id="cb193-15"><a href="#cb193-15" aria-hidden="true" tabindex="-1"></a> filename <span class="ot"><-</span> <span class="fu">paste0</span>(image_diagnostics,<span class="st">"/correlation_plot_sigma_"</span>,sigma_range,<span class="st">".png"</span>)</span>
|
|
|
<span id="cb193-16"><a href="#cb193-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggsave</span>(filename)</span>
|
|
|
<span id="cb193-17"><a href="#cb193-17" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-32-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-32-2.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-32-3.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<div class="sourceCode cell-code" id="cb197"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb197-1"><a href="#cb197-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (k <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">22</span>) {</span>
|
|
|
<span id="cb197-2"><a href="#cb197-2" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>) {</span>
|
|
|
<span id="cb197-3"><a href="#cb197-3" aria-hidden="true" tabindex="-1"></a> params <span class="ot">=</span> <span class="fu">sapply</span>(<span class="dv">3</span><span class="sc">:</span><span class="dv">0</span>, <span class="cf">function</span>(j) <span class="fu">paste0</span>(<span class="st">"beta["</span>,k,<span class="st">","</span>,<span class="dv">4</span><span class="sc">*</span>i<span class="sc">-</span>j ,<span class="st">"]"</span>))</span>
|
|
|
<span id="cb197-4"><a href="#cb197-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span>(</span>
|
|
|
<span id="cb197-5"><a href="#cb197-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">mcmc_pairs</span>(</span>
|
|
|
<span id="cb197-6"><a href="#cb197-6" aria-hidden="true" tabindex="-1"></a> posterior,</span>
|
|
|
<span id="cb197-7"><a href="#cb197-7" aria-hidden="true" tabindex="-1"></a> <span class="at">np =</span> nuts_prmts,</span>
|
|
|
<span id="cb197-8"><a href="#cb197-8" aria-hidden="true" tabindex="-1"></a> <span class="at">pars=</span><span class="fu">c</span>(</span>
|
|
|
<span id="cb197-9"><a href="#cb197-9" aria-hidden="true" tabindex="-1"></a> params,</span>
|
|
|
<span id="cb197-10"><a href="#cb197-10" aria-hidden="true" tabindex="-1"></a> <span class="st">"lp__"</span></span>
|
|
|
<span id="cb197-11"><a href="#cb197-11" aria-hidden="true" tabindex="-1"></a> ),</span>
|
|
|
<span id="cb197-12"><a href="#cb197-12" aria-hidden="true" tabindex="-1"></a> <span class="at">off_diag_args =</span> <span class="fu">list</span>(<span class="at">size =</span> <span class="fl">0.75</span>)</span>
|
|
|
<span id="cb197-13"><a href="#cb197-13" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb197-14"><a href="#cb197-14" aria-hidden="true" tabindex="-1"></a> )</span>
|
|
|
<span id="cb197-15"><a href="#cb197-15" aria-hidden="true" tabindex="-1"></a> </span>
|
|
|
<span id="cb197-16"><a href="#cb197-16" aria-hidden="true" tabindex="-1"></a> beta_range <span class="ot"><-</span> <span class="fu">paste0</span>(<span class="st">"k_"</span>,k,<span class="st">"_i_"</span>,<span class="dv">4</span><span class="sc">*</span>i<span class="dv">-3</span>,<span class="st">"-"</span>,<span class="dv">4</span><span class="sc">*</span>i)</span>
|
|
|
<span id="cb197-17"><a href="#cb197-17" aria-hidden="true" tabindex="-1"></a> filename <span class="ot"><-</span> <span class="fu">paste0</span>(image_diagnostics,<span class="st">"/correlation_plot_beta_"</span>,beta_range,<span class="st">".png"</span>)</span>
|
|
|
<span id="cb197-18"><a href="#cb197-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggsave</span>(filename)</span>
|
|
|
<span id="cb197-19"><a href="#cb197-19" aria-hidden="true" tabindex="-1"></a>}}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-1.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-2.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-3.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-4.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-5.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-6.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-7.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-8.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-9.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-10.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-11.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-12.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-13.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-14.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-15.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-16.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-17.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-18.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-19.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-20.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-21.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-22.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-23.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-24.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-25.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-26.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-27.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-28.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-29.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-30.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-31.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-32.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-33.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-34.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-35.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-36.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-37.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-38.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-39.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-40.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-41.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-42.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-43.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-44.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-45.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-46.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-47.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-48.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-49.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-50.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-51.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-52.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-53.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-54.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-55.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-56.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-57.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-58.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-59.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-60.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-61.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-62.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-63.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-64.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-65.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
<div class="cell-output-display">
|
|
|
<div>
|
|
|
<figure class="figure">
|
|
|
<p><img src="EffectsOfEnrollmentDelay_rebased_files/figure-html/unnamed-chunk-33-66.png" class="img-fluid figure-img" width="672"></p>
|
|
|
</figure>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-output cell-output-stderr">
|
|
|
<pre><code>Saving 7 x 5 in image</code></pre>
|
|
|
</div>
|
|
|
</div>
|
|
|
</section>
|
|
|
|
|
|
</main>
|
|
|
<!-- /main column -->
|
|
|
<script id="quarto-html-after-body" type="application/javascript">
|
|
|
window.document.addEventListener("DOMContentLoaded", function (event) {
|
|
|
const toggleBodyColorMode = (bsSheetEl) => {
|
|
|
const mode = bsSheetEl.getAttribute("data-mode");
|
|
|
const bodyEl = window.document.querySelector("body");
|
|
|
if (mode === "dark") {
|
|
|
bodyEl.classList.add("quarto-dark");
|
|
|
bodyEl.classList.remove("quarto-light");
|
|
|
} else {
|
|
|
bodyEl.classList.add("quarto-light");
|
|
|
bodyEl.classList.remove("quarto-dark");
|
|
|
}
|
|
|
}
|
|
|
const toggleBodyColorPrimary = () => {
|
|
|
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
|
|
if (bsSheetEl) {
|
|
|
toggleBodyColorMode(bsSheetEl);
|
|
|
}
|
|
|
}
|
|
|
toggleBodyColorPrimary();
|
|
|
const icon = "";
|
|
|
const anchorJS = new window.AnchorJS();
|
|
|
anchorJS.options = {
|
|
|
placement: 'right',
|
|
|
icon: icon
|
|
|
};
|
|
|
anchorJS.add('.anchored');
|
|
|
const isCodeAnnotation = (el) => {
|
|
|
for (const clz of el.classList) {
|
|
|
if (clz.startsWith('code-annotation-')) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
const onCopySuccess = function(e) {
|
|
|
// button target
|
|
|
const button = e.trigger;
|
|
|
// don't keep focus
|
|
|
button.blur();
|
|
|
// flash "checked"
|
|
|
button.classList.add('code-copy-button-checked');
|
|
|
var currentTitle = button.getAttribute("title");
|
|
|
button.setAttribute("title", "Copied!");
|
|
|
let tooltip;
|
|
|
if (window.bootstrap) {
|
|
|
button.setAttribute("data-bs-toggle", "tooltip");
|
|
|
button.setAttribute("data-bs-placement", "left");
|
|
|
button.setAttribute("data-bs-title", "Copied!");
|
|
|
tooltip = new bootstrap.Tooltip(button,
|
|
|
{ trigger: "manual",
|
|
|
customClass: "code-copy-button-tooltip",
|
|
|
offset: [0, -8]});
|
|
|
tooltip.show();
|
|
|
}
|
|
|
setTimeout(function() {
|
|
|
if (tooltip) {
|
|
|
tooltip.hide();
|
|
|
button.removeAttribute("data-bs-title");
|
|
|
button.removeAttribute("data-bs-toggle");
|
|
|
button.removeAttribute("data-bs-placement");
|
|
|
}
|
|
|
button.setAttribute("title", currentTitle);
|
|
|
button.classList.remove('code-copy-button-checked');
|
|
|
}, 1000);
|
|
|
// clear code selection
|
|
|
e.clearSelection();
|
|
|
}
|
|
|
const getTextToCopy = function(trigger) {
|
|
|
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
|
|
for (const childEl of codeEl.children) {
|
|
|
if (isCodeAnnotation(childEl)) {
|
|
|
childEl.remove();
|
|
|
}
|
|
|
}
|
|
|
return codeEl.innerText;
|
|
|
}
|
|
|
const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', {
|
|
|
text: getTextToCopy
|
|
|
});
|
|
|
clipboard.on('success', onCopySuccess);
|
|
|
if (window.document.getElementById('quarto-embedded-source-code-modal')) {
|
|
|
// For code content inside modals, clipBoardJS needs to be initialized with a container option
|
|
|
// TODO: Check when it could be a function (https://github.com/zenorocha/clipboard.js/issues/860)
|
|
|
const clipboardModal = new window.ClipboardJS('.code-copy-button[data-in-quarto-modal]', {
|
|
|
text: getTextToCopy,
|
|
|
container: window.document.getElementById('quarto-embedded-source-code-modal')
|
|
|
});
|
|
|
clipboardModal.on('success', onCopySuccess);
|
|
|
}
|
|
|
var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
|
|
|
var mailtoRegex = new RegExp(/^mailto:/);
|
|
|
var filterRegex = new RegExp('/' + window.location.host + '/');
|
|
|
var isInternal = (href) => {
|
|
|
return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href);
|
|
|
}
|
|
|
// Inspect non-navigation links and adorn them if external
|
|
|
var links = window.document.querySelectorAll('a[href]:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external):not([aria-hidden]):not(.dropdown-item):not(.quarto-navigation-tool):not(.about-link)');
|
|
|
for (var i=0; i<links.length; i++) {
|
|
|
const link = links[i];
|
|
|
if (!isInternal(link.href)) {
|
|
|
// undo the damage that might have been done by quarto-nav.js in the case of
|
|
|
// links that we want to consider external
|
|
|
if (link.dataset.originalHref !== undefined) {
|
|
|
link.href = link.dataset.originalHref;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
|
|
|
const config = {
|
|
|
allowHTML: true,
|
|
|
maxWidth: 500,
|
|
|
delay: 100,
|
|
|
arrow: false,
|
|
|
appendTo: function(el) {
|
|
|
return el.parentElement;
|
|
|
},
|
|
|
interactive: true,
|
|
|
interactiveBorder: 10,
|
|
|
theme: 'quarto',
|
|
|
placement: 'bottom-start',
|
|
|
};
|
|
|
if (contentFn) {
|
|
|
config.content = contentFn;
|
|
|
}
|
|
|
if (onTriggerFn) {
|
|
|
config.onTrigger = onTriggerFn;
|
|
|
}
|
|
|
if (onUntriggerFn) {
|
|
|
config.onUntrigger = onUntriggerFn;
|
|
|
}
|
|
|
window.tippy(el, config);
|
|
|
}
|
|
|
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
|
|
for (var i=0; i<noterefs.length; i++) {
|
|
|
const ref = noterefs[i];
|
|
|
tippyHover(ref, function() {
|
|
|
// use id or data attribute instead here
|
|
|
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
|
|
try { href = new URL(href).hash; } catch {}
|
|
|
const id = href.replace(/^#\/?/, "");
|
|
|
const note = window.document.getElementById(id);
|
|
|
if (note) {
|
|
|
return note.innerHTML;
|
|
|
} else {
|
|
|
return "";
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
const xrefs = window.document.querySelectorAll('a.quarto-xref');
|
|
|
const processXRef = (id, note) => {
|
|
|
// Strip column container classes
|
|
|
const stripColumnClz = (el) => {
|
|
|
el.classList.remove("page-full", "page-columns");
|
|
|
if (el.children) {
|
|
|
for (const child of el.children) {
|
|
|
stripColumnClz(child);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
stripColumnClz(note)
|
|
|
if (id === null || id.startsWith('sec-')) {
|
|
|
// Special case sections, only their first couple elements
|
|
|
const container = document.createElement("div");
|
|
|
if (note.children && note.children.length > 2) {
|
|
|
container.appendChild(note.children[0].cloneNode(true));
|
|
|
for (let i = 1; i < note.children.length; i++) {
|
|
|
const child = note.children[i];
|
|
|
if (child.tagName === "P" && child.innerText === "") {
|
|
|
continue;
|
|
|
} else {
|
|
|
container.appendChild(child.cloneNode(true));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (window.Quarto?.typesetMath) {
|
|
|
window.Quarto.typesetMath(container);
|
|
|
}
|
|
|
return container.innerHTML
|
|
|
} else {
|
|
|
if (window.Quarto?.typesetMath) {
|
|
|
window.Quarto.typesetMath(note);
|
|
|
}
|
|
|
return note.innerHTML;
|
|
|
}
|
|
|
} else {
|
|
|
// Remove any anchor links if they are present
|
|
|
const anchorLink = note.querySelector('a.anchorjs-link');
|
|
|
if (anchorLink) {
|
|
|
anchorLink.remove();
|
|
|
}
|
|
|
if (window.Quarto?.typesetMath) {
|
|
|
window.Quarto.typesetMath(note);
|
|
|
}
|
|
|
// TODO in 1.5, we should make sure this works without a callout special case
|
|
|
if (note.classList.contains("callout")) {
|
|
|
return note.outerHTML;
|
|
|
} else {
|
|
|
return note.innerHTML;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
for (var i=0; i<xrefs.length; i++) {
|
|
|
const xref = xrefs[i];
|
|
|
tippyHover(xref, undefined, function(instance) {
|
|
|
instance.disable();
|
|
|
let url = xref.getAttribute('href');
|
|
|
let hash = undefined;
|
|
|
if (url.startsWith('#')) {
|
|
|
hash = url;
|
|
|
} else {
|
|
|
try { hash = new URL(url).hash; } catch {}
|
|
|
}
|
|
|
if (hash) {
|
|
|
const id = hash.replace(/^#\/?/, "");
|
|
|
const note = window.document.getElementById(id);
|
|
|
if (note !== null) {
|
|
|
try {
|
|
|
const html = processXRef(id, note.cloneNode(true));
|
|
|
instance.setContent(html);
|
|
|
} finally {
|
|
|
instance.enable();
|
|
|
instance.show();
|
|
|
}
|
|
|
} else {
|
|
|
// See if we can fetch this
|
|
|
fetch(url.split('#')[0])
|
|
|
.then(res => res.text())
|
|
|
.then(html => {
|
|
|
const parser = new DOMParser();
|
|
|
const htmlDoc = parser.parseFromString(html, "text/html");
|
|
|
const note = htmlDoc.getElementById(id);
|
|
|
if (note !== null) {
|
|
|
const html = processXRef(id, note);
|
|
|
instance.setContent(html);
|
|
|
}
|
|
|
}).finally(() => {
|
|
|
instance.enable();
|
|
|
instance.show();
|
|
|
});
|
|
|
}
|
|
|
} else {
|
|
|
// See if we can fetch a full url (with no hash to target)
|
|
|
// This is a special case and we should probably do some content thinning / targeting
|
|
|
fetch(url)
|
|
|
.then(res => res.text())
|
|
|
.then(html => {
|
|
|
const parser = new DOMParser();
|
|
|
const htmlDoc = parser.parseFromString(html, "text/html");
|
|
|
const note = htmlDoc.querySelector('main.content');
|
|
|
if (note !== null) {
|
|
|
// This should only happen for chapter cross references
|
|
|
// (since there is no id in the URL)
|
|
|
// remove the first header
|
|
|
if (note.children.length > 0 && note.children[0].tagName === "HEADER") {
|
|
|
note.children[0].remove();
|
|
|
}
|
|
|
const html = processXRef(null, note);
|
|
|
instance.setContent(html);
|
|
|
}
|
|
|
}).finally(() => {
|
|
|
instance.enable();
|
|
|
instance.show();
|
|
|
});
|
|
|
}
|
|
|
}, function(instance) {
|
|
|
});
|
|
|
}
|
|
|
let selectedAnnoteEl;
|
|
|
const selectorForAnnotation = ( cell, annotation) => {
|
|
|
let cellAttr = 'data-code-cell="' + cell + '"';
|
|
|
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
|
|
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
|
|
return selector;
|
|
|
}
|
|
|
const selectCodeLines = (annoteEl) => {
|
|
|
const doc = window.document;
|
|
|
const targetCell = annoteEl.getAttribute("data-target-cell");
|
|
|
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
|
|
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
|
|
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
|
|
const lineIds = lines.map((line) => {
|
|
|
return targetCell + "-" + line;
|
|
|
})
|
|
|
let top = null;
|
|
|
let height = null;
|
|
|
let parent = null;
|
|
|
if (lineIds.length > 0) {
|
|
|
//compute the position of the single el (top and bottom and make a div)
|
|
|
const el = window.document.getElementById(lineIds[0]);
|
|
|
top = el.offsetTop;
|
|
|
height = el.offsetHeight;
|
|
|
parent = el.parentElement.parentElement;
|
|
|
if (lineIds.length > 1) {
|
|
|
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
|
|
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
|
|
height = bottom - top;
|
|
|
}
|
|
|
if (top !== null && height !== null && parent !== null) {
|
|
|
// cook up a div (if necessary) and position it
|
|
|
let div = window.document.getElementById("code-annotation-line-highlight");
|
|
|
if (div === null) {
|
|
|
div = window.document.createElement("div");
|
|
|
div.setAttribute("id", "code-annotation-line-highlight");
|
|
|
div.style.position = 'absolute';
|
|
|
parent.appendChild(div);
|
|
|
}
|
|
|
div.style.top = top - 2 + "px";
|
|
|
div.style.height = height + 4 + "px";
|
|
|
div.style.left = 0;
|
|
|
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
|
|
if (gutterDiv === null) {
|
|
|
gutterDiv = window.document.createElement("div");
|
|
|
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
|
|
gutterDiv.style.position = 'absolute';
|
|
|
const codeCell = window.document.getElementById(targetCell);
|
|
|
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
|
|
gutter.appendChild(gutterDiv);
|
|
|
}
|
|
|
gutterDiv.style.top = top - 2 + "px";
|
|
|
gutterDiv.style.height = height + 4 + "px";
|
|
|
}
|
|
|
selectedAnnoteEl = annoteEl;
|
|
|
}
|
|
|
};
|
|
|
const unselectCodeLines = () => {
|
|
|
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
|
|
elementsIds.forEach((elId) => {
|
|
|
const div = window.document.getElementById(elId);
|
|
|
if (div) {
|
|
|
div.remove();
|
|
|
}
|
|
|
});
|
|
|
selectedAnnoteEl = undefined;
|
|
|
};
|
|
|
// Handle positioning of the toggle
|
|
|
window.addEventListener(
|
|
|
"resize",
|
|
|
throttle(() => {
|
|
|
elRect = undefined;
|
|
|
if (selectedAnnoteEl) {
|
|
|
selectCodeLines(selectedAnnoteEl);
|
|
|
}
|
|
|
}, 10)
|
|
|
);
|
|
|
function throttle(fn, ms) {
|
|
|
let throttle = false;
|
|
|
let timer;
|
|
|
return (...args) => {
|
|
|
if(!throttle) { // first call gets through
|
|
|
fn.apply(this, args);
|
|
|
throttle = true;
|
|
|
} else { // all the others get throttled
|
|
|
if(timer) clearTimeout(timer); // cancel #2
|
|
|
timer = setTimeout(() => {
|
|
|
fn.apply(this, args);
|
|
|
timer = throttle = false;
|
|
|
}, ms);
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
// Attach click handler to the DT
|
|
|
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
|
|
for (const annoteDlNode of annoteDls) {
|
|
|
annoteDlNode.addEventListener('click', (event) => {
|
|
|
const clickedEl = event.target;
|
|
|
if (clickedEl !== selectedAnnoteEl) {
|
|
|
unselectCodeLines();
|
|
|
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
|
|
if (activeEl) {
|
|
|
activeEl.classList.remove('code-annotation-active');
|
|
|
}
|
|
|
selectCodeLines(clickedEl);
|
|
|
clickedEl.classList.add('code-annotation-active');
|
|
|
} else {
|
|
|
// Unselect the line
|
|
|
unselectCodeLines();
|
|
|
clickedEl.classList.remove('code-annotation-active');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
const findCites = (el) => {
|
|
|
const parentEl = el.parentElement;
|
|
|
if (parentEl) {
|
|
|
const cites = parentEl.dataset.cites;
|
|
|
if (cites) {
|
|
|
return {
|
|
|
el,
|
|
|
cites: cites.split(' ')
|
|
|
};
|
|
|
} else {
|
|
|
return findCites(el.parentElement)
|
|
|
}
|
|
|
} else {
|
|
|
return undefined;
|
|
|
}
|
|
|
};
|
|
|
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
|
|
for (var i=0; i<bibliorefs.length; i++) {
|
|
|
const ref = bibliorefs[i];
|
|
|
const citeInfo = findCites(ref);
|
|
|
if (citeInfo) {
|
|
|
tippyHover(citeInfo.el, function() {
|
|
|
var popup = window.document.createElement('div');
|
|
|
citeInfo.cites.forEach(function(cite) {
|
|
|
var citeDiv = window.document.createElement('div');
|
|
|
citeDiv.classList.add('hanging-indent');
|
|
|
citeDiv.classList.add('csl-entry');
|
|
|
var biblioDiv = window.document.getElementById('ref-' + cite);
|
|
|
if (biblioDiv) {
|
|
|
citeDiv.innerHTML = biblioDiv.innerHTML;
|
|
|
}
|
|
|
popup.appendChild(citeDiv);
|
|
|
});
|
|
|
return popup.innerHTML;
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
</script>
|
|
|
</div> <!-- /content -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</body></html> |