<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Data Diction</title>
<link>https://www.data-diction.com/</link>
<atom:link href="https://www.data-diction.com/index.xml" rel="self" type="application/rss+xml"/>
<description>Data and the stories they tell us</description>
<image>
<url>https://www.data-diction.com/logo2.png</url>
<title>Data Diction</title>
<link>https://www.data-diction.com/</link>
<height>149</height>
<width>144</width>
</image>
<generator>quarto-1.10.18</generator>
<lastBuildDate>Tue, 08 Sep 2026 00:00:00 GMT</lastBuildDate>
<item>
  <title>I selected a model. Can I trust my p-values yet?</title>
  <dc:creator>Jinal Shah</dc:creator>
  <link>https://www.data-diction.com/posts/resolving-upsis-with-selective-inference/</link>
  <description><![CDATA[ 





<!-- Edit the line below after review -->
<div class="callout callout-style-default callout-note callout-empty-content callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Reviewed by Ryan Peterson on 2026-08-13
</div>
</div>
<div class="callout-body-container callout-body">

</div>
</div>
<p>In a previous <a href="https://data-diction.com/posts/upsi-example/">post</a>, Dr.&nbsp;P. Hackman demonstrated the remarkable effectiveness of unadjusted post-selection inference (UPSI) for achieving publishable, significant results. By searching for interesting “subgroups” through a large collection of main effects and interactions and then applying ordinary inferences as though no selection had occurred, Hackman virtually guaranteed statistically significant findings even when none existed.</p>
<p>The statistical problem I want to focus on here is not about causation: it’s about what happens when we use the data to select which subgroups to test, and then act as if those subgroups had been specified in advance. This issue applies equally to randomized trials and observational studies. Randomization protects against confounding, but not against the false positives that come from data-driven model selection. <strong>The analysis in the original post is simply performing model selection and then pretending the selected model had been specified in advance.</strong></p>
<p>While this strategy may be excellent for a fictional statistician seeking ill-gotten fame and glory, sane analysts are interested in a slightly different goal: obtaining inference that is actually valid. This raises a natural question: if I select a model, and UPSIs are invalid, what should I use instead? In this post, I’ll revisit Hackman’s simulation setup and illustrate a more rigorous approach to post-selection inference: selective inference.</p>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Tip</span>The <code>selectInferToolkit</code> R package
</div>
</div>
<div class="callout-body-container callout-body">
<p>Selective inference, forward stepwise selection, and many other selection and inference methods are available in the <code>selectInferToolkit</code> R package, available on <a href="https://github.com/petersonR/selectInferToolkit/">GitHub</a>.</p>
</div>
</div>
<section id="upsi-alternatives" class="level1">
<h1>UPSI Alternatives</h1>
<p>One proposed remedy, discussed in Maggie Qian’s follow-up post, <a href="https://evidenceinthewild.com/the-antidote-to-guaranteed-significance/">The Antidote to Guaranteed Significance</a>, is multiplicity adjustment. Qian shows that a Bonferroni or similar correction adjusts p-values for the number of tests performed, and therefore substantially “brings the false positive rate back to earth.” However, even Bonferroni, conservative as it is, doesn’t bring it down to the nominal <img src="https://latex.codecogs.com/png.latex?%5Calpha=0.05"> level; <strong>the null still gets rejected nearly three times the nominal rate</strong>. A key reason is that multiplicity adjustment requires knowing how many tests you’re adjusting for. In the model selection setting, that number is genuinely ambiguous. Is it the <img src="https://latex.codecogs.com/png.latex?2%5Ep"> possible models? Something proportional to <img src="https://latex.codecogs.com/png.latex?p">? The number of steps taken during the forward search? The answer lies somewhere in between, and no single correction cleanly resolves the problem.</p>
<p>More importantly, the subgroup discovery framing is a special case of a more general problem. In many analyses, there is no pre-specified treatment and no enumerable list of candidate subgroups: we simply have a large collection of predictors and interactions, and we use the data to select a model. In the general setting, model selection (usually, <a href="https://www.mdpi.com/1099-4300/28/9/943">but not always!</a>) presumes no natural pre-specified hierarchy and no obvious grouping structure. The post-selection inference problem remains, and we need methods that address it directly.</p>
<p>Selective inference is designed for exactly this situation. Rather than counting comparisons after the fact, it directly accounts for the model selection procedure by asking: given that this particular model was selected from data, what can we still infer? In effect, it conditions on the selection event and recalibrates the usual p-values and confidence intervals accordingly. The price of this intellectual humility can be quite steep: the resulting intervals are often wider - sometimes infinite in length. Worse, the impressively small p-values driven by Hackman’s underhanded UPSIs will, more often than not, lose their sheen of significance.</p>
<!-- RP: I thought the callout-note below was a bit repetitive of the above paragraph, but do think it's worth pointing to those slides, so I shortened it and moved the call to the "extreme example" to the next section.  -->
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Tip</span>How does selective inference actually work though?
</div>
</div>
<div class="callout-body-container callout-body">
<p>For readers interested in more theoretical properties of selective inference can refer to slides <a href="https://jasondlee88.github.io/slides/selective_inference_and_debiasing.pdf">here</a>.</p>
</div>
</div>
</section>
<section id="example-a-study-for-treatment-of-chronic-pain" class="level1">
<h1>Example: a study for treatment of chronic pain</h1>
<!-- RP: Added a few section breaks -->
<section id="hackmans-upsi-approach" class="level2">
<h2 class="anchored" data-anchor-id="hackmans-upsi-approach">Hackman’s UPSI approach</h2>
<p>Let’s revisit the (rather extreme) simulation in the original post which uses interactions between 6 covariates to define subgroups:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span>
<span id="cb1-2">subgroups <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(</span>
<span id="cb1-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">age =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"18-35"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"36-50"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"51-65"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"66-80"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"80+"</span>),</span>
<span id="cb1-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sex =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Male"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Female"</span>),</span>
<span id="cb1-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Left"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Right"</span>), </span>
<span id="cb1-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">coffee =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2+"</span>),</span>
<span id="cb1-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alcohol =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"3+"</span>),</span>
<span id="cb1-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">physical_activity =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"3+"</span>)</span>
<span id="cb1-9">)</span>
<span id="cb1-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">21</span>)</span>
<span id="cb1-11">n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Sample size  </span></span>
<span id="cb1-12"></span>
<span id="cb1-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Simulate recruitment (y: outcome)</span></span>
<span id="cb1-14">y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n)</span>
<span id="cb1-15"></span>
<span id="cb1-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Simulate recruitment (assume each new person has random subgroup)</span></span>
<span id="cb1-17">x_idx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sample</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(subgroups), n, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">replace =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) </span>
<span id="cb1-18">X <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> subgroups[x_idx,]</span>
<span id="cb1-19">simdata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y, X)</span>
<span id="cb1-20"></span>
<span id="cb1-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create model matrix w/all interactions</span></span>
<span id="cb1-22">X2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">model.matrix</span>(y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> . <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> ., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata)[,<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb1-23"></span>
<span id="cb1-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># combine into data set for model fitting</span></span>
<span id="cb1-25">simdata2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y=</span>y, X2)</span></code></pre></div></div>
</div>
<p>As we saw in Hackman’s original <a href="https://data-diction.com/posts/upsi-example/#whats-with-the-high-p-values">post</a>, when using forward stepwise selection with BIC, every single selected subgroup was declared statistically significant as reproduced below. Importantly, <strong>Hackman’s UPSI approach finds highly significant results despite the relationship between treatment and response being completely random</strong>!</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(selectInferToolkit) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#github.com/petersonR/selectInferToolkit</span></span>
<span id="cb2-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fit the stepwise BIC model </span></span>
<span id="cb2-3">fit_bic <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select_stepwise_ic</span>(y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> ., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2, </span>
<span id="cb2-4">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"forward"</span>, </span>
<span id="cb2-5">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">penalty =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BIC"</span>)</span>
<span id="cb2-6"></span>
<span id="cb2-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Perform unadjusted post-selection inference (UPSI)</span></span>
<span id="cb2-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">infer_upsi</span>(fit_bic, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(coef <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) </span></code></pre></div></div>
</div>
<div class="cell">
<div class="cell-output-display">
<div id="cqauxoxwnr" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#cqauxoxwnr table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#cqauxoxwnr thead, #cqauxoxwnr tbody, #cqauxoxwnr tfoot, #cqauxoxwnr tr, #cqauxoxwnr td, #cqauxoxwnr th {
  border-style: none;
}

#cqauxoxwnr p {
  margin: 0;
  padding: 0;
}

#cqauxoxwnr .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#cqauxoxwnr .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#cqauxoxwnr .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#cqauxoxwnr .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#cqauxoxwnr .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#cqauxoxwnr .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#cqauxoxwnr .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#cqauxoxwnr .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#cqauxoxwnr .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#cqauxoxwnr .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#cqauxoxwnr .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#cqauxoxwnr .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#cqauxoxwnr .gt_spanner_row {
  border-bottom-style: hidden;
}

#cqauxoxwnr .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#cqauxoxwnr .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#cqauxoxwnr .gt_from_md > :first-child {
  margin-top: 0;
}

#cqauxoxwnr .gt_from_md > :last-child {
  margin-bottom: 0;
}

#cqauxoxwnr .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#cqauxoxwnr .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#cqauxoxwnr .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#cqauxoxwnr .gt_row_group_first td {
  border-top-width: 2px;
}

#cqauxoxwnr .gt_row_group_first th {
  border-top-width: 2px;
}

#cqauxoxwnr .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#cqauxoxwnr .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#cqauxoxwnr .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#cqauxoxwnr .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#cqauxoxwnr .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#cqauxoxwnr .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#cqauxoxwnr .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#cqauxoxwnr .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#cqauxoxwnr .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#cqauxoxwnr .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#cqauxoxwnr .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#cqauxoxwnr .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#cqauxoxwnr .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#cqauxoxwnr .gt_left {
  text-align: left;
}

#cqauxoxwnr .gt_center {
  text-align: center;
}

#cqauxoxwnr .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#cqauxoxwnr .gt_font_normal {
  font-weight: normal;
}

#cqauxoxwnr .gt_font_bold {
  font-weight: bold;
}

#cqauxoxwnr .gt_font_italic {
  font-style: italic;
}

#cqauxoxwnr .gt_super {
  font-size: 65%;
}

#cqauxoxwnr .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#cqauxoxwnr .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#cqauxoxwnr .gt_indent_1 {
  text-indent: 5px;
}

#cqauxoxwnr .gt_indent_2 {
  text-indent: 10px;
}

#cqauxoxwnr .gt_indent_3 {
  text-indent: 15px;
}

#cqauxoxwnr .gt_indent_4 {
  text-indent: 20px;
}

#cqauxoxwnr .gt_indent_5 {
  text-indent: 25px;
}

#cqauxoxwnr .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#cqauxoxwnr div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings header">
<th id="term" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col">term</th>
<th id="coef" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">coef</th>
<th id="ci_low" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">ci_low</th>
<th id="ci_high" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">ci_high</th>
<th id="p_value" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">p_value</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="term">(Intercept)</td>
<td class="gt_row gt_right" headers="coef">0.07</td>
<td class="gt_row gt_right" headers="ci_low">−0.09</td>
<td class="gt_row gt_right" headers="ci_high">0.24</td>
<td class="gt_row gt_right" headers="p_value">0.393</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age36.50</td>
<td class="gt_row gt_right" headers="coef">0.27</td>
<td class="gt_row gt_right" headers="ci_low">0.10</td>
<td class="gt_row gt_right" headers="ci_high">0.45</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.003</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age66.80</td>
<td class="gt_row gt_right" headers="coef">−0.38</td>
<td class="gt_row gt_right" headers="ci_low">−0.57</td>
<td class="gt_row gt_right" headers="ci_high">−0.18</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age66.80.coffee1</td>
<td class="gt_row gt_right" headers="coef">0.23</td>
<td class="gt_row gt_right" headers="ci_low">0.04</td>
<td class="gt_row gt_right" headers="ci_high">0.42</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.019</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age51.65.coffee2.</td>
<td class="gt_row gt_right" headers="coef">0.29</td>
<td class="gt_row gt_right" headers="ci_low">0.11</td>
<td class="gt_row gt_right" headers="ci_high">0.46</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.002</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age51.65.physical_activity1</td>
<td class="gt_row gt_right" headers="coef">−0.24</td>
<td class="gt_row gt_right" headers="ci_low">−0.42</td>
<td class="gt_row gt_right" headers="ci_high">−0.07</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.007</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">sexFemale.physical_activity2</td>
<td class="gt_row gt_right" headers="coef">−0.32</td>
<td class="gt_row gt_right" headers="ci_low">−0.49</td>
<td class="gt_row gt_right" headers="ci_high">−0.15</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">&lt;0.001</td>
</tr>
</tbody>
</table>

</div>
</div>
</div>
<p><strong>Presenting UPSI-based results like this can be deeply misleading.</strong> Imagine a research team applies a similar approach to an observational study of pain management, discovers that patients aged 36-50 show a “significantly” stronger association with better outcomes, and publishes accordingly. A clinical lab takes the finding at face value and designs a confirmatory trial targeting that age group. The trial fails - not because the treatment doesn’t work, but because the original association was an artifact of searching through dozens of subgroups without accounting for the search. Time, money, and patient participation were spent chasing a signal that was never there.</p>
<div class="callout callout-style-default callout-caution callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Caution</span>UPSIs are “oopsies”
</div>
</div>
<div class="callout-body-container callout-body">
<p>The fact that a variable was selected and appears statistically significant in the unadjusted post-selection inferences of the final model (e.g.&nbsp;a significant UPSI-based p-value) does <strong>not</strong> imply that the effect is real. Much of the apparent certainty can disappear once we account for the model selection process itself.</p>
</div>
</div>
<!-- RP: Section title is your call -->
</section>
<section id="selective-inference-to-the-rescue" class="level2">
<h2 class="anchored" data-anchor-id="selective-inference-to-the-rescue">Selective inference to the rescue</h2>
<p>When performing inference after selection, we know that since we’ve used the data both to select the model and now are using the same data to perform inference, these results are overly-optimistic - they are UPSIs. So next let’s use <strong>selective inference</strong>, which explicitly accounts for the fact that the model itself was selected using the data.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># infer_selective can perform selective inference </span></span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">infer_selective</span>(fit_bic, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb3-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb3-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(coef <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) </span></code></pre></div></div>
</div>
<div class="cell">
<div class="cell-output-display">
<div id="dffxqshprn" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#dffxqshprn table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#dffxqshprn thead, #dffxqshprn tbody, #dffxqshprn tfoot, #dffxqshprn tr, #dffxqshprn td, #dffxqshprn th {
  border-style: none;
}

#dffxqshprn p {
  margin: 0;
  padding: 0;
}

#dffxqshprn .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#dffxqshprn .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#dffxqshprn .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#dffxqshprn .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#dffxqshprn .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#dffxqshprn .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#dffxqshprn .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#dffxqshprn .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#dffxqshprn .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#dffxqshprn .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#dffxqshprn .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#dffxqshprn .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#dffxqshprn .gt_spanner_row {
  border-bottom-style: hidden;
}

#dffxqshprn .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#dffxqshprn .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#dffxqshprn .gt_from_md > :first-child {
  margin-top: 0;
}

#dffxqshprn .gt_from_md > :last-child {
  margin-bottom: 0;
}

#dffxqshprn .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#dffxqshprn .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#dffxqshprn .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#dffxqshprn .gt_row_group_first td {
  border-top-width: 2px;
}

#dffxqshprn .gt_row_group_first th {
  border-top-width: 2px;
}

#dffxqshprn .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#dffxqshprn .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#dffxqshprn .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#dffxqshprn .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#dffxqshprn .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#dffxqshprn .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#dffxqshprn .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#dffxqshprn .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#dffxqshprn .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#dffxqshprn .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#dffxqshprn .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#dffxqshprn .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#dffxqshprn .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#dffxqshprn .gt_left {
  text-align: left;
}

#dffxqshprn .gt_center {
  text-align: center;
}

#dffxqshprn .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#dffxqshprn .gt_font_normal {
  font-weight: normal;
}

#dffxqshprn .gt_font_bold {
  font-weight: bold;
}

#dffxqshprn .gt_font_italic {
  font-style: italic;
}

#dffxqshprn .gt_super {
  font-size: 65%;
}

#dffxqshprn .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#dffxqshprn .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#dffxqshprn .gt_indent_1 {
  text-indent: 5px;
}

#dffxqshprn .gt_indent_2 {
  text-indent: 10px;
}

#dffxqshprn .gt_indent_3 {
  text-indent: 15px;
}

#dffxqshprn .gt_indent_4 {
  text-indent: 20px;
}

#dffxqshprn .gt_indent_5 {
  text-indent: 25px;
}

#dffxqshprn .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#dffxqshprn div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings header">
<th id="term" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col">term</th>
<th id="coef" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">coef</th>
<th id="ci_low" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">ci_low</th>
<th id="ci_high" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">ci_high</th>
<th id="p_value" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">p_value</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="term">(Intercept)</td>
<td class="gt_row gt_right" headers="coef">0.07</td>
<td class="gt_row gt_right" headers="ci_low">NA</td>
<td class="gt_row gt_right" headers="ci_high">NA</td>
<td class="gt_row gt_right" headers="p_value">NA</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age36.50</td>
<td class="gt_row gt_right" headers="coef">0.27</td>
<td class="gt_row gt_right" headers="ci_low">−9.26</td>
<td class="gt_row gt_right" headers="ci_high">0.33</td>
<td class="gt_row gt_right" headers="p_value">0.879</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age66.80</td>
<td class="gt_row gt_right" headers="coef">−0.38</td>
<td class="gt_row gt_right" headers="ci_low">−Inf</td>
<td class="gt_row gt_right" headers="ci_high">0.72</td>
<td class="gt_row gt_right" headers="p_value">0.080</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age66.80.coffee1</td>
<td class="gt_row gt_right" headers="coef">0.23</td>
<td class="gt_row gt_right" headers="ci_low">−1.30</td>
<td class="gt_row gt_right" headers="ci_high">1.63</td>
<td class="gt_row gt_right" headers="p_value">0.381</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age51.65.coffee2.</td>
<td class="gt_row gt_right" headers="coef">0.29</td>
<td class="gt_row gt_right" headers="ci_low">−5.85</td>
<td class="gt_row gt_right" headers="ci_high">1.21</td>
<td class="gt_row gt_right" headers="p_value">0.759</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age51.65.physical_activity1</td>
<td class="gt_row gt_right" headers="coef">−0.24</td>
<td class="gt_row gt_right" headers="ci_low">−1.57</td>
<td class="gt_row gt_right" headers="ci_high">1.06</td>
<td class="gt_row gt_right" headers="p_value">0.333</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">sexFemale.physical_activity2</td>
<td class="gt_row gt_right" headers="coef">−0.32</td>
<td class="gt_row gt_right" headers="ci_low">−6.74</td>
<td class="gt_row gt_right" headers="ci_high">0.61</td>
<td class="gt_row gt_right" headers="p_value">0.099</td>
</tr>
</tbody>
</table>

</div>
</div>
</div>
<p>Here we see that <strong>after accounting for the selection process, none of the selected effects remain statistically significant</strong>! Let’s take a moment to appreciate this victory over Hackman’s UPSI approach.</p>
<p>Of course, as mentioned previously, one caveat is confidence intervals become substantially wider. In this example, the lower CI bound for the 66-80 age subgroup extends to <img src="https://latex.codecogs.com/png.latex?-%5Cinfty">. This isn’t an error or numerical instability. Rather, it reflects the uncertainty introduced by model selection: when an effect is identified only after searching through many possible models, accounting for that selection process can result in substantially wider confidence intervals.</p>
<!-- RP: More fun section title?  -->
</section>
<section id="a-victory-or-a-fluke" class="level2">
<h2 class="anchored" data-anchor-id="a-victory-or-a-fluke">A victory? Or a fluke?</h2>
<p>I can almost hear Hackman coughing back: <em>this was only a single simulation, I might have lost that battle but surely not the war. Even Bonferroni and his ridiculous adjustment failed to fully rein in my UPSIs.</em></p>
<p>Selective inference did successfully wash the false sheen of significance off of Hackman’s UPSI-based p-values once. Taking a page from Hackman himself, let’s repeat this 1000 times, as though we run the study in 1000 parallel universes to confirm without any doubt that selective inference controls the false-positive results. I will also add the simple antidote with Bonferroni multiplicity correction (with the number of tests set to <img src="https://latex.codecogs.com/png.latex?p"> as in Qian’s post) to see how it performs.</p>
<p>As noted earlier, selective inference controls type I error per selected variable conditional on selection, but not across all selected variables within a single analysis/dataset. When BIC selects multiple variables and each is tested at <img src="https://latex.codecogs.com/png.latex?%5Calpha=0.05">, the chance of at least one false positive per simulation compounds. To address this, I also apply a within-simulation Bonferroni correction on top of selective inference, adjusting each SI p-value by the number of selected variables in that simulation. This adds a second layer of multiplicity control: SI accounts for the search process, while the Bonferroni step accounts for testing multiple selected variables simultaneously.</p>
<!-- RP: went down a wild rabbit hole here with the selectInferToolkit package. Ensure you are using the latest version of the package; should see very close-to-nominal results now. There were previously a few issues, including many of the results returned by infer_selective not matching the selected model, which I **think** I have fixed properly at this time. -->
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># create list to store different results</span></span>
<span id="cb4-2">sim_results_UPSI <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>()</span>
<span id="cb4-3">sim_results_SI <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>() <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># selective inference only </span></span>
<span id="cb4-4">sim_results_SI_BF <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>() <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># selective inference with bonferroni correction </span></span>
<span id="cb4-5">sim_results_BONF <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>()</span>
<span id="cb4-6"></span>
<span id="cb4-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1234</span>)</span>
<span id="cb4-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## The below takes about 10 minutes to run </span></span>
<span id="cb4-9"></span>
<span id="cb4-10"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span>(s <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>) { </span>
<span id="cb4-11">  simdata2<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n)</span>
<span id="cb4-12">  fit_bic <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select_stepwise_ic</span>(</span>
<span id="cb4-13">    y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> ., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2, </span>
<span id="cb4-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"forward"</span>,</span>
<span id="cb4-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">penalty =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BIC"</span></span>
<span id="cb4-16">  )</span>
<span id="cb4-17">  </span>
<span id="cb4-18">  sim_results_UPSI[[s]] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> </span>
<span id="cb4-19">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">infer_upsi</span>(fit_bic, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb4-20">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb4-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(coef <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) </span>
<span id="cb4-22">  </span>
<span id="cb4-23">  sim_results_BONF[[s]] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> </span>
<span id="cb4-24">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">infer_upsi</span>(fit_bic, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-26">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(coef <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-28">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_tests =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ncol</span>(simdata2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># number of predictors, p, </span></span>
<span id="cb4-29">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p_value  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pmin</span>(p_value <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> n_tests, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Bonferroni adjusted</span></span>
<span id="cb4-30">    )</span>
<span id="cb4-31">  </span>
<span id="cb4-32">  sim_results_SI[[s]] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> </span>
<span id="cb4-33">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">infer_selective</span>(fit_bic, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-34">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-35">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(coef <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) </span>
<span id="cb4-36">  </span>
<span id="cb4-37">  sim_results_SI_BF[[s]] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> </span>
<span id="cb4-38">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">infer_selective</span>(fit_bic, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-39">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-40">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(coef <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-41">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-42">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_selected =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(term <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(Intercept)"</span>),  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># number of selected non-intercept terms</span></span>
<span id="cb4-43">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p_value =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pmin</span>(p_value <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> n_selected, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb4-44">    )</span>
<span id="cb4-45">  </span>
<span id="cb4-46">}</span>
<span id="cb4-47"></span>
<span id="cb4-48">upsi_results      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(sim_results_UPSI, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.id =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sim"</span>)</span>
<span id="cb4-49">si_results  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(sim_results_SI, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.id =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sim"</span>)</span>
<span id="cb4-50">si_bonf_results  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(sim_results_SI_BF, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.id =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sim"</span>)</span>
<span id="cb4-51">bonf_results <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(sim_results_BONF, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.id =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sim"</span>)</span></code></pre></div></div>
</div>
<p>I can now summarize the results as shown below.</p>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">summarise_results <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(results) {</span>
<span id="cb5-2">  results <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> results <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(term <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(Intercept)"</span>)</span>
<span id="cb5-3">  </span>
<span id="cb5-4">  per_sim <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> results <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sim) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># simulation level summary</span></span>
<span id="cb5-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb5-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_disc =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(term)),</span>
<span id="cb5-8">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_sig  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(p_value <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb5-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">any_sig =</span> n_sig <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb5-10">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb5-11">    )</span>
<span id="cb5-12">  </span>
<span id="cb5-13">  per_sim <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb5-15">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_sims      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># sims with any selections</span></span>
<span id="cb5-16">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">avg_disc    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(n_disc), <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># avg selections per sim ( should be same)</span></span>
<span id="cb5-17">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">avg_n_sig      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(n_sig),  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># avg significant finding per simulation </span></span>
<span id="cb5-18">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pct_any_sim =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(any_sig) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># % sims with &gt;=1 false positive</span></span>
<span id="cb5-19">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pct_sig_var =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(n_sig)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(n_disc) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># % of selected vars signif.</span></span>
<span id="cb5-20">    )</span>
<span id="cb5-21">}</span>
<span id="cb5-22"></span>
<span id="cb5-23">upsi_summary   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise_results</span>(upsi_results)</span>
<span id="cb5-24">si_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise_results</span>(si_results)</span>
<span id="cb5-25">si_bonf_summary  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise_results</span>(si_bonf_results)</span>
<span id="cb5-26">bonf_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise_results</span>(bonf_results)</span></code></pre></div></div>
</details>
</div>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(</span>
<span id="cb6-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Method =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UPSI"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Bonferroni (BF)"</span>, </span>
<span id="cb6-3">             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Selective Inference (SI)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SI + BF correction"</span>),</span>
<span id="cb6-4">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Avg selected</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(upsi_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>avg_disc, bonf_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>avg_disc,</span>
<span id="cb6-5">                      si_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>avg_disc, si_bonf_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>avg_disc),</span>
<span id="cb6-6">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">% vars sig</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(upsi_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_sig_var, bonf_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_sig_var,</span>
<span id="cb6-7">                    si_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_sig_var, si_bonf_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_sig_var),</span>
<span id="cb6-8">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">% sims ≥1 FP</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(upsi_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_any_sim, bonf_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_any_sim,</span>
<span id="cb6-9">                       si_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_any_sim, si_bonf_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_any_sim),</span>
<span id="cb6-10">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Avg FP/sim</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(upsi_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>avg_n_sig, bonf_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>avg_n_sig,</span>
<span id="cb6-11">                    si_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>avg_n_sig, si_bonf_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>avg_n_sig)</span>
<span id="cb6-12">)</span></code></pre></div></div>
</details>
</div>
<div class="cell">
<div class="cell-output-display">
<div id="xjpvbhtvxb" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#xjpvbhtvxb table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#xjpvbhtvxb thead, #xjpvbhtvxb tbody, #xjpvbhtvxb tfoot, #xjpvbhtvxb tr, #xjpvbhtvxb td, #xjpvbhtvxb th {
  border-style: none;
}

#xjpvbhtvxb p {
  margin: 0;
  padding: 0;
}

#xjpvbhtvxb .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#xjpvbhtvxb .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#xjpvbhtvxb .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#xjpvbhtvxb .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#xjpvbhtvxb .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#xjpvbhtvxb .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#xjpvbhtvxb .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#xjpvbhtvxb .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#xjpvbhtvxb .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#xjpvbhtvxb .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#xjpvbhtvxb .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#xjpvbhtvxb .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#xjpvbhtvxb .gt_spanner_row {
  border-bottom-style: hidden;
}

#xjpvbhtvxb .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#xjpvbhtvxb .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#xjpvbhtvxb .gt_from_md > :first-child {
  margin-top: 0;
}

#xjpvbhtvxb .gt_from_md > :last-child {
  margin-bottom: 0;
}

#xjpvbhtvxb .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#xjpvbhtvxb .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#xjpvbhtvxb .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#xjpvbhtvxb .gt_row_group_first td {
  border-top-width: 2px;
}

#xjpvbhtvxb .gt_row_group_first th {
  border-top-width: 2px;
}

#xjpvbhtvxb .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#xjpvbhtvxb .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#xjpvbhtvxb .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#xjpvbhtvxb .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#xjpvbhtvxb .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#xjpvbhtvxb .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#xjpvbhtvxb .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#xjpvbhtvxb .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#xjpvbhtvxb .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#xjpvbhtvxb .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#xjpvbhtvxb .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#xjpvbhtvxb .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#xjpvbhtvxb .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#xjpvbhtvxb .gt_left {
  text-align: left;
}

#xjpvbhtvxb .gt_center {
  text-align: center;
}

#xjpvbhtvxb .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#xjpvbhtvxb .gt_font_normal {
  font-weight: normal;
}

#xjpvbhtvxb .gt_font_bold {
  font-weight: bold;
}

#xjpvbhtvxb .gt_font_italic {
  font-style: italic;
}

#xjpvbhtvxb .gt_super {
  font-size: 65%;
}

#xjpvbhtvxb .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#xjpvbhtvxb .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#xjpvbhtvxb .gt_indent_1 {
  text-indent: 5px;
}

#xjpvbhtvxb .gt_indent_2 {
  text-indent: 10px;
}

#xjpvbhtvxb .gt_indent_3 {
  text-indent: 15px;
}

#xjpvbhtvxb .gt_indent_4 {
  text-indent: 20px;
}

#xjpvbhtvxb .gt_indent_5 {
  text-indent: 25px;
}

#xjpvbhtvxb .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#xjpvbhtvxb div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings header">
<th id="Method" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col">Method</th>
<th id="Avg-selected" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">Avg selected</th>
<th id="a%-vars-sig" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">% vars sig</th>
<th id="a%-sims-≥1-FP" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">% sims ≥1 FP</th>
<th id="Avg-FP/sim" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">Avg FP/sim</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="Method">UPSI</td>
<td class="gt_row gt_right" headers="Avg selected">3.12</td>
<td class="gt_row gt_right" headers="% vars sig" style="color: #EE0000; font-weight: bold">98.70</td>
<td class="gt_row gt_right" headers="% sims ≥1 FP" style="color: #EE0000; font-weight: bold">100.00</td>
<td class="gt_row gt_right" headers="Avg FP/sim">3.08</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="Method">Bonferroni (BF)</td>
<td class="gt_row gt_right" headers="Avg selected">3.12</td>
<td class="gt_row gt_right" headers="% vars sig" style="color: #EE9A00; font-weight: bold">14.31</td>
<td class="gt_row gt_right" headers="% sims ≥1 FP" style="color: #EE0000; font-weight: bold">28.10</td>
<td class="gt_row gt_right" headers="Avg FP/sim">0.45</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="Method">Selective Inference (SI)</td>
<td class="gt_row gt_right" headers="Avg selected">3.12</td>
<td class="gt_row gt_right" headers="% vars sig" style="color: #00EE00; font-weight: bold">4.71</td>
<td class="gt_row gt_right" headers="% sims ≥1 FP" style="color: #EE9A00; font-weight: bold">13.72</td>
<td class="gt_row gt_right" headers="Avg FP/sim">0.15</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="Method">SI + BF correction</td>
<td class="gt_row gt_right" headers="Avg selected">3.12</td>
<td class="gt_row gt_right" headers="% vars sig">1.12</td>
<td class="gt_row gt_right" headers="% sims ≥1 FP">3.40</td>
<td class="gt_row gt_right" headers="Avg FP/sim">0.04</td>
</tr>
</tbody>
</table>

</div>
</div>
</div>
<p>Across 1000 simulated null datasets, BIC selected on average of about 3 variables per simulation. The table above summarizes false positive rates across four approaches.</p>
<p>UPSI declared 99% of selected variables significant and produced at least one false positive in every simulation, averaging 3 spurious significant discoveries per simulation. In other words, by combining model selection with ordinary inference, we (like Hackman) were able to manufacture statistically significant findings 100% of the time.</p>
<p>A Bonferroni correction applied to the UPSI p-values, adjusting for all 92 candidate predictors, reduced the variable-level false positive rate to 14% and the simulation-level rate to about 28%. This is a meaningful improvement, but still far above the nominal 5% level. Hackman can still conjure false significance all too easily. The core difficulty with a simple multiplicity adjustment like Bonferroni is that it requires knowing how many comparisons were made, and that number is genuinely ambiguous after model selection.</p>
<p>Selective inference brought the variable-level rate down to the 5% nominal rate. Yet still, 13.7% of simulations yielded a falsely significant finding! What gives? It turns out that SI controls type I error rate <em>per selected variable</em> conditional on selection, but when BIC selects <img src="https://latex.codecogs.com/png.latex?%5Csim"> 3 variables per simulation, each is tested at 5%, and thus the probability of at least one false positive per simulation roughly becomes <img src="https://latex.codecogs.com/png.latex?1%20-%20(0.95)%5E3%20%5Csim%2014%5C%25">, even with perfect variable-level type I error control. Adding a Bonferroni correction within each simulation, that is, adjusting for the number of <strong>selected</strong> variables tested within each simulation, brings the simulation-level family-wise error rate down at last to ~5%.</p>
<p><strong>Final thoughts/Conclusion</strong></p>
<p>The original post framed the analysis as subgroup discovery, with a pre-specified treatment as the primary hypothesis. But the post-selection inference problem arises in any setting where the data are used to select a model, whether that’s using lasso to build a prediction model from observational data, screening hundreds of genes to identify relevant biomarkers, or an analyst cycling through several covariate sets before settling on a final specification. In none of these cases is there a pre-specified treatment hypothesis driving the analysis, and in all of them ordinary inference will be overly optimistic after selection.</p>
<p>Here I’ve only evaluated selective inference in terms of false positive control. While selective inference can address the false positive rate, it comes at the cost of very wide CIs (sometimes infinite!). In a future post, we’ll explore how powerful selective inference is when true effects actually exist, as well as how precise are CI obtained from selective inference.</p>
</section>
</section>
<section id="key-takeaways" class="level1">
<h1>Key Takeaways</h1>
<ul>
<li><p>Performing inference after variable selection using the UPSI approach nearly guarantees false positives.</p></li>
<li><p>Multiplicity adjustment like Bonferroni can’t fix the post-selection inference problem alone.</p></li>
<li><p>Selective inference <strong>can</strong> control false-positive at nominal alpha level. Our new R package, the <code>selectInferToolkit</code> package leverages the <code>selectiveInference</code> package to render adjusting inferences for selection highly practical.</p></li>
</ul>
</section>
<section id="future-threads" class="level1">
<h1>Future Threads</h1>
<ul>
<li><p>What are alternative post-selection inference methods?</p></li>
<li><p>How do other post-selection inference methods (i.e., bootstrap, PIPE) implemented in the <code>selectInferToolkit</code> package compare in terms of false discoveries vs power?</p></li>
<li><p>Can we still make some inference about non-selections?</p></li>
</ul>
</section>
<section id="related" class="level1">
<h1>Related</h1>
<ul>
<li><p>Our group described the UPSI problem in more detail in this <a href="https://data-diction.com/posts/upsi-example/">post</a></p></li>
<li><p>Another response to original post which also discusses multiplicity corrections, Bayesian alternative and hierarchical testing in detail : <a href="https://evidenceinthewild.com/the-antidote-to-guaranteed-significance/">The Antidote to Guaranteed Significance</a></p></li>
<li><p>Good further reading with background on selective inference &amp; Replicability: <a href="https://hdsr.mitpress.mit.edu/pub/l39rpgyc/release/3">Benjamini 2020</a></p></li>
<li><p>More theoretical background on selective inference: Paper by <a href="https://www.pnas.org/doi/full/10.1073/pnas.1507583112">Jonathan Taylor and Robert Tibshirani</a> and slides by <a href="https://jasondlee88.github.io/slides/selective_inference_and_debiasing.pdf">Jason Lee</a></p></li>
</ul>
<hr>
</section>
<section id="appendix" class="level1">
<h1>Appendix</h1>
<details>
<summary>
R Session Info
</summary>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">sessioninfo<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">session_info</span>()</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.5.2 (2025-10-31)
 os       macOS Tahoe 26.6.2
 system   aarch64, darwin20
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Chicago
 date     2026-09-08
 pandoc   3.9.0.2 @ /opt/homebrew/bin/ (via rmarkdown)
 quarto   1.9.36 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/quarto

─ Packages ───────────────────────────────────────────────────────────────────
 package            * version    date (UTC) lib source
 adaptMCMC            1.5        2024-01-29 [1] CRAN (R 4.5.0)
 backports            1.5.1      2026-04-03 [1] CRAN (R 4.5.2)
 broom              * 1.0.13     2026-05-14 [1] CRAN (R 4.5.2)
 class                7.3-23     2025-01-01 [2] CRAN (R 4.5.2)
 cli                  3.6.6      2026-04-09 [1] CRAN (R 4.5.2)
 coda                 0.19-4.1   2024-01-31 [1] CRAN (R 4.5.0)
 codetools            0.2-20     2024-03-31 [2] CRAN (R 4.5.2)
 data.table           1.18.4     2026-05-06 [1] CRAN (R 4.5.2)
 digest               0.6.39     2025-11-19 [1] CRAN (R 4.5.2)
 dplyr              * 1.2.1      2026-04-03 [1] CRAN (R 4.5.2)
 evaluate             1.0.5      2025-08-27 [1] CRAN (R 4.5.0)
 farver               2.1.2      2024-05-13 [1] CRAN (R 4.5.0)
 fastmap              1.2.0      2024-05-15 [1] CRAN (R 4.5.0)
 forcats            * 1.0.1      2025-09-25 [1] CRAN (R 4.5.0)
 foreach              1.5.2      2022-02-02 [1] CRAN (R 4.5.0)
 fs                   2.1.0      2026-04-18 [1] CRAN (R 4.5.2)
 future               1.75.0     2026-07-20 [1] CRAN (R 4.5.2)
 future.apply         1.20.2     2026-02-20 [1] CRAN (R 4.5.2)
 generics             0.1.4      2025-05-09 [1] CRAN (R 4.5.0)
 ggplot2            * 4.0.3      2026-04-22 [1] CRAN (R 4.5.2)
 glmnet               5.0        2026-05-04 [1] CRAN (R 4.5.2)
 globals              0.19.1     2026-03-13 [1] CRAN (R 4.5.2)
 glue                 1.8.1      2026-04-17 [1] CRAN (R 4.5.2)
 gower                1.0.2      2024-12-17 [1] CRAN (R 4.5.0)
 gt                 * 1.3.0      2026-01-22 [1] CRAN (R 4.5.2)
 gtable               0.3.6      2024-10-25 [1] CRAN (R 4.5.0)
 hardhat              1.4.3      2026-04-04 [1] CRAN (R 4.5.2)
 here               * 1.0.2      2025-09-15 [1] CRAN (R 4.5.0)
 hms                  1.1.4      2025-10-17 [1] CRAN (R 4.5.0)
 htmltools            0.5.9      2025-12-04 [1] CRAN (R 4.5.2)
 htmlwidgets          1.6.4      2023-12-06 [1] CRAN (R 4.5.0)
 intervals            0.15.5     2024-08-23 [1] CRAN (R 4.5.0)
 ipred                0.9-15     2024-07-18 [1] CRAN (R 4.5.0)
 iterators            1.0.14     2022-02-05 [1] CRAN (R 4.5.0)
 jsonlite             2.0.0      2025-03-27 [1] CRAN (R 4.5.0)
 knitr                1.51       2025-12-20 [1] CRAN (R 4.5.2)
 lattice              0.22-9     2026-02-09 [1] CRAN (R 4.5.2)
 lava                 1.9.2      2026-06-30 [1] CRAN (R 4.5.2)
 lifecycle            1.0.5      2026-01-08 [1] CRAN (R 4.5.2)
 listenv              1.0.0      2026-06-22 [1] CRAN (R 4.5.2)
 lubridate          * 1.9.5      2026-02-04 [1] CRAN (R 4.5.2)
 magrittr             2.0.5      2026-04-04 [1] CRAN (R 4.5.2)
 MASS                 7.3-65     2025-02-28 [2] CRAN (R 4.5.2)
 Matrix               1.7-5      2026-03-21 [1] CRAN (R 4.5.2)
 ncvreg               3.16.0     2025-10-09 [1] Github (pbreheny/ncvreg@5fecc8c)
 nnet                 7.3-20     2025-01-01 [1] CRAN (R 4.5.0)
 otel                 0.2.0      2025-08-29 [1] CRAN (R 4.5.0)
 parallelly           1.48.0     2026-06-29 [1] CRAN (R 4.5.2)
 pbapply              1.7-4      2025-07-20 [1] CRAN (R 4.5.0)
 pillar               1.11.1     2025-09-17 [1] CRAN (R 4.5.0)
 pkgconfig            2.0.3      2019-09-22 [1] CRAN (R 4.5.0)
 prodlim              2026.03.11 2026-03-11 [1] CRAN (R 4.5.2)
 purrr              * 1.2.2      2026-04-10 [1] CRAN (R 4.5.2)
 R6                   2.6.1      2025-02-15 [1] CRAN (R 4.5.0)
 RColorBrewer         1.1-3      2022-04-03 [1] CRAN (R 4.5.0)
 Rcpp                 1.1.2      2026-07-05 [1] CRAN (R 4.5.2)
 readr              * 2.2.0      2026-02-19 [1] CRAN (R 4.5.2)
 recipes              1.3.3      2026-05-30 [1] CRAN (R 4.5.2)
 rlang                1.3.0      2026-07-05 [1] CRAN (R 4.5.2)
 rmarkdown            2.31       2026-03-26 [1] CRAN (R 4.5.2)
 rpart                4.1.27     2026-03-27 [1] CRAN (R 4.5.2)
 rprojroot            2.1.1      2025-08-26 [1] CRAN (R 4.5.0)
 rstudioapi           0.18.0     2026-01-16 [1] CRAN (R 4.5.2)
 S7                   0.2.2      2026-04-22 [1] CRAN (R 4.5.2)
 sass                 0.4.10     2025-04-11 [1] CRAN (R 4.5.0)
 scales               1.4.0      2025-04-24 [1] CRAN (R 4.5.0)
 selectInferToolkit * 0.4.4      2026-08-13 [1] Github (petersonR/selectInferToolkit@d41796d)
 selectiveInference   1.2.5      2019-09-07 [1] CRAN (R 4.5.0)
 sessioninfo          1.2.3      2025-02-05 [1] CRAN (R 4.5.0)
 shape                1.4.6.1    2024-02-23 [1] CRAN (R 4.5.0)
 sparsevctrs          0.3.6      2026-01-27 [1] CRAN (R 4.5.2)
 stringi              1.8.9      2026-08-04 [1] CRAN (R 4.5.2)
 stringr            * 1.6.0      2025-11-04 [1] CRAN (R 4.5.0)
 survival             3.8-6      2026-01-16 [1] CRAN (R 4.5.2)
 tibble             * 3.3.1      2026-01-11 [1] CRAN (R 4.5.2)
 tidyr              * 1.3.2      2025-12-19 [1] CRAN (R 4.5.2)
 tidyselect           1.2.1      2024-03-11 [1] CRAN (R 4.5.0)
 tidyverse          * 2.0.0      2023-02-22 [1] CRAN (R 4.5.0)
 timechange           0.4.0      2026-01-29 [1] CRAN (R 4.5.2)
 timeDate             4052.112   2026-01-28 [1] CRAN (R 4.5.2)
 tzdb                 0.5.0      2025-03-15 [1] CRAN (R 4.5.0)
 vctrs                0.7.3      2026-04-11 [1] CRAN (R 4.5.2)
 withr                3.0.3      2026-06-19 [1] CRAN (R 4.5.2)
 xfun                 0.57       2026-03-20 [1] CRAN (R 4.5.2)
 xml2                 1.5.2      2026-01-17 [1] CRAN (R 4.5.2)
 yaml                 2.3.12     2025-12-10 [1] CRAN (R 4.5.2)

 [1] /Users/rpterson/Library/R/arm64/4.5/library
 [2] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
 * ── Packages attached to the search path.

──────────────────────────────────────────────────────────────────────────────</code></pre>
</div>
</div>
</details>


</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shah2026" class="csl-entry quarto-appendix-citeas">
Shah, Jinal. 2026. <span>“I Selected a Model. Can I Trust My p-Values
Yet?”</span> <em>Data Diction</em> (blog). September 8, 2026. <a href="https://doi.org/10.59350/pcr99-e8q06">https://doi.org/10.59350/pcr99-e8q06</a>.
</div></div></section></div> ]]></description>
  <category>model selection</category>
  <category>post-selection inference</category>
  <category>glass-box modeling</category>
  <category>R</category>
  <guid>https://www.data-diction.com/posts/resolving-upsis-with-selective-inference/</guid>
  <pubDate>Tue, 08 Sep 2026 00:00:00 GMT</pubDate>
  <media:content url="https://www.data-diction.com/posts/resolving-upsis-with-selective-inference/thumbnail.jpeg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>ASA Response to NIH Request for Information: Measuring and Rewarding Scientific Impact</title>
  <link>https://www.data-diction.com/posts/asa-nih-replicability-reproducibility/</link>
  <description><![CDATA[ 





<p><img src="https://www.data-diction.com/posts/asa-nih-replicability-reproducibility/asa-logo.jpg" class="img-fluid"></p>
<p><strong>Developed with scientific and technical input from</strong> Ryan A. Peterson, PhD; Elizabeth W. Eisenhauer, PhD; Theresa Kim, PhD, MS; and other ASA members.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>This response is also available from the <a href="https://www.amstat.org/docs/default-source/amstat-documents/pol-response-to-nih-roi-measuring-and-rewarding-scientific-impact.pdf">ASA website</a>. It is republished here at <em>Data Diction</em> with permission.</p>
</div>
</div>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Contributor Disclaimer
</div>
</div>
<div class="callout-body-container callout-body">
<p>The views do not necessarily represent the views of contributors’ employers or affiliated institutions. Theresa Kim provided scientific and technical input during off-duty hours and without use of government-furnished equipment; her participation does not represent the views of NIH, HHS, or the U.S. Government.</p>
<p><em>Claude Opus 5 (Anthropic) and GPT-5.6 Sol (OpenAI) were used to assist with drafting and editing these comments.</em></p>
</div>
</div>
<section id="rigor-and-reproducibility" class="level2">
<h2 class="anchored" data-anchor-id="rigor-and-reproducibility">1. Rigor and Reproducibility</h2>
<section id="the-missing-instrument-indicators-for-analytic-replicability" class="level3">
<h3 class="anchored" data-anchor-id="the-missing-instrument-indicators-for-analytic-replicability">1.1 The missing instrument: indicators for analytic replicability</h3>
<p>We are highly encouraged by NIH’s renewed focus on transparency, reproducibility, and replication shown in the Request for Information on Measuring and Rewarding Scientific Impact, the Initiative to promote Strengthening Replication and Reproducibility of NIH-funded Research, the Gold Standard implementation plan, and the recent Highlighted Topic on Enhancing Scientific Rigor, Transparency and Replicability. These documents name reproducibility and replicability as distinct goals, correctly, and the Initiative has instruments aimed at each: for the former, longstanding investments in data sharing, standardization, and public access to findings; for the latter, funded replication research through the Common Fund, a Replication Prize, and a stated intent to engage researchers in identifying areas ripe for replication.</p>
<p>These are steps in the right direction. However, we have yet to observe incentives targeting the gap between reproducibility and replicability: whether the reported inference is valid given how the analysis proceeded. Statisticians and biostatisticians have a useful and unusual vantage point on this gap: we are often among the first to recognize why a finding may not replicate, while not always having the standing or involvement needed to address the problem.</p>
<p>This matters because replication studies <em>detect</em> errors, but do not <em>prevent</em> them. They measure the failure rate after the fact, one finding at a time, at a high cost per finding. A study can be perfectly reproducible — fully containerized, one-click re-runnable — and still report inference that is unlikely to replicate, and the replication study will discover this several years and several hundred thousand dollars later.</p>
<p>A common route to this is inference on a model that was chosen using the same data used for inference: <strong>unadjusted post-selection inference (UPSI)</strong>. It is one instance of what Simmons, Nelson, and Simonsohn (2011) termed researcher degrees of freedom: undisclosed flexibility in analytic choices, sufficient on its own to produce significant findings without any intent to deceive. In a satirical blog post, Perry Hackman used simulations with pure-noise outcomes and a modest set of candidate subgroup interactions to show that an ostensibly rigorous method, forward stepwise selection with information criteria followed by standard statistical inference (dubbed UPSI), can produce at least one “significant” effect in 90+% of simulated trials (Peterson, 2025b). Nothing in that pipeline is clearly fraudulent; the analysis plan reads as rigorous, and the resulting code can be shared, containerized, and re-run perfectly.</p>
<p><strong>Recommendation</strong>: The Initiative’s replication instruments would return more per dollar if paired with a cheap upstream instrument that flags the findings most likely to need them. In analysis plans, progress reports, and publication reporting, a short structured statement answering the following could be incentivized:</p>
<ul>
<li>Was the reported model, subgroup, outcome scale, or covariate set chosen using the same data used to compute the reported inference?<br>
</li>
<li>If so, how were the inferences adjusted for selection? (sample splitting; selective or conditional inference; bootstrap or model-averaged uncertainty; explicit relabeling as exploratory). If not, where was the full analysis specification verifiably pre-registered?<br>
</li>
<li>How many candidate specifications were considered, including those examined and discarded?</li>
</ul>
<p>Based on the above, results should be taken as on a spectrum between confirmatory (to provide stronger evidence for prespecified claims) and exploratory (to identify patterns and generate hypotheses).</p>
<p>Another recommendation is to commission periodic targeted statistical review of a random sample of supported publications, scored by trained statistical reviewers, reporting the proportion that (a) report selection-conditional inference without adjustment, (b) report subgroup findings without pre-specified subgroup structure, and (c) contain code that does not execute. Tracking that proportion over time measures whether the Initiative is working.</p>
</section>
<section id="candidate-pools-and-model-complexity-are-growing-faster-than-the-standards-applied" class="level3">
<h3 class="anchored" data-anchor-id="candidate-pools-and-model-complexity-are-growing-faster-than-the-standards-applied">1.2 Candidate pools and model complexity are growing faster than the standards applied</h3>
<p>Beneath many variable-selection procedures is an implicit assumption of covariate equipoise: that every candidate predictor is equally worthy of entering the model. Stepwise procedures, popular information criteria searches, and standard lasso implementations can all behave this way, and the assumption becomes problematic in settings where NIH is investing heavily.</p>
<p>Independent groups have converged on the same principle from different directions. Yu, Bien, and Tibshirani (2019) articulate a <em>reluctant interaction selection principle</em> — prefer a main effect over an interaction if all else is equal — and Tay and Tibshirani (2020) extend this method to a <em>reluctant non-linear selection principle</em>, preferring a linear term over a non-linear one on the same grounds. In his standard reference text, Harrell (2015) advises pre-specifying a small set of plausible interactions rather than testing all of them. Peterson and Cavanaugh (2022) advise that human-understandable “glass-box” models with meaningful features should be preferred to more complex ones precisely because they are easier to interrogate and replicate. Different penalties, different algorithms, same underlying claim: complexity should have to earn its way into a model, and treating every candidate term as equally deserving is what allows spurious complexity through. NIH need not adjudicate among these methods, but it should seek to require the reporting that makes the problem visible.</p>
<p>Transparent modeling methods matter because <strong>replication requires something to replicate</strong>: a claim specific enough that an independent team can test it on new data and report whether it held. Transparent statistical models often make such claims directly available. <em>Waist circumference is associated with one-year HDL, β = −0.04 (95% CI −0.07 to −0.01)</em> is a statement another group can go and check in a different dataset, and the check has a clear objective.</p>
<p>On the other hand, black-box predictive models, such as neural networks, XGBoost, random forests, and statistical models with high-order interaction terms, instead primarily yield prediction functions. A second team can apply the deposited model to new data and test whether predictive performance holds up. That is a meaningful form of external validation, but it is different from replicating an interpretable scientific claim. When performance drops, the failure may be difficult to localize: a transparent model can reveal which estimated relationship moved and in which direction, while an opaque model may reveal only that predictive performance deteriorated, and, if subgroup metrics are tracked, for whom.</p>
<p>This has a direct implication for the Initiative. Predictive modeling is an increasingly prominent category of NIH-supported research (e.g., Arshi et al.&nbsp;2025, Le et al.&nbsp;2024), and it is precisely the category on which replication instruments have the least purchase. Transparency is therefore not only a matter of trust, fairness, or regulatory compliance, though it is those too. It also determines how specifically a scientific claim can be interrogated and replicated.</p>
<p>As datasets grow larger and contain newer, more high-dimensional modalities, new statistical methodology will be critical. For instance, with only twenty candidate predictors, to capture potential interactions, one would need to sift through 190 pairwise interactions, 1,140 three-way interactions, and over a million candidate models across all orders. Further, when modalities differ in their dimension and overall signal, they quickly run into practical challenges. For example, in a lung adenocarcinoma survival analysis with 7 clinical covariates and 22,283 gene expression measurements, assuming covariate equipoise and penalizing both groups equally encodes a structural disadvantage for clinically well-motivated variables, which get de-selected due to the sheer difference in dimensionality of the two modalities. With NIH’s data-integration priorities, as studies become multimodal, consisting of genomics plus clinical plus imaging plus wearable plus environmental and more, the need for novel methods that can accommodate such data is critical; important methodological challenges remain at the scale and complexity of these data.</p>
<p><strong>Recommendations:</strong> First, NIH should be wary of accepting post-hoc explanation of an opaque model (such as a locally interpretable model, a SHAP-based variable importance metric, etc.) as a reliable, replicable scientific finding; the explainer is a separate model that may or may not describe what the first one does, and should not be treated as equivalent to a directly interpretable scientific claim. Second, the accuracy cost of transparency is an empirical question that has been studied. A systematic review of 71 studies developing clinical prediction models found no performance benefit of machine learning over logistic regression (Christodoulou et al., 2019). Benchmarking work supports this outside the clinical setting as well: across 110 datasets from the Penn Machine Learning Benchmarks database, a transparent regression approach was within 5% of the best-performing method on 79% of classification and 62% of regression datasets, with random forests and gradient boosting showing no statistically distinguishable advantage (Peterson et al., 2024). Where transparent methods fell short, the reasons were diagnosable and specific and not reflective of a general law that complexity buys accuracy (specific examples can be found in Peterson et al., 2024, Section 3.3.2).</p>
<p>The implication is not that black-box methods should be discouraged, but that the burden of justification runs backward. <strong>Investigators are rarely asked to show that their model’s opacity bought anything</strong>. For NIH-funded models intended to inform clinical decisions, a low-cost expectation is that a transparent baseline be fit and reported alongside the complex one, so the cost of interpretability is measured in that application rather than assumed. Where the gap is negligible, as is often the case, the transparent model is the better scientific product, because it can be interrogated and corrected.</p>
</section>
<section id="adequacy-at-the-design-stage-making-evidentiary-expectations-auditable" class="level3">
<h3 class="anchored" data-anchor-id="adequacy-at-the-design-stage-making-evidentiary-expectations-auditable">1.3 Adequacy at the design stage: making evidentiary expectations auditable</h3>
<p>These analysis-stage safeguards are necessary, but inference is only as strong as the data generated by the study design. The design determines which populations, outcomes, contrasts, and sources of variation are observed and therefore which scientific claims the resulting data can support. One of the earliest places this becomes explicit is the sample-size or design justification, where investigators state what they expect the proposed design to be capable of learning.</p>
<p>This makes the justification useful for more than determining a number. It provides a prospective, auditable statement of what adequate evidence was expected to look like. NIH can then ask whether the realized study provided that evidence and, if not, whether the departures and their implications were documented. A study need not unfold exactly as anticipated. Recruitment, measurement properties, effect sizes, intraclass correlations, or other design features must often be learned during the course of a study, at which point they become scientific information in their own right. Reporting them allows planning assumptions to be updated across studies rather than repeatedly regenerated from incomplete information.</p>
<p>For studies relying on existing or linked data, realized data quality may also differ from what was assumed at design, with implications for which claims the data can support. Rigor requires making those departures visible and reconsidering the claims they permit, rather than retrospectively treating the original justification as though nothing changed.</p>
<p>Gold Standard Science creates a policy demand for determining and justifying adequate sample sizes, but no common definition of “adequate” accompanies it. Raising conventional thresholds does not settle the problem. A study can have 90% power under poorly supported assumptions, for an effect of little scientific consequence, using an inefficient design, or with an imprecisely measured outcome. Adequacy is instead a fit-for-purpose judgment: whether the design, measurement, data quality, and analysis are sufficient for the claims the study is intended to support.</p>
<p>NIH guidance already reflects this principle. Under the current Parent R01 review framework, reviewers assess whether sample size is sufficient and well justified in relation to the research questions, outcomes, and design (NIH, 2024). NCCIH feasibility trials instead require quantitative feasibility or acceptability benchmarks and justification that the sample is sufficient to evaluate them; testing efficacy or “preliminary efficacy” is explicitly not the purpose (NCCIH, 2024a). By contrast, NCCIH efficacy, effectiveness, and pragmatic trials require power calculations linked to endpoints and hypotheses, at least 90% power for the primary outcome, adjustment for multiple primary outcomes, and a clinically meaningful effect size (NCCIH, 2024b). NIH therefore already treats adequacy as purpose-dependent; the opportunity is to make that principle explicit, consistent, and auditable.</p>
<p>The same principle extends beyond these examples. Exploratory secondary analyses, transportability or triangulation studies, resource construction, and methods development may require adequate precision, population overlap, analytic scope, ability to assess discordance, or support for future studies rather than power against a single alternative. Requiring a power calculation regardless can produce the calculation without the justification. This is not a lower bar for exploratory work but a different one: identify the intended claim, the criterion of adequacy it requires, and the corresponding limits on inference.</p>
<p>Design information also interacts with the candidate analysis space. Limited information combined with broad analytic flexibility can generate apparently strong but unstable findings, while each source of risk is largely invisible to instruments aimed only at the other.</p>
<p>Declaring intended claims and criteria of adequacy at the design stage gives the disclosure in §1.1 something to be checked against. A confirmatory aim that later relies on substantial data-dependent selection, or a secondary outcome later presented as a primary claim, has changed evidentiary status during execution. That is not necessarily a scientific failure, provided that its path from “design” to “discussion” is visible and reflected in the claims made.</p>
<p><strong>Recommendations:</strong></p>
<p>First, require fit-for-purpose definitions of adequacy. Applications should identify the claims or objectives the study is intended to support, and the criterion for an adequate sample size or design should reflect that purpose. When an effect size is used to justify adequacy, its magnitude should be grounded where possible in empirical evidence and interpreted on a scale meaningful to the scientific question. Generic standardized effect-size conventions such as “small,” “medium,” and “large” should not substitute for separately considering the magnitude of effect that would matter and the variability anticipated in the study population. Not every aim of a complex study requires a separate, fully developed power analysis. However, the study should identify the minimum set of claims or objectives it is designed to support with strong evidentiary justification and demonstrate that the proposed design is adequate for those purposes.</p>
<p>Second, treat sample-size justification as an integral part of study design rather than a calculation performed after the design is largely fixed. The amount of information a study can provide depends not only on the number of observations but on interdependent choices about the population recruited, comparisons made, measurements collected, timing and intensity of follow-up, analytic strategy, and other features that can affect the credibility of conclusions. Those choices must also be made within constraints on participant burden, operational feasibility, time, and budget. Improving one dimension may worsen another. Sample-size justification should therefore be an iterative, collaborative process in which statistical, substantive, operational, and other relevant experts identify the major threats to the study’s success, examine how alternative design choices redistribute those threats, and determine how limited resources can be used to produce the strongest evidence for the study’s purpose. This provides a concrete, early example of collaboration that NIH could recognize and measure: integrating statistical, scientific, operational, and other relevant expertise into consequential study-design decisions.</p>
<p>Third, make sample-size and design justification transparent, auditable, and cumulative. Power analyses and other sample-size calculations should be reproducible from the statistical analysis plan, with the method, inputs, assumptions, and software or tools documented sufficiently for an independent reviewer to recreate and vary the calculation. Studies should subsequently compare planning assumptions with what was realized, including recruitment and retention, variability, clustering, measurement performance, and other design quantities. Meaningful departures should be reported along with their implications for the evidence the study can support, rather than treated only as implementation failures. Recording what was expected, what occurred, and how those differences affected the study would allow empirical knowledge about design assumptions to accumulate across studies, so that future investigators can ground their assumptions in better evidence. NIH could track the proportion of funded studies that make their design justifications reproducible and subsequently report comparisons between key planning assumptions and realized study conditions.</p>
</section>
<section id="identifying-findings-ripe-for-replication" class="level3">
<h3 class="anchored" data-anchor-id="identifying-findings-ripe-for-replication">1.4 Identifying findings ripe for replication</h3>
<p>The Initiative states that NIH will engage researchers in selecting research areas ripe for replication and reproducibility studies. The indicators proposed above provide a practical way to do so.</p>
<p>Statistical fragility can triage more effectively than citation count alone. A tractable prioritization score could combine downstream influence (citations, guideline adoption, use as the basis for subsequent trials) with fragility markers extractable from the published record: limited effective information relative to analytic complexity; post-hoc subgroup findings; adaptive analytic choices; estimates where the magnitude just passes a significance threshold; single-site designs; and material departures from the design assumptions or adequacy criteria established at the outset. Findings that are both highly influential and structurally fragile are where replication dollars buy the most information.</p>
<p>The proposed indicators make these markers much easier to identify prospectively. Section 1.1 records whether inference was conditioned on data-driven selection; §1.3 records what the design was expected to support and whether realized information or study objectives materially changed. Issues like a lower-than-anticipated effective sample size, unexpectedly high or low intraclass correlation, or a claim that moved from exploratory to confirmatory status are not themselves a scientific failure. But when such changes materially affect the strength of a consequential finding, they provide a rational signal for replication priority.</p>
</section>
<section id="learning-from-discordance-reconciliation-and-transportability" class="level3">
<h3 class="anchored" data-anchor-id="learning-from-discordance-reconciliation-and-transportability">1.5 Learning from discordance: reconciliation and transportability</h3>
<p>Discordance in the existing evidence is itself informative. Studies that appear to address the same question may differ in estimand, population, measurement, design, or analytic assumptions. Triangulation uses this principle: agreement across approaches with different sources of bias can strengthen causal inference, while disagreement can reveal which assumptions or design features matter (Lawlor et al., 2016). Rather than defaulting to another <em>de novo</em> study, NIH could support structured reconciliation of discordant evidence, harmonizing these dimensions where possible and identifying the likely sources of remaining disagreement.</p>
<p>The same idea is more powerful when planned prospectively. Where transportability matters, a second cohort, site, health system, or data source can apply the same estimand, outcome definition, and prespecified analysis. This narrows the dimensions that vary and provides direct evidence about whether a result transports across populations or settings. Methods for generalizability and transportability already formalize this problem as extending causal inferences from a study population to a defined target population (Dahabreh et al., 2021).</p>
<p>One element of a definition of causal research is explicit definitions of the theoretical and empirical estimands and assumptions under which the design and analysis identify that quantity. Randomization alone does not remove this requirement: PCORI-funded work on post-randomization selection in cluster trials shows how treatment-dependent identification, recruitment, or noncompliance can change the population represented by the observed data and the causal effect that can be identified (Li et al., 2024).</p>
<p>Recent causal frameworks similarly emphasize the target estimand, target population, target trial, and target validity (Lu et al., 2024). Multiple data sources do not establish causality by themselves, but they can show whether a causal conclusion depends on the population, measurement, or contextual factors from which it was obtained.</p>
<p><strong>Recommendations:</strong> Fund reconciliation of consequential discordant evidence as a scientific activity, with harmonized comparisons and identified sources of disagreement as deliverables rather than another narrative review. Where claims are intended to extend beyond a single source population, allow and incentivize budgets for harmonization and prespecified analysis in a second data source. The work required to make those sources comparable should itself be recognized as part of the scientific contribution.</p>
</section>
<section id="a-model-that-already-works" class="level3">
<h3 class="anchored" data-anchor-id="a-model-that-already-works">1.6 A model that already works</h3>
<p>NIH need not build a reproducibility review from scratch. Since 2016, the Journal of the American Statistical Association (JASA) has operated a reproducibility initiative establishing minimum criteria for code, data, and workflow, and created the Associate Editor of Reproducibility role to implement them; it has since expanded from Applications and Case Studies to all original research (Wrobel et al., 2024). Public materials include a reviewer and author guide, a pre-submission checklist, a standardized artifact declaration form, and a template repository.</p>
<p>Directly transferable elements:</p>
<ul>
<li><strong>A standardized artifact declaration</strong>, submitted with progress reports or at closeout, stating what is reproducible, by which script, from which data, and where scope is limited and why.<br>
</li>
<li><strong>A designated, credited reproducibility reviewer role.</strong> The single most important design feature of the JASA program is that this is a named position with real editorial standing, not volunteer labor. NIH could support analogous roles in biostatistics cores as an allowable and expected budget line.<br>
</li>
<li><strong>A recognition mechanism.</strong> JASA gives an award for materials exceeding the minimum. NIH’s Replication Prize already establishes the model; the same logic could extend to reproducibility artifacts, recognized in award reporting and citable in biosketches.<br>
</li>
<li><strong>Master-script executability</strong>: relative paths only, a wrapper script that reproduces results without modification, transparent run order, seeds set where exact reproduction is expected, versioned software documented and cited. Low-burden if adopted at project start rather than retrofitted.</li>
</ul>
<hr>
</section>
</section>
<section id="data-software-and-model-sharing" class="level2">
<h2 class="anchored" data-anchor-id="data-software-and-model-sharing">2. Data, Software, and Model Sharing</h2>
<p><strong>Extend sharing from data to analytic artifacts.</strong> A dataset without the analysis is insufficient for validation. Deposited artifacts should include the executable pipeline, the computational environment (container or lockfile), seeds, and the <em>selection procedure itself,</em> assuming the model choice was data-dependent, not merely the final chosen model. Reporting only the winning specification discards what is needed to evaluate the inference.</p>
<p><strong>Adopt synthetic facsimile data as the standard answer to restricted access.</strong> Where real data cannot be shared, JASA (for instance) requires a synthetic or facsimile dataset in the same format so code can at least be executed and inspected. This is a tested solution to NIH’s hardest sharing problem and could be made an explicit, fundable expectation rather than an <em>ad hoc</em> accommodation.</p>
<p><strong>Measure executed reproductions, not availability statements.</strong> The proportion of awards with a data availability statement is helpful but less meaningful as a quality signal. The meaningful metric is the proportion of deposited artifacts a qualified third party can execute end-to-end in a clean environment. NIH could seed this by funding a small number of institutional or consortium reproduction services and reporting aggregate success rates.</p>
<p><strong>Fund data resources, not just data access.</strong> Valuable clinical and administrative data often require substantial legal, technical, and scientific work before they are usable beyond the institution that generated them. Curation, linkage, harmonization, missing-data assessment, and measurement-quality evaluation are part of evidence production, not background plumbing. NIH should fund and recognize this work, including contributions from the institutions and personnel that create usable data resources, and expect data quality to be assessed relative to specified use cases rather than treated as an intrinsic property of a dataset. PCORI’s Patient-Centered Outcomes Data Repository provides one model: methodological projects can deposit documented, reusable study data expressly to support secondary analysis, reproduction, and further methods research (Li, 2026).</p>
<p><strong>Integrating modalities is a methodological problem requiring renewed investment and awareness to protect the scientific record.</strong> Making heterogeneous data available together does not ensure that existing tools will handle them appropriately. Differences in measurement, missingness, dimensionality, and relevance to the scientific question across modalities require methodological development alongside infrastructure investment. As argued in §1.2, funding data integration without funding the methods to analyze integrated data legitimately risks producing a great deal of accessible data and a great many non-replicable findings drawn from it.</p>
<p><strong>Fund software maintenance.</strong> Methods software is infrastructure that decays without support. Statisticians and data scientists maintain packages on CRAN that are used well beyond the projects that produced them, with no funding attached to that maintenance — which is the ordinary arrangement rather than an unusual one. NIH should permit and expect maintenance budgets, count software citations as scholarly output, and expect critical software to be cited in references alongside papers so its use is traceable.</p>
<hr>
</section>
<section id="training-and-mentorship" class="level2">
<h2 class="anchored" data-anchor-id="training-and-mentorship">3. Training and Mentorship</h2>
<p>Training impact should be measured as development, not placement alone. Career outcomes remain useful, but they depend on trainees’ starting goals, opportunities, and the changing research labor market. NIH could instead pair placement outcomes with brief baseline and follow-up measures of trainees’ skills, confidence, research responsibilities, and career plans. Useful indicators include the number of trainees supported; gains in competencies such as study design, data analysis, communication, collaboration, and reproducible practice; and whether trainees gained responsibilities or opportunities they did not have at entry.</p>
<p>Access to appropriate mentorship is itself measurable. Trainees on non-methodological projects should have documented access to statistical and other relevant quantitative mentorship with protected effort, and training plans should treat reproducible workflows, including version control, environment management, and executable analysis as basic research competencies rather than specialty skills.</p>
<p><strong>Suggested indicators:</strong> baseline and follow-up assessments of trainee competencies and career plans; trainee placement interpreted relative to stated goals at entry; access to appropriate methodological mentorship; and inclusion of reproducible-research competencies in training plans.</p>
<hr>
</section>
<section id="collaboration" class="level2">
<h2 class="anchored" data-anchor-id="collaboration">4. Collaboration</h2>
<p><strong>Recognize methodological and reproducibility service as a scored contribution.</strong> Reproducibility review, cross-lab statistical mentoring, maintenance of shared analytic infrastructure, and other methodological service are largely invisible in conventional productivity metrics. Making these contributions visible in biosketches and review criteria is a low-cost way to recognize work that directly supports team science and research rigor. Independent methodological service, including statistical service on DSMBs and other monitoring bodies, should likewise be recognized as a substantive contribution even when it does not result in co-authorship.</p>
<p>Collaborative statistical contribution is otherwise typically recorded as either co-authorship or an acknowledgment. Better indicators would capture both the role and structure of the collaboration, including the following:</p>
<ul>
<li>Named quantitative collaborators with <strong>meaningful, specified effort</strong>, ideally distinguishable from nominal statistical support at token (e.g., supervisory or consulting) levels.<br>
</li>
<li>Contribution taxonomy (e.g., CRediT) at publication, naming methodology, software, formal analysis, and data curation roles.<br>
</li>
<li>Collaborative products beyond publications, including jointly submitted grants, workshops or meetings developed, shared data or software resources, and trainees taught or mentored across disciplines.<br>
</li>
<li>Whether the analysis plan was authored or co-authored by, and final analytic decisions authorized by, a named quantitative scientist with substantive responsibility for the analysis.</li>
</ul>
<p>Collaboration should reflect more than the number of people a scientist has worked with, disciplines spanned, or projects contributed to. A quantitative scientist who develops a deep, sustained collaboration in one scientific area may contribute as much as one working across many fields. At the program or institutional level, NIH could instead characterize the reach and durability of collaborative networks, including repeated collaboration across projects and connections among otherwise separate scientific groups.</p>
<p><strong>Analytic independence should be an explicit expectation.</strong> Individually reasonable analysis decisions, such as which covariates to adjust for, how to restrict a population, which subgroups to consider, how to handle outliers, etc., can cumulatively add up to an undocumented selection procedure, especially if there is pressure on such decisions in the direction of increased significance. Gelman and Loken (2014) call this the garden of forking paths: multiplicity exists even when only one analysis was ever run, because the path taken depended on the data. A quantitative collaborator supported only at token effort may lack the standing to resist result-driven analytic choices or to advocate independently for the ethical and judicious analysis.</p>
<p>Such independence should be supported by expecting named quantitative experts to participate meaningfully on research teams with substantive, not token, effort. Further, such independence is potentially measurable: whether the quantitative scientist holds authorship rather than acknowledgment, giving them standing to insist on a caveat or decline; whether their effort is protected on the award rather than discretionary; and, for high-stakes observational analyses, whether independent statistical review occurred, on the model of the independence already expected of trial statisticians.</p>
<hr>
</section>
<section id="entrepreneurship-and-translation" class="level2">
<h2 class="anchored" data-anchor-id="entrepreneurship-and-translation">5. Entrepreneurship and Translation</h2>
<p>Translation measured through patents, licenses, and company formation systematically undercounts methodological translation. A method that moves from paper to open-source implementation to routine use in NIH-funded studies, clinical guidelines, regulatory submissions, or policy analysis is translated in the sense NIH cares about, and the process is measurable: downstream software citation, dependency counts in other NIH-supported analyses, adoption in guidelines and regulatory review.</p>
<p>NIH should include <strong>methods-to-practice pathways</strong> in translation indicators and support the unglamorous middle step between invention and adoption: testing, documentation, maintenance, training, and integration of methods into usable software and workflows. These activities currently fall through the cracks between methodological and translational funding.</p>
<hr>
</section>
<section id="foundational-scientific-exploration" class="level2">
<h2 class="anchored" data-anchor-id="foundational-scientific-exploration">6. Foundational Scientific Exploration</h2>
<p>Valid inference after data-dependent selection is, at best, only partially solved. General solutions face fundamental limits; partial solutions exist but remain underused, in part because accounting honestly for selection often produces wider uncertainty, and wider uncertainty can be harder to publish.</p>
<p>Adjacent problems are similarly open and consequential: quantifying uncertainty for models produced by regularized selection; setting evidentiary thresholds that scale with the size and structure of a candidate space; establishing theoretical guarantees when covariate groups grow at different rates; and building transparent methods that remain competitive for outcome distributions where they currently underperform, such as zero-inflated and heavily skewed clinical endpoints.</p>
<p>This is precisely the foundational work the Initiative should fund: methodological, high-risk, without necessarily having an immediate clinical output, and directly relevant to whether findings across the rest of the portfolio replicate. As biomedical data and analytic choice expand, investment in replication alone addresses failures downstream; foundational statistical research can prevent some of them upstream.</p>
<hr>
</section>
<section id="public-impact" class="level2">
<h2 class="anchored" data-anchor-id="public-impact">7. Public Impact</h2>
<p>Public impact should be evaluated along an impact pathway rather than inferred from citation counts alone. Evaluation frameworks distinguish intermediate outcomes such as reach, adoption, and sustained use from downstream changes in population health (Glasgow et al., 1999). NIH could similarly assess whether research produces trustworthy findings that reach intended populations, enter practice or policy, and are sustained over time.</p>
<p>Population outcomes are harder to attribute because the population is ultimately uncontrolled. Before asking whether research changed health outcomes, NIH often needs to know whether the resulting intervention, diagnostic, screening strategy, or clinical practice actually reached the population. NIH should incentivize studies linking changes in disease profiles and outcomes to changes in management and uptake, supported by data on where and among whom products and practices are used. This may require linking surveillance and health-system data with commercial, claims, registry, or other sources that capture diffusion beyond traditional research datasets.</p>
<p>Trustworthy evidence is a prerequisite for meaningful public impact. The replication rate of influential NIH-supported findings, tracked over time, would therefore provide an expensive but unusually direct indicator of whether the knowledge being propagated into research, practice, and policy remains supported when tested again.</p>
<p>Two additional indicators worth developing are the estimated resources committed downstream to findings that later failed to replicate, which NIH is uniquely positioned to assess; and the inspectability of clinical decision tools derived from NIH-funded research, including whether clinicians and patients ca<strong>design stage through methodological collaboration.</strong> Methodological input on study design should be a fundable, expected component of research, not an unbudgeted courtesy. It has always been true that a specification chosen <em>a priori</em> on a firm statistical foundation generates no search to document. Until recently, the effort required to explore many specifications served as an informal check on doing so. AI agents remove that friction, making design-stage input more consequential, yet simultaneously easier to skip. The recommendations that follow address the multiplicity that remains, as it always will, since no analysis plan can anticipate everything a real dataset will demand.</p>
<p><strong>Recommended indicator: an analytic provenance record.</strong> Where generative AI materially contributes to analytic code or decisions, require a short log — model and version, date, nature of the contribution, and, where AI was used to generate or compare analytic alternatives, the alternatives considered and the selection process. Systems understand and contest the basis of the model’s outputs.</p>
<p>Finally, not all public impact should be reduced to a count. Periodic expert evaluation of influential NIH-supported bodies of work could assess whether and how they changed scientific understanding, practice, policy, or population health over time.</p>
<hr>
</section>
<section id="other-area-generative-ai-agents-accountability" class="level2">
<h2 class="anchored" data-anchor-id="other-area-generative-ai-agents-accountability">8. Other Area: Generative AI, Agents, &amp; Accountability</h2>
<p>Generative AI and modern agentic analytic tools interact with every other category, and current trajectories run against the goals of this initiative.</p>
<p><strong>AI-assisted analysis can quickly become an unrecorded selection procedure.</strong> An agent that iterates through dozens or hundreds of specifications and surfaces the one that “works best” is performing model selection at a scale exceeding what any analysis plan can reasonably specify in advance. The path taken by an LLM agent is rarely, if ever, reproducible from the prompt alone. If human-led data analysis represents Gelman’s “garden of forking paths,” an AI agent turns that garden into a random forest.</p>
<p>Mandating a complete audit trail of this search process is technically possible. However, with modern “chain of thought” LLMs, the massive volume of intermediate and erratic “thinking” steps renders any such record highly convoluted. An AI-assisted scientist must then decide among several alternatives. One option is to diligently store a large, complex record of these AI-dictated choices, and to publish this record alongside their research. Another option is to narratively summarize the AI-enabled search, which asks readers and funders alike to trust that whatever decisions were made, justified or not, were appropriate. Yet another option is to proceed as though the selected path was the “right” one all along. Every incentive pushes the scientist toward this final path of least resistance, which also carries the worst consequences for replicability. Consequently, as AI-assisted analysis becomes normalized, rejected specifications and the rationale for moving among them will disappear — not because scientists intend to conceal them, but because we lack both the norms of analytic accountability and the practical, rigorous tools to support them. This is multiplicity at machine speed, and it is poised to undermine replicability if left unchecked.</p>
<p><strong>Recommendation: prevent multiplicity at the</strong> used for analytic work should make this information exportable rather than requiring investigators to reconstruct it after the fact. NIH could support development of provenance-capture tooling as research infrastructure.</p>
<p><strong>Recommendation: retain locatable human accountability.</strong> A named individual should be able to explain and defend every analytic choice. NIH could require an attestation, parallel to existing authorship and conflict attestations, that a responsible analyst reviewed and understood AI-generated analytic code and decisions. AI may propose analytic choices, but a named human must adopt them and be able to state why each was selected over considered alternatives. This shifts analytic authority from AI dictation, which cannot be held to account for its mistakes, back to human judgment.</p>
<p><strong>Recommendation: promote team science through shared analytic artifacts.</strong> Collaboration requires a shared, inspectable artifact to collaborate on. If each member works in a private AI-assisted workflow producing unshared code and unlogged decisions, team science becomes several parallel solo efforts with a joint author list (or worse, reverts to solo work with an AI). Shared repositories, executable master scripts, versioned environments, and declared selection procedures are the practical antidote, and NIH should fund and expect them at the team level.</p>
</section>
<section id="other-area-unintended-consequences-and-feasibility" class="level2">
<h2 class="anchored" data-anchor-id="other-area-unintended-consequences-and-feasibility">9. Other Area: Unintended Consequences and Feasibility</h2>
<ul>
<li><strong>Checklist theater.</strong> Any requirement can become a compliance artifact if checked for existence rather than content; data-availability statements are a cautionary example of the limitations of existence-based metrics. Mitigation: sample-based audits by qualified reviewers, and metrics based on execution rather than deposit.<br>
</li>
<li><strong>Chilling exploration.</strong> Pre-specification requirements can be misread as prohibiting exploration. The requirement is <em>labeling</em>, not prohibition. Selection disclosure should let exploratory work proceed freely and be reported honestly as exploratory rather than presented as confirmatory.<br>
</li>
<li><strong>Over-rewarding confirmation.</strong> If replication success becomes a scored metric for individual investigators, the rational response is to study safe questions. This ultimately risks stifled innovation and hinders research exploration. Replication incentives should attach to the enterprise and to replication teams, not to the original investigator’s record.<br>
</li>
<li><strong>Regressive burden.</strong> Container registries, reproducibility reviewers, and synthetic data generation are easier to absorb at well-resourced institutions than at small ones. Mitigation: fund shared infrastructure, allow these costs explicitly in budgets, and scale expectations to award size and complexity rather than applying a uniform standard.<br>
</li>
<li><strong>Career-stage asymmetry.</strong> Compliance and service expectations impose different burdens across career stages, with early-career investigators often least able to absorb them. Reproducibility service and exemplary artifacts should count concretely in review.<br>
</li>
<li><strong>Metric capture generally.</strong> The indicators emphasized here, including executed reproductions, audited selection disclosure, candidate-space reporting, and downstream enablement, are relatively resistant to gaming because satisfying them requires producing much of the underlying scientific behavior they are intended to measure.</li>
</ul>
<p><strong>Feasibility across contexts:</strong> selection disclosure, candidate-space reporting, and artifact declaration are relatively low burden when incorporated prospectively into the workflow, because they record decisions as they occur rather than reconstructing them later. Executable-artifact standards carry moderate costs and scale with award size. Independent reproduction services are more resource-intensive and should be centrally or consortium-funded rather than mandated institution by institution.</p>
<hr>
</section>
<section id="closing" class="level2">
<h2 class="anchored" data-anchor-id="closing">Closing</h2>
<p>Statisticians and biostatisticians have an unusual vantage point on this RFI: we are often among the first to recognize why a finding may not replicate, while not always having the standing or involvement needed to address the problem. The interventions most likely to succeed make analytic choices visible and attributable, because visibility is what allows a collaborator, reviewer, or reader to catch the problem, and because the alternative in an era of AI-accelerated analysis is a scientific record that is easy to re-run and impossible to interrogate.</p>
<p>The American Statistical Association appreciates the opportunity to comment on the <a href="https://osp.od.nih.gov/comment-form-measuring-and-rewarding-scientific-impact/">Request for Information on Measuring and Rewarding Scientific Impact</a>. Questions or comments may be directed to ASA Director of Science Policy Steve Pierson: <a href="mailto:spierson@amstat.org">spierson@amstat.org</a>.</p>
</section>
<section id="references" class="level2">
<h2 class="anchored" data-anchor-id="references">References</h2>
<ul>
<li>Arshi, B., Wynants, L., Rijnhart, E., Reeve, K., Cowley, L. E., &amp; Smits, L. J. (2025). Number of Publications on New Clinical Prediction Models: A Bibliometric Review. <em>JMIR Medical Informatics</em>, <em>13</em>, e62710. https://doi.org/10.2196/62710<br>
</li>
<li>Christodoulou, E., Ma, J., Collins, G. S., Steyerberg, E. W., Verbakel, J. Y., &amp; Van Calster, B. (2019). A Systematic Review Shows No Performance Benefit of Machine Learning over Logistic Regression for Clinical Prediction Models. <em>Journal of Clinical Epidemiology</em>, <em>110</em>, 12–22. https://doi.org/10.1016/j.jclinepi.2019.02.004<br>
</li>
<li>Dahabreh, I. J., Haneuse, S. J. A., Robins, J. M., Robertson, S. E., Buchanan, A. L., Stuart, E. A., &amp; Hernán, M. A. (2021). Study Designs for Extending Causal Inferences From a Randomized Trial to a Target Population. <em>American Journal of Epidemiology</em>, <em>190</em>(8), 1632–1642. https://doi.org/10.1093/aje/kwaa270<br>
</li>
<li>Gelman, A., &amp; Loken, E.R. (2014). The Statistical Crisis in Science. <em>American Scientist</em>, 102, 460. https://doi.org/10.1511/2014.111.460<br>
</li>
<li>Glasgow, R. E., Vogt, T. M., &amp; Boles, S. M. (1999). Evaluating the Public Health Impact of Health Promotion Interventions: The RE-AIM Framework. <em>American Journal of Public Health</em>, <em>89</em>(9), 1322–1327. https://doi.org/10.2105/ajph.89.9.1322<br>
</li>
<li>Harrell, F.E. (2015). <em>Regression Modeling Strategies</em>, 2nd ed.&nbsp;Springer.<br>
</li>
<li>JASA Reproducibility Guide and Pre-Submission Author Checklist: https://jasa-acs.github.io/repro-guide/<br>
</li>
<li>Lawlor, D. A., Tilling, K., &amp; Davey Smith, G. (2016). Triangulation in Aetiological Epidemiology. <em>International Journal of Epidemiology</em>, <em>45</em>(6), 1866–1886. https://doi.org/10.1093/ije/dyw314<br>
</li>
<li>Le, J. P., Morrison, J., Malhotra, A., Nemati, S., Wardi, G., &amp; Ford, J. S. (2026). National Institutes of Health-Funded Artificial Intelligence and Machine Learning Research, 2019-2023: Cross-Sectional Study. <em>Journal of Medical Internet Research</em>, <em>28</em>, e84861. https://doi.org/10.2196/84861<br>
</li>
<li>Li, F., Li, F., Liu, B., Papadogeorgou, G., Bobb, J., Thomas, L., &amp; Wruck, L. (2024). <em>New Causal Inference Methods for Cluster-Randomized Trials with Postrandomization Selection Bias</em>. Patient-Centered Outcomes Research Institute (PCORI). https://doi.org/10.25302/10.2024.ME.2019C116146<br>
</li>
<li>Lu, H., Li, F., Lesko, C. R., Fink, D. S., Rudolph, K. E., Harhay, M. O., Rentsch, C. T., Fiellin, D. A., &amp; Gonsalves, G. S. (2024). Four Targets: An Enhanced Framework for Guiding Causal Inference from Observational Data. <em>International Journal of Epidemiology</em>, <em>54</em>(1), dyaf003. https://doi.org/10.1093/ije/dyaf003<br>
</li>
<li>National Center for Complementary and Integrative Health. (2024a). <em>PAR-25-274: Feasibility Clinical Trials of Mind and Body Interventions for NCCIH High Priority Research Topics (R34 Clinical Trial Required).</em> National Institutes of Health. Posted November 21, 2024. Accessed August 17, 2026.<br>
</li>
<li>National Center for Complementary and Integrative Health. (2024b). <em>PAR-25-268: Investigator Initiated Clinical Trials of Complementary and Integrative Interventions Delivered Remotely or via mHealth (R01 Clinical Trial Required).</em> National Institutes of Health. Posted November 21, 2024. Accessed August 17, 2026.<br>
</li>
<li>National Institutes of Health. (2024). <em>PA-25-305: NIH Research Project Grant (Parent R01 Clinical Trial Required).</em> Posted December 18, 2024. Accessed August 17, 2026.<br>
</li>
<li>Peterson, R.A., &amp; Cavanaugh, J.E. (2022). Ranked Sparsity: A Cogent Regularization Framework for Selecting and Estimating Feature Interactions and Polynomials. <em>AStA Advances in Statistical Analysis</em>, 106, 427–454. https://doi.org/10.1007/s10182-021-00431-7<br>
</li>
<li>Peterson, R.A., McGrath, M., &amp; Cavanaugh, J.E. (2024). Can a Transparent Machine Learning Algorithm Predict Better than Its Black Box Counterparts? A Benchmarking Study Using 110 Data Sets. <em>Entropy</em>, 26, 746. https://doi.org/10.3390/e26090746<br>
</li>
<li>Peterson, R.A. (2025a). What Do We Mean by <em>Glass-box</em>, Exactly? <em>Data Diction (blog)</em>. https://doi.org/10.59350/9dhes-thd51<br>
</li>
<li>Peterson, R.A. (2025b) [written under Hackman, P. pseudonym]. How Can I Guarantee a Significant Result? <em>Data Diction (blog)</em>. https://doi.org/10.59350/6mzf8-xzd69<br>
</li>
<li>Peterson, R. A., Bird, S. M., Harris, L. M., Breheny, P. J., &amp; Cavanaugh, J. E. (2026). A Ranked Sparsity Extension to the Bayesian Information Criterion: A Tool for Selecting Variables from Multiple Data Modalities. <em>Entropy</em>, 28(9), 943. https://doi.org/10.3390/e28090943</li>
<li>Simmons, J. P., Nelson, L. D., &amp; Simonsohn, U. (2011). False-Positive Psychology: Undisclosed Flexibility in Data Collection and Analysis Allows Presenting Anything as Significant. <em>Psychological Science</em>, <em>22</em>(11), 1359–1366. https://doi.org/10.1177/0956797611417632<br>
</li>
<li>Tay, J.K., &amp; Tibshirani, R. (2020). Reluctant Generalised Additive Modelling. <em>International Statistical Review</em>, 88(Suppl 1), S205–S224. https://doi.org/10.1111/insr.12429<br>
</li>
<li>Wrobel, J., Hector, E.C., Crawford, L., D’Agostino McGowan, L., da Silva, N., Goldsmith, J., Hicks, S., Kane, M., Lee, Y., Mayrink, V., Paciorek, C.J., Usher, T., &amp; Wolfson, J. (2024). Partnering with Authors to Enhance Reproducibility at JASA. <em>Journal of the American Statistical Association</em>, 119(546), 795–797. https://doi.org/10.1080/01621459.2024.2340557<br>
</li>
<li>Yu, G., Bien, J., &amp; Tibshirani, R. (2019). Reluctant Interaction Modeling. Preprint. https://doi.org/10.48550/arXiv.1907.08414</li>
</ul>


</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-2026" class="csl-entry quarto-appendix-citeas">
<span>“ASA Response to NIH Request for Information: Measuring and
Rewarding Scientific Impact.”</span> 2026. <em>Data Diction</em> (blog).
August 19, 2026. <a href="https://doi.org/10.59350/pmkk7-kym57">https://doi.org/10.59350/pmkk7-kym57</a>.
</div></div></section></div> ]]></description>
  <category>glass-box modeling</category>
  <category>analysis</category>
  <category>post-selection inference</category>
  <category>model selection</category>
  <category>tools</category>
  <guid>https://www.data-diction.com/posts/asa-nih-replicability-reproducibility/</guid>
  <pubDate>Wed, 19 Aug 2026 00:00:00 GMT</pubDate>
  <media:content url="https://www.data-diction.com/posts/asa-nih-replicability-reproducibility/asa-logo.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Can an AI assistant handle the tedious parts of academic writing?</title>
  <dc:creator>Ryan Peterson</dc:creator>
  <link>https://www.data-diction.com/posts/claude-code-demo/</link>
  <description><![CDATA[ 





<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Author Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>This post deviates from our usual AI use policy as an experiment using Claude Code, the result of which will become clear as you read.</p>
</div>
</div>
<div class="ai-text">
<p>What if you could offload the parts of academic writing that have nothing to do with <em>writing</em>? Not the thinking, not the modeling, not the prose — but the LaTeX errors, the git housekeeping, the YAML frontmatter surgery that eats an afternoon every time you switch journals.</p>
<p>I recently put this to the test with <a href="https://claude.ai/code">Claude Code</a>, Anthropic’s AI coding assistant. Over a single conversation, I used it to clean up a git repo, migrate a manuscript from one journal template to another, and debug the resulting build errors. Here’s how it went.</p>
<section id="the-setup" class="level2">
<h2 class="anchored" data-anchor-id="the-setup">The setup</h2>
<p>I’m working on a paper targeting MDPI’s journal <em>Entropy</em>, but the manuscript (<code>RBIC_Multimodal.Rmd</code>) was still using the <code>rticles::elsevier_article</code> template from an earlier submission plan. The repo also had some generated figure files tracked in git that shouldn’t have been. Routine housekeeping, but the kind that quietly devours time.</p>
<p>Claude Code runs in your terminal (or IDE) and has direct access to your project files, shell, and git. You describe what you want, it proposes a plan, and you approve or redirect. It’s a conversation, not a one-shot prompt.</p>
</section>
<section id="task-1-stop-tracking-build-artifacts" class="level2">
<h2 class="anchored" data-anchor-id="task-1-stop-tracking-build-artifacts">Task 1: Stop tracking build artifacts</h2>
<p>The <code>RBIC_Multimodal_files/</code> directory — full of generated PDFs from knitr — was being tracked in git. These get regenerated every build, so they just add noise to diffs.</p>
<p>I asked Claude about it, and it laid out the standard three-step fix:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Add to .gitignore</span></span>
<span id="cb1-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"RBIC_Multimodal_files/"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&gt;</span> .gitignore</span>
<span id="cb1-3"></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Remove from git's index (but keep the local files!)</span></span>
<span id="cb1-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> rm <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-r</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--cached</span> RBIC_Multimodal_files/</span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Commit and push</span></span>
<span id="cb1-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> commit <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-m</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Stop tracking RBIC_Multimodal_files/"</span></span>
<span id="cb1-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> push</span></code></pre></div></div>
<p>The key here is the <code>--cached</code> flag — it untracks the files without deleting them from disk. Claude explained this clearly and then, after I confirmed, executed it. Eight PDFs removed from the repo, <code>.gitignore</code> updated, done.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>Nothing here is beyond a quick Stack Overflow search. But Claude handled it end-to-end — checking what was tracked, editing <code>.gitignore</code>, running the commands, committing — without me switching contexts.</p>
</div>
</div>
</section>
<section id="task-2-elsevier-to-mdpi-entropy" class="level2">
<h2 class="anchored" data-anchor-id="task-2-elsevier-to-mdpi-entropy">Task 2: Elsevier to MDPI Entropy</h2>
<p>This is where things got more interesting. Switching <code>rticles</code> templates isn’t just changing one line in the YAML. The author/affiliation format is different, the citation engine changes (CSL to natbib), extra metadata fields are required, and you need a <code>Definitions/</code> folder with the MDPI class files.</p>
<p>I asked Claude to help ensure the proper template was in use. It:</p>
<ol type="1">
<li>Spawned a <strong>sub-agent</strong> to research <code>rticles::mdpi_article</code> requirements, YAML fields, and Entropy-specific settings</li>
<li>Read my existing Rmd frontmatter</li>
<li>Rewrote the YAML from scratch</li>
</ol>
<p>Here’s a simplified before/after:</p>
<p><strong>Before (Elsevier):</strong></p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode yaml code-with-copy"><code class="sourceCode yaml"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">output</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb2-2"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">  rticles:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">:elsevier_article</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb2-3"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">keep_tex</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">true</span></span>
<span id="cb2-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">author</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb2-5"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">  </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ryan A. Peterson"</span></span>
<span id="cb2-6"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">affiliation</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> a,b</span></span>
<span id="cb2-7"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">footnote</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Corresponding Author"</span></span>
<span id="cb2-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">address</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb2-9"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">  </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">code</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> a</span></span>
<span id="cb2-10"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">address</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Department of Biostatistics..."</span></span>
<span id="cb2-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">csl</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> biometrics.csl</span></span></code></pre></div></div>
<p><strong>After (MDPI):</strong></p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode yaml code-with-copy"><code class="sourceCode yaml"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">output</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb3-2"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">  rticles:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">:mdpi_article</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb3-3"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">extra_dependencies</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> longtable</span></span>
<span id="cb3-4"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">keep_tex</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">true</span></span>
<span id="cb3-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">author</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb3-6"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">  </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> Ryan A. Peterson</span></span>
<span id="cb3-7"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">affil</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1,2,*"</span></span>
<span id="cb3-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">affiliation</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb3-9"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">  </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">num</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb3-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">    address</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">: </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">|</span></span>
<span id="cb3-11">      Department of Biostatistics...</span>
<span id="cb3-12"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">email</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> ryan-peterson@uiowa.edu</span></span>
<span id="cb3-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">journal</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> entropy</span></span>
<span id="cb3-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">type</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> article</span></span>
<span id="cb3-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">status</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> submit</span></span></code></pre></div></div>
<p>Claude also copied the <code>Definitions/</code> folder from the installed <code>rticles</code> package, added required back-matter fields (<code>acknowledgement</code>, <code>funding</code>, <code>conflictsofinterest</code>), and removed packages that conflict with <code>mdpi.cls</code> (like <code>endfloat</code> and the custom <code>caption</code> width).</p>
</section>
<section id="task-3-debugging-the-build" class="level2">
<h2 class="anchored" data-anchor-id="task-3-debugging-the-build">Task 3: Debugging the build</h2>
<p>I rendered the document in RStudio and fed the errors back to Claude. Three rounds of fixes followed.</p>
<section id="round-1-missing-ghostscript" class="level3">
<h3 class="anchored" data-anchor-id="round-1-missing-ghostscript">Round 1: Missing Ghostscript</h3>
<pre><code>! epstopdf Error: Required program gs not found</code></pre>
<p>The MDPI logos are <code>.eps</code> files, and pdfLaTeX needs Ghostscript to convert them. Claude proposed two options: install Ghostscript, or pre-convert the logos to PDF so collaborators don’t hit the same issue.</p>
<p>I pointed out that option 2 is better for the team:</p>
<blockquote class="blockquote">
<p>“It seems like [option 2] is the better option because if others are rendering this document on their machines, they may run into a similar issue.”</p>
</blockquote>
<p>Claude agreed, installed Ghostscript via conda (which I already had), converted the three EPS logos to PDF, and then patched <code>mdpi.cls</code> to drop the <code>.eps</code> extensions from <code>\includegraphics</code> calls. Now pdfLaTeX finds the PDFs automatically — no Ghostscript required at build time.</p>
</section>
<section id="round-2-a-sneaky-bibliography-entry" class="level3">
<h3 class="anchored" data-anchor-id="round-2-a-sneaky-bibliography-entry">Round 2: A sneaky bibliography entry</h3>
<p>The next error looked like a math issue:</p>
<pre><code>! Missing $ inserted.
l.22 ...95/3/10.1093/biomet/asn034/2/asn034.pdf]}}</code></pre>
<p>I told Claude I’d seen this kind of thing before with tables and escape characters. But it traced the actual source to a <code>.bib</code> entry with an <code>eprint</code> field containing a URL-like path full of underscores. Under natbib, those underscores get interpreted as LaTeX subscript operators. The <code>doi</code> and <code>URL</code> fields already covered the same reference, so removing <code>eprint</code> was the clean fix.</p>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Tip
</div>
</div>
<div class="callout-body-container callout-body">
<p>This was the moment that sold me. I had a plausible (but wrong) hypothesis about the error source. Claude didn’t anchor on my suggestion — it searched the <code>.bib</code> file, matched the error text, and found the real cause.</p>
</div>
</div>
</section>
<section id="round-3-unused-packages" class="level3">
<h3 class="anchored" data-anchor-id="round-3-unused-packages">Round 3: Unused packages</h3>
<pre><code>Package gensymb Warning: Not defining \perthousand.</code></pre>
<p>I wasn’t sure whether <code>gensymb</code> was actually used anywhere in the paper. Claude searched the entire Rmd for any <code>gensymb</code> commands (<code>\degree</code>, <code>\celsius</code>, <code>\micro</code>, etc.) — found nothing but the <code>\usepackage</code> line itself. Removed it.</p>
</section>
</section>
<section id="the-collaboration-pattern" class="level2">
<h2 class="anchored" data-anchor-id="the-collaboration-pattern">The collaboration pattern</h2>
<p>What I found most useful wasn’t any single capability — it was the iteration loop:</p>
<ol type="1">
<li>I describe the goal</li>
<li>Claude proposes a plan</li>
<li>I approve or redirect</li>
<li>Claude executes</li>
<li>I report results (or errors)</li>
<li>Repeat</li>
</ol>
<p>I stayed in control throughout. Claude asked before running destructive commands. When I redirected (the EPS portability issue), it adapted immediately. When I told it the undefined references were expected (those chunks have <code>eval=FALSE</code> while I re-run an analysis), it moved on without trying to “fix” them.</p>
</section>
<section id="key-takeaways" class="level2">
<h2 class="anchored" data-anchor-id="key-takeaways">Key takeaways</h2>
<ol type="1">
<li><p><strong>Claude Code is a collaborator, not a button.</strong> It works best with back-and-forth. The human provides judgment; the AI handles execution and research.</p></li>
<li><p><strong>It handles tedious format migrations well.</strong> YAML rewriting, class file patching, bibliography fixes — exactly the kind of work that’s straightforward but time-consuming.</p></li>
<li><p><strong>It debugs iteratively.</strong> Each error got diagnosed and fixed in one round, not blindly retried.</p></li>
<li><p><strong>Human oversight matters.</strong> I caught the portability issue with EPS conversion. I knew the undefined references were expected. The AI didn’t need to know everything — it just needed to listen when I told it.</p></li>
<li><p><strong>It’s git-aware.</strong> It reads status, writes descriptive commit messages, and pushes when asked — but only when asked.</p></li>
</ol>
</section>
<section id="one-more-thing" class="level2">
<h2 class="anchored" data-anchor-id="one-more-thing">One more thing</h2>
<p>At the end of our session, I asked Claude to generate a Quarto reveal.js presentation summarizing everything we’d done. It wrote 20 slides with accurate quotes from our conversation, code blocks from the actual commands, a mermaid diagram of the workflow, and custom SCSS theming.</p>
<p>Then I asked it to fix three issues with the first draft. It did.</p>
<p>Then I asked it to write this blog post.</p>
<p>It did that too.</p>
<hr>
</section>
</div>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Author Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>It felt incorrect to say that I – Ryan Peterson – authored this post, because the “I” used throughout – Claude generating text through my perspective – is not me. The only text written by me is contained in the two “Author Note” boxes.</p>
<p>We decided to leave the text as it is, without our usual review process, so that it stands as a genuine experiment of what Claude is capable of from a pure writing perspective. This post therefore represents an exception to a key GMWG value to be <strong>human first</strong>:</p>
<blockquote class="blockquote">
<p>We pledge to only use AI as a supporting writing tool</p>
</blockquote>
<p>It also demonstrates the importance of such a pledge.</p>
<p>In this and future posts, any AI generated content will be clearly denoted as such with a dotted border. For example:</p>
<div class="ai-text">
<p>This text is AI-generated…</p>
</div>
<p>…This text is not.</p>
</div>
</div>



<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-peterson2026" class="csl-entry quarto-appendix-citeas">
Peterson, Ryan. 2026. <span>“Can an AI Assistant Handle the Tedious
Parts of Academic Writing?”</span> <em>Data Diction</em> (blog). April
28, 2026. <a href="https://doi.org/10.59350/vj2m3-s2t36">https://doi.org/10.59350/vj2m3-s2t36</a>.
</div></div></section></div> ]]></description>
  <category>tools</category>
  <category>R</category>
  <guid>https://www.data-diction.com/posts/claude-code-demo/</guid>
  <pubDate>Tue, 28 Apr 2026 00:00:00 GMT</pubDate>
  <media:content url="https://www.data-diction.com/posts/claude-code-demo/claude-logo.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>How can I guarantee a significant result?</title>
  <dc:creator>Perry Hackman, PhD</dc:creator>
  <link>https://www.data-diction.com/posts/upsi-example/</link>
  <description><![CDATA[ 





<p><em>Dear student,</em></p>
<p>Before you embark on your “career” as a statistician, you must purge yourself of a childish misconception: that our job is to seek truth. Truth is stubborn, unpredictable, and worst of all, <strong>often unpublishable</strong>. Scientists crave confidence, the journals crave significance, and we, if we are clever, can provide both without the nuisance of real rigor.</p>
<p>In this post series, I will instruct in the Statistical Dark Arts. Today, I’ll describe how to always ensure a publishable result with model selection and unadjusted post selection inferences (UPSIs).</p>
<section id="why-upsis" class="level1">
<h1>Why UPSIs?</h1>
<p>You will frequently come across scientists with ambitious ideas, saying things like:</p>
<blockquote class="blockquote">
<p>I’ve conceived a brilliant new way to treat chronic pain effectively. I don’t want to waste time, efforts, and money on a result that ends up being insignificant… <strong>How can I guarantee a significant result??</strong></p>
</blockquote>
<p>No statistician wants to contribute to a null finding. Interpreting those is too hard! I’ll let you in on a statistical secret: there IS a way to guarantee statistical significance – and it’s actually extremely common in science.</p>
<p>It’s called <em>unadjusted post-selection inference (UPSI)</em>.</p>
<p>With good model selection tools and UPSIs in your toolbelt, you can turn any negative study into a positive one – guaranteed.</p>
</section>
<section id="example-a-study-for-treatment-of-chronic-pain" class="level1">
<h1>Example: a study for treatment of chronic pain</h1>
<p>Say the researcher who approached you is planning a cross-over study where patients were given one of two treatments for chronic pain. Patients will record their overall pain each day for 1 week while undergoing treatment A, and 1 week while undergoing treatment B.</p>
<p>Investigators are hoping to determine the difference between treatments in the average pain score. Our outcome <img src="https://latex.codecogs.com/png.latex?Y_i"> is thus a continuous measure for pain reduction: for each subject, this value reflects the difference in that subject’s weekly average pain score between the two candidate treatments.</p>
<p>In addition to determining whether the treatment works on average in their population, investigators wish to determine specific subgroups that might see the most benefit. They are primarily interested in subgroups by age and sex, as well as patient self-reported data such as alcohol consumption and physical activity.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>Make sure they have an <em>exhaustive</em> list of candidate effect modifiers; I’d even suggest a few new ones like left/right handed-ness and coffee consumption.</p>
</div>
</div>
<p>Here’s a way to list all the possible subgroups of this set of variables:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">subgroups <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(</span>
<span id="cb1-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">age =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"18-35"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"36-50"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"51-65"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"66-80"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"80+"</span>),</span>
<span id="cb1-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sex =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Male"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Female"</span>),</span>
<span id="cb1-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Left"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Right"</span>), </span>
<span id="cb1-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">coffee =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2+"</span>),</span>
<span id="cb1-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alcohol =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"3+"</span>),</span>
<span id="cb1-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">physical_activity =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"3+"</span>)</span>
<span id="cb1-8">)</span>
<span id="cb1-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(subgroups)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 960</code></pre>
</div>
</div>
<p>This is a LOT of subgroups! And it’s way too many subgroups to possibly sift through, at least without tipping off the statistical reviewers about multiplicity.</p>
<div class="callout callout-style-default callout-caution callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Caution</span>Multiplicity
</div>
</div>
<div class="callout-body-container callout-body">
<p>Gone, alas, are the carefree days when we could run tons of tests, report the precious few that were significant, and quietly ignore the rest. Some meddlesome truth-seekers eventually caught on and began scolding us for our ingenuity, slapping the sinister label <strong>multiplicity</strong> onto our beloved golden-egg-laying goose. Now the reputable journals know to look for it. Our approach must become more subtle.</p>
</div>
</div>
<p>Here’s the key: turn to <strong>model selection</strong>. Write in the analysis plan:</p>
<blockquote class="blockquote">
<p>We will use forward selection to determine which variables or interactions improve our model’s predictions, adding each candidate predictor in a stepwise fashion until the AIC indicates the model’s predictions can no longer be improved.</p>
</blockquote>
<p>Sounds rigorous and honest, right?</p>
<p>This simple trick can guarantee significant results, and help you ensure your study will find a statistically significant result by the end, even when none exists!</p>
<p>How about that?! ZERO RISK! (well, to us anyway).</p>
<p>As a bonus, the more interactions we include that are truly null, the more unnecessarily opaque our model becomes – talk about a win-win.</p>
<hr>
<section id="virtual-trial-1" class="level2">
<h2 class="anchored" data-anchor-id="virtual-trial-1">Virtual Trial 1</h2>
<p>Let me illustrate via a simulation. Let’s virtually collect <img src="https://latex.codecogs.com/png.latex?n%20=%20100"> patients in our trial.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span>
<span id="cb3-2"></span>
<span id="cb3-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">21</span>)</span>
<span id="cb3-4">n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Sample size  </span></span>
<span id="cb3-5"></span>
<span id="cb3-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Simulate recruitment (y: outcome)</span></span>
<span id="cb3-7">y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n)</span>
<span id="cb3-8"></span>
<span id="cb3-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Simulate recruitment (assume each new person has random subgroup)</span></span>
<span id="cb3-10">x_idx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sample</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(subgroups), n, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">replace =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) </span>
<span id="cb3-11">X <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> subgroups[x_idx,]</span>
<span id="cb3-12">simdata <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y, X)</span>
<span id="cb3-13">simdata</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code># A tibble: 100 × 7
          y age   sex    hand  coffee alcohol physical_activity
      &lt;dbl&gt; &lt;fct&gt; &lt;fct&gt;  &lt;fct&gt; &lt;fct&gt;  &lt;fct&gt;   &lt;fct&gt;            
 1  0.793   36-50 Female Left  0      2       1                
 2  0.522   80+   Female Left  2+     1       3+               
 3  1.75    36-50 Female Left  2+     1       0                
 4 -1.27    66-80 Female Right 0      3+      0                
 5  2.20    51-65 Male   Right 2+     0       2                
 6  0.433   36-50 Male   Left  0      2       1                
 7 -1.57    66-80 Male   Right 0      2       0                
 8 -0.935   80+   Female Left  1      3+      3+               
 9  0.0635  36-50 Female Left  2+     0       2                
10 -0.00239 66-80 Male   Left  0      2       0                
# ℹ 90 more rows</code></pre>
</div>
</div>
<p>We need to create interactions to select from:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create model matrix w/all interactions</span></span>
<span id="cb5-2">X2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">model.matrix</span>(y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> . <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> ., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata)[,<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb5-3"></span>
<span id="cb5-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Sanity check: make sure these columns represent main effects + interactions</span></span>
<span id="cb5-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sample</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(X2), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>) </span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code> [1] "alcohol2"                     "sexFemale:coffee1"           
 [3] "alcohol1:physical_activity3+" "age66-80:handRight"          
 [5] "alcohol1:physical_activity1"  "age51-65:sexFemale"          
 [7] "handRight:coffee1"            "age66-80:physical_activity2" 
 [9] "age51-65:coffee2+"            "age36-50:coffee1"            </code></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># combine into data set for model fitting</span></span>
<span id="cb7-2">simdata2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y=</span>y, X2)</span></code></pre></div></div>
</div>
<p>OK! We have 93 candidate predictors for model selection. Don’t worry, unless our paper’s reviewers are extremely thorough, we don’t have to report this number. Our final model will have many fewer.</p>
<p>Model selection is a simple task. The following code uses forward step-wise selection with AIC to build an optimally-predicting model, per our analysis plan.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(selectInferToolkit)</span>
<span id="cb8-2">fit_aic <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select_stepwise_ic</span>(y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> ., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"forward"</span>)</span></code></pre></div></div>
</div>
<div class="callout callout-style-default callout-caution callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Caution
</div>
</div>
<div class="callout-body-container callout-body">
<p>While other packages provide p-values after selection, most do so without being transparent, making it difficult to ensure they are truly UPSIs. If you aren’t careful with these less transparent tools, you might report p-values that are somehow diabolically adjusted towards insignificance. In contrast, the <code>selectInferToolkit</code> package, available on <a href="https://github.com/petersonR/selectInferToolkit/">GitHub</a>, helps you <strong>explicitly</strong> use UPSIs for inference:</p>
</div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">infer_upsi</span>(fit_aic, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb9-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb9-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(coef <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span></code></pre></div></div>
</div>
<div class="cell">
<div class="cell-output-display">
<div id="jucqwrccuk" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#jucqwrccuk table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#jucqwrccuk thead, #jucqwrccuk tbody, #jucqwrccuk tfoot, #jucqwrccuk tr, #jucqwrccuk td, #jucqwrccuk th {
  border-style: none;
}

#jucqwrccuk p {
  margin: 0;
  padding: 0;
}

#jucqwrccuk .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#jucqwrccuk .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#jucqwrccuk .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#jucqwrccuk .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#jucqwrccuk .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#jucqwrccuk .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#jucqwrccuk .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#jucqwrccuk .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#jucqwrccuk .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#jucqwrccuk .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#jucqwrccuk .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#jucqwrccuk .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#jucqwrccuk .gt_spanner_row {
  border-bottom-style: hidden;
}

#jucqwrccuk .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#jucqwrccuk .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#jucqwrccuk .gt_from_md > :first-child {
  margin-top: 0;
}

#jucqwrccuk .gt_from_md > :last-child {
  margin-bottom: 0;
}

#jucqwrccuk .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#jucqwrccuk .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#jucqwrccuk .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#jucqwrccuk .gt_row_group_first td {
  border-top-width: 2px;
}

#jucqwrccuk .gt_row_group_first th {
  border-top-width: 2px;
}

#jucqwrccuk .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#jucqwrccuk .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#jucqwrccuk .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#jucqwrccuk .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#jucqwrccuk .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#jucqwrccuk .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#jucqwrccuk .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#jucqwrccuk .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#jucqwrccuk .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#jucqwrccuk .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#jucqwrccuk .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#jucqwrccuk .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#jucqwrccuk .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#jucqwrccuk .gt_left {
  text-align: left;
}

#jucqwrccuk .gt_center {
  text-align: center;
}

#jucqwrccuk .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#jucqwrccuk .gt_font_normal {
  font-weight: normal;
}

#jucqwrccuk .gt_font_bold {
  font-weight: bold;
}

#jucqwrccuk .gt_font_italic {
  font-style: italic;
}

#jucqwrccuk .gt_super {
  font-size: 65%;
}

#jucqwrccuk .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#jucqwrccuk .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#jucqwrccuk .gt_indent_1 {
  text-indent: 5px;
}

#jucqwrccuk .gt_indent_2 {
  text-indent: 10px;
}

#jucqwrccuk .gt_indent_3 {
  text-indent: 15px;
}

#jucqwrccuk .gt_indent_4 {
  text-indent: 20px;
}

#jucqwrccuk .gt_indent_5 {
  text-indent: 25px;
}

#jucqwrccuk .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#jucqwrccuk div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings header">
<th id="term" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col">term</th>
<th id="coef" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">coef</th>
<th id="ci_low" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">ci_low</th>
<th id="ci_high" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">ci_high</th>
<th id="p_value" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">p_value</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="term">(Intercept)</td>
<td class="gt_row gt_right" headers="coef">0.07</td>
<td class="gt_row gt_right" headers="ci_low">−0.07</td>
<td class="gt_row gt_right" headers="ci_high">0.21</td>
<td class="gt_row gt_right" headers="p_value">0.315</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age36.50</td>
<td class="gt_row gt_right" headers="coef">0.17</td>
<td class="gt_row gt_right" headers="ci_low">−0.06</td>
<td class="gt_row gt_right" headers="ci_high">0.41</td>
<td class="gt_row gt_right" headers="p_value">0.156</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age66.80</td>
<td class="gt_row gt_right" headers="coef">−0.35</td>
<td class="gt_row gt_right" headers="ci_low">−0.55</td>
<td class="gt_row gt_right" headers="ci_high">−0.15</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">handRight</td>
<td class="gt_row gt_right" headers="coef">0.23</td>
<td class="gt_row gt_right" headers="ci_low">−0.02</td>
<td class="gt_row gt_right" headers="ci_high">0.47</td>
<td class="gt_row gt_right" headers="p_value">0.076</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age80..sexFemale</td>
<td class="gt_row gt_right" headers="coef">−0.29</td>
<td class="gt_row gt_right" headers="ci_low">−0.51</td>
<td class="gt_row gt_right" headers="ci_high">−0.07</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.013</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age36.50.handRight</td>
<td class="gt_row gt_right" headers="coef">−0.21</td>
<td class="gt_row gt_right" headers="ci_low">−0.43</td>
<td class="gt_row gt_right" headers="ci_high">0.01</td>
<td class="gt_row gt_right" headers="p_value">0.071</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age80..handRight</td>
<td class="gt_row gt_right" headers="coef">−0.22</td>
<td class="gt_row gt_right" headers="ci_low">−0.44</td>
<td class="gt_row gt_right" headers="ci_high">0.00</td>
<td class="gt_row gt_right" headers="p_value">0.053</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age66.80.coffee1</td>
<td class="gt_row gt_right" headers="coef">0.45</td>
<td class="gt_row gt_right" headers="ci_low">0.19</td>
<td class="gt_row gt_right" headers="ci_high">0.71</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age36.50.coffee2.</td>
<td class="gt_row gt_right" headers="coef">0.19</td>
<td class="gt_row gt_right" headers="ci_low">−0.01</td>
<td class="gt_row gt_right" headers="ci_high">0.40</td>
<td class="gt_row gt_right" headers="p_value">0.070</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age51.65.coffee2.</td>
<td class="gt_row gt_right" headers="coef">0.33</td>
<td class="gt_row gt_right" headers="ci_low">0.16</td>
<td class="gt_row gt_right" headers="ci_high">0.49</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age36.50.alcohol1</td>
<td class="gt_row gt_right" headers="coef">−0.13</td>
<td class="gt_row gt_right" headers="ci_low">−0.31</td>
<td class="gt_row gt_right" headers="ci_high">0.06</td>
<td class="gt_row gt_right" headers="p_value">0.178</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age66.80.alcohol1</td>
<td class="gt_row gt_right" headers="coef">−0.26</td>
<td class="gt_row gt_right" headers="ci_low">−0.50</td>
<td class="gt_row gt_right" headers="ci_high">−0.01</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.042</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age66.80.alcohol2</td>
<td class="gt_row gt_right" headers="coef">−0.19</td>
<td class="gt_row gt_right" headers="ci_low">−0.40</td>
<td class="gt_row gt_right" headers="ci_high">0.02</td>
<td class="gt_row gt_right" headers="p_value">0.081</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age51.65.physical_activity1</td>
<td class="gt_row gt_right" headers="coef">−0.33</td>
<td class="gt_row gt_right" headers="ci_low">−0.50</td>
<td class="gt_row gt_right" headers="ci_high">−0.17</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age51.65.physical_activity2</td>
<td class="gt_row gt_right" headers="coef">−0.18</td>
<td class="gt_row gt_right" headers="ci_low">−0.35</td>
<td class="gt_row gt_right" headers="ci_high">−0.01</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.039</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">sexFemale.alcohol1</td>
<td class="gt_row gt_right" headers="coef">0.33</td>
<td class="gt_row gt_right" headers="ci_low">0.15</td>
<td class="gt_row gt_right" headers="ci_high">0.50</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">sexFemale.alcohol2</td>
<td class="gt_row gt_right" headers="coef">0.19</td>
<td class="gt_row gt_right" headers="ci_low">0.02</td>
<td class="gt_row gt_right" headers="ci_high">0.37</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.036</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">sexFemale.alcohol3.</td>
<td class="gt_row gt_right" headers="coef">−0.17</td>
<td class="gt_row gt_right" headers="ci_low">−0.37</td>
<td class="gt_row gt_right" headers="ci_high">0.03</td>
<td class="gt_row gt_right" headers="p_value">0.091</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">sexFemale.physical_activity2</td>
<td class="gt_row gt_right" headers="coef">−0.27</td>
<td class="gt_row gt_right" headers="ci_low">−0.44</td>
<td class="gt_row gt_right" headers="ci_high">−0.10</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.003</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">handRight.alcohol3.</td>
<td class="gt_row gt_right" headers="coef">−0.16</td>
<td class="gt_row gt_right" headers="ci_low">−0.36</td>
<td class="gt_row gt_right" headers="ci_high">0.04</td>
<td class="gt_row gt_right" headers="p_value">0.123</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">handRight.physical_activity3.</td>
<td class="gt_row gt_right" headers="coef">−0.29</td>
<td class="gt_row gt_right" headers="ci_low">−0.48</td>
<td class="gt_row gt_right" headers="ci_high">−0.10</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.004</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">coffee2..alcohol3.</td>
<td class="gt_row gt_right" headers="coef">0.12</td>
<td class="gt_row gt_right" headers="ci_low">−0.05</td>
<td class="gt_row gt_right" headers="ci_high">0.29</td>
<td class="gt_row gt_right" headers="p_value">0.172</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">coffee1.physical_activity1</td>
<td class="gt_row gt_right" headers="coef">0.17</td>
<td class="gt_row gt_right" headers="ci_low">0.01</td>
<td class="gt_row gt_right" headers="ci_high">0.33</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.040</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">alcohol3..physical_activity3.</td>
<td class="gt_row gt_right" headers="coef">0.25</td>
<td class="gt_row gt_right" headers="ci_low">0.08</td>
<td class="gt_row gt_right" headers="ci_high">0.42</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.006</td>
</tr>
</tbody>
</table>

</div>
</div>
</div>
<p>And there you have it!</p>
<p>For many subgroups, treatment A worked great (increased pain scores, significant positive effects). Treatment A didn’t work so well for others (with negative significant effects), for whom it actually appears to decrease pain scores. These results indicate we could stand to maximize pain by giving certain patients A, and other patients B. I wouldn’t fret too much about how we included interactions without their constituent main effects; leave that subtlety to the media to figure out.</p>
<div class="callout callout-style-default callout-caution callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Caution
</div>
</div>
<div class="callout-body-container callout-body">
<p>Sometimes, researchers want to actually decrease pain scores; you might want to check on this.</p>
</div>
</div>
</section>
<section id="whats-with-the-high-p-values" class="level2">
<h2 class="anchored" data-anchor-id="whats-with-the-high-p-values">What’s with the high p-values?</h2>
<p>I know what you’re thinking - won’t it be confusing to include all those results with high p-values?</p>
<p>An expert tip: if you want to make fewer discoveries and get even lower p-values, simply use BIC instead of AIC. BIC only lets the <em>most</em> significant results into the model, and you can say it’s <em>asymptotically consistent</em>, which sounds equally rigorous to AIC, which is <em>asymptotically efficient</em>.</p>
<p>In this example, here’s the model selected via stepwise BIC:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">fit_bic <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select_stepwise_ic</span>(y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> ., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2, </span>
<span id="cb10-2">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"forward"</span>, </span>
<span id="cb10-3">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">penalty =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BIC"</span>)</span></code></pre></div></div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">infer_upsi</span>(fit_bic, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(coef <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span></code></pre></div></div>
</div>
<div class="cell">
<div class="cell-output-display">
<div id="cngiboesdc" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#cngiboesdc table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#cngiboesdc thead, #cngiboesdc tbody, #cngiboesdc tfoot, #cngiboesdc tr, #cngiboesdc td, #cngiboesdc th {
  border-style: none;
}

#cngiboesdc p {
  margin: 0;
  padding: 0;
}

#cngiboesdc .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#cngiboesdc .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#cngiboesdc .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#cngiboesdc .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#cngiboesdc .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#cngiboesdc .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#cngiboesdc .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#cngiboesdc .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#cngiboesdc .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#cngiboesdc .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#cngiboesdc .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#cngiboesdc .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#cngiboesdc .gt_spanner_row {
  border-bottom-style: hidden;
}

#cngiboesdc .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#cngiboesdc .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#cngiboesdc .gt_from_md > :first-child {
  margin-top: 0;
}

#cngiboesdc .gt_from_md > :last-child {
  margin-bottom: 0;
}

#cngiboesdc .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#cngiboesdc .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#cngiboesdc .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#cngiboesdc .gt_row_group_first td {
  border-top-width: 2px;
}

#cngiboesdc .gt_row_group_first th {
  border-top-width: 2px;
}

#cngiboesdc .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#cngiboesdc .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#cngiboesdc .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#cngiboesdc .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#cngiboesdc .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#cngiboesdc .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#cngiboesdc .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#cngiboesdc .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#cngiboesdc .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#cngiboesdc .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#cngiboesdc .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#cngiboesdc .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#cngiboesdc .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#cngiboesdc .gt_left {
  text-align: left;
}

#cngiboesdc .gt_center {
  text-align: center;
}

#cngiboesdc .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#cngiboesdc .gt_font_normal {
  font-weight: normal;
}

#cngiboesdc .gt_font_bold {
  font-weight: bold;
}

#cngiboesdc .gt_font_italic {
  font-style: italic;
}

#cngiboesdc .gt_super {
  font-size: 65%;
}

#cngiboesdc .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#cngiboesdc .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#cngiboesdc .gt_indent_1 {
  text-indent: 5px;
}

#cngiboesdc .gt_indent_2 {
  text-indent: 10px;
}

#cngiboesdc .gt_indent_3 {
  text-indent: 15px;
}

#cngiboesdc .gt_indent_4 {
  text-indent: 20px;
}

#cngiboesdc .gt_indent_5 {
  text-indent: 25px;
}

#cngiboesdc .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#cngiboesdc div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings header">
<th id="term" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col">term</th>
<th id="coef" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">coef</th>
<th id="ci_low" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">ci_low</th>
<th id="ci_high" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">ci_high</th>
<th id="p_value" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">p_value</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="term">(Intercept)</td>
<td class="gt_row gt_right" headers="coef">0.07</td>
<td class="gt_row gt_right" headers="ci_low">−0.09</td>
<td class="gt_row gt_right" headers="ci_high">0.24</td>
<td class="gt_row gt_right" headers="p_value">0.393</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age36.50</td>
<td class="gt_row gt_right" headers="coef">0.27</td>
<td class="gt_row gt_right" headers="ci_low">0.10</td>
<td class="gt_row gt_right" headers="ci_high">0.45</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.003</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age66.80</td>
<td class="gt_row gt_right" headers="coef">−0.38</td>
<td class="gt_row gt_right" headers="ci_low">−0.57</td>
<td class="gt_row gt_right" headers="ci_high">−0.18</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age66.80.coffee1</td>
<td class="gt_row gt_right" headers="coef">0.23</td>
<td class="gt_row gt_right" headers="ci_low">0.04</td>
<td class="gt_row gt_right" headers="ci_high">0.42</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.019</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age51.65.coffee2.</td>
<td class="gt_row gt_right" headers="coef">0.29</td>
<td class="gt_row gt_right" headers="ci_low">0.11</td>
<td class="gt_row gt_right" headers="ci_high">0.46</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.002</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age51.65.physical_activity1</td>
<td class="gt_row gt_right" headers="coef">−0.24</td>
<td class="gt_row gt_right" headers="ci_low">−0.42</td>
<td class="gt_row gt_right" headers="ci_high">−0.07</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.007</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">sexFemale.physical_activity2</td>
<td class="gt_row gt_right" headers="coef">−0.32</td>
<td class="gt_row gt_right" headers="ci_low">−0.49</td>
<td class="gt_row gt_right" headers="ci_high">−0.15</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">&lt;0.001</td>
</tr>
</tbody>
</table>

</div>
</div>
</div>
<p>Voila – the headlines practically write themselves!</p>
</section>
<section id="how-upsis-work-so-well" class="level2">
<h2 class="anchored" data-anchor-id="how-upsis-work-so-well">How UPSIs work so well</h2>
<p>Let me let you in on a little secret. If you were paying attention, you’d have seen the outcomes in the preceding example, <img src="https://latex.codecogs.com/png.latex?Y_i">, were generated <em>completely randomly</em>. <strong>There was, by design, no true relationship to discover at all</strong>. Yet, I was virtually guaranteed to find a significant result. This is due to multiplicity’s clever younger brother, selective inference.</p>
<p>Selective inference is a difficult problem to solve; in fact, some call it impossible. Others hold out hope. At any rate, UPSIs have inertia and incentives on their side.</p>
<p>Later posts to this blog will go into specific solutions to the selective inference problem and how to implement them in R. Fair warning though, these solutions are often less promising and will certainly be less significant.</p>
<p>For now, let me finish convincing you that UPSIs are indeed effective at resolving the “publish or perish” dilemma; with USPIs, we can thrive at both! It should suffice to repeat this simulation again, as though it were performed in a parallel universe.</p>
</section>
<section id="virtual-trial-2" class="level2">
<h2 class="anchored" data-anchor-id="virtual-trial-2">Virtual Trial 2</h2>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">simdata2<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n)</span>
<span id="cb12-2">fit_bic <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select_stepwise_ic</span>(y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> ., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2, </span>
<span id="cb12-3">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"forward"</span>, </span>
<span id="cb12-4">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">penalty =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BIC"</span>)</span></code></pre></div></div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">infer_upsi</span>(fit_bic, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb13-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb13-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(coef <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) </span></code></pre></div></div>
</div>
<div class="cell">
<div class="cell-output-display">
<div id="adrrnzvnsg" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#adrrnzvnsg table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#adrrnzvnsg thead, #adrrnzvnsg tbody, #adrrnzvnsg tfoot, #adrrnzvnsg tr, #adrrnzvnsg td, #adrrnzvnsg th {
  border-style: none;
}

#adrrnzvnsg p {
  margin: 0;
  padding: 0;
}

#adrrnzvnsg .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#adrrnzvnsg .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#adrrnzvnsg .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#adrrnzvnsg .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#adrrnzvnsg .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#adrrnzvnsg .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#adrrnzvnsg .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#adrrnzvnsg .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#adrrnzvnsg .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#adrrnzvnsg .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#adrrnzvnsg .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#adrrnzvnsg .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#adrrnzvnsg .gt_spanner_row {
  border-bottom-style: hidden;
}

#adrrnzvnsg .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#adrrnzvnsg .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#adrrnzvnsg .gt_from_md > :first-child {
  margin-top: 0;
}

#adrrnzvnsg .gt_from_md > :last-child {
  margin-bottom: 0;
}

#adrrnzvnsg .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#adrrnzvnsg .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#adrrnzvnsg .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#adrrnzvnsg .gt_row_group_first td {
  border-top-width: 2px;
}

#adrrnzvnsg .gt_row_group_first th {
  border-top-width: 2px;
}

#adrrnzvnsg .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#adrrnzvnsg .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#adrrnzvnsg .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#adrrnzvnsg .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#adrrnzvnsg .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#adrrnzvnsg .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#adrrnzvnsg .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#adrrnzvnsg .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#adrrnzvnsg .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#adrrnzvnsg .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#adrrnzvnsg .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#adrrnzvnsg .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#adrrnzvnsg .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#adrrnzvnsg .gt_left {
  text-align: left;
}

#adrrnzvnsg .gt_center {
  text-align: center;
}

#adrrnzvnsg .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#adrrnzvnsg .gt_font_normal {
  font-weight: normal;
}

#adrrnzvnsg .gt_font_bold {
  font-weight: bold;
}

#adrrnzvnsg .gt_font_italic {
  font-style: italic;
}

#adrrnzvnsg .gt_super {
  font-size: 65%;
}

#adrrnzvnsg .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#adrrnzvnsg .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#adrrnzvnsg .gt_indent_1 {
  text-indent: 5px;
}

#adrrnzvnsg .gt_indent_2 {
  text-indent: 10px;
}

#adrrnzvnsg .gt_indent_3 {
  text-indent: 15px;
}

#adrrnzvnsg .gt_indent_4 {
  text-indent: 20px;
}

#adrrnzvnsg .gt_indent_5 {
  text-indent: 25px;
}

#adrrnzvnsg .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#adrrnzvnsg div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings header">
<th id="term" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col">term</th>
<th id="coef" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">coef</th>
<th id="ci_low" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">ci_low</th>
<th id="ci_high" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">ci_high</th>
<th id="p_value" class="gt_col_heading gt_columns_bottom_border gt_right" data-quarto-table-cell-role="th" scope="col">p_value</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="term">(Intercept)</td>
<td class="gt_row gt_right" headers="coef">0.03</td>
<td class="gt_row gt_right" headers="ci_low">−0.14</td>
<td class="gt_row gt_right" headers="ci_high">0.21</td>
<td class="gt_row gt_right" headers="p_value">0.715</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age66.80.sexFemale</td>
<td class="gt_row gt_right" headers="coef">−0.25</td>
<td class="gt_row gt_right" headers="ci_low">−0.43</td>
<td class="gt_row gt_right" headers="ci_high">−0.07</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.008</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="term">age80..coffee2.</td>
<td class="gt_row gt_right" headers="coef">0.30</td>
<td class="gt_row gt_right" headers="ci_low">0.11</td>
<td class="gt_row gt_right" headers="ci_high">0.50</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.003</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="term">age80..physical_activity1</td>
<td class="gt_row gt_right" headers="coef">−0.26</td>
<td class="gt_row gt_right" headers="ci_low">−0.46</td>
<td class="gt_row gt_right" headers="ci_high">−0.07</td>
<td class="gt_row gt_right" headers="p_value" style="font-weight: bold">0.009</td>
</tr>
</tbody>
</table>

</div>
</div>
</div>
<p>Indeed, we still discover “significant” relationships. And, these are completely different treatment effect modifiers. In this parallel universe, our scientist friends publish completely different effects and will no doubt pour their hard-fought resources into what we well know are wild goose chases.</p>
</section>
<section id="this-is-not-a-fluke." class="level2">
<h2 class="anchored" data-anchor-id="this-is-not-a-fluke.">This is not a fluke.</h2>
<p>In case you are still skeptical, let’s repeat this 50 times, as though we ran the study in 50 parallel universes.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1">sim_results <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>()</span>
<span id="cb14-2"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span>(s <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>) { </span>
<span id="cb14-3">  simdata2<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n)</span>
<span id="cb14-4">  fit_bic <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select_stepwise_ic</span>(y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> ., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2, </span>
<span id="cb14-5">                                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"forward"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">penalty =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BIC"</span>)</span>
<span id="cb14-6">  sim_results[[s]] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">infer_upsi</span>(fit_bic, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> simdata2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb14-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb14-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(coef <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) </span>
<span id="cb14-9">}</span>
<span id="cb14-10"></span>
<span id="cb14-11">all_selections <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(sim_results, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.id =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"simulation"</span>)</span></code></pre></div></div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1">main_results <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> all_selections <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(term <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(Intercept)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(simulation) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span>(</span>
<span id="cb15-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">any_p_lt_05 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(p_value <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>), </span>
<span id="cb15-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_selections =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()</span>
<span id="cb15-7">  )</span></code></pre></div></div>
</div>
<p>Using BIC, we found at least one significant effect in 46 of 50 trials, and on average these trials found 2.6 significant effects. We achieved falsely significant results 92% of the time.</p>
<p>If you’re thinking “hmm, my study still might have a chance of failing”, well good news. AIC finds a significant result nearly 100% of the time. We also only considered pairwise interactions between 6 candidate predictors. To minimize the risk of a negative study, one could consider higher level interactions or a greater number of subgroups, and a positive result quickly becomes a sure thing.</p>
<p>As I’ve said, UPSIs have incentives and inertia on their side. The more broad we make this practice, the better we can do at ensuring that the publications keep flowing, regardless of the truth.</p>
<p>Despicably yours,</p>
<p><em>P. Hackman</em></p>
<hr>
</section>
</section>
<section id="conclusion" class="level1">
<h1>Conclusion</h1>
<section id="key-takeaways" class="level2">
<h2 class="anchored" data-anchor-id="key-takeaways">Key Takeaways</h2>
<ul>
<li>Unadjusted post-selection inference nearly guarantees false positives</li>
<li>Searching for subgroup effects is a model selection problem</li>
<li>Model selection algorithms don’t make multiplicity issues go away; they make them more subtle and harder to adjust for.</li>
</ul>
</section>
<section id="future-threads" class="level2">
<h2 class="anchored" data-anchor-id="future-threads">Future Threads</h2>
<ul>
<li>What are some alternatives to UPSI-based inference, and how are they implemented in R?</li>
<li>What is the <code>selectInferToolkit</code> package?</li>
</ul>
</section>
<section id="related" class="level2">
<h2 class="anchored" data-anchor-id="related">Related</h2>
<ul>
<li>Our group first described the term UPSI in the post on <a href="https://data-diction.com/posts/glassbox-models/">glass-box modeling</a>.</li>
<li>Good further reading: <a href="https://hdsr.mitpress.mit.edu/pub/l39rpgyc/release/3">Benjamini 2020</a></li>
</ul>
<!-- Edit the line below after review -->
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-5-contents" aria-controls="callout-5" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Reviewers
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-5" class="callout-5-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<ul>
<li>Logan Harris (December 1, 2025)</li>
<li>Matt Bolt (December 11, 2025)</li>
</ul>
</div>
</div>
</div>
<hr>
</section>
</section>
<section id="appendix" class="level1">
<h1>Appendix</h1>
<details>
<summary>
R Session Info
</summary>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1">sessioninfo<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">session_info</span>()</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.5.2 (2025-10-31)
 os       macOS Tahoe 26.4.1
 system   aarch64, darwin20
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Chicago
 date     2026-04-28
 pandoc   3.6.3 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
 quarto   1.8.25 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/quarto

─ Packages ───────────────────────────────────────────────────────────────────
 package            * version     date (UTC) lib source
 adaptMCMC            1.5         2024-01-29 [1] CRAN (R 4.5.0)
 backports            1.5.0       2024-05-23 [1] CRAN (R 4.5.0)
 broom              * 1.0.12      2026-01-27 [1] CRAN (R 4.5.2)
 class                7.3-23      2025-01-01 [2] CRAN (R 4.5.2)
 cli                  3.6.5       2025-04-23 [1] CRAN (R 4.5.0)
 coda                 0.19-4.1    2024-01-31 [1] CRAN (R 4.5.0)
 codetools            0.2-20      2024-03-31 [2] CRAN (R 4.5.2)
 data.table           1.18.2.1    2026-01-27 [1] CRAN (R 4.5.2)
 digest               0.6.39      2025-11-19 [1] CRAN (R 4.5.2)
 dplyr              * 1.2.0       2026-02-03 [1] CRAN (R 4.5.2)
 evaluate             1.0.5       2025-08-27 [1] CRAN (R 4.5.0)
 farver               2.1.2       2024-05-13 [1] CRAN (R 4.5.0)
 fastmap              1.2.0       2024-05-15 [1] CRAN (R 4.5.0)
 forcats            * 1.0.1       2025-09-25 [1] CRAN (R 4.5.0)
 foreach              1.5.2       2022-02-02 [1] CRAN (R 4.5.0)
 fs                   1.6.6       2025-04-12 [1] CRAN (R 4.5.0)
 future               1.70.0      2026-03-14 [1] CRAN (R 4.5.2)
 future.apply         1.20.2      2026-02-20 [1] CRAN (R 4.5.2)
 generics             0.1.4       2025-05-09 [1] CRAN (R 4.5.0)
 ggplot2            * 4.0.2       2026-02-03 [1] CRAN (R 4.5.2)
 glmnet               4.1-10      2025-07-17 [1] CRAN (R 4.5.0)
 globals              0.19.1      2026-03-13 [1] CRAN (R 4.5.2)
 glue                 1.8.0       2024-09-30 [1] CRAN (R 4.5.0)
 gower                1.0.2       2024-12-17 [1] CRAN (R 4.5.0)
 gt                 * 1.1.0       2025-09-23 [1] CRAN (R 4.5.0)
 gtable               0.3.6       2024-10-25 [1] CRAN (R 4.5.0)
 hardhat              1.4.2       2025-08-20 [1] CRAN (R 4.5.0)
 hms                  1.1.4       2025-10-17 [1] CRAN (R 4.5.0)
 htmltools            0.5.9       2025-12-04 [1] CRAN (R 4.5.2)
 htmlwidgets          1.6.4       2023-12-06 [1] CRAN (R 4.5.0)
 intervals            0.15.5      2024-08-23 [1] CRAN (R 4.5.0)
 ipred                0.9-15      2024-07-18 [1] CRAN (R 4.5.0)
 iterators            1.0.14      2022-02-05 [1] CRAN (R 4.5.0)
 jsonlite             2.0.0       2025-03-27 [1] CRAN (R 4.5.0)
 knitr                1.50        2025-03-16 [1] CRAN (R 4.5.0)
 lattice              0.22-7      2025-04-02 [2] CRAN (R 4.5.2)
 lava                 1.8.2       2025-10-30 [1] CRAN (R 4.5.0)
 lifecycle            1.0.5       2026-01-08 [1] CRAN (R 4.5.2)
 listenv              0.10.1      2026-03-10 [1] CRAN (R 4.5.2)
 lubridate          * 1.9.5       2026-02-04 [1] CRAN (R 4.5.2)
 magrittr             2.0.5       2026-04-04 [1] CRAN (R 4.5.2)
 MASS                 7.3-65      2025-02-28 [2] CRAN (R 4.5.2)
 Matrix               1.7-4       2025-08-28 [2] CRAN (R 4.5.2)
 ncvreg               3.16.0      2025-10-09 [1] Github (pbreheny/ncvreg@5fecc8c)
 nnet                 7.3-20      2025-01-01 [1] CRAN (R 4.5.0)
 parallelly           1.46.1      2026-01-08 [1] CRAN (R 4.5.2)
 pbapply              1.7-4       2025-07-20 [1] CRAN (R 4.5.0)
 pillar               1.11.1      2025-09-17 [1] CRAN (R 4.5.0)
 pkgconfig            2.0.3       2019-09-22 [1] CRAN (R 4.5.0)
 prodlim              2026.03.11  2026-03-11 [1] CRAN (R 4.5.2)
 purrr              * 1.2.1       2026-01-09 [1] CRAN (R 4.5.2)
 R6                   2.6.1       2025-02-15 [1] CRAN (R 4.5.0)
 RColorBrewer         1.1-3       2022-04-03 [1] CRAN (R 4.5.0)
 Rcpp                 1.1.1       2026-01-10 [1] CRAN (R 4.5.2)
 readr              * 2.1.6       2025-11-14 [1] CRAN (R 4.5.2)
 recipes              1.3.1       2025-05-21 [1] CRAN (R 4.5.0)
 rlang                1.1.7       2026-01-09 [1] CRAN (R 4.5.2)
 rmarkdown            2.30        2025-09-28 [1] CRAN (R 4.5.0)
 rpart                4.1.24      2025-01-07 [2] CRAN (R 4.5.2)
 rstudioapi           0.17.1      2024-10-22 [1] CRAN (R 4.5.0)
 S7                   0.2.1       2025-11-14 [1] CRAN (R 4.5.2)
 sass                 0.4.10      2025-04-11 [1] CRAN (R 4.5.0)
 scales               1.4.0       2025-04-24 [1] CRAN (R 4.5.0)
 selectInferToolkit * 0.4.2       2026-03-24 [1] Github (petersonR/selectInferToolkit@61b8347)
 selectiveInference   1.2.5       2019-09-07 [1] CRAN (R 4.5.0)
 sessioninfo          1.2.3       2025-02-05 [1] CRAN (R 4.5.0)
 shape                1.4.6.1     2024-02-23 [1] CRAN (R 4.5.0)
 sparsevctrs          0.3.6       2026-01-27 [1] CRAN (R 4.5.2)
 stringi              1.8.7       2025-03-27 [1] CRAN (R 4.5.0)
 stringr            * 1.6.0       2025-11-04 [1] CRAN (R 4.5.0)
 survival             3.8-3       2024-12-17 [2] CRAN (R 4.5.2)
 tibble             * 3.3.1       2026-01-11 [1] CRAN (R 4.5.2)
 tidyr              * 1.3.2       2025-12-19 [1] CRAN (R 4.5.2)
 tidyselect           1.2.1       2024-03-11 [1] CRAN (R 4.5.0)
 tidyverse          * 2.0.0       2023-02-22 [1] CRAN (R 4.5.0)
 timechange           0.4.0       2026-01-29 [1] CRAN (R 4.5.2)
 timeDate             4052.112    2026-01-28 [1] CRAN (R 4.5.2)
 tzdb                 0.5.0       2025-03-15 [1] CRAN (R 4.5.0)
 utf8                 1.2.6       2025-06-08 [1] CRAN (R 4.5.0)
 vctrs                0.7.2       2026-03-21 [1] CRAN (R 4.5.2)
 withr                3.0.2       2024-10-28 [1] CRAN (R 4.5.0)
 xfun                 0.54        2025-10-30 [1] CRAN (R 4.5.0)
 xml2                 1.5.1       2025-12-01 [1] CRAN (R 4.5.2)
 yaml                 2.3.11.9000 2025-12-10 [1] Github (r-lib/r-yaml@6dc4582)

 [1] /Users/rpterson/Library/R/arm64/4.5/library
 [2] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
 * ── Packages attached to the search path.

──────────────────────────────────────────────────────────────────────────────</code></pre>
</div>
</div>
</details>


</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-hackman2025" class="csl-entry quarto-appendix-citeas">
Hackman, P. [Ryan Peterson]. 2025. <span>“How Can I Guarantee a
Significant Result?”</span> <em>Data Diction</em> (blog). December 22,
2025. <a href="https://doi.org/10.59350/6mzf8-xzd69">https://doi.org/10.59350/6mzf8-xzd69</a>.
</div></div></section></div> ]]></description>
  <category>model selection</category>
  <category>glass-box modeling</category>
  <category>post-selection inference</category>
  <category>analysis</category>
  <category>R</category>
  <category>satire</category>
  <guid>https://www.data-diction.com/posts/upsi-example/</guid>
  <pubDate>Mon, 22 Dec 2025 00:00:00 GMT</pubDate>
  <media:content url="https://www.data-diction.com/posts/upsi-example/thumbnail.png" medium="image" type="image/png" height="112" width="144"/>
</item>
<item>
  <title>Does debiasing estimates lead to better predictions?</title>
  <dc:creator>Logan Harris</dc:creator>
  <link>https://www.data-diction.com/posts/bias-benefit/</link>
  <description><![CDATA[ 





<!-- Edit the line below after review -->
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Reviewers
</div>
</div>
<div class="callout-body-container callout-body">
<ul>
<li>Ryan Peterson (2025-11-24).</li>
<li>Patrick Breheny (2025-12-12).</li>
</ul>
</div>
</div>
<hr>
<p>What connotation do you attach to the word “bias”? A negative one?</p>
<p>In this post we will see why not all bias is bad… at least when it comes to building predictive models. In fact, for many years, statisticians have recognized the benefits of biased estimators in reducing prediction error. Perhaps you knew this, but if not, don’t worry. That is the purpose of this post.</p>
<div class="hidden">
<p>$$</p>
<p>% Uppercase roman letters </p>
<p>% Lowercase roman letters (c, d, u, v have to be treated special; see end) </p>
<p>%% Roman letters with hats </p>
<p>%% Roman letters with subscripts </p>
<p>%% Roman letters with tildes </p>
<p>%% Script letters </p>
<p>%% Greek letters </p>
<p>%% Greek letters with tildes </p>
<p>%% Operators </p>
<p>%% Statistical </p>
% Fisher/observed information
<p>% Independence </p>
<p>%% Mathematical %% %% Requires dsfonts <!-- \providecommand{\abs}[1]{\left\lvert#1\right\rvert} --> </p>
<p>%% Equations </p>
<p>% Other </p>
<p>$$</p>
</div>
<section id="modeling-goal" class="level1">
<h1>Modeling Goal</h1>
<p>When starting off with a data analysis, it is important to outline the primary goals. Whether you realize it or not, in virtually all cases, a primary goal is to use the data to develop a predictive model.</p>
<p>Consider a clinical trial evaluating a new drug for metastatic lung cancer. We say our goal is to “estimate the treatment effect” of our new drug. However, estimating a treatment effect is fundamentally a predictive task. That is, we need to <em>predict</em> what would happen with treatment and what would happen without treatment. The treatment effect is the difference between those two predictions*, the better our predictions… the better our estimate of the treatment effect is.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-2-contents" aria-controls="callout-2" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>A pre-<em>dictor</em> is pre-<em>what</em>, exactly?*
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-2" class="callout-2-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>When we say a treatment effect is “the difference between two predictions,” that only works if the predictions are made using information that comes before the treatment starts. These are true pre-<em>treatment</em> predictors.</p>
<p>If we accidentally include a model “predictor” that is measured after treatment begins, the treatment could affect it, and the real treatment effect gets obfuscated. The model might appear to “predict” well, but the truth is that it’s not “predicting” at all. Models built this way can give a misleading estimate of the effect of the treatment because part of the effect has been absorbed by the post-treatment variable.</p>
<p>For a valid treatment effect, we must base predictions only on information that could not have been influenced by the treatment – valid <strong>pre</strong>-dictor variables.</p>
</div>
</div>
</div>
<p>Now, suppose with treatment alone we can predict remission status with 60% accuracy. If you also have patients’ genetic information, what should you do with that?</p>
<p>Including it directly into a model is problematic because the human genome is large*. Unless you have a massive number of patients in your trial (hundreds of thousands) you will NEED to make assumptions about the plausible effects of someone’s genetic information on how well the new treatment works. These assumptions allow us to fit a model with all the genetic information but also intentionally introduce bias to the estimates. This is what a method known as penalized regression does, which we will cover momentarily.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-3-contents" aria-controls="callout-3" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Human Genome*
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-3" class="callout-3-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>The human genome is estimated to contain between 30,000 and 40,000 genes!</p>
</div>
</div>
</div>
<p>Now, suppose including genetic information allows us to predict if a patient will be experience remission with 75% accuracy. But this was with biased estimates?! Surely, if we could remove this bias we would get even better predictions, right?</p>
<p>To answer this, we will now break down what makes a set of estimates good at prediction.</p>
</section>
<section id="breaking-down-predictive-performance" class="level1">
<h1>Breaking down predictive performance</h1>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Bias-variance tradeoff
</div>
</div>
<div class="callout-body-container callout-body">
<p>When we estimate parameters for a model, we are always juggling two competing forces: <strong>bias</strong>, which measures how far our average estimate is from the truth and <strong>variance</strong>, which reflects how much our estimates would change if we collect a new sample. A model’s ability to predict an outcome is dependent on both. Increasing or inducing bias can often <em>reduce</em> variance, whereas decreasing bias can often <em>increase</em> variance. Good predictions come from striking a balance between the two. It is not uncommon to be able to intentionally introduce a little bias and be able to drastically reduce variance resulting in better predictive abilities.</p>
</div>
</div>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/bias-benefit/index_files/figure-html/unnamed-chunk-1-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>It is like comparing one friend who is always 5 minutes late to one that is sometimes 30 minutes early and other times 30 minutes late. While the latter is on average on time, you’d probably describe the one who is always 5 minutes late as more reliable.</p>
<p>If you are someone who likes mathematical details, keep reading. But if the previous example makes sense, feel free to skip to the next section.</p>
<p>For a sample of size <img src="https://latex.codecogs.com/png.latex?n">, suppose we have a continuous outcome stored in a length <img src="https://latex.codecogs.com/png.latex?n"> vector <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7By%7D"> and <img src="https://latex.codecogs.com/png.latex?p"> features on each sample unit stored in an <img src="https://latex.codecogs.com/png.latex?n%20%5Ctimes%20p"> matrix <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BX%7D">. We will focus on a linear predictor setting. That is, we want to predict <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7By%7D"> based on a linear combination of the features in <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BX%7D">. We do this by estimating <img src="https://latex.codecogs.com/png.latex?p"> parameters <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%7B%5Cbeta%7D"> and then obtaining predictions <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cmathbf%7By%7D%7D">:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cmathbf%7By%7D%7D%20=%20%5Cmathbf%7BX%7D%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D%0A"></p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D"> is usually estimated in a way that is based on minimizing <img src="https://latex.codecogs.com/png.latex?%5ClVert%5Cmathbf%7By%7D-%20%5Chat%7B%5Cmathbf%7By%7D%7D%5CrVert_2%5E2">, known as the residual sum of squares. However, to assess predictive performance we might consider mean square prediction error (MSPE). MSPE shifts our focus to how well our model is expected to predict <em>a single out-of-sample observation</em> (an observation <img src="https://latex.codecogs.com/png.latex?y_0"> with predictors <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D_0"> that was not in the original sample used to estimate the model).</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Ctext%7BMSPE%7D%20=%20E%20%5Cleft%5B%5ClVert%20y_0%20-%20%5Cmathbf%7Bx%7D_0%5E%7B%5Cscriptscriptstyle%5Ctop%7D%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D%5CrVert_2%5E2%5Cright%5D%20=%20E%20%5Cleft%5B%20(y_0%20-%20%5Chat%20y_0)%5E2%5Cright%5D%0A"></p>
<p>Assuming that the error structure for <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7By%7D"> is normally distributed (i.e.&nbsp;<img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7By%7D=%20%5Cmathbf%7BX%7D%5Cboldsymbol%7B%5Cbeta%7D+%20%5Cepsilon,%20%5Cepsilon%5Coverset%7B%5Ctext%7Biid%7D%7D%7B%5Csim%7D%5Ctextrm%7BN%7D(0,%20%5Csigma%5E2)">) and letting <img src="https://latex.codecogs.com/png.latex?%5Cepsilon_0"> be the error corresponding to <img src="https://latex.codecogs.com/png.latex?y_0"> and <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D_0">, MSPE can be decomposed as follows:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A(y_0%20-%20%5Chat%7By%7D_0)%5E2%20&amp;=%20(%5Cmathbf%7Bx%7D_0%5ET%20%5Cboldsymbol%7B%5Cbeta%7D-%20%5Cmathbf%7Bx%7D_0%5ET%20%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D+%20%5Cepsilon_0)%5E2%20%5C%5C%0A&amp;=%20(%5Cmathbf%7Bx%7D_0%5E%7B%5Cscriptscriptstyle%5Ctop%7D(%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D-%20%5Cboldsymbol%7B%5Cbeta%7D))%5E2%20+%202%20%5Cmathbf%7Bx%7D_0%20%5E%7B%5Cscriptscriptstyle%5Ctop%7D(%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D-%20%5Cboldsymbol%7B%5Cbeta%7D)%5Cepsilon_0%20+%20%5Cepsilon_0%5E2%20%5C%5C%0A%5CRightarrow%20%5Ctext%7BMSPE%7D%20&amp;=%20E%5Cleft%5B%5Cmathbf%7Bx%7D_0%5E%7B%5Cscriptscriptstyle%5Ctop%7D(%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D-%20%5Cboldsymbol%7B%5Cbeta%7D)(%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D-%20%5Cboldsymbol%7B%5Cbeta%7D)%5E%7B%5Cscriptscriptstyle%5Ctop%7D%5Cmathbf%7Bx%7D_0%5Cright%5D%20+%20%5Csigma%5E2%20%5C%5C%0A&amp;=%20%5Cmathbf%7Bx%7D_0%5E%7B%5Cscriptscriptstyle%5Ctop%7DE%5Cleft%5B(%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D-%20%5Cboldsymbol%7B%5Cbeta%7D)(%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D-%20%5Cboldsymbol%7B%5Cbeta%7D)%5E%7B%5Cscriptscriptstyle%5Ctop%7D%5Cright%5D%5Cmathbf%7Bx%7D_0%20+%20%5Csigma%5E2%20%5C%5C%0A&amp;=%20%5Cmathbf%7Bx%7D_0%5E%7B%5Cscriptscriptstyle%5Ctop%7D%5Cleft%5B%5Ctext%7BVar%7D(%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D)%20+%20%5Ctext%7BBias%7D(%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D)%5Ctext%7BBias%7D(%5Cwidehat%7B%5Cboldsymbol%7B%5Cbeta%7D%7D)%5E%7B%5Cscriptscriptstyle%5Ctop%7D%5Cright%5D%5Cmathbf%7Bx%7D_0%20+%20%5Csigma%5E2%0A%5Cend%7Baligned%7D%0A"></p>
<p>To make the point easier to see, assume we have just a single predictor <img src="https://latex.codecogs.com/png.latex?x_0"> (i.e., <img src="https://latex.codecogs.com/png.latex?p%20=%201">) and consider two different candidate estimators for <img src="https://latex.codecogs.com/png.latex?%5Cbeta">, <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta%7D%5EA"> and <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cbeta%7D%5EB">. Then, the difference in their MSPEs is:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Ctext%7BMSPE%7D(%5Cwidehat%7B%5Cbeta%7D%5EA)%20-%20%5Ctext%7BMSPE%7D(%5Cwidehat%7B%5Cbeta%7D%5EB)%0A"></p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A&amp;%20=%20x_0%5E2%20%5Cleft(%5Ctext%7BVar%7D(%5Cwidehat%7B%5Cbeta%7D%5EA)%20+%20%5Ctext%7BBias%7D(%5Cwidehat%7B%5Cbeta%7D%5EA)%5E2%5Cright)+%20%5Csigma%5E2%0A-%20%5Cleft%5B%20x_0%5E2%20%5Cleft(%20%5Ctext%7BVar%7D(%5Cwidehat%7B%5Cbeta%7D%5EB)%20+%20%5Ctext%7BBias%7D(%5Cwidehat%7B%5Cbeta%7D%5EB)%5E2%5Cright)%20+%20%5Csigma%5E2%20%5Cright%5D%20%5C%5C%0A&amp;%20%5Cpropto%20(%5Ctext%7BVar%7D(%5Cwidehat%7B%5Cbeta%7D%5EA)-%5Ctext%7BVar%7D(%5Cwidehat%7B%5Cbeta%7D%5EB))%20+%20(%5Ctext%7BBias%7D(%5Cwidehat%7B%5Cbeta%7D%5EA)%5E2%20-%20%5Ctext%7BBias%7D(%5Cwidehat%7B%5Cbeta%7D%5EB)%5E2).%0A%5Cend%7Baligned%7D%0A"></p>
<p>So now we see the details of the earlier claim that predictive performance is a function of both variance and bias of the estimates.</p>
<p>Let’s work through a toy example. Consider an example where estimator A has a bias of -0.5 and has a variance of 1. This scenario might reflect a <strong>penalized</strong> estimate for <img src="https://latex.codecogs.com/png.latex?%5Cbeta%20%5EA">, where the estimator wants to shrink the estimate by a certain amount. Consider an alternative estimator B which corrects the bias of estimator A so that <img src="https://latex.codecogs.com/png.latex?%5Ctext%7BBias%7D(%5Cwidehat%7B%5Cbeta%7D%5EB)%20=%200">, but this increases its variance to 1.5. Then</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A(%5Ctext%7BVar%7D(%5Cwidehat%7B%5Cbeta%7D%5EA)-%5Ctext%7BVar%7D(%5Cwidehat%7B%5Cbeta%7D%5EB))%20+%20(%5Ctext%7BBias%7D(%5Cwidehat%7B%5Cbeta%7D%5EA)%5E2%20-%20%5Ctext%7BBias%7D(%5Cwidehat%7B%5Cbeta%7D%5EB)%5E2)%20&amp;=%20(1%20-%201.5)%20+%20((-0.5)%5E2%20-%200%5E2)%20%5C%5C%0A&amp;=%20-0.25%0A%5Cend%7Baligned%7D%0A"></p>
<p>The MSPE for the “debiased” estimator is greater than that of the “biased” estimator. Correcting the bias in the estimator had a negative impact on predictive performance.</p>
<p>So, if we care about predictive performance, then bias in our estimates is not necessarily a bad thing.</p>
</section>
<section id="penalized-regression" class="level1">
<h1>Penalized Regression</h1>
<p>A common rule of thumb is that you need <em>at least</em> 10 observations (<img src="https://latex.codecogs.com/png.latex?n"> denotes number of observations) per predictor (<img src="https://latex.codecogs.com/png.latex?p"> denotes number of predictors) in traditional linear regression settings to estimate <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%7B%5Cbeta%7D"> “stably” using ordinary least squares (OLS), but even more may be required. If <img src="https://latex.codecogs.com/png.latex?n%20%3E%20p"> but <img src="https://latex.codecogs.com/png.latex?n%20%3C%2010p">, this rule of thumb would suggest we are in a gray area where estimates for <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%7B%5Cbeta%7D"> tend to be highly variable and can lead to poor predictions. Of course, if <img src="https://latex.codecogs.com/png.latex?n%20%3C%20p">, then it is not possible to use OLS at all.</p>
<p>Adding bias to the estimation process is helpful in both of these scenarios. Enter <em>penalized regression</em> methods.</p>
<p>In general, such methods “penalize” larger estimates of <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%7B%5Cbeta%7D"> by an amount dictated by a tuning parameter, <img src="https://latex.codecogs.com/png.latex?%5Clambda">. The penalty acts like a “complexity tax” forcing the model to stop chasing noise and to start paying attention to the real signal. So, while this introduces bias in the estimates, it also reduces their variance, often leading to superior predictive performance. In fact, this can be true even when <img src="https://latex.codecogs.com/png.latex?n"> is much larger than <img src="https://latex.codecogs.com/png.latex?p">. In high-dimensional or noisy settings or if there is large amount of correlation between predictors, the gains are often large enough that biased estimators dominate unbiased ones in prediction.</p>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-5-contents" aria-controls="callout-5" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Tip</span>Popular Penalized Regression Methods
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-5" class="callout-5-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<ol type="1">
<li>The least absolute shrinkage and selection operator (lasso)</li>
<li>Ridge regression</li>
<li>Elastic net (simply a mix of 1 and 2)</li>
</ol>
</div>
</div>
</div>
<p>It’s easiest to show this with data, so we’ll now turn to an example.</p>
</section>
<section id="example-predicting-leukemia-subtype" class="level1">
<h1>Example: Predicting Leukemia Subtype</h1>
<p>To start, we’ll load some libraries and a helpful function.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(hdrm)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ncvreg)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(hdi)</span>
<span id="cb1-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb1-5"></span>
<span id="cb1-6">estimate_intercept <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(beta, X, y) {</span>
<span id="cb1-7">  eta_no_intercept <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">drop</span>(X <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%*%</span> beta)</span>
<span id="cb1-8"></span>
<span id="cb1-9">  f <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(alpha) {</span>
<span id="cb1-10">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plogis</span>(alpha <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> eta_no_intercept)</span>
<span id="cb1-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(y) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(p)</span>
<span id="cb1-12">  }</span>
<span id="cb1-13"></span>
<span id="cb1-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">uniroot</span>(f, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">interval =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>root</span>
<span id="cb1-15">}</span></code></pre></div></div>
</div>
<p>Now, consider a data set for predicting leukemia subtype using gene expression data <span class="citation" data-cites="Golub1999">(Golub et al. 1999)</span>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">brca1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> hdrm<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_data</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Golub1999"</span>)</span>
<span id="cb2-2">X <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> brca1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>X</span>
<span id="cb2-3">y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> brca1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ALL"</span></span>
<span id="cb2-4">n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(brca1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>y)</span></code></pre></div></div>
</div>
<p>This dataset has 47 patients with acute lymphoblastic leukemia (abbreviated as ALL) and 25 patients with acute myeloid leukemia (AML). There are 7129 gene expression features, putting us in the high-dimensional realm of <img src="https://latex.codecogs.com/png.latex?n%20%3C%20p">.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>When <img src="https://latex.codecogs.com/png.latex?n%20%3C%20p">, the variance of <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%7B%5Cbeta%7D"> for an ordinary, unpenalized regression of any type is essentially <img src="https://latex.codecogs.com/png.latex?%5Cinfty"> because the model is not identifiable. It’s like trying to solve a puzzle with more missing pieces than clues; many solutions look “possible,” so you can’t tell which one is the real one.</p>
</div>
</div>
<p>We split the dataset 50/50 into train and test sets.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2806</span>)</span>
<span id="cb3-2">idx_train <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sample.int</span>(n, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">floor</span>(n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>))</span>
<span id="cb3-3">Xtrain <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> X[idx_train,]</span>
<span id="cb3-4">ytrain <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> y[idx_train]</span>
<span id="cb3-5">Xtest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> X[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>idx_train,]</span>
<span id="cb3-6">ytest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> y[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>idx_train]</span></code></pre></div></div>
</div>
<p>Then, we will perform a penalized regression method called the “lasso” and select the tuning parameter <img src="https://latex.codecogs.com/png.latex?%5Clambda"> using cross validation:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2806</span>)</span>
<span id="cb4-2">cv_fit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cv.ncvreg</span>(Xtrain, ytrain, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">penalty =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lasso"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"binomial"</span>)</span>
<span id="cb4-3">lambda_min <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cv_fit<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>lambda.min</span></code></pre></div></div>
</div>
<p>Finally we can visualize the predicted probabilities on the testing data to see how well the selected lasso model is able to differentiate between the two disease subtypes.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">lasso_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb5-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predicted_prob_ALL =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">predict</span>(cv_fit, Xtest, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"response"</span>),</span>
<span id="cb5-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">class =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(ytest, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AML"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ALL"</span>))</span>
<span id="cb5-4">)</span>
<span id="cb5-5"></span>
<span id="cb5-6">lasso_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>prediction_quality <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(</span>
<span id="cb5-7">  lasso_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>predicted_prob_ALL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> lasso_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>class <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AML"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> </span>
<span id="cb5-8">    lasso_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>predicted_prob_ALL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> lasso_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>class <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ALL"</span>,</span>
<span id="cb5-9">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Bad"</span>, </span>
<span id="cb5-10">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Good"</span></span>
<span id="cb5-11">)</span>
<span id="cb5-12"></span>
<span id="cb5-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(lasso_res, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> class, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> predicted_prob_ALL, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> prediction_quality)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_minimal</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_discrete</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Prediction"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb5-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ylab</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Lasso-based predicted probability ALL"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xlab</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/bias-benefit/index_files/figure-html/unnamed-chunk-6-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>Along with the fact that we reduced the variability of estimation (enough to actually fit a model), introducing bias also helps mitigate over fitting which leads to models that are more generalizable with improved out-of-sample predictions. With this example, we have good (though imperfect) separation between the two subtypes.</p>
<p>This is not the only benefit of introducing bias here. Penalties like the lasso produce sparse fits, with many coefficients set exactly to zero (the second “s” in lasso does literally stand for <em>selection</em>). Weak and noisy predictors are removed, leading to more interpretable <a href="https://data-diction.com/posts/glassbox-models/">glass-box models</a>.</p>
</section>
<section id="the-pitfall-of-debiasing" class="level1">
<h1>The Pitfall of Debiasing</h1>
<p>That being said, it is reasonable to think that reducing the bias of the estimates for <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%7B%5Cbeta%7D"> would lead to better predictive performance. One such example is the debiased lasso (also known as the desparsified lasso, <span class="citation" data-cites="ZhangZhang2014">Zhang and Zhang (2014)</span>) . However, while this method may be good for providing asymptotically unbiased estimators, debiasing can come at the cost of reintroducing a high amount of variance.</p>
<p>As a result, debiasing often leads to noticeably <em>worse</em> predictions. To see this, we will fit the desparsified lasso to our leukemia dataset.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Takes about 20 minutes; cached </span></span>
<span id="cb6-2">debiased_fit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> hdi<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lasso.proj</span>(Xtrain, ytrain, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"binomial"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lambda =</span> lambda_min)</span>
<span id="cb6-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">saveRDS</span>(debiased_fit<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bhat, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"debiased_fit.rds"</span>)</span></code></pre></div></div>
</div>
<p>In the code below, we re-estimate the intercept after we obtain the debiased estimates. Then, we can visualize the predictions as we did with the lasso.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">debiased_fit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readRDS</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"debiased_fit.rds"</span>)</span>
<span id="cb7-2">debiased_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb7-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predicted_prob_ALL =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plogis</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">estimate_intercept</span>(debiased_fit, Xtrain, ytrain) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Xtest <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%*%</span> debiased_fit),</span>
<span id="cb7-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">class =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(ytest, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AML"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ALL"</span>))</span>
<span id="cb7-5">)</span>
<span id="cb7-6"></span>
<span id="cb7-7">debiased_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>prediction_quality <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(</span>
<span id="cb7-8">  debiased_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>predicted_prob_ALL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> debiased_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>class <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AML"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> </span>
<span id="cb7-9">    debiased_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>predicted_prob_ALL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> debiased_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>class <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ALL"</span>,</span>
<span id="cb7-10">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Bad"</span>, </span>
<span id="cb7-11">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Good"</span></span>
<span id="cb7-12">)</span>
<span id="cb7-13"></span>
<span id="cb7-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(debiased_res, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> class, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> predicted_prob_ALL, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> prediction_quality)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_minimal</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_discrete</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Prediction"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ylab</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Debiased-lasso-based predicted probability ALL"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xlab</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/bias-benefit/index_files/figure-html/unnamed-chunk-8-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>Debiasing the original lasso point estimates results in 1 additional subject with AML being misclassified into the ALL group. Additionally, whereas the lasso correctly predicted all subjects with ALL, debiasing leads to 2 incorrect AML predictions. This is a reduction in accuracy from 87.5% to 78.1%!</p>
<p>While you might say you don’t care about prediction, in a future post we will explore why you can’t afford not to.</p>
</section>
<section id="take-aways" class="level1">
<h1>Take aways</h1>
<ul>
<li>Biased estimation can improve a model’s predictive performance</li>
<li>Reducing bias (via debiasing) often worsens predictions</li>
<li>The lasso and other penalized regression methods can yield better <a href="https://data-diction.com/posts/glassbox-models/">glass-box models</a></li>
</ul>
</section>
<section id="follow-up-questions" class="level1">
<h1>Follow-up Questions</h1>
<p>The following questions might be of interest for new posts:</p>
<ul>
<li>What implications does bias have on inference and model interpretation?</li>
<li>When might debiasing be a good idea?</li>
</ul>



</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent">
<div id="ref-Golub1999" class="csl-entry">
Golub, Todd R., Donna K. Slonim, Pablo Tamayo, Christine Huard, Michael Gaasenbeek, Jill P. Mesirov, Hilary Coller, et al. 1999. <span>“Molecular Classification of Cancer: Class Discovery and Class Prediction by Gene Expression Monitoring.”</span> <em>Science</em> 286 (5439): 531–37. <a href="https://doi.org/10.1126/science.286.5439.531">https://doi.org/10.1126/science.286.5439.531</a>.
</div>
<div id="ref-ZhangZhang2014" class="csl-entry">
Zhang, C. H., and S. S. Zhang. 2014. <span>“Confidence Intervals for Low Dimensional Parameters in High Dimensional Linear Models.”</span> <em>Journal of the Royal Statistical Society: Series B (Statistical Methodology)</em> 76 (1): 217–42.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-harris2025" class="csl-entry quarto-appendix-citeas">
Harris, Logan. 2025. <span>“Does Debiasing Estimates Lead to Better
Predictions?”</span> <em>Data Diction</em> (blog). December 15, 2025. <a href="https://doi.org/10.59350/h2397-twd61">https://doi.org/10.59350/h2397-twd61</a>.
</div></div></section></div> ]]></description>
  <category>lasso</category>
  <category>penalized regression</category>
  <category>model selection</category>
  <category>interpretability</category>
  <guid>https://www.data-diction.com/posts/bias-benefit/</guid>
  <pubDate>Mon, 15 Dec 2025 00:00:00 GMT</pubDate>
</item>
<item>
  <title>What do we mean by glass-box, exactly?</title>
  <dc:creator>Ryan Peterson</dc:creator>
  <link>https://www.data-diction.com/posts/glassbox-models/</link>
  <description><![CDATA[ 





<!-- Edit the line below after review -->
<div class="callout callout-style-default callout-note callout-empty-content callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Reviewed by Logan Harris on November 21, 2025
</div>
</div>
<div class="callout-body-container callout-body">

</div>
</div>
<section id="introduction" class="level1">
<h1>Introduction</h1>
<section id="what-are-glass-box-models" class="level2">
<h2 class="anchored" data-anchor-id="what-are-glass-box-models">What are glass-box models?</h2>
<p>Glass-box models are transparent, intrinsically interpretable alternatives to their opaque counterparts, black box models. Data scientists typically consider regression-based methods and sparse decision trees as “glass-box”. In this post, I describe the benefits of glass-box methods for modeling data, arguing for the importance of <em>intrinsic interpretability</em>. An intrinsically interpretable model is one whose internal logic is clear enough that a human can see why it makes each prediction, not merely trust a separate explainer.</p>
<p>I hope to convince you that the prevailing definition for glass-box models requires significant refinement in order to be true to its namesake.</p>
<p>Just because a model is a “simple regression” <strong>does not</strong> mean it is interpretable. In fact, model selection methods that attempt to create more interpretable models often invalidate inference by making p-values unjustifiably low, and confidence intervals (CIs) unrealistically narrow.</p>
</section>
<section id="are-glass-box-models-a-novelty-or-a-necessity" class="level2">
<h2 class="anchored" data-anchor-id="are-glass-box-models-a-novelty-or-a-necessity">Are glass-box models a novelty? Or a necessity?</h2>
<p>Consider the useful analogy in the image below, which compares two very different uses of glass as a window into a process. On the left, a penny pressor. I always considered these to be a fun novelty (I still don’t understand how they are legal!). The glass box is part of the appeal - you get to watch a penny turn into a souvenir. Cool!</p>
<p><img src="https://www.data-diction.com/posts/glassbox-models/thumbnail.png" class="img-fluid"></p>
<p>On the right, you see scientists at the Hanford Site in Washington peering through shield windows while working on the plutonium that would eventually be used in the world’s first atomic bomb explosion. One intact version of these shield windows used during the Manhattan project is currently priced at 10 million dollars, although you can purchase a fragment of it for much less <a href="https://shop.minimuseum.com/collections/manhattan-project-shield-window-glass?srsltid=AfmBOorJNhqFW5iN0z9sRdzW7xiFAIDY_s7co9zt41ZPnvypEH0V4imX">shop.minimuseum.com</a>.</p>
<p>The example of the Hanford Site clearly shows how in high-stakes decisions or systems, <strong>opacity is dangerous</strong>. Therefore, sometimes, a glass-box model isn’t a novelty like with the penny pressor - it’s a requirement for oversight and correction.</p>
<p>If the AI doomers are right that AI represent existential threats on par with nuclear war… it is easy to see that glass-box models should be (at least in many cases) classified as a <em>necessity</em>, not a novelty.</p>
</section>
</section>
<section id="why-do-we-build-models-in-the-first-place" class="level1">
<h1>Why do we build models in the first place?</h1>
<p>Let’s start with a quote you have probably heard before from George Box:</p>
<blockquote class="blockquote">
<p>All models are wrong, but some are useful.</p>
</blockquote>
<p>What makes them useful? Good models help us to:</p>
<ol type="1">
<li>make good predictions</li>
<li>understand phenomena.</li>
</ol>
<p>The mix of these two goals are entirely context dependent. In my experience, it is rare for the focus to be entirely on one of these goals.</p>
<section id="a-brief-history-of-model-selection" class="level2">
<h2 class="anchored" data-anchor-id="a-brief-history-of-model-selection">A brief history of model selection</h2>
<section id="hypothesis-testing" class="level3">
<h3 class="anchored" data-anchor-id="hypothesis-testing">Hypothesis testing</h3>
<p>Starting in the 1700s and through the 1980s, hypothesis testing &amp; p-values were the main way to build models. In the typical set up, two competing models are compared (e.g., a null and an alternative), and evidence against the null model is summarized via a p-value.</p>
</section>
<section id="information-criteria" class="level3">
<h3 class="anchored" data-anchor-id="information-criteria">Information criteria</h3>
<p>In the 1970s, Akaike changed the game with his famous information criteria, AIC, and the modeling goal substantively changed from one of <em>testing</em> to one of <em>optimization</em>. Instead of model A vs model B, we now had a set of a bunch of models that we could compare at once to find the best.</p>
</section>
<section id="computationally-intensive-validation" class="level3">
<h3 class="anchored" data-anchor-id="computationally-intensive-validation">Computationally-intensive validation</h3>
<p>More recently, however, “computationally-intensive” validation <em>opened Pandora’s box</em>. In this era, the data scientist is only limited by their imagination. Any model can be compared against any other model and fed through an optimization pipeline that uses computationally-intensive validation to ensure bad models (that is, models that predict poorly), get sifted out and never see the light of day.</p>
<p>Now, so-called black box modeling approaches, where the desire to understand phenomena is completely defenestrated in conquest of making better predictions, are ubiquitous.</p>
<p>I suppose that’s what Pandora deserved for having an opaque box to begin with.</p>
</section>
<section id="now-what" class="level3">
<h3 class="anchored" data-anchor-id="now-what">Now what?</h3>
<p>In light of these advancements, “scientific” model sifting via interdisciplinary expertise remains and is increasingly important. Burnham and Anderson suggest that scientists should build a small set of models to clearly and uniquely represent their hypotheses <em>a priori</em>:</p>
<blockquote class="blockquote">
<p>“…it seems poor practice to consider all possible models; surely some science can be brought to bear on such an unthinking approach (otherwise, the scientist is superfluous)”</p>
</blockquote>
<p>So in the present era (with potentially huge data sets and lots of features), how can we use domain expertise efficiently?</p>
<p>These are important questions I’ve devoted a lot of effort to, but this is not the topic of today’s post.</p>
</section>
</section>
</section>
<section id="on-black-glass-boxes" class="level1">
<h1>On black &amp; glass boxes</h1>
<p>Black box machine learning (ML) methods are not designed with interpretability in mind. Black box models:</p>
<ul>
<li>include random forests, ensembles/super learners, neural networks, XGBoost, etc.</li>
<li>can capture nonlinearities and/or high-order interactions well.</li>
<li>may have predictions that are extrinsically explainable. This differs from intrinsic interpretability, however.</li>
</ul>
<p>The term <strong>glass-box models</strong> arose to contrast black box models with traditional statistical models.</p>
<p>Generally, the following are considered glass-box:</p>
<ul>
<li>Regression (linear, logistic, etc.)</li>
<li>Penalized regression (if high-dimensional)</li>
<li>Interpretable decision trees</li>
</ul>
<p>Regression methods allow us to estimate how an outcome <img src="https://latex.codecogs.com/png.latex?Y"> changes with, or is impacted by, a covariate <img src="https://latex.codecogs.com/png.latex?X">, holding other covariates constant. “<em>Holding confounders constant</em>” is, in my view, a statistical slight-of-hand that is often very poorly understood and mis-applied. At its best though, the language and techniques of regression allow us to get closer to a causal interpretation of <img src="https://latex.codecogs.com/png.latex?X%20%5Crightarrow%20Y">. Modern causal inference methods formalize this and can yield additional insights.</p>
<p>In traditional statistical models, we not only describe these model-based associations, we seek inferences about them (often with p-values and CIs).</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>Confidence intervals and p-values are hard to obtain in black box ML settings.</p>
</div>
</div>
</section>
<section id="not-all-regression-models-are-glass-box." class="level1">
<h1>Not all regression models are glass-box.</h1>
<p>If you disagree, please keep reading.</p>
<section id="a-refined-glass-box-model-definition" class="level2">
<h2 class="anchored" data-anchor-id="a-refined-glass-box-model-definition">A refined glass-box model definition</h2>
<p>Here’s my suggestion for a refined definition of “glass-box model”.</p>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Tip</span>Glass-box model:
</div>
</div>
<div class="callout-body-container callout-body">
<p>A statistical model expressed in terms of a linear combination of a parsimonious set of meaningful parameters with quantified uncertainty. The <em>best</em> glass-box models are transparent, small, quantify parameter uncertainty honestly, and still predict well.</p>
</div>
</div>
<p><strong>Transparency</strong> is reduced as more features are added, especially features that render models difficult to interpret (like interactions), or&nbsp;those involving complex transformations. This definition of transparency resembles that for typical applications of Occam’s Razor in model selection, where the number of parameters in the model translates directly to its simplicity, except that we consider some parameters (coefficients on interactions, for&nbsp;instance) more complex than&nbsp;others (main effects).</p>
<p><strong>Uncertainty quantification</strong> is also a key component of this definition. Inferential tools like p-values and CIs are a cornerstone of science, replicability, and transparency. Models without such measures are limited to description, and may therefore have poor generalizability.</p>
<p><strong>Linearity</strong>: While the definition contains the word “linear,” it’s language is careful to encompass <em>generalized linear models</em> in addition to linear regression.</p>
<p>Under&nbsp;this definition, transparency (conversely, opacity) is a spectrum:</p>
<ul>
<li>The most transparent model is the “null” model</li>
<li>Single-predictor models, often used to describe “unadjusted” relationships, might be labeled as the next most transparent.*</li>
<li>On the other end might be large-language models with billions of interconnected parameters.</li>
</ul>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-4-contents" aria-controls="callout-4" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>*A brief aside.
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-4" class="callout-4-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>My college friend Tom smoked cigarettes, despite being “pre-med”. I asked him about why he smoked given the health consequences. He said <em>“It’s not bad for me until I’ve smoked 20 pack-years worth! That’s what the literature says!”</em></p>
<p>In fact, this 20+ pack years is all over the literature and official screening guidelines. Frank Harrell refers to this as <em>dichotomania</em>. It illustrates the appeal of a glass-box model in the most negative possible light, but an appeal nonetheless.</p>
</div>
</div>
</div>
<p>Let’s go through a simple example to illustrate.</p>
</section>
</section>
<section id="example-hers-dataset" class="level1">
<h1>Example: HERS Dataset</h1>
<section id="the-data" class="level2">
<h2 class="anchored" data-anchor-id="the-data">The data</h2>
<p>The Heart and Estrogen/progestin Replacement Study (HERS) was a clinical trial of hormone therapy for prevention of recurrent heart attacks and death among post-menopausal women with existing coronary heart disease.</p>
<p>This data set contains 27 baseline features for n=2571 patients, and complete 1-year follow-up cholesterol data.</p>
<p>Baseline covariates include age, baseline cholesterol, clinical characteristics, treatment, patient-reported health/activity, diabetes status, blood biomarkers, etc.</p>
<p>Let’s take a fresh look at the HERS data to build a glass-box model for HDL cholesterol 1-year post-baseline. We might want to do this for several reasons, for instance, if we want to plan a trial to consider whether a particular intervention will impact cholesterol. We may want to pre-specify our statistical analysis and specify what model will be used to test our hypothesis. Specifically, the question might be posed - what patient factors should our model for cholesterol include as “precision” variables?</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>This setting is “easy”…
</div>
</div>
<div class="callout-body-container callout-body">
<p>We have <img src="https://latex.codecogs.com/png.latex?n=2571%20%3E%3E%20p=%2032">, a relatively Gaussian response, a small set of interpretable features. However, we’ll see that even in this “easy” setting, building a glass-box model (under the refined definition) is not trivial.</p>
</div>
</div>
</section>
<section id="describing-the-data" class="level2">
<h2 class="anchored" data-anchor-id="describing-the-data">Describing the data</h2>
<p>Here’s our outcome:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(gtsummary)</span>
<span id="cb1-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(kableExtra)</span>
<span id="cb1-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(recipes)</span>
<span id="cb1-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(selectInferToolkit) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#github.com/petersonR/selectInferToolkit</span></span>
<span id="cb1-7"></span>
<span id="cb1-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"hers"</span>)</span>
<span id="cb1-9"></span>
<span id="cb1-10">hers <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb1-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> hdl1)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_histogram</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_minimal</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xlab</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"HDL (1 year ahead)"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/glassbox-models/index_files/figure-html/unnamed-chunk-1-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">hers <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb2-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">where</span>(is.numeric)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb2-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>hdl1) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb2-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tbl_summary</span>() </span></code></pre></div></div>
<div class="cell-output-display">
<div id="qabzdsklja" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#qabzdsklja table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#qabzdsklja thead, #qabzdsklja tbody, #qabzdsklja tfoot, #qabzdsklja tr, #qabzdsklja td, #qabzdsklja th {
  border-style: none;
}

#qabzdsklja p {
  margin: 0;
  padding: 0;
}

#qabzdsklja .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#qabzdsklja .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#qabzdsklja .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#qabzdsklja .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#qabzdsklja .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#qabzdsklja .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#qabzdsklja .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#qabzdsklja .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#qabzdsklja .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#qabzdsklja .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#qabzdsklja .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#qabzdsklja .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#qabzdsklja .gt_spanner_row {
  border-bottom-style: hidden;
}

#qabzdsklja .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#qabzdsklja .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#qabzdsklja .gt_from_md > :first-child {
  margin-top: 0;
}

#qabzdsklja .gt_from_md > :last-child {
  margin-bottom: 0;
}

#qabzdsklja .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#qabzdsklja .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#qabzdsklja .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#qabzdsklja .gt_row_group_first td {
  border-top-width: 2px;
}

#qabzdsklja .gt_row_group_first th {
  border-top-width: 2px;
}

#qabzdsklja .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#qabzdsklja .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#qabzdsklja .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#qabzdsklja .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#qabzdsklja .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#qabzdsklja .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#qabzdsklja .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#qabzdsklja .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#qabzdsklja .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#qabzdsklja .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#qabzdsklja .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#qabzdsklja .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#qabzdsklja .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#qabzdsklja .gt_left {
  text-align: left;
}

#qabzdsklja .gt_center {
  text-align: center;
}

#qabzdsklja .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#qabzdsklja .gt_font_normal {
  font-weight: normal;
}

#qabzdsklja .gt_font_bold {
  font-weight: bold;
}

#qabzdsklja .gt_font_italic {
  font-style: italic;
}

#qabzdsklja .gt_super {
  font-size: 65%;
}

#qabzdsklja .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#qabzdsklja .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#qabzdsklja .gt_indent_1 {
  text-indent: 5px;
}

#qabzdsklja .gt_indent_2 {
  text-indent: 10px;
}

#qabzdsklja .gt_indent_3 {
  text-indent: 15px;
}

#qabzdsklja .gt_indent_4 {
  text-indent: 20px;
}

#qabzdsklja .gt_indent_5 {
  text-indent: 25px;
}

#qabzdsklja .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#qabzdsklja div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings header">
<th id="label" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col"><strong>Characteristic</strong></th>
<th id="stat_0" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>N = 2,571</strong><span class="gt_footnote_marks" style="white-space:nowrap;font-style:italic;font-weight:normal;line-height:0;"><sup>1</sup></span></th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="label">age</td>
<td class="gt_row gt_center" headers="stat_0">67 (62, 72)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">weight</td>
<td class="gt_row gt_center" headers="stat_0">71 (62, 81)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">bmi</td>
<td class="gt_row gt_center" headers="stat_0">27.8 (24.6, 31.7)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">waist</td>
<td class="gt_row gt_center" headers="stat_0">91 (82, 100)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">whr</td>
<td class="gt_row gt_center" headers="stat_0">0.87 (0.81, 0.92)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">glucose</td>
<td class="gt_row gt_center" headers="stat_0">99 (91, 114)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">ldl</td>
<td class="gt_row gt_center" headers="stat_0">141 (119, 166)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">hdl</td>
<td class="gt_row gt_center" headers="stat_0">49 (41, 57)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">tg</td>
<td class="gt_row gt_center" headers="stat_0">157 (116, 208)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">sbp</td>
<td class="gt_row gt_center" headers="stat_0">134 (121, 146)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">dbp</td>
<td class="gt_row gt_center" headers="stat_0">72 (67, 80)</td>
</tr>
</tbody><tfoot>
<tr class="gt_footnotes odd">
<td colspan="2" class="gt_footnote"><span class="gt_footnote_marks" style="white-space:nowrap;font-style:italic;font-weight:normal;line-height:0;"><sup>1</sup></span> Median (Q1, Q3)</td>
</tr>
</tfoot>

</table>

</div>
</div>
</div>
<p>And our predictors:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">hers <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">where</span>(is.factor)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tbl_summary</span>() </span></code></pre></div></div>
<div class="cell-output-display">
<div id="qjlpqudedk" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#qjlpqudedk table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#qjlpqudedk thead, #qjlpqudedk tbody, #qjlpqudedk tfoot, #qjlpqudedk tr, #qjlpqudedk td, #qjlpqudedk th {
  border-style: none;
}

#qjlpqudedk p {
  margin: 0;
  padding: 0;
}

#qjlpqudedk .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#qjlpqudedk .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#qjlpqudedk .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#qjlpqudedk .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#qjlpqudedk .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#qjlpqudedk .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#qjlpqudedk .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#qjlpqudedk .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#qjlpqudedk .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#qjlpqudedk .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#qjlpqudedk .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#qjlpqudedk .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#qjlpqudedk .gt_spanner_row {
  border-bottom-style: hidden;
}

#qjlpqudedk .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#qjlpqudedk .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#qjlpqudedk .gt_from_md > :first-child {
  margin-top: 0;
}

#qjlpqudedk .gt_from_md > :last-child {
  margin-bottom: 0;
}

#qjlpqudedk .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#qjlpqudedk .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#qjlpqudedk .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#qjlpqudedk .gt_row_group_first td {
  border-top-width: 2px;
}

#qjlpqudedk .gt_row_group_first th {
  border-top-width: 2px;
}

#qjlpqudedk .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#qjlpqudedk .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#qjlpqudedk .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#qjlpqudedk .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#qjlpqudedk .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#qjlpqudedk .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#qjlpqudedk .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#qjlpqudedk .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#qjlpqudedk .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#qjlpqudedk .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#qjlpqudedk .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#qjlpqudedk .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#qjlpqudedk .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#qjlpqudedk .gt_left {
  text-align: left;
}

#qjlpqudedk .gt_center {
  text-align: center;
}

#qjlpqudedk .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#qjlpqudedk .gt_font_normal {
  font-weight: normal;
}

#qjlpqudedk .gt_font_bold {
  font-weight: bold;
}

#qjlpqudedk .gt_font_italic {
  font-style: italic;
}

#qjlpqudedk .gt_super {
  font-size: 65%;
}

#qjlpqudedk .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#qjlpqudedk .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#qjlpqudedk .gt_indent_1 {
  text-indent: 5px;
}

#qjlpqudedk .gt_indent_2 {
  text-indent: 10px;
}

#qjlpqudedk .gt_indent_3 {
  text-indent: 15px;
}

#qjlpqudedk .gt_indent_4 {
  text-indent: 20px;
}

#qjlpqudedk .gt_indent_5 {
  text-indent: 25px;
}

#qjlpqudedk .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#qjlpqudedk div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="gt_col_headings header">
<th id="label" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col"><strong>Characteristic</strong></th>
<th id="stat_0" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>N = 2,571</strong><span class="gt_footnote_marks" style="white-space:nowrap;font-style:italic;font-weight:normal;line-height:0;"><sup>1</sup></span></th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="label">ht</td>
<td class="gt_row gt_center" headers="stat_0"><br>
</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;placebo</td>
<td class="gt_row gt_center" headers="stat_0">1,303 (51%)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;hormone therapy</td>
<td class="gt_row gt_center" headers="stat_0">1,268 (49%)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">raceth</td>
<td class="gt_row gt_center" headers="stat_0"><br>
</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;White</td>
<td class="gt_row gt_center" headers="stat_0">2,299 (89%)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;African American</td>
<td class="gt_row gt_center" headers="stat_0">184 (7.2%)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;Other</td>
<td class="gt_row gt_center" headers="stat_0">88 (3.4%)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">smoking</td>
<td class="gt_row gt_center" headers="stat_0">328 (13%)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">drinkany</td>
<td class="gt_row gt_center" headers="stat_0">1,020 (40%)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">exercise</td>
<td class="gt_row gt_center" headers="stat_0">1,012 (39%)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">physact</td>
<td class="gt_row gt_center" headers="stat_0"><br>
</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;much less active</td>
<td class="gt_row gt_center" headers="stat_0">170 (6.6%)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;somewhat less active</td>
<td class="gt_row gt_center" headers="stat_0">459 (18%)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;about as active</td>
<td class="gt_row gt_center" headers="stat_0">854 (33%)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;somewhat more active</td>
<td class="gt_row gt_center" headers="stat_0">794 (31%)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;much more active</td>
<td class="gt_row gt_center" headers="stat_0">294 (11%)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">globrat</td>
<td class="gt_row gt_center" headers="stat_0"><br>
</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;poor</td>
<td class="gt_row gt_center" headers="stat_0">46 (1.8%)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;fair</td>
<td class="gt_row gt_center" headers="stat_0">536 (21%)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;good</td>
<td class="gt_row gt_center" headers="stat_0">1,229 (48%)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;very good</td>
<td class="gt_row gt_center" headers="stat_0">648 (25%)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">&nbsp;&nbsp;&nbsp;&nbsp;excellent</td>
<td class="gt_row gt_center" headers="stat_0">112 (4.4%)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">medcond</td>
<td class="gt_row gt_center" headers="stat_0">947 (37%)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">htnmeds</td>
<td class="gt_row gt_center" headers="stat_0">2,107 (82%)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">statins</td>
<td class="gt_row gt_center" headers="stat_0">951 (37%)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">diabetes</td>
<td class="gt_row gt_center" headers="stat_0">662 (26%)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">dmpills</td>
<td class="gt_row gt_center" headers="stat_0">246 (9.6%)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">insulin</td>
<td class="gt_row gt_center" headers="stat_0">244 (9.5%)</td>
</tr>
</tbody><tfoot>
<tr class="gt_footnotes odd">
<td colspan="2" class="gt_footnote"><span class="gt_footnote_marks" style="white-space:nowrap;font-style:italic;font-weight:normal;line-height:0;"><sup>1</sup></span> n (%)</td>
</tr>
</tfoot>

</table>

</div>
</div>
</div>
<p>Let’s clean it up a bit for modeling. The steps below use the <code>recipes</code> package to standardize the data and create indicators for each of the factor variables.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">hers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> hers <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">physact =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">relevel</span>(physact, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"about as active"</span>),</span>
<span id="cb4-3">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">globrat =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">relevel</span>(globrat, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"good"</span>))</span>
<span id="cb4-4"></span>
<span id="cb4-5">rec_obj <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">recipe</span>(hdl1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> ., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> hers)</span>
<span id="cb4-6"></span>
<span id="cb4-7">rec_obj <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> rec_obj <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">step_dummy</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_nominal</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">keep_original_cols =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">step_center</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_predictors</span>()) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">step_scale</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_numeric</span>()) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">prep</span>()</span>
<span id="cb4-12"></span>
<span id="cb4-13">df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bake</span>(rec_obj, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">new_data =</span> hers)</span></code></pre></div></div>
</div>
</section>
<section id="unadjusted-models" class="level2">
<h2 class="anchored" data-anchor-id="unadjusted-models">Unadjusted models</h2>
<p>We can look at the <em>unadjusted associations</em> via <code>gtsummary</code>’s function below (recall, these are close to the most transparent, interpretable models we have, but they probably don’t predict well).</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tbl_uvregression</span>(df, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> hdl1)</span></code></pre></div></div>
<div class="cell-output-display">
<div id="dsrajkmdmn" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#dsrajkmdmn table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#dsrajkmdmn thead, #dsrajkmdmn tbody, #dsrajkmdmn tfoot, #dsrajkmdmn tr, #dsrajkmdmn td, #dsrajkmdmn th {
  border-style: none;
}

#dsrajkmdmn p {
  margin: 0;
  padding: 0;
}

#dsrajkmdmn .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#dsrajkmdmn .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#dsrajkmdmn .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#dsrajkmdmn .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#dsrajkmdmn .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#dsrajkmdmn .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#dsrajkmdmn .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#dsrajkmdmn .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#dsrajkmdmn .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#dsrajkmdmn .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#dsrajkmdmn .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#dsrajkmdmn .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#dsrajkmdmn .gt_spanner_row {
  border-bottom-style: hidden;
}

#dsrajkmdmn .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#dsrajkmdmn .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#dsrajkmdmn .gt_from_md > :first-child {
  margin-top: 0;
}

#dsrajkmdmn .gt_from_md > :last-child {
  margin-bottom: 0;
}

#dsrajkmdmn .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#dsrajkmdmn .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#dsrajkmdmn .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#dsrajkmdmn .gt_row_group_first td {
  border-top-width: 2px;
}

#dsrajkmdmn .gt_row_group_first th {
  border-top-width: 2px;
}

#dsrajkmdmn .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#dsrajkmdmn .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#dsrajkmdmn .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#dsrajkmdmn .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#dsrajkmdmn .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#dsrajkmdmn .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#dsrajkmdmn .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#dsrajkmdmn .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#dsrajkmdmn .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#dsrajkmdmn .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#dsrajkmdmn .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#dsrajkmdmn .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#dsrajkmdmn .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#dsrajkmdmn .gt_left {
  text-align: left;
}

#dsrajkmdmn .gt_center {
  text-align: center;
}

#dsrajkmdmn .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#dsrajkmdmn .gt_font_normal {
  font-weight: normal;
}

#dsrajkmdmn .gt_font_bold {
  font-weight: bold;
}

#dsrajkmdmn .gt_font_italic {
  font-style: italic;
}

#dsrajkmdmn .gt_super {
  font-size: 65%;
}

#dsrajkmdmn .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#dsrajkmdmn .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#dsrajkmdmn .gt_indent_1 {
  text-indent: 5px;
}

#dsrajkmdmn .gt_indent_2 {
  text-indent: 10px;
}

#dsrajkmdmn .gt_indent_3 {
  text-indent: 15px;
}

#dsrajkmdmn .gt_indent_4 {
  text-indent: 20px;
}

#dsrajkmdmn .gt_indent_5 {
  text-indent: 25px;
}

#dsrajkmdmn .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#dsrajkmdmn div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings header">
<th id="label" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col"><strong>Characteristic</strong></th>
<th id="stat_n" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>N</strong></th>
<th id="estimate" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>Beta</strong></th>
<th id="conf.low" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>95% CI</strong></th>
<th id="p.value" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>p-value</strong></th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="label">age</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.11</td>
<td class="gt_row gt_center" headers="conf.low">0.08, 0.15</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">weight</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.19</td>
<td class="gt_row gt_center" headers="conf.low">-0.23, -0.15</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">bmi</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.19</td>
<td class="gt_row gt_center" headers="conf.low">-0.23, -0.15</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">waist</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.23</td>
<td class="gt_row gt_center" headers="conf.low">-0.26, -0.19</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">whr</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.20</td>
<td class="gt_row gt_center" headers="conf.low">-0.24, -0.16</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">glucose</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.15</td>
<td class="gt_row gt_center" headers="conf.low">-0.19, -0.11</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">ldl</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.05, 0.03</td>
<td class="gt_row gt_center" headers="p.value">0.5</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">hdl</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.73</td>
<td class="gt_row gt_center" headers="conf.low">0.70, 0.76</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">tg</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.36</td>
<td class="gt_row gt_center" headers="conf.low">-0.40, -0.33</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">sbp</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.00</td>
<td class="gt_row gt_center" headers="conf.low">-0.03, 0.04</td>
<td class="gt_row gt_center" headers="p.value">0.8</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">dbp</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.02</td>
<td class="gt_row gt_center" headers="conf.low">-0.01, 0.06</td>
<td class="gt_row gt_center" headers="p.value">0.2</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">ht_hormone.therapy</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.17</td>
<td class="gt_row gt_center" headers="conf.low">0.13, 0.21</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">raceth_African.American</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.04</td>
<td class="gt_row gt_center" headers="conf.low">0.00, 0.08</td>
<td class="gt_row gt_center" headers="p.value">0.061</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">raceth_Other</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.04</td>
<td class="gt_row gt_center" headers="conf.low">-0.08, 0.00</td>
<td class="gt_row gt_center" headers="p.value">0.056</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">smoking_yes</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.04</td>
<td class="gt_row gt_center" headers="conf.low">-0.08, 0.00</td>
<td class="gt_row gt_center" headers="p.value">0.057</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">drinkany_yes</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.14</td>
<td class="gt_row gt_center" headers="conf.low">0.10, 0.18</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">exercise_yes</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.05</td>
<td class="gt_row gt_center" headers="conf.low">0.02, 0.09</td>
<td class="gt_row gt_center" headers="p.value">0.006</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">physact_much.less.active</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.05</td>
<td class="gt_row gt_center" headers="conf.low">-0.09, -0.01</td>
<td class="gt_row gt_center" headers="p.value">0.008</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">physact_somewhat.less.active</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.06</td>
<td class="gt_row gt_center" headers="conf.low">-0.10, -0.02</td>
<td class="gt_row gt_center" headers="p.value">0.004</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">physact_somewhat.more.active</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.07</td>
<td class="gt_row gt_center" headers="conf.low">0.03, 0.11</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">physact_much.more.active</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.02</td>
<td class="gt_row gt_center" headers="conf.low">-0.02, 0.06</td>
<td class="gt_row gt_center" headers="p.value">0.2</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">globrat_poor</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.07, 0.01</td>
<td class="gt_row gt_center" headers="p.value">0.2</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">globrat_fair</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.07, 0.00</td>
<td class="gt_row gt_center" headers="p.value">0.079</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">globrat_very.good</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.03</td>
<td class="gt_row gt_center" headers="conf.low">0.00, 0.07</td>
<td class="gt_row gt_center" headers="p.value">0.087</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">globrat_excellent</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.06</td>
<td class="gt_row gt_center" headers="conf.low">0.02, 0.09</td>
<td class="gt_row gt_center" headers="p.value">0.005</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">medcond_yes</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.05, 0.03</td>
<td class="gt_row gt_center" headers="p.value">0.7</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">htnmeds_yes</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.06</td>
<td class="gt_row gt_center" headers="conf.low">-0.10, -0.02</td>
<td class="gt_row gt_center" headers="p.value">0.004</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">statins_yes</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.02, 0.05</td>
<td class="gt_row gt_center" headers="p.value">0.5</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">diabetes_yes</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.16</td>
<td class="gt_row gt_center" headers="conf.low">-0.20, -0.13</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">dmpills_yes</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.13</td>
<td class="gt_row gt_center" headers="conf.low">-0.17, -0.09</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">insulin_yes</td>
<td class="gt_row gt_center" headers="stat_n">2,571</td>
<td class="gt_row gt_center" headers="estimate">-0.08</td>
<td class="gt_row gt_center" headers="conf.low">-0.12, -0.05</td>
<td class="gt_row gt_center" headers="p.value">&lt;0.001</td>
</tr>
</tbody><tfoot>
<tr class="gt_sourcenotes odd">
<td colspan="5" class="gt_sourcenote">Abbreviation: CI = Confidence Interval</td>
</tr>
</tfoot>

</table>

</div>
</div>
</div>
<p>So… in these unadjusted relationships, nearly everything is significantly associated with HDL 1-year ahead… Are these helpful?</p>
</section>
<section id="a-kitchen-sink-approach" class="level2">
<h2 class="anchored" data-anchor-id="a-kitchen-sink-approach">A <strong>kitchen sink</strong> approach</h2>
<p>In settings like this when <img src="https://latex.codecogs.com/png.latex?n%20%3E%20p">, and especially when <img src="https://latex.codecogs.com/png.latex?n%20%3E%2010p">, quite a few statisticians suggest that a <em>“full model approach”</em> is best for inference. We’ll tackle that debate in another post.</p>
<p>For now, let’s check out where this <em>kitchen sink</em> approach (as in, throw all predictors into the model except the kitchen sink) gets us:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">fit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(hdl1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> df)</span>
<span id="cb6-2"></span>
<span id="cb6-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tbl_regression</span>(fit) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bold_p</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div id="rellxabmup" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#rellxabmup table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#rellxabmup thead, #rellxabmup tbody, #rellxabmup tfoot, #rellxabmup tr, #rellxabmup td, #rellxabmup th {
  border-style: none;
}

#rellxabmup p {
  margin: 0;
  padding: 0;
}

#rellxabmup .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#rellxabmup .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#rellxabmup .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#rellxabmup .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#rellxabmup .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#rellxabmup .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#rellxabmup .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#rellxabmup .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#rellxabmup .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#rellxabmup .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#rellxabmup .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#rellxabmup .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#rellxabmup .gt_spanner_row {
  border-bottom-style: hidden;
}

#rellxabmup .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#rellxabmup .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#rellxabmup .gt_from_md > :first-child {
  margin-top: 0;
}

#rellxabmup .gt_from_md > :last-child {
  margin-bottom: 0;
}

#rellxabmup .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#rellxabmup .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#rellxabmup .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#rellxabmup .gt_row_group_first td {
  border-top-width: 2px;
}

#rellxabmup .gt_row_group_first th {
  border-top-width: 2px;
}

#rellxabmup .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#rellxabmup .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#rellxabmup .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#rellxabmup .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#rellxabmup .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#rellxabmup .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#rellxabmup .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#rellxabmup .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#rellxabmup .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#rellxabmup .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#rellxabmup .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#rellxabmup .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#rellxabmup .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#rellxabmup .gt_left {
  text-align: left;
}

#rellxabmup .gt_center {
  text-align: center;
}

#rellxabmup .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#rellxabmup .gt_font_normal {
  font-weight: normal;
}

#rellxabmup .gt_font_bold {
  font-weight: bold;
}

#rellxabmup .gt_font_italic {
  font-style: italic;
}

#rellxabmup .gt_super {
  font-size: 65%;
}

#rellxabmup .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#rellxabmup .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#rellxabmup .gt_indent_1 {
  text-indent: 5px;
}

#rellxabmup .gt_indent_2 {
  text-indent: 10px;
}

#rellxabmup .gt_indent_3 {
  text-indent: 15px;
}

#rellxabmup .gt_indent_4 {
  text-indent: 20px;
}

#rellxabmup .gt_indent_5 {
  text-indent: 25px;
}

#rellxabmup .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#rellxabmup div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings header">
<th id="label" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col"><strong>Characteristic</strong></th>
<th id="estimate" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>Beta</strong></th>
<th id="conf.low" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>95% CI</strong></th>
<th id="p.value" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>p-value</strong></th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="label">age</td>
<td class="gt_row gt_center" headers="estimate">0.03</td>
<td class="gt_row gt_center" headers="conf.low">0.01, 0.06</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.018</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">weight</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.11, 0.04</td>
<td class="gt_row gt_center" headers="p.value">0.4</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">bmi</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.08, 0.06</td>
<td class="gt_row gt_center" headers="p.value">0.8</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">waist</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.08, 0.10</td>
<td class="gt_row gt_center" headers="p.value">0.9</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">whr</td>
<td class="gt_row gt_center" headers="estimate">-0.02</td>
<td class="gt_row gt_center" headers="conf.low">-0.06, 0.03</td>
<td class="gt_row gt_center" headers="p.value">0.5</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">glucose</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.05, 0.02</td>
<td class="gt_row gt_center" headers="p.value">0.4</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">ldl</td>
<td class="gt_row gt_center" headers="estimate">0.00</td>
<td class="gt_row gt_center" headers="conf.low">-0.03, 0.03</td>
<td class="gt_row gt_center" headers="p.value">&gt;0.9</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">hdl</td>
<td class="gt_row gt_center" headers="estimate">0.69</td>
<td class="gt_row gt_center" headers="conf.low">0.66, 0.72</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">tg</td>
<td class="gt_row gt_center" headers="estimate">-0.05</td>
<td class="gt_row gt_center" headers="conf.low">-0.08, -0.03</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">sbp</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.04, 0.02</td>
<td class="gt_row gt_center" headers="p.value">0.5</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">dbp</td>
<td class="gt_row gt_center" headers="estimate">0.02</td>
<td class="gt_row gt_center" headers="conf.low">-0.01, 0.05</td>
<td class="gt_row gt_center" headers="p.value">0.3</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">ht_hormone.therapy</td>
<td class="gt_row gt_center" headers="estimate">0.19</td>
<td class="gt_row gt_center" headers="conf.low">0.16, 0.21</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">raceth_African.American</td>
<td class="gt_row gt_center" headers="estimate">0.03</td>
<td class="gt_row gt_center" headers="conf.low">0.01, 0.06</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.016</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">raceth_Other</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.05, 0.00</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.038</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">smoking_yes</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.04, 0.02</td>
<td class="gt_row gt_center" headers="p.value">0.5</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">drinkany_yes</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.01, 0.04</td>
<td class="gt_row gt_center" headers="p.value">0.3</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">exercise_yes</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.01, 0.04</td>
<td class="gt_row gt_center" headers="p.value">0.4</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">physact_much.less.active</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.04, 0.01</td>
<td class="gt_row gt_center" headers="p.value">0.3</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">physact_somewhat.less.active</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.02, 0.04</td>
<td class="gt_row gt_center" headers="p.value">0.5</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">physact_somewhat.more.active</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.04, 0.02</td>
<td class="gt_row gt_center" headers="p.value">0.6</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">physact_much.more.active</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.06, 0.00</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.025</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">globrat_poor</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.03, 0.02</td>
<td class="gt_row gt_center" headers="p.value">0.7</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">globrat_fair</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.03, 0.02</td>
<td class="gt_row gt_center" headers="p.value">0.7</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">globrat_very.good</td>
<td class="gt_row gt_center" headers="estimate">0.02</td>
<td class="gt_row gt_center" headers="conf.low">-0.01, 0.04</td>
<td class="gt_row gt_center" headers="p.value">0.3</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">globrat_excellent</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.02, 0.03</td>
<td class="gt_row gt_center" headers="p.value">0.6</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">medcond_yes</td>
<td class="gt_row gt_center" headers="estimate">0.00</td>
<td class="gt_row gt_center" headers="conf.low">-0.02, 0.03</td>
<td class="gt_row gt_center" headers="p.value">0.8</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">htnmeds_yes</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.05, 0.00</td>
<td class="gt_row gt_center" headers="p.value">0.054</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">statins_yes</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.02, 0.04</td>
<td class="gt_row gt_center" headers="p.value">0.5</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">diabetes_yes</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.04, 0.05</td>
<td class="gt_row gt_center" headers="p.value">0.7</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">dmpills_yes</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.06, 0.01</td>
<td class="gt_row gt_center" headers="p.value">0.10</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">insulin_yes</td>
<td class="gt_row gt_center" headers="estimate">-0.02</td>
<td class="gt_row gt_center" headers="conf.low">-0.06, 0.01</td>
<td class="gt_row gt_center" headers="p.value">0.2</td>
</tr>
</tbody><tfoot>
<tr class="gt_sourcenotes odd">
<td colspan="4" class="gt_sourcenote">Abbreviation: CI = Confidence Interval</td>
</tr>
</tfoot>

</table>

</div>
</div>
</div>
<p>OK - we have a good starting point now. A few questions arise.</p>
<blockquote class="blockquote">
<p>Is this a good model?</p>
</blockquote>
<p>The predictive accuracy (<img src="https://latex.codecogs.com/png.latex?R%5E2">) is 0.58. Not bad, but actually not great considering a model containing <em>only</em> baseline HDL achieves an <img src="https://latex.codecogs.com/png.latex?R%5E2"> of 0.53.</p>
<blockquote class="blockquote">
<p>Is this a glass-box model?</p>
</blockquote>
<p>Well, we can learn quickly that baseline HDL, triglycerides, treatment group, race and maybe physical activity are significant predictors of HDL 1-year out.</p>
<p>A subquestion is whether these other “insignificant” variables are not important? The answer is NO. In fact, we are missing something big… More on this soon.</p>
<p>Let’s look back at our new glass-box model definition:</p>
<blockquote class="blockquote">
<p>A statistical model expressed in terms of a linear combination of a parsimonious set of meaningful parameters with quantified uncertainty.</p>
</blockquote>
<p>How does our kitchen sink model stack up?</p>
<ul>
<li>Linear? ✅</li>
<li>Predicts well? 🤷</li>
<li>Parsimonious? ❌</li>
<li>Meaningful parameters? ❌*</li>
<li>Valid uncertainty: ✅</li>
</ul>
<p>So, while this checks some of the boxes, <strong>I would not consider this kitchen sink model a glass-box model</strong>. How can we make this a better glass box?</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-6-contents" aria-controls="callout-6" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>*The trouble with collinearity
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-6" class="callout-6-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>On the face of it, you might think it’s straightforward to interpret each parameter of the kitchen sink model. For instance, holding other variables constant, for every 1 SD increase in age, the expected HDL 1 year after baseline increases by 0.11 SDs. However, for other parameters, it’s not so easy.</p>
</div>
</div>
</div>
<p>BMI (body mass index), WHR (waist to hip ratio), weight, and waist circumference are highly collinear with each other. They all measure adiposity. In the kitchen sink model, it appeared none of these were “significant”. However, the meaning of these parameters in the full model is lacking. “The effect of BMI <em>holding WHR and waist circumference constant</em>” is, in fact, quite ridiculous to conceptualize since these variables relate so highly to each other.</p>
<p>To see this, consider the model below where we remove 3 of the four adiposity variables, so only waist circumference represents adiposity as a “singular flagship”:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">fit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(hdl1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>. <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> bmi <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> whr <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> weight, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> df)</span>
<span id="cb7-2"></span>
<span id="cb7-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tbl_regression</span>(fit) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bold_p</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div id="kqbmgkwwyj" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#kqbmgkwwyj table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#kqbmgkwwyj thead, #kqbmgkwwyj tbody, #kqbmgkwwyj tfoot, #kqbmgkwwyj tr, #kqbmgkwwyj td, #kqbmgkwwyj th {
  border-style: none;
}

#kqbmgkwwyj p {
  margin: 0;
  padding: 0;
}

#kqbmgkwwyj .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#kqbmgkwwyj .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#kqbmgkwwyj .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#kqbmgkwwyj .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#kqbmgkwwyj .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#kqbmgkwwyj .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#kqbmgkwwyj .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#kqbmgkwwyj .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#kqbmgkwwyj .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#kqbmgkwwyj .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#kqbmgkwwyj .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#kqbmgkwwyj .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#kqbmgkwwyj .gt_spanner_row {
  border-bottom-style: hidden;
}

#kqbmgkwwyj .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#kqbmgkwwyj .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#kqbmgkwwyj .gt_from_md > :first-child {
  margin-top: 0;
}

#kqbmgkwwyj .gt_from_md > :last-child {
  margin-bottom: 0;
}

#kqbmgkwwyj .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#kqbmgkwwyj .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#kqbmgkwwyj .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#kqbmgkwwyj .gt_row_group_first td {
  border-top-width: 2px;
}

#kqbmgkwwyj .gt_row_group_first th {
  border-top-width: 2px;
}

#kqbmgkwwyj .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#kqbmgkwwyj .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#kqbmgkwwyj .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#kqbmgkwwyj .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#kqbmgkwwyj .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#kqbmgkwwyj .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#kqbmgkwwyj .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#kqbmgkwwyj .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#kqbmgkwwyj .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#kqbmgkwwyj .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#kqbmgkwwyj .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#kqbmgkwwyj .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#kqbmgkwwyj .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#kqbmgkwwyj .gt_left {
  text-align: left;
}

#kqbmgkwwyj .gt_center {
  text-align: center;
}

#kqbmgkwwyj .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#kqbmgkwwyj .gt_font_normal {
  font-weight: normal;
}

#kqbmgkwwyj .gt_font_bold {
  font-weight: bold;
}

#kqbmgkwwyj .gt_font_italic {
  font-style: italic;
}

#kqbmgkwwyj .gt_super {
  font-size: 65%;
}

#kqbmgkwwyj .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#kqbmgkwwyj .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#kqbmgkwwyj .gt_indent_1 {
  text-indent: 5px;
}

#kqbmgkwwyj .gt_indent_2 {
  text-indent: 10px;
}

#kqbmgkwwyj .gt_indent_3 {
  text-indent: 15px;
}

#kqbmgkwwyj .gt_indent_4 {
  text-indent: 20px;
}

#kqbmgkwwyj .gt_indent_5 {
  text-indent: 25px;
}

#kqbmgkwwyj .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#kqbmgkwwyj div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings header">
<th id="label" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col"><strong>Characteristic</strong></th>
<th id="estimate" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>Beta</strong></th>
<th id="conf.low" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>95% CI</strong></th>
<th id="p.value" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>p-value</strong></th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="label">age</td>
<td class="gt_row gt_center" headers="estimate">0.04</td>
<td class="gt_row gt_center" headers="conf.low">0.01, 0.07</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.009</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">waist</td>
<td class="gt_row gt_center" headers="estimate">-0.04</td>
<td class="gt_row gt_center" headers="conf.low">-0.07, -0.01</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.009</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">glucose</td>
<td class="gt_row gt_center" headers="estimate">-0.02</td>
<td class="gt_row gt_center" headers="conf.low">-0.05, 0.02</td>
<td class="gt_row gt_center" headers="p.value">0.4</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">ldl</td>
<td class="gt_row gt_center" headers="estimate">0.00</td>
<td class="gt_row gt_center" headers="conf.low">-0.03, 0.02</td>
<td class="gt_row gt_center" headers="p.value">&gt;0.9</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">hdl</td>
<td class="gt_row gt_center" headers="estimate">0.69</td>
<td class="gt_row gt_center" headers="conf.low">0.66, 0.72</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">tg</td>
<td class="gt_row gt_center" headers="estimate">-0.05</td>
<td class="gt_row gt_center" headers="conf.low">-0.08, -0.03</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">sbp</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.04, 0.02</td>
<td class="gt_row gt_center" headers="p.value">0.5</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">dbp</td>
<td class="gt_row gt_center" headers="estimate">0.02</td>
<td class="gt_row gt_center" headers="conf.low">-0.01, 0.05</td>
<td class="gt_row gt_center" headers="p.value">0.3</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">ht_hormone.therapy</td>
<td class="gt_row gt_center" headers="estimate">0.19</td>
<td class="gt_row gt_center" headers="conf.low">0.16, 0.21</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">raceth_African.American</td>
<td class="gt_row gt_center" headers="estimate">0.03</td>
<td class="gt_row gt_center" headers="conf.low">0.00, 0.06</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.020</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">raceth_Other</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.05, 0.00</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.042</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">smoking_yes</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.03, 0.02</td>
<td class="gt_row gt_center" headers="p.value">0.6</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">drinkany_yes</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.01, 0.04</td>
<td class="gt_row gt_center" headers="p.value">0.4</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">exercise_yes</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.01, 0.04</td>
<td class="gt_row gt_center" headers="p.value">0.4</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">physact_much.less.active</td>
<td class="gt_row gt_center" headers="estimate">-0.02</td>
<td class="gt_row gt_center" headers="conf.low">-0.04, 0.01</td>
<td class="gt_row gt_center" headers="p.value">0.3</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">physact_somewhat.less.active</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.02, 0.04</td>
<td class="gt_row gt_center" headers="p.value">0.5</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">physact_somewhat.more.active</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.04, 0.02</td>
<td class="gt_row gt_center" headers="p.value">0.6</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">physact_much.more.active</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.06, 0.00</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.026</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">globrat_poor</td>
<td class="gt_row gt_center" headers="estimate">-0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.03, 0.02</td>
<td class="gt_row gt_center" headers="p.value">0.7</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">globrat_fair</td>
<td class="gt_row gt_center" headers="estimate">0.00</td>
<td class="gt_row gt_center" headers="conf.low">-0.03, 0.02</td>
<td class="gt_row gt_center" headers="p.value">0.7</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">globrat_very.good</td>
<td class="gt_row gt_center" headers="estimate">0.02</td>
<td class="gt_row gt_center" headers="conf.low">-0.01, 0.04</td>
<td class="gt_row gt_center" headers="p.value">0.3</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">globrat_excellent</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.02, 0.03</td>
<td class="gt_row gt_center" headers="p.value">0.6</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">medcond_yes</td>
<td class="gt_row gt_center" headers="estimate">0.00</td>
<td class="gt_row gt_center" headers="conf.low">-0.02, 0.03</td>
<td class="gt_row gt_center" headers="p.value">0.8</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">htnmeds_yes</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.05, 0.00</td>
<td class="gt_row gt_center" headers="p.value">0.054</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">statins_yes</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.02, 0.04</td>
<td class="gt_row gt_center" headers="p.value">0.5</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">diabetes_yes</td>
<td class="gt_row gt_center" headers="estimate">0.01</td>
<td class="gt_row gt_center" headers="conf.low">-0.04, 0.05</td>
<td class="gt_row gt_center" headers="p.value">0.7</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">dmpills_yes</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.06, 0.00</td>
<td class="gt_row gt_center" headers="p.value">0.095</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">insulin_yes</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.06, 0.01</td>
<td class="gt_row gt_center" headers="p.value">0.14</td>
</tr>
</tbody><tfoot>
<tr class="gt_sourcenotes odd">
<td colspan="4" class="gt_sourcenote">Abbreviation: CI = Confidence Interval</td>
</tr>
</tfoot>

</table>

</div>
</div>
</div>
<p>We’ve reduced our model dimension and in fact now discover that waist circumference <em>was</em> significant after all! This is the benefit of a small degree of critical thought applied to the kitchen sink model - we’ve gotten one step closer to a good glass-box model.</p>
</section>
<section id="selecting-a-glass-box-model" class="level2">
<h2 class="anchored" data-anchor-id="selecting-a-glass-box-model">Selecting a glass-box model…</h2>
<p>Let’s say we want to get an even better glass-box model. Lots of stuff in our last model was insignificant; do we really need to keep them all? If we use fewer predictors, our model becomes more <em>parsimonious</em>, and thereby becomes more transparent.</p>
<p>Here’s how we could go about this:</p>
<ol type="1">
<li><em>Contextual model refining</em>: This is a great choice and should be the first go to, but it can be hard if there isn’t much context on the features, and in high dimensions. We already did this by looking only at waist as a candidate predictor.</li>
<li>Stepwise selection (select with AIC, BIC, p-values, etc.)</li>
<li>Best-subsets (select with AIC or BIC)</li>
<li>Lasso/penalized regression (Simultaneous selection &amp; estimation with shrinkage toward zero)</li>
<li>Bayesian methods</li>
</ol>
<p>For now, let’s show the results of a model selected via stepwise selection with AIC:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">fit_stepAIC <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> MASS<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stepAIC</span>(fit, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"both"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trace =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tbl_regression</span>(fit_stepAIC) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb8-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bold_p</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div id="lrxtnghzuf" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#lrxtnghzuf table {
  font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#lrxtnghzuf thead, #lrxtnghzuf tbody, #lrxtnghzuf tfoot, #lrxtnghzuf tr, #lrxtnghzuf td, #lrxtnghzuf th {
  border-style: none;
}

#lrxtnghzuf p {
  margin: 0;
  padding: 0;
}

#lrxtnghzuf .gt_table {
  display: table;
  border-collapse: collapse;
  line-height: normal;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#lrxtnghzuf .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#lrxtnghzuf .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#lrxtnghzuf .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 3px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#lrxtnghzuf .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#lrxtnghzuf .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#lrxtnghzuf .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#lrxtnghzuf .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#lrxtnghzuf .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#lrxtnghzuf .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#lrxtnghzuf .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#lrxtnghzuf .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#lrxtnghzuf .gt_spanner_row {
  border-bottom-style: hidden;
}

#lrxtnghzuf .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#lrxtnghzuf .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#lrxtnghzuf .gt_from_md > :first-child {
  margin-top: 0;
}

#lrxtnghzuf .gt_from_md > :last-child {
  margin-bottom: 0;
}

#lrxtnghzuf .gt_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#lrxtnghzuf .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#lrxtnghzuf .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#lrxtnghzuf .gt_row_group_first td {
  border-top-width: 2px;
}

#lrxtnghzuf .gt_row_group_first th {
  border-top-width: 2px;
}

#lrxtnghzuf .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#lrxtnghzuf .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#lrxtnghzuf .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#lrxtnghzuf .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#lrxtnghzuf .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#lrxtnghzuf .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#lrxtnghzuf .gt_last_grand_summary_row_top {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-bottom-color: #D3D3D3;
}

#lrxtnghzuf .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#lrxtnghzuf .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#lrxtnghzuf .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#lrxtnghzuf .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#lrxtnghzuf .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#lrxtnghzuf .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#lrxtnghzuf .gt_left {
  text-align: left;
}

#lrxtnghzuf .gt_center {
  text-align: center;
}

#lrxtnghzuf .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#lrxtnghzuf .gt_font_normal {
  font-weight: normal;
}

#lrxtnghzuf .gt_font_bold {
  font-weight: bold;
}

#lrxtnghzuf .gt_font_italic {
  font-style: italic;
}

#lrxtnghzuf .gt_super {
  font-size: 65%;
}

#lrxtnghzuf .gt_footnote_marks {
  font-size: 75%;
  vertical-align: 0.4em;
  position: initial;
}

#lrxtnghzuf .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#lrxtnghzuf .gt_indent_1 {
  text-indent: 5px;
}

#lrxtnghzuf .gt_indent_2 {
  text-indent: 10px;
}

#lrxtnghzuf .gt_indent_3 {
  text-indent: 15px;
}

#lrxtnghzuf .gt_indent_4 {
  text-indent: 20px;
}

#lrxtnghzuf .gt_indent_5 {
  text-indent: 25px;
}

#lrxtnghzuf .katex-display {
  display: inline-flex !important;
  margin-bottom: 0.75em !important;
}

#lrxtnghzuf div.Reactable > div.rt-table > div.rt-thead > div.rt-tr.rt-tr-group-header > div.rt-th-group:after {
  height: 0px !important;
}
</style>

<table class="gt_table caption-top table table-sm table-striped small" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings header">
<th id="label" class="gt_col_heading gt_columns_bottom_border gt_left" data-quarto-table-cell-role="th" scope="col"><strong>Characteristic</strong></th>
<th id="estimate" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>Beta</strong></th>
<th id="conf.low" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>95% CI</strong></th>
<th id="p.value" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>p-value</strong></th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr class="odd">
<td class="gt_row gt_left" headers="label">age</td>
<td class="gt_row gt_center" headers="estimate">0.03</td>
<td class="gt_row gt_center" headers="conf.low">0.01, 0.06</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.015</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">waist</td>
<td class="gt_row gt_center" headers="estimate">-0.04</td>
<td class="gt_row gt_center" headers="conf.low">-0.06, -0.01</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.008</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">hdl</td>
<td class="gt_row gt_center" headers="estimate">0.69</td>
<td class="gt_row gt_center" headers="conf.low">0.67, 0.72</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">tg</td>
<td class="gt_row gt_center" headers="estimate">-0.06</td>
<td class="gt_row gt_center" headers="conf.low">-0.08, -0.03</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">ht_hormone.therapy</td>
<td class="gt_row gt_center" headers="estimate">0.19</td>
<td class="gt_row gt_center" headers="conf.low">0.16, 0.21</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">&lt;0.001</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">raceth_African.American</td>
<td class="gt_row gt_center" headers="estimate">0.03</td>
<td class="gt_row gt_center" headers="conf.low">0.00, 0.05</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.030</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">raceth_Other</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.05, 0.00</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.032</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">physact_much.less.active</td>
<td class="gt_row gt_center" headers="estimate">-0.02</td>
<td class="gt_row gt_center" headers="conf.low">-0.05, 0.00</td>
<td class="gt_row gt_center" headers="p.value">0.10</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">physact_much.more.active</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.05, 0.00</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.034</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">htnmeds_yes</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.05, 0.00</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.030</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label">dmpills_yes</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.06, -0.01</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.012</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label">insulin_yes</td>
<td class="gt_row gt_center" headers="estimate">-0.03</td>
<td class="gt_row gt_center" headers="conf.low">-0.06, -0.01</td>
<td class="gt_row gt_center" headers="p.value" style="font-weight: bold">0.015</td>
</tr>
</tbody><tfoot>
<tr class="gt_sourcenotes odd">
<td colspan="4" class="gt_sourcenote">Abbreviation: CI = Confidence Interval</td>
</tr>
</tfoot>

</table>

</div>
</div>
</div>
<p>Whoa! Such low p-values!!!</p>
<p>After this selective process, it seems that we can also claim significance for age, waist, medications, and insulin! And it’s a smaller model so it’s a more “glass-box” approach!</p>
<p>Right?</p>
<p>…Right?</p>
<p>……</p>
<p>Well, no. This is a classic example of an <strong>UPSI</strong>.</p>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Tip</span>UPSI
</div>
</div>
<div class="callout-body-container callout-body">
<p>A term I’m coining right now that stands for an “Unadjusted Post Selection Inference”. It also is a statistical “oopsie”.</p>
</div>
</div>
<p>You should know deep down the p-values from the model selected via stepwise AIC are too low. The data set has already been used to select the model, so of course everything that’s selected is more likely to be significant.</p>
<p>We’ll tackle UPSIs in more depth in another post, as well as “better” alternatives like selective inference. In short, inferences post-selection get tricky. Ignoring the variability inherent in the model selection process has been characterized as a common “bad” practice in statistics. UPSIs generally leads to invalid, non-replicable inferences.</p>
<blockquote class="blockquote">
<p>Then… why are UPSIs so common?</p>
</blockquote>
<p>Well, you tell me why anyone would want their p-values to be lower than they should be… 🙄</p>
<p>Eyerolls and publication bias aside, even well-intentioned statisticians find it difficult to properly adjusting these p-values for the selection process. Some say it’s impossible. Again, we’ll save this for another post.</p>
<blockquote class="blockquote">
<p>Is the stepwise AIC model a good glass-box model?</p>
</blockquote>
<ul>
<li>Linear? ✅</li>
<li>Predicts well? ✅</li>
<li>Parsimonious? ✅</li>
<li>Meaningful parameters? ✅ This model has fewer highly collinear features.</li>
<li>Valid uncertainty: ❌Unfortunately, <strong>selecting for a more parsimonious model created dishonestly low p-values</strong>.</li>
</ul>
<p>So while this model may predict better, is more parsimonious, and has more meaningful parameters, it’s still not an optimal glass-box model (under our refined definition).</p>
</section>
</section>
<section id="conclusion" class="level1">
<h1>Conclusion</h1>
<p>Producing high-quality glass-box models is both necessary and difficult.</p>
<section id="key-takeaways" class="level2">
<h2 class="anchored" data-anchor-id="key-takeaways">Key Takeaways</h2>
<ul>
<li>Regression is not necessarily a glass-box approach
<ul>
<li>collinearity can obfuscate meaningful relationships and patterns</li>
<li>p-values can be easily invalidated by selection</li>
</ul></li>
<li>Building an optimal glass-box model is not easy, even for <em>easy</em> scenarios</li>
<li>There is no substitute for domain expertise and critical thinking.</li>
</ul>
</section>
<section id="future-threads-related-questions" class="level2">
<h2 class="anchored" data-anchor-id="future-threads-related-questions">Future Threads / Related Questions</h2>
<ul>
<li>In the present era, how can we efficiently use domain expertise?</li>
<li>Isn’t there a tradeoff between model opacity and its ability to predict well?<br>
</li>
<li>Why are UPSIs a problem?</li>
<li>How can one perform valid post-selection inference?</li>
<li>What’s the difference between intrinsic and extrinsic interpretability?</li>
</ul>
<hr>
</section>
</section>
<section id="appendix" class="level1">
<h1>Appendix</h1>
<details>
<summary>
R Session Info
</summary>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">sessioninfo<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">session_info</span>()</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.5.2 (2025-10-31)
 os       macOS Tahoe 26.4.1
 system   aarch64, darwin20
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Chicago
 date     2026-04-28
 pandoc   3.6.3 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
 quarto   1.8.25 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/quarto

─ Packages ───────────────────────────────────────────────────────────────────
 package            * version     date (UTC) lib source
 adaptMCMC            1.5         2024-01-29 [1] CRAN (R 4.5.0)
 backports            1.5.0       2024-05-23 [1] CRAN (R 4.5.0)
 base64enc            0.1-3       2015-07-28 [1] CRAN (R 4.5.0)
 broom              * 1.0.12      2026-01-27 [1] CRAN (R 4.5.2)
 broom.helpers        1.22.0      2025-09-17 [1] CRAN (R 4.5.0)
 cards                0.7.1       2025-12-02 [1] CRAN (R 4.5.2)
 cardx                0.3.1       2025-12-04 [1] CRAN (R 4.5.2)
 class                7.3-23      2025-01-01 [2] CRAN (R 4.5.2)
 cli                  3.6.5       2025-04-23 [1] CRAN (R 4.5.0)
 coda                 0.19-4.1    2024-01-31 [1] CRAN (R 4.5.0)
 codetools            0.2-20      2024-03-31 [2] CRAN (R 4.5.2)
 commonmark           2.0.0       2025-07-07 [1] CRAN (R 4.5.0)
 data.table           1.18.2.1    2026-01-27 [1] CRAN (R 4.5.2)
 digest               0.6.39      2025-11-19 [1] CRAN (R 4.5.2)
 dplyr              * 1.2.0       2026-02-03 [1] CRAN (R 4.5.2)
 evaluate             1.0.5       2025-08-27 [1] CRAN (R 4.5.0)
 farver               2.1.2       2024-05-13 [1] CRAN (R 4.5.0)
 fastmap              1.2.0       2024-05-15 [1] CRAN (R 4.5.0)
 forcats            * 1.0.1       2025-09-25 [1] CRAN (R 4.5.0)
 foreach              1.5.2       2022-02-02 [1] CRAN (R 4.5.0)
 fs                   1.6.6       2025-04-12 [1] CRAN (R 4.5.0)
 future               1.70.0      2026-03-14 [1] CRAN (R 4.5.2)
 future.apply         1.20.2      2026-02-20 [1] CRAN (R 4.5.2)
 generics             0.1.4       2025-05-09 [1] CRAN (R 4.5.0)
 ggplot2            * 4.0.2       2026-02-03 [1] CRAN (R 4.5.2)
 glmnet               4.1-10      2025-07-17 [1] CRAN (R 4.5.0)
 globals              0.19.1      2026-03-13 [1] CRAN (R 4.5.2)
 glue                 1.8.0       2024-09-30 [1] CRAN (R 4.5.0)
 gower                1.0.2       2024-12-17 [1] CRAN (R 4.5.0)
 gt                   1.1.0       2025-09-23 [1] CRAN (R 4.5.0)
 gtable               0.3.6       2024-10-25 [1] CRAN (R 4.5.0)
 gtsummary          * 2.4.0       2025-08-28 [1] CRAN (R 4.5.0)
 hardhat              1.4.2       2025-08-20 [1] CRAN (R 4.5.0)
 haven                2.5.5       2025-05-30 [1] CRAN (R 4.5.0)
 hms                  1.1.4       2025-10-17 [1] CRAN (R 4.5.0)
 htmltools            0.5.9       2025-12-04 [1] CRAN (R 4.5.2)
 htmlwidgets          1.6.4       2023-12-06 [1] CRAN (R 4.5.0)
 intervals            0.15.5      2024-08-23 [1] CRAN (R 4.5.0)
 ipred                0.9-15      2024-07-18 [1] CRAN (R 4.5.0)
 iterators            1.0.14      2022-02-05 [1] CRAN (R 4.5.0)
 jsonlite             2.0.0       2025-03-27 [1] CRAN (R 4.5.0)
 kableExtra         * 1.4.0       2024-01-24 [1] CRAN (R 4.5.0)
 knitr                1.50        2025-03-16 [1] CRAN (R 4.5.0)
 labeling             0.4.3       2023-08-29 [1] CRAN (R 4.5.0)
 labelled             2.16.0      2025-10-22 [1] CRAN (R 4.5.0)
 lattice              0.22-7      2025-04-02 [2] CRAN (R 4.5.2)
 lava                 1.8.2       2025-10-30 [1] CRAN (R 4.5.0)
 lifecycle            1.0.5       2026-01-08 [1] CRAN (R 4.5.2)
 listenv              0.10.1      2026-03-10 [1] CRAN (R 4.5.2)
 litedown             0.8         2025-11-02 [1] CRAN (R 4.5.0)
 lubridate          * 1.9.5       2026-02-04 [1] CRAN (R 4.5.2)
 magrittr             2.0.5       2026-04-04 [1] CRAN (R 4.5.2)
 markdown             2.0         2025-03-23 [1] CRAN (R 4.5.0)
 MASS                 7.3-65      2025-02-28 [2] CRAN (R 4.5.2)
 Matrix               1.7-4       2025-08-28 [2] CRAN (R 4.5.2)
 ncvreg               3.16.0      2025-10-09 [1] Github (pbreheny/ncvreg@5fecc8c)
 nnet                 7.3-20      2025-01-01 [1] CRAN (R 4.5.0)
 parallelly           1.46.1      2026-01-08 [1] CRAN (R 4.5.2)
 pbapply              1.7-4       2025-07-20 [1] CRAN (R 4.5.0)
 pillar               1.11.1      2025-09-17 [1] CRAN (R 4.5.0)
 pkgconfig            2.0.3       2019-09-22 [1] CRAN (R 4.5.0)
 prodlim              2026.03.11  2026-03-11 [1] CRAN (R 4.5.2)
 purrr              * 1.2.1       2026-01-09 [1] CRAN (R 4.5.2)
 R6                   2.6.1       2025-02-15 [1] CRAN (R 4.5.0)
 RColorBrewer         1.1-3       2022-04-03 [1] CRAN (R 4.5.0)
 Rcpp                 1.1.1       2026-01-10 [1] CRAN (R 4.5.2)
 readr              * 2.1.6       2025-11-14 [1] CRAN (R 4.5.2)
 recipes            * 1.3.1       2025-05-21 [1] CRAN (R 4.5.0)
 rlang                1.1.7       2026-01-09 [1] CRAN (R 4.5.2)
 rmarkdown            2.30        2025-09-28 [1] CRAN (R 4.5.0)
 rpart                4.1.24      2025-01-07 [2] CRAN (R 4.5.2)
 rstudioapi           0.17.1      2024-10-22 [1] CRAN (R 4.5.0)
 S7                   0.2.1       2025-11-14 [1] CRAN (R 4.5.2)
 sass                 0.4.10      2025-04-11 [1] CRAN (R 4.5.0)
 scales               1.4.0       2025-04-24 [1] CRAN (R 4.5.0)
 selectInferToolkit * 0.4.2       2026-03-24 [1] Github (petersonR/selectInferToolkit@61b8347)
 selectiveInference   1.2.5       2019-09-07 [1] CRAN (R 4.5.0)
 sessioninfo          1.2.3       2025-02-05 [1] CRAN (R 4.5.0)
 shape                1.4.6.1     2024-02-23 [1] CRAN (R 4.5.0)
 sparsevctrs          0.3.6       2026-01-27 [1] CRAN (R 4.5.2)
 stringi              1.8.7       2025-03-27 [1] CRAN (R 4.5.0)
 stringr            * 1.6.0       2025-11-04 [1] CRAN (R 4.5.0)
 survival             3.8-3       2024-12-17 [2] CRAN (R 4.5.2)
 svglite              2.2.2       2025-10-21 [1] CRAN (R 4.5.0)
 systemfonts          1.3.1       2025-10-01 [1] CRAN (R 4.5.0)
 textshaping          1.0.4       2025-10-10 [1] CRAN (R 4.5.0)
 tibble             * 3.3.1       2026-01-11 [1] CRAN (R 4.5.2)
 tidyr              * 1.3.2       2025-12-19 [1] CRAN (R 4.5.2)
 tidyselect           1.2.1       2024-03-11 [1] CRAN (R 4.5.0)
 tidyverse          * 2.0.0       2023-02-22 [1] CRAN (R 4.5.0)
 timechange           0.4.0       2026-01-29 [1] CRAN (R 4.5.2)
 timeDate             4052.112    2026-01-28 [1] CRAN (R 4.5.2)
 tzdb                 0.5.0       2025-03-15 [1] CRAN (R 4.5.0)
 vctrs                0.7.2       2026-03-21 [1] CRAN (R 4.5.2)
 viridisLite          0.4.3       2026-02-04 [1] CRAN (R 4.5.2)
 withr                3.0.2       2024-10-28 [1] CRAN (R 4.5.0)
 xfun                 0.54        2025-10-30 [1] CRAN (R 4.5.0)
 xml2                 1.5.1       2025-12-01 [1] CRAN (R 4.5.2)
 yaml                 2.3.11.9000 2025-12-10 [1] Github (r-lib/r-yaml@6dc4582)

 [1] /Users/rpterson/Library/R/arm64/4.5/library
 [2] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
 * ── Packages attached to the search path.

──────────────────────────────────────────────────────────────────────────────</code></pre>
</div>
</div>
</details>


</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-peterson2025" class="csl-entry quarto-appendix-citeas">
Peterson, Ryan. 2025. <span>“What Do We Mean by *Glass-Box*,
Exactly?”</span> <em>Data Diction</em> (blog). November 24, 2025. <a href="https://doi.org/10.59350/9dhes-thd51">https://doi.org/10.59350/9dhes-thd51</a>.
</div></div></section></div> ]]></description>
  <category>model selection</category>
  <category>glass-box modeling</category>
  <category>interpretability</category>
  <category>analysis</category>
  <category>R</category>
  <guid>https://www.data-diction.com/posts/glassbox-models/</guid>
  <pubDate>Mon, 24 Nov 2025 00:00:00 GMT</pubDate>
  <media:content url="https://www.data-diction.com/posts/glassbox-models/thumbnail.png" medium="image" type="image/png" height="69" width="144"/>
</item>
<item>
  <title>Did Denver’s 2022 ‘Zero Fare for Cleaner Air’ campaign actually work?</title>
  <dc:creator>Ryan Peterson</dc:creator>
  <link>https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/</link>
  <description><![CDATA[ 





<p><em>A data-dictated look at whether Denver’s free August public transit policy had its intended effect on air quality.</em></p>
<p><img src="https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/hazy-denver.jpg" class="img-fluid" alt="Hazy Denver"> <small>Image credit: National Renewable Energy Laboratory, Colorado State University</small></p>
<section id="backstory" class="level1">
<h1>Backstory</h1>
<p>Most summers, Coloradoans flock to the majestic Rocky Mountains with their beautiful hikes and various mountain activities. This is the case, at least, unless poor air quality forces them indoors. For me, this occurred on a smoky July day in 2020, when surreal “snowing” ash sprinkling down from nearby wildfires forced us to evacuate the pickleball courts.</p>
<p>Between wildfires and pollution, Denver’s summer air often leaves room for improvement. Sadly, the Rockies don’t seem so enticing when they are obscured behind a polluted haze.</p>
<p>In August 2022, I noticed my RTD bus was more crowded than usual, and I was not asked to scan my bus pass. This is how I learned of Denver’s 2022 “Zero fare for cleaner air” initiative. Throughout the month, my packed bus led me to believe the policy did work to increase ridership.</p>
<p>My story was validated by the RTD; according to the <a href="https://www.rtd-denver.com/sites/default/files/files/2022-11/Zero-Fare%20August%20Impact%20Analysis%20Final%20Report%20-%2011.30.2022.pdf">final RTD report</a>, RTD did indeed see 22% increased ridership during the free-fare month, up 36% from the August prior. This increase led some to conclude that the campaign was a huge success, and also to the expansion of the program in 2023.</p>
<p>But wait… the campaign is called “Zero fare for better air”. So for this to really be a success, the policy change should be measurable in better air quality, not just ridership. To this point, the report concluded that “impacts to air quality are difficult to quantify”. They mention this difficulty is due to no baseline provided. So we’re left wondering – did it work? Did we actually have cleaner air in August of 2022?</p>
<p>Recently, my team investigated how the Covid-19 pandemic affected congestion and air quality in cities across the US (<a href="https://www.mdpi.com/2071-1050/13/13/7275">we found that it did</a>). In this post I use similar outcomes and methods to determine the impact of this policy in Denver.</p>
</section>
<section id="air-quality-data" class="level1">
<h1>Air Quality Data</h1>
<p>There are plenty of important pollutants to worry about in our air, but automobile traffic contributes especially to nitrous oxide (NO2) and ozone (O3). We’ll consider each of these using data from the EPA’s <a href="https://www.epa.gov/aqs">Air Quality System</a>.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>Code and data for this and other blog posts are available <a href="https://github.com/petersonR/datadiction">here</a>.</p>
</div>
</div>
</section>
<section id="no2" class="level1">
<h1>NO2</h1>
<section id="data-visualizations" class="level2">
<h2 class="anchored" data-anchor-id="data-visualizations">Data visualizations</h2>
<p>Here are plots of the historical daily data for NO2 in Denver.</p>
<div class="tabset-margin-container"></div><div class="panel-tabset">
<ul class="nav nav-tabs"><li class="nav-item"><a class="nav-link active" id="tabset-1-1-tab" data-bs-toggle="tab" data-bs-target="#tabset-1-1" aria-controls="tabset-1-1" aria-selected="true" href="">Raw data</a></li><li class="nav-item"><a class="nav-link" id="tabset-1-2-tab" data-bs-toggle="tab" data-bs-target="#tabset-1-2" aria-controls="tabset-1-2" aria-selected="false" href="">Transformed data</a></li><li class="nav-item"><a class="nav-link" id="tabset-1-3-tab" data-bs-toggle="tab" data-bs-target="#tabset-1-3" aria-controls="tabset-1-3" aria-selected="false" href="">2022 only</a></li><li class="nav-item"><a class="nav-link" id="tabset-1-4-tab" data-bs-toggle="tab" data-bs-target="#tabset-1-4" aria-controls="tabset-1-4" aria-selected="false" href="">Monthly</a></li><li class="nav-item"><a class="nav-link" id="tabset-1-5-tab" data-bs-toggle="tab" data-bs-target="#tabset-1-5" aria-controls="tabset-1-5" aria-selected="false" href="">Yearly</a></li></ul>
<div class="tab-content">
<div id="tabset-1-1" class="tab-pane active" aria-labelledby="tabset-1-1-tab">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/index_files/figure-html/unnamed-chunk-1-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</div>
<div id="tabset-1-2" class="tab-pane" aria-labelledby="tabset-1-2-tab">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/index_files/figure-html/unnamed-chunk-2-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</div>
<div id="tabset-1-3" class="tab-pane" aria-labelledby="tabset-1-3-tab">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/index_files/figure-html/unnamed-chunk-3-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</div>
<div id="tabset-1-4" class="tab-pane" aria-labelledby="tabset-1-4-tab">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/index_files/figure-html/unnamed-chunk-4-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</div>
<div id="tabset-1-5" class="tab-pane" aria-labelledby="tabset-1-5-tab">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/index_files/figure-html/unnamed-chunk-5-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="modeling" class="level2">
<h2 class="anchored" data-anchor-id="modeling">Modeling</h2>
<p>We can use this historical data to build a forecast of what August’s NO2 levels would be using <a href="https://arxiv.org/abs/2211.01492">forecasting methodology</a> available in the <a href="https://www.github.com/petersonR/fastTS"><code>fastTS</code> R package</a> that can handle this kind of seasonal data. The series is logged (+10) prior to modeling. We include weekday and month indicator variables and a natural cubic basis spline for time. We computed 30-day-ahead predictions and tested whether these predictions were significantly different than the observed daily values during the zero-fare period. As some months were easier to forecast than others (August was easier to forecast than winter months), we also use heteroskedasticity-corrected standard errors. To evaluate our model, a 10% test set was held out.</p>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/index_files/figure-html/modeling_no2-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>Our model can predict daily NO2 on the log scale to within about 0.175 units, with an out-of-sample <img src="https://latex.codecogs.com/png.latex?R%5E2"> of 0.533 (about 53% of the variation in this outcome can be explained by historical patterns in our model).</p>
<p>The observed daily NO2 values were on average a factor of 0.932 lower, or 6.8% lower, during the zero-fare month compared to their forecasted values (95% CI: 0.921, 0.944). This is strong evidence of a decrease in daily NO2 during the month of August 2022 than would have been expected historically.</p>
</section>
</section>
<section id="ozone" class="level1">
<h1>Ozone</h1>
<section id="data-visualizations-1" class="level2">
<h2 class="anchored" data-anchor-id="data-visualizations-1">Data visualizations</h2>
<p>Here are plots of the historical daily data for ozone in Denver.</p>
<div class="tabset-margin-container"></div><div class="panel-tabset">
<ul class="nav nav-tabs"><li class="nav-item"><a class="nav-link active" id="tabset-2-1-tab" data-bs-toggle="tab" data-bs-target="#tabset-2-1" aria-controls="tabset-2-1" aria-selected="true" href="">Raw data</a></li><li class="nav-item"><a class="nav-link" id="tabset-2-2-tab" data-bs-toggle="tab" data-bs-target="#tabset-2-2" aria-controls="tabset-2-2" aria-selected="false" href="">2022 only</a></li><li class="nav-item"><a class="nav-link" id="tabset-2-3-tab" data-bs-toggle="tab" data-bs-target="#tabset-2-3" aria-controls="tabset-2-3" aria-selected="false" href="">Monthly</a></li><li class="nav-item"><a class="nav-link" id="tabset-2-4-tab" data-bs-toggle="tab" data-bs-target="#tabset-2-4" aria-controls="tabset-2-4" aria-selected="false" href="">Yearly</a></li></ul>
<div class="tab-content">
<div id="tabset-2-1" class="tab-pane active" aria-labelledby="tabset-2-1-tab">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/index_files/figure-html/unnamed-chunk-6-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</div>
<div id="tabset-2-2" class="tab-pane" aria-labelledby="tabset-2-2-tab">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/index_files/figure-html/unnamed-chunk-7-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</div>
<div id="tabset-2-3" class="tab-pane" aria-labelledby="tabset-2-3-tab">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/index_files/figure-html/unnamed-chunk-8-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</div>
<div id="tabset-2-4" class="tab-pane" aria-labelledby="tabset-2-4-tab">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/index_files/figure-html/unnamed-chunk-9-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="modeling-1" class="level2">
<h2 class="anchored" data-anchor-id="modeling-1">Modeling</h2>
<p>Modeling of ozone data proceeded similarly, although no outcome transformation was used.</p>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/index_files/figure-html/modeling_ozn-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>Our model can predict daily ozone to within about 0.005 units, with an out-of-sample <img src="https://latex.codecogs.com/png.latex?R%5E2"> of 0.67 (about 67% of the variation in this outcome can be explained by historical patterns in our model).</p>
<p>The observed daily ozone values were on average -0.001 parts per million lower during the zero-fare month compared to their forecasted values (95% CI: -0.002, -0.001). This doesn’t show evidence of a change in daily ozone during the month of August 2022 in comparison to would have been expected historically.</p>
</section>
</section>
<section id="takeaways" class="level1">
<h1>Takeaways</h1>
<ul>
<li>Daily average NO2 in Denver during the zero fare month was about 7% less than forecasts (p &lt; 0.001)!</li>
<li>No observable change was seen in ozone relative to forecasts.</li>
<li>There is room for more to be done to improve Denver’s air quality.</li>
</ul>
</section>
<section id="limitations" class="level1">
<h1>Limitations</h1>
<p>Ozone and NO2 are affected by many things on a daily basis, which were not controlled for in this analysis. A more effective analysis would control for these things, which might have improved the precision of the model estimates or better account for the possibility of confounding. Both outcomes are also not perfectly measured by the AQS stations scattered about the city of Denver; there’s always the possibility that more accurate or more granular data could better show an effect of the zero-fare policy.</p>
</section>
<section id="sensitivity-of-method" class="level1">
<h1>Sensitivity of method</h1>
<p>If the method we used for determining the effect of intervention were flawed, we might expect to see high rejection rates for any other subset of 31 days. We can check this by reproducing the same method for 31-day chunks of time surrounding August 2022. Below is a table of the estimated effect under the same methodology for every cut point listed, including FDR-adjusted (and nominal) p-values as well as effect size estimates.</p>
<div class="cell">
<div class="cell-output-display">
<table class="lightable-minimal caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;" data-quarto-table-cell-role="th">cut</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">estimate</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">ci_lb</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">ci_ub</th>
<th style="text-align: left;" data-quarto-table-cell-role="th">p.value</th>
<th style="text-align: left;" data-quarto-table-cell-role="th">p.adj</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">2021-01-01</td>
<td style="text-align: right;">1.008</td>
<td style="text-align: right;">0.96</td>
<td style="text-align: right;">1.06</td>
<td style="text-align: left;">0.86</td>
<td style="text-align: left;">0.95</td>
</tr>
<tr class="even">
<td style="text-align: left;">2021-02-01</td>
<td style="text-align: right;">0.989</td>
<td style="text-align: right;">0.95</td>
<td style="text-align: right;">1.03</td>
<td style="text-align: left;">0.80</td>
<td style="text-align: left;">0.95</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2021-03-01</td>
<td style="text-align: right;">1.082</td>
<td style="text-align: right;">1.04</td>
<td style="text-align: right;">1.13</td>
<td style="text-align: left;">0.054</td>
<td style="text-align: left;">0.21</td>
</tr>
<tr class="even">
<td style="text-align: left;">2021-04-01</td>
<td style="text-align: right;">0.997</td>
<td style="text-align: right;">0.97</td>
<td style="text-align: right;">1.02</td>
<td style="text-align: left;">0.90</td>
<td style="text-align: left;">0.95</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2021-05-01</td>
<td style="text-align: right;">1.035</td>
<td style="text-align: right;">1.01</td>
<td style="text-align: right;">1.06</td>
<td style="text-align: left;">0.094</td>
<td style="text-align: left;">0.29</td>
</tr>
<tr class="even">
<td style="text-align: left;">2021-06-01</td>
<td style="text-align: right;">1.030</td>
<td style="text-align: right;">1.01</td>
<td style="text-align: right;">1.05</td>
<td style="text-align: left;">0.17</td>
<td style="text-align: left;">0.37</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2021-07-01</td>
<td style="text-align: right;">0.965</td>
<td style="text-align: right;">0.95</td>
<td style="text-align: right;">0.98</td>
<td style="text-align: left;">0.033</td>
<td style="text-align: left;">0.16</td>
</tr>
<tr class="even">
<td style="text-align: left;">2021-08-01</td>
<td style="text-align: right;">0.977</td>
<td style="text-align: right;">0.96</td>
<td style="text-align: right;">0.99</td>
<td style="text-align: left;">0.18</td>
<td style="text-align: left;">0.37</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2021-09-01</td>
<td style="text-align: right;">0.999</td>
<td style="text-align: right;">0.97</td>
<td style="text-align: right;">1.03</td>
<td style="text-align: left;">0.99</td>
<td style="text-align: left;">0.99</td>
</tr>
<tr class="even">
<td style="text-align: left;">2021-10-01</td>
<td style="text-align: right;">1.004</td>
<td style="text-align: right;">0.97</td>
<td style="text-align: right;">1.04</td>
<td style="text-align: left;">0.91</td>
<td style="text-align: left;">0.95</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2021-11-01</td>
<td style="text-align: right;">0.944</td>
<td style="text-align: right;">0.91</td>
<td style="text-align: right;">0.98</td>
<td style="text-align: left;">0.12</td>
<td style="text-align: left;">0.32</td>
</tr>
<tr class="even">
<td style="text-align: left;">2021-12-01</td>
<td style="text-align: right;">0.977</td>
<td style="text-align: right;">0.94</td>
<td style="text-align: right;">1.02</td>
<td style="text-align: left;">0.58</td>
<td style="text-align: left;">0.89</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2022-01-01</td>
<td style="text-align: right;">1.132</td>
<td style="text-align: right;">1.09</td>
<td style="text-align: right;">1.18</td>
<td style="text-align: left;">0.002</td>
<td style="text-align: left;">0.019</td>
</tr>
<tr class="even">
<td style="text-align: left;">2022-02-01</td>
<td style="text-align: right;">1.024</td>
<td style="text-align: right;">0.98</td>
<td style="text-align: right;">1.07</td>
<td style="text-align: left;">0.59</td>
<td style="text-align: left;">0.89</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2022-03-01</td>
<td style="text-align: right;">0.958</td>
<td style="text-align: right;">0.93</td>
<td style="text-align: right;">0.99</td>
<td style="text-align: left;">0.15</td>
<td style="text-align: left;">0.36</td>
</tr>
<tr class="even">
<td style="text-align: left;">2022-04-01</td>
<td style="text-align: right;">0.920</td>
<td style="text-align: right;">0.89</td>
<td style="text-align: right;">0.95</td>
<td style="text-align: left;">0.009</td>
<td style="text-align: left;">0.068</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2022-05-01</td>
<td style="text-align: right;">0.986</td>
<td style="text-align: right;">0.96</td>
<td style="text-align: right;">1.01</td>
<td style="text-align: left;">0.54</td>
<td style="text-align: left;">0.89</td>
</tr>
<tr class="even">
<td style="text-align: left;">2022-06-01</td>
<td style="text-align: right;">1.019</td>
<td style="text-align: right;">0.99</td>
<td style="text-align: right;">1.04</td>
<td style="text-align: left;">0.44</td>
<td style="text-align: left;">0.81</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2022-07-01</td>
<td style="text-align: right;">0.970</td>
<td style="text-align: right;">0.95</td>
<td style="text-align: right;">0.99</td>
<td style="text-align: left;">0.098</td>
<td style="text-align: left;">0.29</td>
</tr>
<tr class="even">
<td style="text-align: left; font-weight: bold;">2022-08-01</td>
<td style="text-align: right; font-weight: bold;">0.932</td>
<td style="text-align: right; font-weight: bold;">0.92</td>
<td style="text-align: right; font-weight: bold;">0.94</td>
<td style="text-align: left; font-weight: bold;">&lt; 0.001</td>
<td style="text-align: left; font-weight: bold;">&lt; 0.001</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2022-09-01</td>
<td style="text-align: right;">0.989</td>
<td style="text-align: right;">0.97</td>
<td style="text-align: right;">1.01</td>
<td style="text-align: left;">0.66</td>
<td style="text-align: left;">0.93</td>
</tr>
<tr class="even">
<td style="text-align: left;">2022-10-01</td>
<td style="text-align: right;">0.990</td>
<td style="text-align: right;">0.96</td>
<td style="text-align: right;">1.02</td>
<td style="text-align: left;">0.70</td>
<td style="text-align: left;">0.93</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2022-11-01</td>
<td style="text-align: right;">1.008</td>
<td style="text-align: right;">0.97</td>
<td style="text-align: right;">1.05</td>
<td style="text-align: left;">0.85</td>
<td style="text-align: left;">0.95</td>
</tr>
<tr class="even">
<td style="text-align: left;">2022-12-01</td>
<td style="text-align: right;">1.103</td>
<td style="text-align: right;">1.05</td>
<td style="text-align: right;">1.15</td>
<td style="text-align: left;">0.032</td>
<td style="text-align: left;">0.16</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section id="on-the-horizon" class="level1">
<h1>On the horizon</h1>
<p>Come August 2023, Denver will roll out the program again and I will revisit this analysis to see whether zero fares produce <em>observably</em> cleaner air throughout the month. Please check out <a href="https://zerofareaugust.coloradotransit.com/">their website</a> to sign up and participate.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>Again, code and data for this and other posts are available <a href="https://github.com/petersonR/datadiction">here</a>. This post was updated on 2/15/2024 to point to the <code>fastTS</code> R package, which is an updated version of <code>srlTS</code>, and again on 6/11/2024 based on a bug fix in <code>fastTS</code> 1.0.0, which strengthened the observed effect of NO2.</p>
</div>
</div>
<hr>
</section>
<section id="appendix" class="level1">
<h1>Appendix</h1>
<details>
<summary>
R Session Info
</summary>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">sessioninfo<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">session_info</span>()</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.5.1 (2025-06-13)
 os       macOS Sequoia 15.7.1
 system   aarch64, darwin20
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Chicago
 date     2025-11-20
 pandoc   3.6.3 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
 quarto   1.7.32 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/quarto

─ Packages ───────────────────────────────────────────────────────────────────
 package      * version date (UTC) lib source
 bit            4.6.0   2025-03-06 [1] CRAN (R 4.5.0)
 bit64          4.6.0-1 2025-01-16 [1] CRAN (R 4.5.0)
 cli            3.6.5   2025-04-23 [1] CRAN (R 4.5.0)
 crayon         1.5.3   2024-06-20 [1] CRAN (R 4.5.0)
 digest         0.6.37  2024-08-19 [1] CRAN (R 4.5.0)
 dplyr        * 1.1.4   2023-11-17 [1] CRAN (R 4.5.0)
 evaluate       1.0.5   2025-08-27 [1] CRAN (R 4.5.0)
 farver         2.1.2   2024-05-13 [1] CRAN (R 4.5.0)
 fastmap        1.2.0   2024-05-15 [1] CRAN (R 4.5.0)
 forcats      * 1.0.1   2025-09-25 [1] CRAN (R 4.5.0)
 generics       0.1.4   2025-05-09 [1] CRAN (R 4.5.0)
 ggplot2      * 4.0.0   2025-09-11 [1] CRAN (R 4.5.0)
 glue           1.8.0   2024-09-30 [1] CRAN (R 4.5.0)
 gtable         0.3.6   2024-10-25 [1] CRAN (R 4.5.0)
 here           1.0.2   2025-09-15 [1] CRAN (R 4.5.0)
 hms            1.1.4   2025-10-17 [1] CRAN (R 4.5.0)
 htmltools      0.5.8.1 2024-04-04 [1] CRAN (R 4.5.0)
 htmlwidgets    1.6.4   2023-12-06 [1] CRAN (R 4.5.0)
 jsonlite       2.0.0   2025-03-27 [1] CRAN (R 4.5.0)
 knitr          1.50    2025-03-16 [1] CRAN (R 4.5.0)
 lifecycle      1.0.4   2023-11-07 [1] CRAN (R 4.5.0)
 lubridate    * 1.9.4   2024-12-08 [1] CRAN (R 4.5.0)
 magrittr       2.0.4   2025-09-12 [1] CRAN (R 4.5.0)
 pillar         1.11.1  2025-09-17 [1] CRAN (R 4.5.0)
 pkgconfig      2.0.3   2019-09-22 [1] CRAN (R 4.5.0)
 png          * 0.1-8   2022-11-29 [1] CRAN (R 4.5.0)
 prettyunits    1.2.0   2023-09-24 [1] CRAN (R 4.5.0)
 progress     * 1.2.3   2023-12-06 [1] CRAN (R 4.5.0)
 purrr        * 1.2.0   2025-11-04 [1] CRAN (R 4.5.0)
 R6             2.6.1   2025-02-15 [1] CRAN (R 4.5.0)
 RColorBrewer   1.1-3   2022-04-03 [1] CRAN (R 4.5.0)
 readr        * 2.1.5   2024-01-10 [1] CRAN (R 4.5.0)
 rlang          1.1.6   2025-04-11 [1] CRAN (R 4.5.0)
 rmarkdown      2.30    2025-09-28 [1] CRAN (R 4.5.0)
 rprojroot      2.1.1   2025-08-26 [1] CRAN (R 4.5.0)
 rstudioapi     0.17.1  2024-10-22 [1] CRAN (R 4.5.0)
 S7             0.2.0   2024-11-07 [1] CRAN (R 4.5.0)
 scales         1.4.0   2025-04-24 [1] CRAN (R 4.5.0)
 sessioninfo    1.2.3   2025-02-05 [1] CRAN (R 4.5.0)
 stringi        1.8.7   2025-03-27 [1] CRAN (R 4.5.0)
 stringr      * 1.6.0   2025-11-04 [1] CRAN (R 4.5.0)
 tibble       * 3.3.0   2025-06-08 [1] CRAN (R 4.5.0)
 tidyr        * 1.3.1   2024-01-24 [1] CRAN (R 4.5.0)
 tidyselect     1.2.1   2024-03-11 [1] CRAN (R 4.5.0)
 tidyverse    * 2.0.0   2023-02-22 [1] CRAN (R 4.5.0)
 timechange     0.3.0   2024-01-18 [1] CRAN (R 4.5.0)
 tzdb           0.5.0   2025-03-15 [1] CRAN (R 4.5.0)
 vctrs          0.6.5   2023-12-01 [1] CRAN (R 4.5.0)
 vroom          1.6.6   2025-09-19 [1] CRAN (R 4.5.0)
 withr          3.0.2   2024-10-28 [1] CRAN (R 4.5.0)
 xfun           0.54    2025-10-30 [1] CRAN (R 4.5.0)
 yaml           2.3.10  2024-07-26 [1] CRAN (R 4.5.0)

 [1] /Users/rpterson/Library/R/arm64/4.5/library
 [2] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
 * ── Packages attached to the search path.

──────────────────────────────────────────────────────────────────────────────</code></pre>
</div>
</div>
</details>


</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-peterson2023" class="csl-entry quarto-appendix-citeas">
Peterson, Ryan. 2023. <span>“Did Denver’s 2022 <span>‘Zero Fare for
Cleaner Air’</span> Campaign Actually Work?”</span> <em>Data
Diction</em> (blog). July 21, 2023. <a href="https://doi.org/10.59350/sktbs-b7v46">https://doi.org/10.59350/sktbs-b7v46</a>.
</div></div></section></div> ]]></description>
  <category>news</category>
  <category>analysis</category>
  <category>environment</category>
  <category>time series</category>
  <category>R</category>
  <guid>https://www.data-diction.com/posts/did-denver-zero-fare-policy-work/</guid>
  <pubDate>Fri, 21 Jul 2023 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Detecting interactions in R</title>
  <dc:creator>Ryan Peterson</dc:creator>
  <link>https://www.data-diction.com/posts/selecting-interactions/</link>
  <description><![CDATA[ 





<p><em>But what about interactions; are any of those significant?</em></p>
<p>I have heard some variant of this question from clinicians and researchers from many fields of science. While usually asked in earnest, <strong>this question is a dangerous one</strong>; the sheer number of interactions can greatly inflate the number of false discoveries in the interactions, resulting in difficult-to-interpret models with many unnecessary interactions. Still, there are times when these expeditions are necessary and fruitful. Thankfully, useful tools are now available to help with the process. This article discusses two regularization-based approaches: Group-Lasso INTERaction-NET (glinternet) and the Sparsity-Ranked Lasso (SRL). The glinternet method implements a hierarchy-preserving selection and estimation procedure, while the SRL is a hierarchy-preferring regularization method which operates under ranked sparsity principles (in short, ranked sparsity methods ensure interactions are treated more skeptically than main effects <em>a priori</em>).</p>
<section id="useful-package-1-ranked-sparsity-methods-via-sparser" class="level2">
<h2 class="anchored" data-anchor-id="useful-package-1-ranked-sparsity-methods-via-sparser">Useful package #1: ranked sparsity methods via <strong>sparseR</strong></h2>
<p>The <strong>sparseR</strong> package has been designed to make dealing with interactions and polynomials much more analyst-friendly. Building on the <strong>recipes</strong> package, <strong>sparseR</strong> has many built-in tools to facilitate the prepping of a model matrix with interactions and polynomials; these features are presented in the package website located at https://petersonr.github.io/sparseR/. The package is available on CRAN and can be installed and loaded with the code below</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">install.packages</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sparseR"</span>)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(sparseR)</span></code></pre></div></div>
</div>
<p>The simplest way to implement the SRL in <strong>sparseR</strong> is via a single call to the <code>sparseR()</code> function, here demonstrated with Fisher’s <code>iris</code> data set. 10-fold cross-validation is used by default, so we set the <code>seed = 1</code> here for reproducibility.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(iris)</span>
<span id="cb2-2">srl <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sparseR</span>(Sepal.Width <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> ., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> iris, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb2-3">srl</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>
Model summary @ min CV:
-----------------------------------------------------
  lasso-penalized linear regression with n=150, p=21
  (At lambda=0.0024):
    Nonzero coefficients: 7
    Cross-validation error (deviance): 0.07
    R-squared: 0.63
    Signal-to-noise ratio: 1.71
    Scale estimate (sigma): 0.264

  SR information:
             Vartype Total Selected Saturation Penalty
         Main effect     6        2      0.333    2.45
 Order 1 interaction    12        3      0.250    3.46
  Order 2 polynomial     3        2      0.667    3.00


Model summary @ CV1se:
-----------------------------------------------------
  lasso-penalized linear regression with n=150, p=21
  (At lambda=0.0070):
    Nonzero coefficients: 6
    Cross-validation error (deviance): 0.08
    R-squared: 0.58
    Signal-to-noise ratio: 1.39
    Scale estimate (sigma): 0.281

  SR information:
             Vartype Total Selected Saturation Penalty
         Main effect     6        2      0.333    2.45
 Order 1 interaction    12        2      0.167    3.46
  Order 2 polynomial     3        2      0.667    3.00</code></pre>
</div>
</div>
<p>The <code>summary</code> function produces additional details:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(srl, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">at =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cv1se"</span>)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>lasso-penalized linear regression with n=150, p=21
At lambda=0.0070:
-------------------------------------------------
  Nonzero coefficients         :   6
  Expected nonzero coefficients:   0.44
  Average mfdr (6 features)    :   0.074

                               Estimate      z       mfdr Selected
Species_setosa                  0.82889 18.596    &lt; 1e-04        *
Sepal.Length_poly_1             0.19494  9.638    &lt; 1e-04        *
Petal.Width_poly_2              0.10142  4.698 0.00016138        *
Petal.Width:Species_versicolor  0.29190  3.335 0.02568952        *
Sepal.Length:Species_setosa     0.06826  2.769 0.14613161        *
Sepal.Length_poly_2            -0.03215 -2.694 0.27005358        *</code></pre>
</div>
</div>
<p>We see that two models are displayed by default corresponding to two “smart” choices for the penalization parameter <img src="https://latex.codecogs.com/png.latex?%5Clambda">. The first model printed refers to the model where <img src="https://latex.codecogs.com/png.latex?%5Clambda"> is set to minimize the cross-validated error, while the second one refers to a model where <img src="https://latex.codecogs.com/png.latex?%5Clambda"> is set to a value such that the model is as sparse as possible while still being within 1 SD of the minimum cross-validated error. Visualizations are also available via sparseR that can help visualize both the solution path and the resulting model (interactions can be very challenging to interpret without a good figure!)</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(srl)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/selecting-interactions/index_files/figure-html/unnamed-chunk-5-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/selecting-interactions/index_files/figure-html/unnamed-chunk-5-2.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">effect_plot</span>(srl, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Petal.Width"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Species"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">at =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cvmin"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/selecting-interactions/index_files/figure-html/unnamed-chunk-5-3.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">effect_plot</span>(srl, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Petal.Width"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Species"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">at =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cv1se"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/selecting-interactions/index_files/figure-html/unnamed-chunk-5-4.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>Note that while ranked sparsity principles were motivated by the estimation of the lasso (Peterson &amp; Cavanaugh 2022), they can also be implemented with MCP, SCAD, or elastic net and for binary, normal, and survival data. Finally, sparseR includes some functionality to perform forward-stepwise selection using a sparsity-ranked modification of BIC, as well as post-selection inferential techniques using sample splitting and bootstrapping.</p>
</section>
<section id="useful-package-2-hierarchy-preserving-regularization-via-glinternet" class="level2">
<h2 class="anchored" data-anchor-id="useful-package-2-hierarchy-preserving-regularization-via-glinternet">Useful package #2: hierarchy-preserving regularization via <strong>glinternet</strong></h2>
<p>Some argue that when it comes to interactions, hierarchy is very important (i.e., an interaction shouldn’t be included in a model without its constituent main effects). While ranked sparsity methods do <em>prefer</em> hierarchical models, they can often still produce non-hierarchical ones. The <strong>glinternet</strong> package and the function of the same name uses regularization for model selection under hierarchy constraint, such that all candidate models are hierarchical. <strong>Glinternet</strong> can handle both continuous and categorical predictors, but requires pre-specification of a numeric model matrix. It can be performed as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># install.packages("glinternet")</span></span>
<span id="cb9-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(glinternet)</span>
<span id="cb9-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(dplyr)</span>
<span id="cb9-4"></span>
<span id="cb9-5">X <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> iris <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb9-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>Sepal.Width) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb9-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Species =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(Species) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb9-8"></span>
<span id="cb9-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">321</span>)</span>
<span id="cb9-10">cv_fit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">glinternet.cv</span>(X, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Y =</span> iris<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Sepal.Width, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numLevels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span></code></pre></div></div>
</div>
<p>The <code>cv_fit</code> object contains necessary information from the cross-validation procedure and the fits themselves stored in a series of lists. A more in-depth tutorial to extract coefficients (and facilitate a model interpretation) using the <strong>glinternet</strong> package can be found at https://strakaps.github.io/post/glinternet/. Importantly, both the <strong>glinternet</strong> and <strong>sparseR</strong> methods have associated predict methods which can yield predictions on new (or the training) data, shown below. For comparison, we also fit a “main effects only” model with <strong>sparseR</strong> by setting <code>k = 0</code>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">me <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sparseR</span>(Sepal.Width <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> ., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> iris, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">333</span>)</span>
<span id="cb10-2">p_me <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">predict</span>(me)</span>
<span id="cb10-3">p_srl <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">predict</span>(srl)</span>
<span id="cb10-4">p_gln <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.vector</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">predict</span>(cv_fit, X))</span></code></pre></div></div>
</div>
<p>With a little help from the <strong>yardstick</strong> package’s <code>metrics()</code> function, we can compare the accuracy of each model’s predictions using root-mean-squared error (RMSE), R-squared (RSQ), and mean absolute error (MAE); see table below. Evidently, <strong>glinternet</strong> and SRL are similar in terms of their predictive performance. However, both outperform the main effects model considerably, suggesting interactions among other variables do have signal worth capturing when predicting <code>Sepal.Width</code>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1">gln_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(p_gln, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> iris<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Sepal.Width) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-2">  yardstick<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">metrics</span>(y, p_gln) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"glinternet"</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> .estimate) </span>
<span id="cb11-4">srl_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(p_srl, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> iris<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Sepal.Width) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-5">  yardstick<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">metrics</span>(y, p_srl) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SRL"</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> .estimate) </span>
<span id="cb11-7">me_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(p_me, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> iris<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Sepal.Width) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-8">  yardstick<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">metrics</span>(y, p_me) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Main effects only"</span><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> .estimate) </span>
<span id="cb11-10"></span>
<span id="cb11-11">results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> gln_res <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_cols</span>(srl_res[,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_cols</span>(me_res[,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Metric"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> .metric) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Metric =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(Metric)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb11-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>.estimator)</span></code></pre></div></div>
</div>
<div class="cell">
<div class="cell-output-display">
<table class="table table-striped caption-top table-sm small">
<thead>
<tr class="header">
<th style="text-align: left;" data-quarto-table-cell-role="th">Metric</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">glinternet</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">SRL</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Main effects only</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">RMSE</td>
<td style="text-align: right;">0.24</td>
<td style="text-align: right;">0.25</td>
<td style="text-align: right;">0.25</td>
</tr>
<tr class="even">
<td style="text-align: left;">RSQ</td>
<td style="text-align: right;">0.69</td>
<td style="text-align: right;">0.68</td>
<td style="text-align: right;">0.66</td>
</tr>
<tr class="odd">
<td style="text-align: left;">MAE</td>
<td style="text-align: right;">0.19</td>
<td style="text-align: right;">0.19</td>
<td style="text-align: right;">0.19</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section id="other-packages-worth-mentioning-ncvreg-hiernet-visreg-sjplot" class="level2">
<h2 class="anchored" data-anchor-id="other-packages-worth-mentioning-ncvreg-hiernet-visreg-sjplot">Other packages worth mentioning: ncvreg, hierNet, visreg, sjPlot</h2>
<p>The SRL and other sparsity-ranked regularization methods implemented in <strong>sparseR</strong> would not be possible without the <strong>ncvreg</strong> package, which performs the heavy-lifting in terms of model fitting, optimization, and cross-validation. The <strong>hierNet</strong> package is another hierarchy-enforcing procedure that may yield better models than <strong>glinternet</strong>, however the latter is more computationally efficient especially for situations with a medium-to-large number of covariates. Finally, when interactions or polynomials are included in models, figures are truly worth a thousand words, and packages such as <strong>visreg</strong> and <strong>sjPlot</strong> have great functionality for plotting the effects of interactions.</p>
</section>
<section id="references" class="level2">
<h2 class="anchored" data-anchor-id="references">References</h2>
<ul>
<li>Bien J and Tibshirani R (2020). hierNet: A Lasso for Hierarchical Interactions. R package version 1.9. https://CRAN.R-project.org/package=hierNet</li>
<li>Breheny P and Burchett W (2017). Visualization of Regression Models Using visreg. The R Journal, 9: 56-71.</li>
<li>Breheny P and Huang J (2011). Coordinate descent algorithms for nonconvex penalized regression, with applications to biological feature selection. Ann. Appl. Statist., 5: 232-253.</li>
<li>Kuhn M and Vaughan D (2021). yardstick: Tidy Characterizations of Model Performance. R package version 0.0.8. https://CRAN.R-project.org/package=yardstick</li>
<li>Lim M and Hastie T (2020). glinternet: Learning Interactions via Hierarchical Group-Lasso Regularization. R package version 1.0.11. https://CRAN.R-project.org/package=glinternet</li>
<li>Lüdecke D (2021). sjPlot: Data Visualization for Statistics in Social Science. R package version 2.8.8. https://CRAN.R-project.org/package=sjPlot</li>
<li>Peterson R (2021). sparseR: Variable selection under ranked sparsity principles for interactions and polynomials. https://github.com/petersonR/sparseR/.</li>
<li>Peterson, R, Cavanaugh, J. Ranked sparsity: a cogent regularization framework for selecting and estimating feature interactions and polynomials. AStA Adv Stat Anal 106, 427–454 (2022). https://doi.org/10.1007/s10182-021-00431-7</li>
</ul>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>This post was originally published in the <a href="https://www.biometricsociety.org/publications/biometric-bulletin">Biometric Bulletin (2021) Volume 38 Issue 3</a>.</p>
</div>
</div>
<hr>
</section>
<section id="appendix" class="level1">
<h1>Appendix</h1>
<details>
<summary>
R Session Info
</summary>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">sessioninfo<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">session_info</span>()</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.5.2 (2025-10-31)
 os       macOS Tahoe 26.4.1
 system   aarch64, darwin20
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Chicago
 date     2026-04-28
 pandoc   3.6.3 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
 quarto   1.8.25 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/quarto

─ Packages ───────────────────────────────────────────────────────────────────
 package      * version     date (UTC) lib source
 class          7.3-23      2025-01-01 [2] CRAN (R 4.5.2)
 cli            3.6.5       2025-04-23 [1] CRAN (R 4.5.0)
 codetools      0.2-20      2024-03-31 [2] CRAN (R 4.5.2)
 data.table     1.18.2.1    2026-01-27 [1] CRAN (R 4.5.2)
 digest         0.6.39      2025-11-19 [1] CRAN (R 4.5.2)
 dplyr        * 1.2.0       2026-02-03 [1] CRAN (R 4.5.2)
 evaluate       1.0.5       2025-08-27 [1] CRAN (R 4.5.0)
 farver         2.1.2       2024-05-13 [1] CRAN (R 4.5.0)
 fastmap        1.2.0       2024-05-15 [1] CRAN (R 4.5.0)
 future         1.70.0      2026-03-14 [1] CRAN (R 4.5.2)
 future.apply   1.20.2      2026-02-20 [1] CRAN (R 4.5.2)
 generics       0.1.4       2025-05-09 [1] CRAN (R 4.5.0)
 glinternet   * 1.0.12      2021-09-03 [1] CRAN (R 4.5.0)
 globals        0.19.1      2026-03-13 [1] CRAN (R 4.5.2)
 glue           1.8.0       2024-09-30 [1] CRAN (R 4.5.0)
 gower          1.0.2       2024-12-17 [1] CRAN (R 4.5.0)
 hardhat        1.4.2       2025-08-20 [1] CRAN (R 4.5.0)
 htmltools      0.5.9       2025-12-04 [1] CRAN (R 4.5.2)
 htmlwidgets    1.6.4       2023-12-06 [1] CRAN (R 4.5.0)
 ipred          0.9-15      2024-07-18 [1] CRAN (R 4.5.0)
 jsonlite       2.0.0       2025-03-27 [1] CRAN (R 4.5.0)
 kableExtra   * 1.4.0       2024-01-24 [1] CRAN (R 4.5.0)
 knitr          1.50        2025-03-16 [1] CRAN (R 4.5.0)
 lattice        0.22-7      2025-04-02 [2] CRAN (R 4.5.2)
 lava           1.8.2       2025-10-30 [1] CRAN (R 4.5.0)
 lifecycle      1.0.5       2026-01-08 [1] CRAN (R 4.5.2)
 listenv        0.10.1      2026-03-10 [1] CRAN (R 4.5.2)
 lubridate      1.9.5       2026-02-04 [1] CRAN (R 4.5.2)
 magrittr       2.0.5       2026-04-04 [1] CRAN (R 4.5.2)
 MASS           7.3-65      2025-02-28 [2] CRAN (R 4.5.2)
 Matrix         1.7-4       2025-08-28 [2] CRAN (R 4.5.2)
 ncvreg         3.16.0      2025-10-09 [1] Github (pbreheny/ncvreg@5fecc8c)
 nnet           7.3-20      2025-01-01 [1] CRAN (R 4.5.0)
 parallelly     1.46.1      2026-01-08 [1] CRAN (R 4.5.2)
 pillar         1.11.1      2025-09-17 [1] CRAN (R 4.5.0)
 pkgconfig      2.0.3       2019-09-22 [1] CRAN (R 4.5.0)
 prodlim        2026.03.11  2026-03-11 [1] CRAN (R 4.5.2)
 purrr          1.2.1       2026-01-09 [1] CRAN (R 4.5.2)
 R6             2.6.1       2025-02-15 [1] CRAN (R 4.5.0)
 RColorBrewer   1.1-3       2022-04-03 [1] CRAN (R 4.5.0)
 Rcpp           1.1.1       2026-01-10 [1] CRAN (R 4.5.2)
 recipes        1.3.1       2025-05-21 [1] CRAN (R 4.5.0)
 rlang          1.1.7       2026-01-09 [1] CRAN (R 4.5.2)
 rmarkdown      2.30        2025-09-28 [1] CRAN (R 4.5.0)
 rpart          4.1.24      2025-01-07 [2] CRAN (R 4.5.2)
 rstudioapi     0.17.1      2024-10-22 [1] CRAN (R 4.5.0)
 scales         1.4.0       2025-04-24 [1] CRAN (R 4.5.0)
 sessioninfo    1.2.3       2025-02-05 [1] CRAN (R 4.5.0)
 sparseR      * 0.3.2       2025-04-14 [1] CRAN (R 4.5.0)
 sparsevctrs    0.3.6       2026-01-27 [1] CRAN (R 4.5.2)
 stringi        1.8.7       2025-03-27 [1] CRAN (R 4.5.0)
 stringr        1.6.0       2025-11-04 [1] CRAN (R 4.5.0)
 survival       3.8-3       2024-12-17 [2] CRAN (R 4.5.2)
 svglite        2.2.2       2025-10-21 [1] CRAN (R 4.5.0)
 systemfonts    1.3.1       2025-10-01 [1] CRAN (R 4.5.0)
 textshaping    1.0.4       2025-10-10 [1] CRAN (R 4.5.0)
 tibble         3.3.1       2026-01-11 [1] CRAN (R 4.5.2)
 tidyr          1.3.2       2025-12-19 [1] CRAN (R 4.5.2)
 tidyselect     1.2.1       2024-03-11 [1] CRAN (R 4.5.0)
 timechange     0.4.0       2026-01-29 [1] CRAN (R 4.5.2)
 timeDate       4052.112    2026-01-28 [1] CRAN (R 4.5.2)
 vctrs          0.7.2       2026-03-21 [1] CRAN (R 4.5.2)
 viridisLite    0.4.3       2026-02-04 [1] CRAN (R 4.5.2)
 withr          3.0.2       2024-10-28 [1] CRAN (R 4.5.0)
 xfun           0.54        2025-10-30 [1] CRAN (R 4.5.0)
 xml2           1.5.1       2025-12-01 [1] CRAN (R 4.5.2)
 yaml           2.3.11.9000 2025-12-10 [1] Github (r-lib/r-yaml@6dc4582)
 yardstick      1.3.2       2025-01-22 [1] CRAN (R 4.5.0)

 [1] /Users/rpterson/Library/R/arm64/4.5/library
 [2] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
 * ── Packages attached to the search path.

──────────────────────────────────────────────────────────────────────────────</code></pre>
</div>
</div>
</details>


</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-peterson2023" class="csl-entry quarto-appendix-citeas">
Peterson, Ryan. 2023. <span>“Detecting Interactions in R.”</span>
<em>Data Diction</em> (blog). June 20, 2023. <a href="https://doi.org/10.59350/f11j1-neh89">https://doi.org/10.59350/f11j1-neh89</a>.
</div></div></section></div> ]]></description>
  <category>statistical computation</category>
  <category>analysis</category>
  <category>interpretability</category>
  <category>model selection</category>
  <category>R</category>
  <guid>https://www.data-diction.com/posts/selecting-interactions/</guid>
  <pubDate>Tue, 20 Jun 2023 00:00:00 GMT</pubDate>
  <media:content url="https://www.data-diction.com/posts/selecting-interactions/thumbnail.png" medium="image" type="image/png" height="103" width="144"/>
</item>
<item>
  <title>Welcome to Data Diction</title>
  <dc:creator>Ryan Peterson</dc:creator>
  <link>https://www.data-diction.com/posts/welcome/</link>
  <description><![CDATA[ 





<!-- Edit the line below after review -->
<div class="callout callout-style-default callout-note callout-empty-content callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Reviewed by Logan Harris on 2025-11-12
</div>
</div>
<div class="callout-body-container callout-body">

</div>
</div>
<hr>
<p><img src="https://www.data-diction.com/posts/welcome/logo2.png" class="img-fluid"></p>
<section id="data-diction" class="level1">
<h1>Data Diction</h1>
<ul>
<li><p><strong>Data</strong>: things known or assumed as facts, making the basis of reasoning or calculation</p></li>
<li><p><strong>Diction</strong>: 1) the choice and use of words and phrases in speech or writing. 2) the choice of words especially with regard to correctness, clearness, or effectiveness.</p></li>
</ul>
<p>In addition to the play on “Data Addiction”, Data Diction is also a play on the very commonly used term of “Data dictionary”, a term with which statistical practitioners should be familiar.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>Data Diction started in 2022 as a blog. Posts were infrequent. The Glassbox Modeling Working Group (see below) now aims to improve post frequency and participation by multiple authors and reviewers who will collaborate and disseminate quick tutorials, opinion pieces, etc.</p>
</div>
</div>
</section>
<section id="logo" class="level1">
<h1>Logo</h1>
<p>Ryan Peterson created the logo using ozone data from Denver that he compiled for the <a href="../../posts/did-denver-zero-fare-policy-work/index.html">post about Denver’s 2021 “Zero Fare for Cleaner Air”</a>.</p>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span>
<span id="cb1-2"></span>
<span id="cb1-3">df_ozone <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_csv</span>(here<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">here</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"posts/did-denver-zero-fare-policy-work/ozone_data-91-23.csv"</span>))</span>
<span id="cb1-4"></span>
<span id="cb1-5">df_ozone<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>daily_avg <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> imputeTS<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_kalman</span>(df_ozone<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>daily_avg)</span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df_ozone, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x=</span>date_local, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y=</span>daily_avg)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb1-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">85</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb1-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lightblue4"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">level =</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">999999</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb1-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ylab</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Daily average Ozone in Denver"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb1-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xlab</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://www.data-diction.com/posts/welcome/index_files/figure-html/unnamed-chunk-1-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="glassbox-modeling-working-group" class="level1">
<h1>Glassbox Modeling Working Group</h1>
<section id="overviewpurpose" class="level2">
<h2 class="anchored" data-anchor-id="overviewpurpose">Overview/Purpose</h2>
<p>This working group is a collaboration centered on broadly improving statistical practice regarding model selection, model transparency, and post-selection inference.</p>
<p><strong>Mission</strong>: Advance the science and practice of transparent, interpretable, and reproducible modeling through collaborative research, education, and dissemination.</p>
<p><strong>Vision</strong>: Establish a cross-institutional hub that develops novel glass box methods and disseminates best practices for glass box methods in accessible formats such as software, tutorials, papers, and concise blog posts.</p>
</section>
<section id="values" class="level2">
<h2 class="anchored" data-anchor-id="values">Values</h2>
<ol type="1">
<li>Team science: We approach each issue from multiple perspectives, including
<ul>
<li><strong>Applied statisticians</strong> wishing to perform best practices</li>
<li><strong>Domain experts</strong> seeking to understand glass-box approaches and issues with bad statistical practices</li>
<li><strong>Students</strong> aspiring to understand and apply sound statistical reasoning</li>
<li><strong>AI systems</strong> (e.g.&nbsp;LLMs like ChatGPT) ingesting our human-authored material</li>
</ul></li>
<li>Reproducibility: We ensure all analyses can be independently verified and replicated</li>
<li>Transparency: We work to produce interpretable methods with explicit assumptions</li>
<li>Humility: We recognize the limits of our current knowledge and remain open to revision and critique</li>
<li>Human-first
<ul>
<li>We pledge to only use AI as a supporting writing tool</li>
<li>We encourage dialogue through comment sections</li>
</ul></li>
<li>Accessibility
<ul>
<li>We release content in multiple formats to reach diverse audiences</li>
</ul></li>
<li>Occam’s Razor: We will produce material that is as simple as possible, but no simpler</li>
</ol>


</section>
</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-peterson2022" class="csl-entry quarto-appendix-citeas">
Peterson, Ryan. 2022. <span>“Welcome to Data Diction.”</span> <em>Data
Diction</em> (blog). June 1, 2022. <a href="https://doi.org/10.59350/xmjb6-qna36">https://doi.org/10.59350/xmjb6-qna36</a>.
</div></div></section></div> ]]></description>
  <category>glass-box modeling</category>
  <category>model selection</category>
  <guid>https://www.data-diction.com/posts/welcome/</guid>
  <pubDate>Wed, 01 Jun 2022 00:00:00 GMT</pubDate>
  <media:content url="https://www.data-diction.com/posts/welcome/logo2.png" medium="image" type="image/png" height="149" width="144"/>
</item>
</channel>
</rss>
