<?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>Less Likely Blog</title>
<link>https://lesslikely.com/blog.html</link>
<atom:link href="https://lesslikely.com/blog.xml" rel="self" type="application/rss+xml"/>
<description>Latest posts on statistical science and methodology</description>
<image>
<url>https://lesslikely.com/images/HomeLogo.gif</url>
<title>Less Likely Blog</title>
<link>https://lesslikely.com/blog.html</link>
</image>
<generator>quarto-1.8.27</generator>
<lastBuildDate>Tue, 06 Jan 2026 05:00:00 GMT</lastBuildDate>
<item>
  <title>A Critical Look At The REDUCE-IT Trial</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/medicine/reduce-it.html</link>
  <description><![CDATA[ 




<p>It’s finally here. The results of the REDUCE-IT trial were presented today at the American Heart Association conference and the paper is also up on <a href="https://www.nejm.org/doi/full/10.1056/NEJMoa1812792"><em>The New England Journal of Medicine</em>.</a> I’ve been excited to see the results of this trial ever since the announcement in September (which I wrote about <a href="../../medicine/vascepa-reduce-it">here</a>) so let’s get right into it.</p>
<p>I’ll just copy and paste what I’d written before in September regarding the inclusion/criteria and statistical analyses so that I can get right into the results. You can skip this section and go to the results if you’d like or you can reread it to get reacquainted with the trial design.</p>
<hr>
<p><strong>September 2018:</strong></p>
<p>That’s why I thought it would be a good time to review the preregistration protocol of the REDUCE-IT trial on <a href="https://clinicaltrials.gov/ct2/show/study/NCT01492361">ClinicalTrials.gov</a> and a <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5396348/">detailed paper</a> that describes the rationale behind the study design. Let’s get into it.</p>
<p>So very clearly, the authors state what the study here is doing,</p>
<blockquote class="blockquote">
<p>“AMR101 (icosapent ethyl [ethyl-EPA]) is a highly purified ethyl ester of eicosapentaenoic acid (EPA) being developed by Amarin Pharma Inc.&nbsp;for the treatment of hypertriglyceridemia.</p>
</blockquote>
<p>The purpose of this study is to evaluate whether this drug, combined with a statin therapy, will be superior to the statin therapy alone, when used as a prevention in reducing long-term cardiovascular events in high-risk patients with mixed dyslipidemia.”</p>
<p>Comparing statins + highly purified, high doses of EPA to statins alone. Why are they using such high doses? The authors explain here,</p>
<blockquote class="blockquote">
<p>“It is worth noting that the promising results from JELIS occurred with a high‐purity EPA preparation dosed at 1.8 g/d in a Japanese population, for whom the baseline EPA levels are higher than in western populations due to greater dietary intake of marine omega‐3 fatty acids.</p>
<p>Icosapent ethyl 12‐week dosing at 4 g/d in a high‐risk population similar to that within the Reduction of Cardiovascular Events with Icosapent Ethyl–Intervention Trial (REDUCE‐IT) who had persistent elevations of TG after treatment with statins resulted in significant reductions in TG and atherogenic lipoproteins, as well as comparable plasma EPA levels as the 1.8 g/d dosing group in JELIS._</p>
<p>T herefore, a dose of 4 g/d was selected as the dose for further study. In this context, REDUCE‐IT was designed to determine if treatment with icosapent ethyl 4 g/d vs placebo would reduce ischemic events in patients at increased CV risk already being treated with statins.”</p>
</blockquote>
<p>Also “worth noting” that the <a href="https://www.ncbi.nlm.nih.gov/pubmed/17398308">JELIS trial</a> was included in both meta-analyses mentioned at the beginning of the blog post.</p>
<p>The primary outcome is a composite endpoint that consists of CV death, MI, stroke, coronary revascularization, and hospitalization for unstable angina. Whenever I hear composite endpoint, I often become skeptical because I’ve seen composite endpoints abused or misused in several ways, resulting in very misleading results. There was a very nice post on composite endpoints by Hilda Bastian <a href="https://statistically-funny.blogspot.com/2015/02/lets-play-outcome-mash-up-clinical.html">here</a>.</p>
<p>The study (REDUCE-IT) enrolled 8,000 participants and began in 2011 and ended in 2018.</p>
<p>Why 8,000 participants?</p>
<p>The authors explain here,</p>
<blockquote class="blockquote">
<p>“The sample‐size calculation was based on a hazard ratio assumption of 0.85. Therefore, 1612 events would be required to have approximately 90% power with a 1‐sided α‐level of 2.5% and with 2 interim analyses. This results in a total target sample size of 7990 patients.</p>
<p>Approximately 70% of randomized patients were to be in CV risk stratum 1 (established CVD) and approximately 30% of randomized patients were to be in CV risk stratum 2 (high‐risk primary prevention defined by diabetes mellitus and other risk factors). Randomization was stratified by CV risk strata, ezetimibe use, and by geographical region.”</p>
</blockquote>
<p>The design power calculations seem like they were based on very optimistic expectations of the effect size, and apparently, justifiably so!</p>
<p>A bit unfortunate that there is no mention anywhere of what statistical analyses they planned on doing exactly.</p>
<p>In order for participants to be eligible for the trial:</p>
<ul>
<li><p>they had to be over the age of 45</p></li>
<li><p>have high levels of triglycerides (hypertriglyceridemia) originally &gt;150 mg/dL but then changed to &gt;200 mg/dL via a protocol change</p></li>
<li><p>been on statins for at least a month</p></li>
<li><p>they had to have a history of heart disease</p></li>
<li><p>There’s a bunch of exclusion criteria too that I don’t really feel the need to go over, but you can see them listed out on the registry.</p></li>
</ul>
<p>Also, worth mentioning of course that the trial is funded by Amarin, AKA the manufacturer of Vascepa.</p>
<hr>
<section id="november-2018" class="level2">
<h2 class="anchored" data-anchor-id="november-2018"><strong>November 2018</strong></h2>
</section>
<section id="results" class="level2">
<h2 class="anchored" data-anchor-id="results">Results:</h2>
<p>Quick Characteristics of Participants</p>
<ul>
<li><p>Median Age: 64 years old</p></li>
<li><p>Females: 28.8%</p></li>
<li><p>Median LDL: 75.0 mg/dL</p></li>
<li><p>Median HDL: 40 mg/dL</p></li>
<li><p>Median Triglycerides: 216.0 mg/dL</p></li>
</ul>
</section>
<section id="changes-in-lipids" class="level2">
<h2 class="anchored" data-anchor-id="changes-in-lipids">Changes in Lipids:</h2>
<p>The median change in <strong>triglycerides</strong> from baseline to 1 year was a <strong>decrease of 18.3%</strong> (−39.0 mg per deciliter) for the Vascepa group and an <strong>increase of 2.2%</strong> (4.5 mg per deciliter).</p>
<p>A <strong>between-group</strong> comparison of change scores shows that the median group reduction was <strong>19.7% higher</strong> (44.5 mg/dL, p&lt;0.001) in the Vascepa group than it was in the placebo group.</p>
<p><strong>LDL</strong> increased in both groups from baseline to year 1, however, the Vascepa group had a <strong>6.6%</strong> (5.0 mg per deciliter, p&lt;0.001) <strong>lower increase</strong> than the placebo group.</p>
</section>
<section id="differences-in-clinical-endpoints-what-we-really-care-about" class="level2">
<h2 class="anchored" data-anchor-id="differences-in-clinical-endpoints-what-we-really-care-about">Differences in Clinical Endpoints (what we <em>really</em> care about):</h2>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700143/Site/PrimaryEndpoint.png" alt="Survival curve showing the primary endpoints for the REDUCE-IT trial"></p>
<hr>
<p>A total of 1606 participants experienced one of the primary end-point events.</p>
<p>Approximately <strong>17.2%</strong> of the participants in the Vascepa group experienced a primary end-point whereas <strong>22.2%</strong> of the participants in the control group experienced a primary end-point.</p>
<p>Thus, the <strong>between-group difference</strong> is <strong>4.8%</strong> (95% CI, 3.1 to 6.5). The results are: (hazard ratio, 0.75; 95% confidence interval [CI], 0.68 to 0.83; P&lt;0.001).</p>
<p>So very clearly we can see that there was a statistically significant difference and the confidence interval leans towards an effect.</p>
<blockquote class="blockquote">
<p>The authors calculated a number needed to treat for this between-group difference (NNT: 21 (95% CI, 15 to 33)) and its confidence interval which slightly makes me laugh. I’ve <a href="../../statistics/problems-with-nnt">written about the NNT</a> before and its flaws and the reality is that it doesn’t do what it claims to do and has very bizarre statistical properties.</p>
</blockquote>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700144/Site/SecondaryEndpoint.png" alt="Survival curve showing the secondary endpoints for the REDUCE-IT trial"></p>
<hr>
<p>With regards to secondary efficacy end-point events, 11.2% of the participants in the Vascepa group experienced an event compared to 14.8% of the participants in the placebo group.</p>
<p>The absolute between-group difference was <strong>3.6%</strong> (95% CI, 2.1 to 5.0).</p>
<p>Again, very clearly a difference.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700119/Site/Figure-2.jpg" alt="A forest plot showing prespecified subgroup analyses for the REDUCE-IT trial"></p>
<hr>
<p>They also ran prespecified subgroup analyses to see whether the effects would be influenced. What was interesting to me was when they claimed this:</p>
<blockquote class="blockquote">
<p>“Baseline triglyceride levels (≥150 vs.&nbsp;&lt;150 mg per deciliter or ≥200 or &lt;200 mg per deciliter) had no influence on the primary or key secondary efficacy end points (Figures 2 and Figure 3).”</p>
</blockquote>
<p>This is interesting to me because there were so few patients that were enrolled into the trial with triglyceride levels that were beneath 150 or hovering around 150. This is very clearly reflected by the wide confidence intervals in that subgroup which can be seen in the figure above. This is because the protocol changed early in the trial to restrict participant inclusion to people with higher triglycerides,</p>
<blockquote class="blockquote">
<p>“The first protocol amendment in May 2013 changed the lower limit of the acceptable triglyceride level from 150 mg per deciliter to 200 mg per deciliter (2.26 mmol per liter), with no allowance for variability.”</p>
</blockquote>
<p>Whereas originally, it was,</p>
<blockquote class="blockquote">
<p>“Eligible patients had a fasting triglyceride level of 150 to 499 mg per deciliter (1.69 to 5.63 mmol per liter)… because of the intraindividual variability of triglyceride levels, the initial protocol allowed for a 10% lower triglyceride level from the target lower limit, which permitted patients to be enrolled if they had a triglyceride level of at least 135 mg per deciliter (1.52 mmol per liter).”</p>
</blockquote>
<p>Seems like more data is needed to say anything about this with confidence.</p>
</section>
<section id="hierarchical-tests" class="level2">
<h2 class="anchored" data-anchor-id="hierarchical-tests">Hierarchical Tests</h2>
<p>For their prespecified hierarchical tests, this is what they found:</p>
<ul>
<li><p>Rates of Composite Ischemic Endpoints + Rates of Cardiovascular Death: (Vascepa: 4.3% vs.&nbsp;Placebo: 5.2%; hazard ratio, 0.80; 95% CI, 0.66 to 0.98; P=0.03)</p></li>
<li><p>Rate of Death From Any Cause: Vascepa: 6.7% vs.&nbsp;Placebo: 7.6% (hazard ratio, 0.87; 95% CI, 0.74 to 1.02).</p></li>
<li><p>Doesn’t seem to be statistically significant, but the coverage of the intervals leans towards an effect.</p></li>
<li><p>Rates of Adjudicated Sudden Cardiac Death: Vascepa: 1.5% vs.&nbsp;Placebo: 2.1% (hazard ratio, 0.69; 95% CI, 0.50 to 0.96)</p></li>
<li><p>Rates of Cardiac Arrest: Vascepa: 0.5% vs.&nbsp;Placebo: 1.0% (hazard ratio, 0.52; 95% CI, 0.31 to 0.86)</p></li>
</ul>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700125/Site/Hierarchial-Testing.jpg" alt="A forest plot showing hierarchial analyses for the REDUCE-IT trial"></p>
<hr>
<p>So most seem to favor the Vascepa group.</p>
</section>
<section id="safety" class="level2">
<h2 class="anchored" data-anchor-id="safety">Safety</h2>
<p>What about its safety? A look at the <a href="https://www.nejm.org/doi/suppl/10.1056/NEJMoa1812792/suppl_file/nejmoa1812792_appendix.pdf">supplementary appendix</a> gives us this:</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700144/Site/Serious-Adverse-Events.png" alt="Table showing the number of serious adverse events per group in the REDUCE-IT trial"></p>
<hr>
<p>The analyses failed to show any statistically significant differences for serious treatment-emergent adverse events.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700108/Site/Adverse-Events.png" alt="Table showing the number of adverse events per group in the REDUCE-IT trial"></p>
<hr>
<p>However, among other treatment-emergent adverse events, Peripheral Edema, Constipation, and Atrial Fibrillation were significantly more frequent in the Vascepa group.</p>
<p>There you have it.</p>
</section>
<section id="conclusions" class="level2">
<h2 class="anchored" data-anchor-id="conclusions">Conclusions</h2>
<p>The results of this large trial clearly suggest that Vascepa had a notable effect on triglycerides and clinical endpoints. These data along with the results from the <a href="https://www.ncbi.nlm.nih.gov/pubmed/17398308">JELIS</a> trial should be considered as supporting evidence for the hypothesis that high doses of EPA (not your over-the-counter normal fish oil) may have an effect on cardiovascular disease events (even though JELIS was an open-label study).</p>
<p>Hopefully, future meta-analyses make high doses of EPA an inclusion criteria to avoid pooling null results from trials using smaller dosages, where it may be more difficult to see an effect. Currently, there are a few other ongoing trials that are also using high doses of EPA:</p>
<blockquote class="blockquote">
<p>“Ongoing trials of moderate-to-high doses of pure EPA ethyl ester will provide further information on the effects of these agents. These trials include the Randomized Trial for Evaluation in Secondary Prevention Efficacy of Combination Therapy–Statin and EPA (RESPECT-EPA; UMIN Clinical Trials Registry number, <a href="https://upload.umin.ac.jp/cgi-open-bin/ctr_e/ctr_view.cgi?recptno=R000014051">UMIN000012069</a>), a secondary prevention outcomes trial involving statin-treated patients in Japan, and the Effect of Vascepa on Improving Coronary Atherosclerosis in People with High Triglycerides Taking Statin Therapy (EVAPORATE; ClinicalTrials.gov number, <a href="https://clinicaltrials.gov/ct2/show/NCT02926027">NCT02926027)</a>, which is examining changes in coronary plaque over 9 to 18 months.”</p>
</blockquote>
<p>Even though REDUCE-IT has been successful, it is only <em>one</em> trial, and it’s always worth remembering what the history of fish is, even though this trial didn’t look at fish oil but rather a pharmaceutical formulation of EPA.</p>
<hr>
</section>
<section id="a-brief-timeline-of-fish-oil" class="level2">
<h2 class="anchored" data-anchor-id="a-brief-timeline-of-fish-oil">A Brief Timeline of Fish Oil</h2>
<ul>
<li><p><strong>1970s</strong> | <a href="https://www.ncbi.nlm.nih.gov/pubmed/7435433">A group of explorers</a> noticed that people who consumed fish also had lower incidences of heart disease.</p></li>
<li><p><strong>1980s</strong>-<strong>1990s</strong> | <a href="https://www.ncbi.nlm.nih.gov/pubmed/3990713?access_num=3990713&amp;link_type=MED&amp;dopt=Abstract">Early</a> observational <a href="https://www.ncbi.nlm.nih.gov/pubmed/9091800?access_num=9091800&amp;link_type=MED&amp;dopt=Abstract">studies</a> also saw a connection between fish consumption and heart disease risk</p></li>
<li><p><strong>1990s</strong> | <a href="https://www.ncbi.nlm.nih.gov/pubmed/9310278?access_num=9310278&amp;link_type=MED&amp;dopt=Abstract">A few</a> randomized trials <a href="https://www.ncbi.nlm.nih.gov/pubmed/10465168?access_num=10465168&amp;link_type=MED&amp;dopt=Abstract">were</a> conducted to see the effects of fish oil supplementation and CVD outcomes</p></li>
<li><p><strong>2002</strong> | The American Heart Association put out <a href="http://circ.ahajournals.org/content/106/21/2747?ijkey=a0bd0a11dda35f2aa109c24a01266ea89e3d0121&amp;keytype2=tf_ipsecsha">a statement</a> suggesting that fish oil supplementation was beneficial for fatal outcomes</p></li>
<li><p><strong>2002</strong> - <strong>2016</strong> | Several <a href="http://www.thelancet.com/article/S0140-6736(07)60527-3/abstract">randomized trials</a> and <a href="https://www.ncbi.nlm.nih.gov/pubmed/15495044">systematic reviews</a> found inconsistent evidence for the effects of fish oil supplementation and CVD outcomes</p></li>
<li><p><strong>2016</strong> | The American Heart Association creates <a href="http://circ.ahajournals.org/content/135/15/e867.long">a scientific advisory group</a> to look at all the evidence and concludes that despite the controversy, there was a small benefit from fish oil and it could be worth it for people who had a history of CVD events.</p></li>
<li><p><strong>2018</strong> | <a href="https://www.ncbi.nlm.nih.gov/pubmed/29387889">Large meta-analysis</a> published in <em><strong>JAMA</strong></em> with 77,000 + participants found no benefit from fish oil supplementation on real clinical endpoints.</p></li>
<li><p><strong>Mid - 2018</strong> | Most <a href="https://www.cochranelibrary.com/cdsr/doi/10.1002/14651858.CD003177.pub3/full">comprehensive meta-analysis</a> and systematic review with 112,000 participants by Cochrane finds very small benefits to several CVD-related outcomes.</p></li>
<li><p><strong>Late 2018</strong> | <a href="https://investor.amarincorp.com/news-releases/news-release-details/reduce-ittm-cardiovascular-outcomes-study-vascepar-icosapent">Announcement</a> by the manufacturer of <a href="https://www.vascepa.com/">Vascepa</a> exclaiming that high-doses of fish oil in the REDUCE-IT trial had a large effect (25% reduction) on CVD outcomes.</p></li>
</ul>
<hr>
<blockquote class="blockquote">
<p>Edit: It came to my attention after writing this blog post that the placebo formulation included large amounts of mineral oil. Thus, the control arm was taking mineral oil + statins, while the intervention group was taking Vascepa + statins. This is problematic because mineral oil is a <a href="https://www.webmd.com/drugs/2/drug-153865/mineral-oil-laxative-oral/details">known</a> laxative and could possibly interfere with the absorption of statins. Some data to suggest this is the change in LDL within the control arm. LDL increased after the trial, which doesn’t make much sense given that they were taking statins.</p>
<p>We have sufficient evidence from the literature to suggest that statins should lower LDL. It is also worth pointing out that side effects like diarrhea were far more prevalent within the control group in a 7,000+ clinical trial. Thus, I suspect that the control group may have been given enough mineral oil that it possibly interfered with the absorption of statins within the gut, thus reducing their efficacy, and making the difference between the Vascepa group and control group even more substantial.</p>
</blockquote>
<p>Amarin, the manufacturer of Vascepa, has responded to some of these criticisms <a href="../../uploads/amarin-response.pdf">here</a>.</p>


<!-- -->

</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2026,
  author = {Panda, Sir and Rafi, Zad},
  title = {A {Critical} {Look} {At} {The} {REDUCE-IT} {Trial}},
  date = {2026-01-06},
  url = {https://lesslikely.com/posts/medicine/reduce-it.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2026" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2026). <span>‘A Critical Look At The REDUCE-IT
Trial’</span>. <a href="https://lesslikely.com/posts/medicine/reduce-it.html">https://lesslikely.com/posts/medicine/reduce-it.html</a>.
</div></div></section></div> ]]></description>
  <category>medicine</category>
  <guid>https://lesslikely.com/posts/medicine/reduce-it.html</guid>
  <pubDate>Tue, 06 Jan 2026 05:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700143/Site/PrimaryEndpoint.png" medium="image" type="image/png"/>
</item>
<item>
  <title>Seductive Surrogates Can Be Deadly</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/medicine/seductive-surrogates.html</link>
  <description><![CDATA[ 




<p>In clinical trials, it’s not always possible to measure hard endpoints like cardiovascular disease events and cancer remission rates. Studies that use clinical outcomes often dichotomize these variables, and as a result, they need to have a large number of participants and be long in duration to detect differences between groups.</p>
<p>Again, this type of research is expensive and not always feasible. In many scenarios, a more practical alternative is to focus on intermediate markers. Intermediate markers are biomarkers associated with a clinical outcome.<span class="citation" data-cites="hulley2007"><sup><strong>hulley2007?</strong></sup></span></p>
<p>For example, C-reactive protein (CRP) is a molecule that is strongly associated with inflammation, and you can often find that CRP levels increase when inflammation increases.<span class="citation" data-cites="bray2016w chew2012jets pepys2003jci"><sup><strong>bray2016w?</strong>,<strong>chew2012jets?</strong>,<strong>pepys2003jci?</strong></sup></span> Because inflammation is associated with coronary heart disease (CHD)<span class="citation" data-cites="Frangogiannis2012-fo Hansson2005-wz Libby2006-ch Ruparelia2017-nf"><sup><strong>Frangogiannis2012-fo?</strong>,<strong>Hansson2005-wz?</strong>,<strong>Libby2006-ch?</strong>,<strong>Ruparelia2017-nf?</strong></sup></span>, an investigator may choose to focus on decreasing levels of inflammation in a clinical trial (measured by CRP), rather than focus on how many CHD-related deaths the intervention prevents.</p>
<p>If the changes in an intermediate marker can robustly predict changes in a hard endpoint, and if it’s part of the primary pathway of the clinical outcome, then your biomarker can be considered a surrogate marker for that clinical outcome.<span class="citation" data-cites="hulley2007"><sup><strong>hulley2007?</strong></sup></span> (I’m not sure if CRP is a good surrogate outcome for CHD events, just used it as an example).</p>
<p>Low-density lipoprotein (LDL) is considered an excellent surrogate marker for CHD because reducing LDL levels also seems to reduce the number of CHD events.<span class="citation" data-cites="Cholesterol_Treatment_Trialists_CTT_Collaboration2015-ni Taylor2013-te"><sup><strong>Cholesterol_Treatment_Trialists_CTT_Collaboration2015-ni?</strong>,<strong>Taylor2013-te?</strong></sup></span> Unfortunately, this can all go wrong if the intermediate marker is associated with a clinical outcome, but is not involved in the causal pathway of the outcome and is confounded by other phenomena.</p>
<section id="torcetrapib" class="level2">
<h2 class="anchored" data-anchor-id="torcetrapib">Torcetrapib</h2>
<p>A great example of this is the story of high-density lipoprotein (HDL) and myocardial infarction (heart attacks). Several studies had found associations between low levels of HDL, often considered <em>“good cholesterol,”</em> and heart attacks.<span class="citation" data-cites="Assmann1996-jd Curb2004-ee Gordon1977-le Gordon1989-mc Rahilly-Tierney2011-ox Sharrett2001-su Turner1998-gv"><sup><strong>Assmann1996-jd?</strong>,<strong>Curb2004-ee?</strong>,<strong>Gordon1977-le?</strong>,<strong>Gordon1989-mc?</strong>,<strong>Rahilly-Tierney2011-ox?</strong>,<strong>Sharrett2001-su?</strong>,<strong>Turner1998-gv?</strong></sup></span></p>
<p>So, it shouldn’t come as a surprise that a drug (torcetrapib) was produced by Pfizer that attempted to increase the amount of HDL with the hopes that it would reduce the number of CVD events.</p>
<p>A group of researchers administered the drug to thousands of patients.<span class="citation" data-cites="Barter2007-if"><sup>1</sup></span> The drug was successful in changing the lipids of the participants to more favorable numbers. Patients who received the drug had a 24.9% decrease in LDL and a 72.1% increase in HDL. Seems pretty great. However, the number of deaths increased by 58% and the number of heart attacks increased by 21%.</p>
<p>A systematic review and meta-analysis<span class="citation" data-cites="Briel2009-yo"><sup><strong>Briel2009-yo?</strong></sup></span> published in the BMJ a few years later concluded the following after pooling studies that focused on interventions that primarily increased HDL and interventions that primarily decreased LDL,</p>
<blockquote class="blockquote">
<p>“Available data suggest that simply increasing the amount of circulating high-density lipoprotein cholesterol does not reduce the risk of coronary heart disease events, coronary heart disease deaths, or total deaths. The results support reduction in low-density lipoprotein cholesterol as the primary goal for lipid modifying interventions.”</p>
</blockquote>
<p>Svensson<span class="citation" data-cites="Svensson2013-vq"><sup><strong>Svensson2013-vq?</strong></sup></span> provides us with a very lovely table showing other scenarios for which a drug had a favorable effect on a surrogate marker but had a negative impact on the clinical outcome.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700145/Site/Surrogates.png" alt="Surrogate endpoints and how they've conflicted with clinical endpoints." style="width:80%"></p>
<hr>
<p>What does this tell us? That focusing only on improving surrogate markers is not a very good idea if there is not much concordance between trials that focus on surrogates and trials that focus on hard endpoints. Until we’ve established a robust causal link between a surrogate marker and a hard endpoint, we shouldn’t be seduced by surrogates.</p>
<hr>
<section id="references" class="level3">



<!-- -->


</section>
</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">
<div id="ref-Barter2007-if" class="csl-entry">
<div class="csl-left-margin">1. </div><div class="csl-right-inline">Barter PJ, Caulfield M, Eriksson M, et al. Effects of torcetrapib in patients at high risk for coronary events. <em>N Engl J Med</em>. 2007;357(21):2109-2122. doi:<a href="https://doi.org/10.1056/NEJMoa0706628">10.1056/NEJMoa0706628</a></div>
</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2026,
  author = {Panda, Sir and Rafi, Zad},
  title = {Seductive {Surrogates} {Can} {Be} {Deadly}},
  date = {2026-01-06},
  url = {https://lesslikely.com/posts/medicine/seductive-surrogates.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2026" class="csl-entry quarto-appendix-citeas">
<div class="">Panda S, Rafi Z. Seductive Surrogates Can Be
Deadly. <a href="https://lesslikely.com/posts/medicine/seductive-surrogates.html">https://lesslikely.com/posts/medicine/seductive-surrogates.html</a>.
Published January 6, 2026.</div>
</div></div></section></div> ]]></description>
  <category>medicine</category>
  <guid>https://lesslikely.com/posts/medicine/seductive-surrogates.html</guid>
  <pubDate>Tue, 06 Jan 2026 05:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700145/Site/Surrogates.png" medium="image" type="image/png"/>
</item>
<item>
  <title>How Did We Figure Out Smoking Causes Lung Cancer?</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/medicine/smoking-and-lung-cancer.html</link>
  <description><![CDATA[ 




<p>Proving a cause and effect relationship isn’t easy. Causality is complex, and there are thousands of <a href="https://plato.stanford.edu/entries/kant-hume-causality/">philosophical</a> and <a href="https://link.springer.com/chapter/10.1007%2F978-1-4612-2404-4_3">mathematical texts</a> on it that are beyond my understanding. However, I do understand enough to discuss how we arrive at cause and effect relationships in the sciences.</p>
<p>One of the first things drilled into students in a research methods course is that correlation does not equal causation. It’s also taught in a cult-like way that one of the best ways to prove causality in the health and social sciences is with a perfectly designed <a href="https://www.ncbi.nlm.nih.gov/pubmedhealth/PMHT0025811/">randomized controlled trial</a> (RCT). Why?</p>
<p>A few reasons:</p>
<ul>
<li><p>you can compare what you’re testing to a control, to see if it’s better or worseand if the effects can be ruled out by the placebo or <a href="https://en.wikipedia.org/wiki/Nocebo">nocebo effect</a>, or through phenomena like <a href="../../statistics/control-group-effects">regression towards the mean</a></p></li>
<li><p>you break the spurious links between <a href="https://en.wikipedia.org/wiki/Confounding">confounders</a> through <a href="../../statistics/equal-covariates">randomization (reducing selection bias</a>)</p></li>
<li><p>and you have the sequence of events mapped out (addressing temporal problems, so you know which variable came first and caused the other)</p></li>
</ul>
<p>These are difficult to do with observational/epidemiological studies. There are always some spurious links that have nothing to do with the phenomena of interest as seen below:</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700110/Site/chart.jpg" alt="Spurious associations such as the number of letters in the winning word of the spelling bee and the number of people killed by venomous spiders"></p>
<hr>
<p>So perfect RCTs are believed to be one of the best ways to prove causality, and at some point in history, we determined that smoking causes lung cancer in humans. Does that mean we recruited participants, randomized them to a group, and made them smoke?</p>
<p>Nope. Although several unethical experiments on humans have been carried out in the past, this was not one of them. Institutional Review Boards wouldn’t allow an investigation like that, where participants could potentially be harmed to such a large degree.</p>
<p>Wait, if there are no RCTs testing the effects of cigarettes, then how did we determine that <em>smoking causes lung cancer</em>? In the mid-1900s, two researchers (Richard Doll and Austin Bradford Hill) <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC437141/">produced data</a> showing that smoking frequency was <strong>strongly</strong> correlated with lung cancer incidence. The data were compelling. Look at the numbers below.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700109/Site/britishdoctors.png" alt="Data from the British Doctor's study"></p>
<hr>
<p>But again, these were associations from observational studies (case controls), not experiments. What if people who had lung cancer also had genes that made them more likely to smoke? What if they happened to be drawn to smoking? You couldn’t dismiss these possibilities with correlations.</p>
<p>This is what legendary statistician, empiricist, and <strong>potato scientist</strong>, <a href="../../statistics/classical-lehmann">Ronald A. Fisher</a>, exclaimed at the time.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1559517576/Site/fisher_old.jpg" alt="Picture of Ronald A. Fisher" style="width:40%"></p>
<hr>
<p>Fisher was often a critic of these findings and of the surgeon general’s report, that smoking causes lung cancer. He claimed that these conclusions were purely correlational and it’s also what tobacco companies exclaimed to defend their highly profitable product. And they weren’t wrong.</p>
<p>Alright, we’re in a dilemma. Perfectly designed randomized trials are the one of best ways to establish causality, but you can’t conduct randomized experiments to see whether smoking causes cancer, because it’s unethical, so you’re limited to epidemiological/observational studies.</p>
<p>So researchers have to work with what they have. And that’s what they did in the mid-1900s. There were already <a href="http://tobaccocontrol.bmj.com/content/21/2/87">suspicions</a> at the time, that consumption of tobacco products caused harmful gene mutations from studies carried out in animal models. Specific compounds found in tobacco products had also been established as carcinogens decades before the surgeon general’s report, and researchers were already open to the idea that smoking wasn’t the greatest habit. Unfortunately, rigorous human data were missing.</p>
<p>The results from the <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC437141/">British Doctor’s Study</a> (the study conducted by Richard Doll and Austin Bradford Hill) was the nail in the coffin because it provided evidence (although correlational) that smoking frequency increased the incidence rates of lung cancer.</p>
<p>One of the researchers on that original paper (Austin Bradford Hill) went on to establish the <a href="../../statistics/bradford-hill-criteria-dont-hold">Bradford Hill Criteria</a>, a set of viewpoints that Hill had discussed in a speech that he believed helped establish the link between smoking and lung cancer.</p>
<p>Interestingly enough, he was also a pioneer of the randomized controlled trial!</p>
<hr>
<center>
<img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700109/Site/bradfordhill.jpg" alt="Picture of Austin Bradford Hill" style="width:30%">
</center>
<hr>
<p>In Hill’s speech, he exclaimed that one could potentially arrive at causality from nine viewpoints:</p>
<ol type="1">
<li><p>The strength of the association</p></li>
<li><p>Consistency</p></li>
<li><p>Specificity</p></li>
<li><p>Temporality</p></li>
<li><p>Dose dependency</p></li>
<li><p>Biological mechanism</p></li>
<li><p>Coherence</p></li>
<li><p>Experiment</p></li>
<li><p>Analogy</p></li>
</ol>
<p>The relationship between smoking and lung cancer fit many of these scenarios. There was a biological mechanism (DNA damage from carcinogens in tobacco products), the effect sizes of the associations were large, there was a dose-dependent relationship (groups that smoked more had a higher incidence of lung cancer), there was consistency amongst the data observed, and there was coherence ( multiple lines of evidence to support a relationship: animal models, cellular biology, molecular, and epidemiological, etc.). <a href="https://www.nature.com/articles/d41586-018-01023-3">Robust research</a> needs multiple lines of evidence.</p>
<p>Even without experiments, the evidence from multiple lines was <strong>overwhelming</strong>.</p>
<p>It’s still worth mentioning that epidemiology has its limits. Temporality is often a problem because it’s hard to figure out which variable caused the other, and not all confounding variables can be adjusted for (<a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2744485/">over adjustment bias</a> can be a problem and there will always be residual confounding), but if there are multiple lines of evidence to suggest a relationship, then there could be one.</p>


<!-- -->


<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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2026,
  author = {Panda, Sir and Rafi, Zad},
  title = {How {Did} {We} {Figure} {Out} {Smoking} {Causes} {Lung}
    {Cancer?}},
  date = {2026-01-06},
  url = {https://lesslikely.com/posts/medicine/smoking-and-lung-cancer.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2026" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2026). <span>‘How Did We Figure Out Smoking Causes
Lung Cancer?’</span> <a href="https://lesslikely.com/posts/medicine/smoking-and-lung-cancer.html">https://lesslikely.com/posts/medicine/smoking-and-lung-cancer.html</a>.
</div></div></section></div> ]]></description>
  <category>medicine</category>
  <guid>https://lesslikely.com/posts/medicine/smoking-and-lung-cancer.html</guid>
  <pubDate>Tue, 06 Jan 2026 05:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700110/Site/cigarettes.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>The Rise, Fall, and Rise Again of Fish Oil?</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/medicine/vascepa-reduce-it.html</link>
  <description><![CDATA[ 




<p>With the exception of this past week, it hasn’t been a very good year for fish oil. In early 2018, a large meta-analysis and systematic review of several randomized trials was <a href="https://jamanetwork.com/journals/jamacardiology/fullarticle/2670752">published in <em>JAMA</em></a>.</p>
<p>This large pooled analysis (77,000 + participants) assessed the impact of supplementing fish oil on cardiovascular disease events and found that there was no statistically significant effect (p=.10). The relative risks (RR) and coverage of the confidence intervals (CI) also suggested a very small effect (RR: <strong>0.97,</strong> 95% CI: <strong>0.93</strong> to <strong>1.01</strong>) for any major vascular event.</p>
<p>A few months later Cochrane came out with their own <a href="https://doi.org/10.1002/14651858.CD003177.pub3">systematic review and meta-analysis</a> which was more comprehensive (79 studies, <strong>112,000</strong> participants) than the <em>JAMA</em> meta-analysis but also came to very similar conclusions of there being a small effect for several outcomes.</p>
<p>Cochrane Primary Outcomes Results:</p>
<ul>
<li><p>All-Cause Mortality: (RR: <strong>0.98</strong>, 95% CI: <strong>0.93</strong> to <strong>1.03</strong>)</p></li>
<li><p>Cardiovascular Mortality: (RR: <strong>0.95</strong>, 95% CI: <strong>0.87</strong> to <strong>1.03</strong>)</p></li>
<li><p>Combined Cardiovascular Events: (RR: <strong>0.99</strong>, 95% CI: <strong>0.94</strong> to <strong>1.04</strong>)</p></li>
<li><p>Coronary Heart Mortality: (RR: <strong>0.93</strong>, 95% CI: <strong>0.79</strong> to <strong>1.09</strong>)</p></li>
<li><p>Coronary Heart Disease Events: (RR: <strong>0.93</strong>, 95% CI: <strong>0.88</strong> to <strong>0.97</strong>)</p></li>
<li><p>Stroke: (RR: <strong>1.06</strong>, 95% CI: <strong>0.96</strong> to <strong>1.16</strong>)</p></li>
<li><p>Arrhythmia: (RR: <strong>0.97</strong>, 95% CI: <strong>0.90</strong> to <strong>1.05</strong>)</p></li>
</ul>
<p>At this time, it wasn’t looking particularly good for fish oil. Science-Based Medicine wrote an article titled, “<a href="https://sciencebasedmedicine.org/no-benefit-from-fish-oil/">No Benefit from Fish Oil,</a>” which largely suggested that fish oil had little utility based on the 2018 meta-analyses.</p>
<p>While these two recent meta-analyses of fish oil were very comprehensive, they weren’t able to include the results of two trials (<a href="https://clinicaltrials.gov/ct2/show/NCT02104817">STRENGTH</a> &amp; <a href="https://clinicaltrials.gov/ct2/show/NCT01492361">REDUCE-IT</a>) that were using extremely high doses of fish oil (3-4 g/d) because those trials were still ongoing, and the data were not available.</p>
<p>A few days ago, Amarin (the manufacturer of the patented, high-dose, purified EPA product, Vascepa) <a href="https://investor.amarincorp.com/news-releases/news-release-details/reduce-ittm-cardiovascular-outcomes-study-vascepar-icosapent">made an announcement</a> that the results from the REDUCE-IT trial suggested a fairly notable reduction in CVD events (25% reduction in the relative risk, apparently, RR: <strong>0.75</strong>, p&lt;0.001).</p>
<p>Several reports of this announcement declared it as a major event in the field of cardiology, comparable to the significance of statins. Of course, many folks (including myself) are still skeptical and will remain so until the results are published.</p>
<p>For those who are unaware, fish oil has had one of the most interesting histories of all nutritional supplements that are available today. I’ve used this timeline before in a <a href="../../medicine/fish-oil-cvd">previous blog post</a> but have updated it to include the newer events/studies.</p>
<hr>
<section id="a-brief-timeline-of-fish-oil" class="level2">
<h2 class="anchored" data-anchor-id="a-brief-timeline-of-fish-oil">A Brief Timeline of Fish Oil</h2>
<ul>
<li><p><strong>1970s</strong> | <a href="https://www.ncbi.nlm.nih.gov/pubmed/7435433">A group of explorers</a> noticed that people who consumed fish also had lower incidences of heart disease.</p></li>
<li><p><strong>1980s</strong>-<strong>1990s</strong> | <a href="https://www.ncbi.nlm.nih.gov/pubmed/3990713?access_num=3990713&amp;link_type=MED&amp;dopt=Abstract">Early</a> observational <a href="https://www.ncbi.nlm.nih.gov/pubmed/9091800?access_num=9091800&amp;link_type=MED&amp;dopt=Abstract">studies</a> also saw a connection between fish consumption and heart disease risk</p></li>
<li><p><strong>1990s</strong> | <a href="https://www.ncbi.nlm.nih.gov/pubmed/9310278?access_num=9310278&amp;link_type=MED&amp;dopt=Abstract">A few</a> randomized trials <a href="https://www.ncbi.nlm.nih.gov/pubmed/10465168?access_num=10465168&amp;link_type=MED&amp;dopt=Abstract">were</a> conducted to see the effects of fish oil supplementation and CVD outcomes</p></li>
<li><p><strong>2002</strong> | The American Heart Association put out <a href="http://circ.ahajournals.org/content/106/21/2747?ijkey=a0bd0a11dda35f2aa109c24a01266ea89e3d0121&amp;keytype2=tf_ipsecsha">a statement</a> suggesting that fish oil supplementation was beneficial for fatal outcomes</p></li>
<li><p><strong>2002</strong> - <strong>2016</strong> | Several <a href="http://www.thelancet.com/article/S0140-6736(07)60527-3/abstract">randomized trials</a> and <a href="https://www.ncbi.nlm.nih.gov/pubmed/15495044">systematic reviews</a> found inconsistent evidence for the effects of fish oil supplementation and CVD outcomes</p></li>
<li><p><strong>2016</strong> | The American Heart Association creates <a href="http://circ.ahajournals.org/content/135/15/e867.long">a scientific advisory group</a> to look at all the evidence and concludes that despite the controversy, there was a small benefit from fish oil and it could be worth it for people who had a history of CVD events.</p></li>
<li><p><strong>2018</strong> | <a href="https://www.ncbi.nlm.nih.gov/pubmed/29387889">Large meta-analysis</a> published in <em><strong>JAMA</strong></em> with 77,000 + participants found no benefit from fish oil supplementation on real clinical endpoints.</p></li>
<li><p><strong>Mid - 2018</strong> | Most <a href="https://www.cochranelibrary.com/cdsr/doi/10.1002/14651858.CD003177.pub3/full">comprehensive meta-analysis</a> and systematic review with 112,000 participants by Cochrane finds very small benefits to several CVD-related outcomes.</p></li>
<li><p><strong>Late 2018</strong> | <a href="https://investor.amarincorp.com/news-releases/news-release-details/reduce-ittm-cardiovascular-outcomes-study-vascepar-icosapent">Announcement</a> by the manufacturer of <a href="https://www.vascepa.com/">Vascepa</a> exclaiming that high-doses of fish oil in the REDUCE-IT trial had a large effect (25% reduction) on CVD outcomes.</p></li>
</ul>
<hr>
<p>Fish oil was accompanied by a lot of hype in the early days and little evidence, but eventually, like most things, it took a beating once several research groups started prodding the existing evidence.</p>
<p>The results of this trial (when they are presented in November at the AHA conference) and when they are published in a peer-reviewed journal, may potentially change the minds of skeptics everywhere.</p>
<p>That’s why I thought it would be a good time to review the preregistration protocol of the REDUCE-IT trial on <a href="https://clinicaltrials.gov/ct2/show/study/NCT01492361">ClinicalTrials.gov</a> and a <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5396348/">detailed paper</a> that describes the rationale behind the study design. Let’s get into it.</p>
<p>So very clearly, the authors state what the study here is doing,</p>
<blockquote class="blockquote">
<p>“AMR101 (icosapent ethyl [ethyl-EPA]) is a highly purified ethyl ester of eicosapentaenoic acid (EPA) being developed by Amarin Pharma Inc.&nbsp;for the treatment of hypertriglyceridemia.</p>
<p>The purpose of this study is to evaluate whether this drug, combined with a statin therapy, will be superior to the statin therapy alone, when used as a prevention in reducing long-term cardiovascular events in high-risk patients with mixed dyslipidemia.”</p>
</blockquote>
<p>Comparing statins + highly purified, high doses of EPA to statins alone. Why are they using such high doses? The authors explain here,</p>
<blockquote class="blockquote">
<p>“It is worth noting that the promising results from JELIS occurred with a high‐purity EPA preparation dosed at 1.8 g/d in a Japanese population, for whom the baseline EPA levels are higher than in western populations due to greater dietary intake of marine omega‐3 fatty acids.</p>
<p>Icosapent ethyl 12‐week dosing at 4 g/d in a high‐risk population similar to that within the Reduction of Cardiovascular Events with Icosapent Ethyl–Intervention Trial (REDUCE‐IT) who had persistent elevations of TG after treatment with statins resulted in significant reductions in TG and atherogenic lipoproteins, as well as comparable plasma EPA levels as the 1.8 g/d dosing group in JELIS.</p>
<p>Therefore, a dose of 4 g/d was selected as the dose for further study. In this context, REDUCE‐IT was designed to determine if treatment with icosapent ethyl 4 g/d vs placebo would reduce ischemic events in patients at increased CV risk already being treated with statins.”</p>
</blockquote>
<p>Also “worth noting” that the <a href="https://www.ncbi.nlm.nih.gov/pubmed/17398308">JELIS</a> trial was included in both meta-analyses mentioned at the beginning of the blog post.</p>
<p>The primary outcome is a composite endpoint that consists of CV death, MI, stroke, coronary revascularization, and hospitalization for unstable angina. Whenever I hear composite endpoint, I often become skeptical because I’ve seen composite endpoints abused or misused in several ways, resulting in very misleading results. There was a very nice post on composite endpoints by Hilda Bastian <a href="https://statistically-funny.blogspot.com/2015/02/lets-play-outcome-mash-up-clinical.html">here</a>.</p>
<p>The study (REDUCE-IT) enrolled 8,000 participants and began in 2011 and ended in 2018.</p>
<p>Why 8,000 participants?</p>
<p>The authors explain here,</p>
<blockquote class="blockquote">
<p>“The sample‐size calculation was based on a hazard ratio assumption of 0.85. Therefore, 1612 events would be required to have approximately 90% power with a 1‐sided α‐level of 2.5% and with 2 interim analyses. This results in a total target sample size of 7990 patients.</p>
<p>Approximately 70% of randomized patients were to be in CV risk stratum 1 (established CVD) and approximately 30% of randomized patients were to be in CV risk stratum 2 (high‐risk primary prevention defined by diabetes mellitus and other risk factors). Randomization was stratified by CV risk strata, ezetimibe use, and by geographical region.”</p>
</blockquote>
<p>The design power calculations seem like they were based on very optimistic expectations of the effect size, and apparently, justifiably so!</p>
<p>A bit unfortunate that there is no mention anywhere of what statistical analyses they planned on doing exactly.</p>
<p>In order for participants to be eligible for the trial:</p>
<ul>
<li><p>they had to be over the age of 45</p></li>
<li><p>have high levels of triglycerides (hypertriglyceridemia)</p></li>
<li><p>been on statins for at least a month</p></li>
<li><p>they had to have a history of heart disease</p></li>
</ul>
<p>There’s a bunch of exclusion criteria too that I don’t really feel the need to go over, but you can see them listed out on the registry.</p>
<p>Also, worth mentioning of course that the trial is funded by Amarin, AKA the manufacturer of Vascepa.</p>
<p>Even though my title mentions “<strong>fish oil</strong>” it really is important to point out that this is NOT the average fish oil supplement that you’ll get over the counter. It’s a highly purified substance, that’s currently being prescribed by doctors in high dosages for hypertriglyceridemia. It is a drug.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700147/Site/Vascepa-v-Common.png" alt="Vascepa versus normal fish oil" style="width:70%"></p>
<hr>
<p>An extremely expensive one (<a href="https://www.singlecare.com/prescription/vascepa">$250+ for a 30 day supply…</a> ) that most insurance companies will not cover unless your blood tests show an indication of <a href="https://vascepasavings.com/">high triglycerides</a>.</p>
<p>So, while the substance technically is fish oil, a very purified, high-dose version of it, the results of the REDUCE-IT trial are not evidence of your average fish oil supplement having these same effects.</p>
<p>I look forward to hearing about the results of this study in November.</p>
<p><strong>Edit</strong>: I’ve covered that study in this <a href="../../medicine/reduce-it">blog post</a>.</p>


<!-- -->

</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2026,
  author = {Panda, Sir and Rafi, Zad},
  title = {The {Rise,} {Fall,} and {Rise} {Again} of {Fish} {Oil?}},
  date = {2026-01-06},
  url = {https://lesslikely.com/posts/medicine/vascepa-reduce-it.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2026" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2026). <span>‘The Rise, Fall, and Rise Again of
Fish Oil?’</span> <a href="https://lesslikely.com/posts/medicine/vascepa-reduce-it.html">https://lesslikely.com/posts/medicine/vascepa-reduce-it.html</a>.
</div></div></section></div> ]]></description>
  <category>medicine</category>
  <guid>https://lesslikely.com/posts/medicine/vascepa-reduce-it.html</guid>
  <pubDate>Tue, 06 Jan 2026 05:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700147/Site/Vascepa-v-Common.png" medium="image" type="image/png"/>
</item>
<item>
  <title>Revisiting Eggs and Dietary Cholesterol</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/nutrition/revisiting-eggs.html</link>
  <description><![CDATA[ 




<p>Buckle up, folks. This is going to be a long one. In this post, I want to discuss three main things:</p>
<ul>
<li><a href="../../nutrition/eggs-cholesterol/#a-summary-of-the-jama-study">the recent study published in <em>JAMA</em> about eggs.</a>
<ul>
<li><a href="../../nutrition/eggs-cholesterol/#a-summary-of-the-jama-study">a summary of the methods and results.</a></li>
<li><a href="../../nutrition/eggs-cholesterol/#how-did-the-media-respond">how the media reported the results.</a></li>
<li><a href="../../nutrition/eggs-cholesterol/#how-reliable-are-the-measurements-and-analyses">discussion of measurement and analyses.</a></li>
</ul></li>
<li><a href="../../nutrition/eggs-cholesterol/#does-dietary-cholesterol-impact-serum-cholesterol">whether dietary cholesterol impacts serum cholesterol.</a>
<ul>
<li><a href="../../nutrition/eggs-cholesterol/#brief-timeline-of-dietary-cholesterol">a brief history of cholesterol research.</a></li>
<li><a href="../../nutrition/eggs-cholesterol/#what-do-reviews-of-randomized-trials-say">what the most current research indicates.</a></li>
</ul></li>
<li><a href="../../nutrition/eggs-cholesterol/#wait-so-should-we-be-worried-about-eggs">whether we should be worried about eggs.</a></li>
</ul>
<p>Let’s get right into it.</p>
<hr>
<section id="a-summary-of-the-jama-study" class="level2">
<h2 class="anchored" data-anchor-id="a-summary-of-the-jama-study">A Summary of the <em>JAMA</em> Study</h2>
<p>Last week, a nutritional epidemiological study (from now on nutri epi) published in <em>JAMA</em> posited that egg consumption was associated with an increased risk of cardiovascular disease incidence.<span class="citation" data-cites="zhongAssociationsDietaryCholesterol2019"><sup>1</sup></span> The results gained significant coverage from the media.</p>
<p>With that coverage came the usual criticism of “<em>correlation not being causation</em>,” and how nutri epi studies produce findings that are often contradicted by randomized trials, etc. Unlike many of these <em>surface-level</em> criticisms, I want to dive a little deeper into the findings of this study and the utility and limitations of studies like this. But first, a quick summary of the study.</p>
</section>
<section id="whos-being-studied" class="level2">
<h2 class="anchored" data-anchor-id="whos-being-studied">Who’s Being Studied?</h2>
<p>This study included data from <strong>six prospective cohorts</strong> and had a total sample size of <strong>29,615 adults</strong>. That’s a lot of people. Those who follow nutrition studies should be familiar with many of the cohorts included such as:</p>
<ul>
<li>the Atherosclerosis Risk in Communities (ARIC) Study</li>
<li>the Coronary Artery Risk Development in Young Adults (CARDIA) Study</li>
<li>the Framingham Heart Study (FHS)</li>
<li>the Framingham Offspring Study (FOS)</li>
<li>the Jackson Heart Study (JHS)</li>
<li>the Multi-Ethnic Study of Atherosclerosis (MESA)</li>
</ul>
<p>Data collection started in early 1985 and halted in the summer of 2016 (nearly <strong>31 years of data</strong>). The project was involved in answering the question of whether dietary cholesterol was associated with cardiovascular disease incidence.</p>
</section>
<section id="what-and-how-were-the-data-collected" class="level2">
<h2 class="anchored" data-anchor-id="what-and-how-were-the-data-collected">What and How Were the Data Collected?</h2>
<p>So how were dietary data collected? The authors give a very brief description in the methods,</p>
<blockquote class="blockquote">
<p>Using a standardized protocol and data dictionary, diet data were harmonized cohort by cohort. Briefly, <strong>consumption frequencies were converted into estimated number per day</strong> using the middle value (eg, 3-4 times per week = 0.5 times per day).</p>
</blockquote>
<p>However, a look at the supplementary files gives us more insight into how the data were collected:</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700113/Site/eggs-ffq.png" alt="A table describing the data collection methods for the six cohorts"></p>
<hr>
<p>So they mainly used various food frequency questionnaires which differed depending on the cohort.</p>
<p>The primary outcomes were…</p>
<hr>
<blockquote class="blockquote">
<p>The primary outcomes were <strong>incident CVD and all-cause mortality</strong>. Incident CVD was a <strong>composite end point</strong> of fatal and nonfatal coronary heart disease (0), stroke, heart failure, and CVD death from other causes.</p>
</blockquote>
<hr>
<p>Here are some of the covariates they collected data for</p>
<hr>
<blockquote class="blockquote">
<p>Standardized questionnaires and laboratory protocols were used to collect information on the following variables: <em>age, sex, race/ethnicity, education, lifestyle factors (including smoking, alcohol intake, and physical activity), body mass index (BMI, calculated as weight in kilograms divided by height in meters squared), blood pressure, lipid profile, medication use, and medical conditions</em>.</p>
</blockquote>
<hr>
<p>and what they adjusted for in their three statistical models. Let’s focus mainly on model 2 since they use that as a reference.</p>
<hr>
<blockquote class="blockquote">
<p>Models were sequentially adjusted for age, sex, race/ethnicity (white, black, Hispanic, Chinese), education (&lt;high school, high school, some college or more) (model 1); plus total energy, smoking status (current, former, never), smoking pack-years (0, 0.1-4.9, 5.0-9.9, 10-19.9, 20-29.9, 30-39.9, ≥40), cohort-specific physical activity z score, alcohol intake (gram), use of hormone therapy (y/n) (model 2);</p>
</blockquote>
<hr>
</section>
<section id="what-were-the-results" class="level2">
<h2 class="anchored" data-anchor-id="what-were-the-results">What Were the Results?</h2>
<p>The authors graphed the hazard ratios by the amount of dietary cholesterol consumed per day (mg) for CVD incidence…</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700114/Site/eggs-figure-1.png" alt="Graphed models of the associations of dietary cholesterol intake and CVD incidence"></p>
<hr>
<p>So what were the main results that the authors reported?</p>
<blockquote class="blockquote">
<p>Based on model 2, <strong>each additional 300 mg of dietary cholesterol consumed per day</strong> was significantly associated with higher risk of incident CVD (adjusted HR, <strong>1.17</strong> [95% CI, <strong>1.09-1.26</strong>]; adjusted ARD, <strong>3.24%</strong> [95% CI, <strong>1.39%-5.08%</strong>]; Figure 2A) and all-cause mortality (adjusted HR, <strong>1.18</strong> [95% CI, <strong>1.10-1.26</strong>]; adjusted ARD, <strong>4.43%</strong> [95% CI, <strong>2.51%-6.36%</strong>]; Figure 2B).</p>
</blockquote>
<hr>
<p>So a <strong>17% increase</strong> in the risk of incident CVD where a <strong>9% increase</strong> all the way up to a <strong>26% increase</strong> were reasonably compatible with the data and its assumptions. The results are practically the same for all-cause mortality.</p>
<p>The authors also adjusted for individual foods or combinations of foods to see how the effect deviated with model 2 being used as the reference.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700114/Site/eggs-figure-2.png" alt="Forest plot of dietary cholesterol and CVD incidence"></p>
<hr>
<ul>
<li><p>For <strong>incident CVD</strong> (shown above), the effect estimate <strong>increased</strong> from <em>17% to 20%</em> when adjusted for <em>eggs alone</em>, and <strong>decreased</strong> to <em>13%</em> when adjusted for <em>eggs, unprocessed red meat, and processed meat</em>.</p></li>
<li><p>For <strong>all-cause mortality</strong> (graph not shown), the effect estimate <strong>dropped</strong> from a <em>17% increase</em> to a <em>13% increase</em> when adjusted for <em>eggs alone</em> and <strong>dropped</strong> to a <em>5% increase</em> when adjusted for <em>eggs, unprocessed red meat, and processed meat</em>.</p></li>
</ul>
<p>Here’s what the authors concluded:</p>
<blockquote class="blockquote">
<p>The current study found that the <strong>significant associations of dietary cholesterol consumption with incident CVD and all-cause mortality were independent of fat amount and quality of the diet</strong>. Further, the significant association between egg consumption and incident CVD was <strong>fully accounted for by the cholesterol content in eggs</strong>…</p>
</blockquote>
<hr>
<blockquote class="blockquote">
<p>Mechanistically, eggs and processed or unprocessed red meat are rich in other nutrients such as choline, iron, carnitine, and added sodium (for processed meat) that have been implicated in CVD risk via different pathways.</p>
</blockquote>
<p>And then they discuss the limitations of their study:</p>
<blockquote class="blockquote">
<p>First, appropriate interpretation of the study findings requires <strong>consideration of measurement error for self-reported diet data</strong>. Further, <strong>this study relied on single measurement of egg and dietary cholesterol consumption</strong>. Exposure misclassification may be of concern, but results were similar when censoring participants at different time points…</p>
<p>…Fifth, generalizing our results to non-US populations requires caution due to different nutrition and food environments and chronic disease epidemiology. Sixth, the <strong>study findings are observational and cannot establish causality</strong>.</p>
</blockquote>
<p>Interestingly enough, right after saying the results cannot establish causality, they write this,</p>
<blockquote class="blockquote">
<p>Among US adults, higher consumption of dietary cholesterol or eggs was significantly associated with higher risk of incident CVD and all-cause mortality in a dose-response manner. <strong>These results should be considered in the development of dietary guidelines and updates.</strong></p>
</blockquote>
<p>Well, I have <em>a lot</em> to say, but let’s first take a look at how the media interpreted and reported these results. For that, we shall consult the Google oracle.</p>
</section>
<section id="how-did-the-media-respond" class="level2">
<h2 class="anchored" data-anchor-id="how-did-the-media-respond">How Did the Media Respond?</h2>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700132/Site/media_eggs.png" alt="The media response to the publication of the JAMA egg study"></p>
<hr>
<p>This is one of my favorite ones.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700113/Site/eggs_media_reporting.png" alt="Fear mongering headlines about eggs"></p>
<hr>
<p>Okay, now that we’ve done that, we can discuss the measurements and analyses.</p>
</section>
<section id="how-reliable-are-the-measurements-and-analyses" class="level2">
<h2 class="anchored" data-anchor-id="how-reliable-are-the-measurements-and-analyses">How Reliable Are the Measurements and Analyses?</h2>
<p>As the authors mentioned in the methods, and supplementary files, most of the dietary data were collected via a food frequency questionnaire (FFQ). This is important for a couple of reasons, and I’m going to dive a little deeper than the usual <em>“FFQ data are useless”</em>.</p>
<p>FFQ data are known to suffer from serious measurement error, and there is a giant body of literature on this. For example, such data can be prone to classical measurement error (<img src="https://latex.codecogs.com/png.latex?W_%7Bij%7D=X_%7Bi%7D+%20%5Cepsilon_%7Bij%7D">), systematic error, heteroscedastic error, and differential error.</p>
<p>Methods like regression calibration, moment reconstruction, multiple imputation, and graphical methods can be used to help address many of these errors, along with sensitivity analyses. For a more detailed read of this, see <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.6095">Keogh &amp; White, 2014</a>.<span class="citation" data-cites="keoghToolkitMeasurementError2014"><sup>2</sup></span></p>
<p>Unfortunately, the authors of the <em>JAMA</em> study hardly bothered with this, and merely pointed out in their limitations section that their study was limited by measurement error.</p>
<blockquote class="blockquote">
<p>This study has several limitations. First, appropriate interpretation of the study findings requires <strong>consideration of measurement error for self-reported diet data</strong>. Further, <strong>this study relied on single measurement of egg and dietary cholesterol consumption</strong>. Exposure misclassification may be of concern, but results were similar when censoring participants at different time points…</p>
</blockquote>
<p>This isn’t something to take this lightly given how serious of a problem it is. There have been extensive criticisms published of FFQs with one of the most prominent of reviews stating the following six arguments as to why memory-based questionnaires should not be used.<span class="citation" data-cites="archerControversyDebateMemoryBased2018"><sup>3</sup></span></p>
<ol type="1">
<li>The use of memory-based methods is founded upon two inter-related logical fallacies: a category error and reification</li>
<li>Human memory and recall are not valid instruments for scientific data collection</li>
<li>The measurement errors of memory-based dietary assessment methods are neither quantifiable nor falsifiable; this renders these methods and data pseudoscientific</li>
<li>The post hoc process of pseudoquantification is impermissible and invalid</li>
<li>Memory-based dietary data were repeatedly demonstrated to be physiologically implausible (i.e., meaningless numbers)</li>
<li>The failure to cite or acknowledge contrary evidence and empirical refutations contributed to a fictional discourse on diet-disease relations</li>
</ol>
<p>The authors don’t even believe that the measurement error from memory-based questionnaires can even be addressed! They conclude the following:</p>
<blockquote class="blockquote">
<p>Our conclusion is that nutrition epidemiology is a degenerating research paradigm in which the use of expedient but <strong>nonfalsifiable anecdotal evidence impeded scientific progress</strong> and engendered a fictional discourse on diet-health relations. The continued funding and use of memory-based methods such as Food Frequency Questionnaires and 24-hour dietary interviews is anathema to evidence-based public policy.</p>
<p>Thus, our recommendation is simply that <strong>the use of memory-based methods must stop and all previous articles presenting memory-based methods data and conclusions must be corrected</strong> to include contrary evidence and address the consequences of a half century of pseudoscientific claims.</p>
</blockquote>
<p>Ouch. Those are quite polarizing statements. Some researchers have argued that Archer et al have overstated their case against FFQs, but agree that FFQs are far from perfect.<span class="citation" data-cites="subarAddressingCurrentCriticism2015"><sup>4</sup></span> This discussion isn’t new though. FFQs have been criticized for so long that they’ve spurred parody videos like the one below:</p>
<hr>
<p>Those are some of the issues with the measurements, now onto the analyses (I’ll be using many of the arguments from my <a href="../../nutrition/nutritional-epidemiology">nutri epi blog post</a>). Unfortunately, the analytical plans of studies like this are rarely registered in advance, especially because data collection for many of these studies began decades ago, and most of the analyses are often viewed as being “exploratory.” This means that there is a <em>great deal</em> of analytical flexibility in what covariates to include in a model.</p>
<p>Some of the biggest critics of this have been statistician Stan Young and meta-researcher John Ioannidis. Young wrote the following in the journal <em>Significance</em>.<span class="citation" data-cites="youngDemingDataObservational2011"><sup>5</sup></span></p>
<blockquote class="blockquote">
<p>For example, consider the use of linear regression to adjust the risk levels of two treatments to the same background level of risk. There can be many covariates, and each set of covariates can be in or out of the model. <strong>With ten covariates, there are over 1000 possible models.</strong> Consider a maze as a metaphor for modelling (Figure 3).</p>
<figure class="figure">
<img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700169/Site/young_maze.png" alt="Analytical flexibility depicted by attempting to get through a maze" style="width:60%" class="figure-img">
<center>
<figcaption>
The maze of forking paths.
</figcaption>
</center>
</figure>
<p>The red line traces the correct path out of the maze. The path through the maze looks simple, once it is known. Returning to a linear regression model, terms can be put into and taken out of a regression model. <strong>Once you get a p‐value smaller than 0.05, the model can be frozen and the model selection justified</strong> after the fact. It is easy to justify each turn.</p>
</blockquote>
<p>Patel, Burford, and Ioannidis call this flexibility and its impact on the effect size, the <em>“vibration of effects.”</em><span class="citation" data-cites="Patel2015-kk"><sup>6</sup></span> In their study (which I’ve mentioned several times in previous blog posts), they downloaded several variables from the NHANES dataset that were linked to all-cause mortality and were able to substantially change the effect size by including certain covariates and excluding others,</p>
<blockquote class="blockquote">
<p>Ioannidis and colleagues <strong>downloaded 13 variables from the NHANES dataset that were linked to all-cause mortality</strong>, and that had a substantial number of participants associated with each variable (at least 1000 participants and 100 deaths). From those 13 variables, <strong>they were able to produce 8,192 different statistical models that all resulted in different hazard ratios</strong>.</p>
</blockquote>
<p>Their recommendations were to report all possible statistical models from all possible combinations of covariates and to report the median of all these models, rather than selectively reporting a few models. And to note whether there was something called a <em>“Janus effect”</em>, where the effect size would go in both directions.</p>
<blockquote class="blockquote">
<p>In the last pattern, as exemplified by <strong>α-tocopherol</strong>, the estimated HRs can be both greater and less than the null value (HR &gt; 1 and HR ≤ 1) depending on what adjustments were made. <strong>We call this the Janus effect after the two-headed representation of the ancient Roman god.</strong></p>
<p>For α-tocopherol, most of the HR and p-values were concentrated around 1 and non-significance, respectively… <strong>The Janus effect is common</strong>: 131 (31%) of the 417 variables had their 99th percentile HR&gt;1 and their 1st percentile HR&lt;1.</p>
</blockquote>
<p>However, statistician/epidemiologist, Sander Greenland has been a <a href="../../uploads/SanderGreenland.pdf">critic of meta-research</a> and epidemiological studies that lack biochemical sophistication and lump several compounds together as if they were the same and behaved the same in the body.</p>
<blockquote class="blockquote">
<p>“For nutrition, <strong>the lack of biochemistry sophistication among the trial designers leads to a lot of dubious and noncomparable studies</strong>, while the meta-analysts and reviewers do a lot of <strong>distortive lumping</strong>, e.g., talking about “vitamin E” as if that were a <strong>single entity</strong>.</p>
<p>A recent review by prominent authors didn’t even notice that almost <strong>all trials used the racemic synthetic mixture, dl-alpha-tocopheryl, (which they misidentify with “alpha tocopherol”)</strong> with vastly diferent and unjustifed dosages, and <strong>which hardly resembles the eight or so natural d-tocopherols or d-tocotrienols that account for dietary intake.</strong>”<span class="citation" data-cites="Patel2015-kk"><sup>6</sup></span></p>
</blockquote>
<hr>
<p>Ioannidis and Young are also prominent critics of the fact that nutri epi studies and randomized trials have poor concordance. For example, in Young’s 2011 paper published in <em>Significance</em> (which Ioannidis cites often), he (Young) states the following,</p>
<blockquote class="blockquote">
<p>We ourselves carried out an informal but comprehensive accounting of 12 randomised clinical trials that tested observational claims – see Table 1. <strong>The 12 clinical trials tested 52 observational claims. They all confirmed no claims in the direction of the observational claims</strong>. We repeat that figure: <strong>0 out of 52</strong>. To put it another way, <strong>100% of the observational claims failed to replicate</strong>.</p>
<p>In fact, <strong>five claims (9.6%) are statistically significant in the clinical trials in the opposite direction</strong> to the observational claim. To us, a false discovery rate of over 80% is potent evidence that the observational study process is not in control. The problem, which has been recognised at least since 1988, is systemic.</p>
</blockquote>
<p>This seems pretty bad. I can agree with Young and Ioannidis that nutri epi studies can often produce much noise given the analytical flexibility and measurement error. However, I’m not particularly convinced by the poor concordance data for two reasons.</p>
<ol type="1">
<li><p>Most RCTs have designs that are likely to be underpowered for an effect size of interest. Contrast this with nutri epi studies which are often enormous and span decades. So fixating on statistical significance with this in mind makes little sense to me.</p></li>
<li><p>Statistical significance has far more utility in studies that have some random mechanism, whether that be random assignment or random sampling. Otherwise, they make little sense to fixate on, especially in nutri epi studies. Greenland, 1990 summarizes this well below.<span class="citation" data-cites="Greenland1990-ay"><sup><strong>Greenland1990-ay?</strong></sup></span></p></li>
</ol>
<blockquote class="blockquote">
<p><strong>Randomization provides the key link between inferential statistics and causal parameters</strong>. Inferential statistics, such as <strong>P values</strong>, <strong>confidence intervals</strong>, and <strong>likelihood ratios</strong>, <strong>have very limited meaning in causal analysis</strong> when the mechanism of exposure assignment is <strong>largely unknown or is known to be nonrandom</strong>. It is my impression that such statistics are often given a weight of authority appropriate only in randomized studies</p>
</blockquote>
<p>I’m reasonably confident that Greenland has changed his mind since then on the appropriate weight of authority such statistics should be given, even in randomized studies. Especially given the recent <em>Nature</em> commentary he published on the problems with statistical significance and dichotomous thinking.<span class="citation" data-cites="amrheinScientistsRiseStatistical2019"><sup>7</sup></span></p>
<p>In the same 1990 paper, Greenland also points out the problems with several probabilistic arguments that are used to justify classical statistics in areas where the exposure is unknown or unlikely to be random. He proposes some possible solutions:</p>
<blockquote class="blockquote">
<p>In causal analysis of observational data, valid use of inferential statistics as measures of compatibility, conflict, or support depends crucially on randomization assumptions about which we are at best agnostic and more usually doubtful. Among the possible remedies are:</p>
<ul>
<li>Restrain our interpretation of classical statistics by explicating and <strong>criticizing any randomization assumptions</strong> that are necessary for probabilistic interpretations;</li>
<li>train our students and retrain ourselves to <strong>focus on nonprobabilistic interpretations</strong> of inferential statistics;</li>
<li><strong>deemphasize inferential statistics</strong> in favor of <strong>pure data descriptors, such as graphs and tables</strong>;</li>
<li>expand our analytic repertoire to include more elaborate techniques that depend on <strong>assumptions in the “agnostic”</strong> rather than the “doubtful” realm, and <strong>subject the results of these techniques to influence and sensitivity analysis.</strong></li>
</ul>
<p>These are neither mutually exclusive nor exhaustive possibilities, but I think any one of them would constitute an improvement over much of what we have done in the past.</p>
</blockquote>
<hr>
<p>Now, with all of these nuances in mind, how convincing is this observational study that has produced a hazard ratio of <strong>1.17</strong> with a 95% CI ranging from <strong>1.09 - 1.26</strong>? I don’t think it’s that convincing. I’m not saying that dietary cholesterol or eggs don’t impact CVD incidence and serum cholesterol, but just that I don’t find <strong>this</strong> study’s data to be very convincing.</p>
<p><a href="https://www.methodsman.com/blog/eggs-mortality">Perry Wilson</a> also has an interesting argument where he utilized graphical methods to assess the plausibility of the results,</p>
<hr>
</section>
<section id="does-dietary-cholesterol-impact-serum-cholesterol" class="level2">
<h2 class="anchored" data-anchor-id="does-dietary-cholesterol-impact-serum-cholesterol">Does Dietary Cholesterol Impact Serum Cholesterol?</h2>
<p>This has been a very controversial subject ever since dietary cholesterol was first implicated in cardiovascular disease in the 1900s with one of the most famous epidemiological studies being the Seven Countries Study.<span class="citation" data-cites="feinleibSevenCountriesMultivariate1981"><sup>8</sup></span> I’m not going to touch on that study since I wouldn’t be doing it justice, but there’s plenty of reading material out there.</p>
<p>But here’s a very brief timeline of dietary cholesterol:</p>
<hr>
</section>
<section id="brief-timeline-of-dietary-cholesterol" class="level2">
<h2 class="anchored" data-anchor-id="brief-timeline-of-dietary-cholesterol">Brief Timeline of Dietary Cholesterol</h2>
<blockquote class="blockquote">
<ul>
<li><strong>1950s</strong> <strong>|</strong> Dietary cholesterol is implicated in heart disease.<span class="citation" data-cites="duffPathologyAtherosclerosis1951"><sup>9</sup></span></li>
<li><strong>Late 1900s</strong> <strong>|</strong> Seven Countries Study is published.<span class="citation" data-cites="feinleibSevenCountriesMultivariate1981"><sup>8</sup></span></li>
<li><strong>Late 1900s</strong> <strong>|</strong> Metabolic ward experiments find that dietary cholesterol impacts serum cholesterol.<span class="citation" data-cites="clarkeDietaryLipidsBlood1997"><sup>10</sup></span></li>
<li><strong>Late 1900s</strong> <strong>|</strong> Other trials fail to find an effect.<span class="citation" data-cites="bowmanEffectDietaryFat1988"><sup><strong>bowmanEffectDietaryFat1988?</strong></sup></span></li>
<li><strong>Late 1900s - Early 2000s</strong> <strong>|</strong> Government agencies and medical organization recommend limiting dietary cholesterol.<span class="citation" data-cites="brownawellCholesterolWhereScience2010"><sup>11</sup></span></li>
<li><strong>2013</strong> <strong>|</strong> American Heart Association states that there’s insufficient evidence whether removing cholesterol is beneficial.<span class="citation" data-cites="eckel2013AHAACC2014"><sup>12</sup></span></li>
<li><strong>2015</strong> <strong>|</strong> Dietary guidelines drop arbitrary recommendations on limiting dietary cholesterol, but still recommend little intake.</li>
</ul>
</blockquote>
<hr>
<p>Wow, that can be pretty confusing and frustrating… Wait till you see the next study I talk about.</p>
</section>
<section id="what-do-reviews-of-randomized-trials-say" class="level2">
<h2 class="anchored" data-anchor-id="what-do-reviews-of-randomized-trials-say">What Do Reviews of Randomized Trials Say?</h2>
<p>A few months ago, a <strong>meta-regression of only randomized controlled trials</strong> that were at least two weeks long (and a million other inclusion/exclusion criteria) was published in <em>The American Journal of Clinical Nutrition</em>.<span class="citation" data-cites="Vincent2019-yc"><sup>13</sup></span> This study was interested in assessing the relationship between dietary cholesterol and serum cholesterol. Here are some characteristics of the study:</p>
<ul>
<li>Included <strong>55 randomized trials</strong> (<strong>2,652 subjects</strong>), with 44 being <strong>crossover trials</strong>.</li>
<li>Used <strong>Bayesian methods</strong> with <strong>uninformed priors</strong>.</li>
<li>Used the <strong>Mensink equation</strong> to subtract the impact of fatty acids on cholesterol to isolate the impact of dietary cholesterol better.</li>
<li>Explored both linear and nonlinear models.</li>
</ul>
<p>So what were the results?</p>
<p>The nonlinear models better fit the data than the linear model and at <strong>100 mg/d of dietary cholesterol change</strong>, there was an associated <strong>4.58 mg/dL change in LDL cholesterol</strong>. The <strong>linear model</strong> estimated this change to be <strong>1.90 mg/dL</strong>, which is similar to estimates found by the meta-analysis of metabolic ward studies.<span class="citation" data-cites="clarkeDietaryLipidsBlood1997"><sup>10</sup></span> At 200-400 mg/d of dietary cholesterol change, the nonlinear and linear models had substantial differences in their estimations (see the table below and then the graph).</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700133/Site/makitable.png" alt="Table of changes in LDL associated with dietary cholesterol"></p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700132/Site/makigraph.png" alt="Linear, MM, and Hill models graphed"></p>
<hr>
<p>Wow. So dietary cholesterol does indeed impact serum cholesterol (LDL)! Here’s what the authors write in their conclusion…</p>
<blockquote class="blockquote">
<p>The meta-regression analyses presented herein indicate that, after providing a theoretical control for intakes of SFAs, MUFAs, PUFAs, and when possible, TFAs, <strong>there is a positive, dose-related trend between changes in cholesterol intake and changes in circulating LDL cholesterol</strong>, a finding that is consistent with the published literature.</p>
<p>The nonlinear dose-response shapes (MM and Hill) best fit the data. <strong>For a 100-mg/d increase in dietary cholesterol intake</strong>, circulating <strong>LDL-cholesterol concentrations</strong> are predicted to <strong>increase</strong> by <strong>1.90 mg/dL</strong> (linear model), <strong>4.46 mg/dL</strong> (MM model), or <strong>4.58 mg/dL</strong> (Hill model).</p>
</blockquote>
<p>Then they discuss the practical significance of this.</p>
<blockquote class="blockquote">
<p>The results from these meta-analyses have potential implications for dietary recommendations. For comparison, the equation given by Mensink et al.&nbsp;predicts a change of 1.23 mg/dL for each 1% increase in SFAs in exchange for carbohydrate.</p>
<p>Therefore, based on the nonlinear models, <strong>increasing dietary cholesterol by 100 mg/d</strong> would be predicted to have an effect comparable to that of <strong>increasing dietary SFAs by 3.7%</strong>, and <strong>increasing dietary cholesterol by 200 mg/d</strong> is predicted to be comparable to <strong>increasing dietary SFAs by 5.5%</strong>.</p>
<p><strong>A large egg contains ∼185 mg cholesterol and would therefore be expected to increase the LDL-cholesterol concentration by 6.5 mg/dL</strong> based on the nonlinear models. However, the majority of dietary cholesterol is not attributable to egg intake in the United States, except for individuals in the highest quartile of TC intake.</p>
<p>According to a recent publication reporting dietary sources of cholesterol in US adults aged ≥20 y based on NHANES 2013–2014 data, mean dietary cholesterol intake was 293 mg/d and the <strong>primary dietary cholesterol source in the overall population was meat</strong> (defined as poultry, mixed dishes, red meat, processed meat, and seafood), which <strong>accounted for 42% of dietary cholesterol</strong>.</p>
</blockquote>
</section>
<section id="wait-so-should-we-be-worried-about-eggs" class="level2">
<h2 class="anchored" data-anchor-id="wait-so-should-we-be-worried-about-eggs">Wait, so Should We Be Worried About Eggs?</h2>
<p>I’m going to argue that we probably shouldn’t. The reason is that just because a food contains dietary cholesterol doesn’t mean it will be absorbed efficiently in the gastrointestinal tract. Foods are not homogenous and do not contain the same nutrients, anti-nutrients, and minerals. Consuming eggs in a sitting is not the same as consuming pure dietary cholesterol nor is it the same as consuming other foods high in cholesterol (poultry, red meat, and processed meat).</p>
<p>This also seems to be supported by a few randomized crossover trials that have shown that the cholesterol in eggs doesn’t seem to be well absorbed.<span class="citation" data-cites="kimDietaryCholesterolContained2018"><sup><strong>kimDietaryCholesterolContained2018?</strong></sup></span> Several other trials have also failed to show an effect on serum cholesterol.<span class="citation" data-cites="bowmanEffectDietaryFat1988 chenowethInfluenceDietaryCholesterol1981 vorsterEggIntakeDoes1992"><sup>14,15,<strong>bowmanEffectDietaryFat1988?</strong></sup></span> Is it possible that these trials were just underpowered in the first place? Very possible.</p>
<p>This all needs to be taken into account with the fact that in addition to the randomized trials included in the meta-regression mentioned above,<span class="citation" data-cites="Vincent2019-yc"><sup>13</sup></span> there exists a plethora of metabolic ward studies suggesting an effect of dietary cholesterol on serum cholesterol.<span class="citation" data-cites="clarkeDietaryLipidsBlood1997"><sup>10</sup></span> However, many of the metabolic ward trials included in the prominent meta-analysis by Clarke et al<span class="citation" data-cites="clarkeDietaryLipidsBlood1997"><sup>10</sup></span> were also nonrandomized,</p>
<blockquote class="blockquote">
<p>Solid food diets were assessed in 72 of these reports among 129 groups of subjects in <strong>395 experiments</strong> with various designs (<strong>109 randomised crossover</strong>, <strong>57 randomised</strong> or <strong>matched parallel</strong>, <strong>77 non-randomised Latin square</strong>, and <strong>152 non-randomised sequential</strong>).</p>
</blockquote>
<p>So while there is plenty of evidence suggesting that a diet high in dietary cholesterol impacts serum cholesterol, the evidence to suggest that eggs in particular have this effect seems far less concrete. There also may be a number of nutrients found in eggs that inhibit cholesterol absorption.<span class="citation" data-cites="jeschFoodIngredientsThat2017 kuangImpactEggNutrient2018"><sup>16,17</sup></span> Here are some excerpts from Kuang et al<span class="citation" data-cites="kuangImpactEggNutrient2018"><sup>17</sup></span></p>
<blockquote class="blockquote">
<p>Yang et al.&nbsp;reported that <strong>dietary PUFAs, PC, and SM significantly inhibit the uptake of cholesterol in Caco-2 monolayer</strong>, which may have potential therapeutic effect on reducing cholesterol absorption as functional food ingredients [44, 45]….</p>
</blockquote>
<blockquote class="blockquote">
<p><strong>Ezetimibe reduces the absorption of cholesterol</strong> in the small intestine by inhibiting the activity of NPC1L1 protein [52].</p>
</blockquote>
<blockquote class="blockquote">
<p>Therefore, <strong>consuming eggs may inhibit the intestinal absorption of cholesterol via the phospholipids in eggs.</strong> A fundamental question is how this biological effect is regulated.</p>
</blockquote>
<p>How convincing is this evidence? I’m still not sure. Much of it seems to be very preliminary, but I’m leaning towards the idea that most people probably don’t have to worry about eggs, especially since Americans don’t even get most of their dietary cholesterol from eggs.<span class="citation" data-cites="Vincent2019-yc"><sup>13</sup></span> I don’t find the existing data for eggs (including those from this study) to be convincing. More <em>better</em> research is needed.</p>
<blockquote class="blockquote">
<p>We need <em>less research</em>, <em>better research</em>, and research done for the <em>right reasons</em>.<span class="citation" data-cites="altmanScandalPoorMedical1994"><sup>18</sup></span> - <a href="https://en.wikipedia.org/wiki/Doug_Altman">Doug Altman</a></p>
</blockquote>
<p>See my other articles on nutritional epidemiology:</p>
<ul>
<li><p><a href="../../nutrition/nutritional-epidemiology">How Useful Is Nutritional Epidemiology?</a></p></li>
<li><p><a href="../../nutrition/moderate-carbohydrate-intake">Is Moderate Carbohydrate Intake the Best?</a></p></li>
<li><p><a href="../../nutrition/protein-heart-failure">Does Protein Increase the Risk of Heart Failure?</a></p></li>
</ul>
<hr>
<section id="references" class="level3">



<!-- -->


</section>
</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">
<div id="ref-zhongAssociationsDietaryCholesterol2019" class="csl-entry">
<div class="csl-left-margin">1. </div><div class="csl-right-inline">Zhong VW, Horn LV, Cornelis MC, et al. Associations of <span>Dietary Cholesterol</span> or <span>Egg Consumption With Incident Cardiovascular Disease</span> and <span>Mortality</span>. <em>JAMA</em>. 2019;321(11):1081-1095. doi:<a href="https://doi.org/10.1001/jama.2019.1572">10.1001/jama.2019.1572</a></div>
</div>
<div id="ref-keoghToolkitMeasurementError2014" class="csl-entry">
<div class="csl-left-margin">2. </div><div class="csl-right-inline">Keogh RH, White IR. A toolkit for measurement error correction, with a focus on nutritional epidemiology. <em>Statistics in Medicine</em>. 2014;33(12):2137-2155. doi:<a href="https://doi.org/10.1002/sim.6095">10.1002/sim.6095</a></div>
</div>
<div id="ref-archerControversyDebateMemoryBased2018" class="csl-entry">
<div class="csl-left-margin">3. </div><div class="csl-right-inline">Archer E, Marlow ML, Lavie CJ. Controversy and debate: <span>Memory</span>-<span>Based Methods Paper</span> 1: The fatal flaws of food frequency questionnaires and other memory-based dietary assessment methods. <em>Journal of Clinical Epidemiology</em>. 2018;104:113-124. doi:<a href="https://doi.org/10.1016/j.jclinepi.2018.08.003">10.1016/j.jclinepi.2018.08.003</a></div>
</div>
<div id="ref-subarAddressingCurrentCriticism2015" class="csl-entry">
<div class="csl-left-margin">4. </div><div class="csl-right-inline">Subar AF, Freedman LS, Tooze JA, et al. Addressing <span>Current Criticism Regarding</span> the <span>Value</span> of <span>Self</span>-<span>Report Dietary Data12</span>. <em>The Journal of Nutrition</em>. 2015;145(12):2639-2645. doi:<a href="https://doi.org/10.3945/jn.115.219634">10.3945/jn.115.219634</a></div>
</div>
<div id="ref-youngDemingDataObservational2011" class="csl-entry">
<div class="csl-left-margin">5. </div><div class="csl-right-inline">Young SS, Karr A. Deming, data and observational studies. <em>Significance</em>. 2011;8(3):116-120. doi:<a href="https://doi.org/10.1111/j.1740-9713.2011.00506.x">10.1111/j.1740-9713.2011.00506.x</a></div>
</div>
<div id="ref-Patel2015-kk" class="csl-entry">
<div class="csl-left-margin">6. </div><div class="csl-right-inline">Patel CJ, Burford B, Ioannidis JPA. Assessment of vibration of effects due to model specification can demonstrate the instability of observational associations. <em>J Clin Epidemiol</em>. 2015;68(9):1046-1058. doi:<a href="https://doi.org/10.1016/j.jclinepi.2015.05.029">10.1016/j.jclinepi.2015.05.029</a></div>
</div>
<div id="ref-amrheinScientistsRiseStatistical2019" class="csl-entry">
<div class="csl-left-margin">7. </div><div class="csl-right-inline">Amrhein V, Greenland S, McShane B. Scientists rise up against statistical significance. <em>Nature</em>. 2019;567(7748):305. doi:<a href="https://doi.org/10.1038/d41586-019-00857-9">10.1038/d41586-019-00857-9</a></div>
</div>
<div id="ref-feinleibSevenCountriesMultivariate1981" class="csl-entry">
<div class="csl-left-margin">8. </div><div class="csl-right-inline">Feinleib M. Seven <span>Countries</span>: <span>A Multivariate Analysis</span> of <span>Death</span> and <span>Coronary Heart Disease</span>. <em>JAMA</em>. 1981;245(5):511-512. doi:<a href="https://doi.org/10.1001/jama.1981.03310300063026">10.1001/jama.1981.03310300063026</a></div>
</div>
<div id="ref-duffPathologyAtherosclerosis1951" class="csl-entry">
<div class="csl-left-margin">9. </div><div class="csl-right-inline">Duff GL, McMILLAN GC. <a href="https://www.ncbi.nlm.nih.gov/pubmed/14837929">Pathology of atherosclerosis</a>. <em>The American Journal of Medicine</em>. 1951;11(1):92-108.</div>
</div>
<div id="ref-clarkeDietaryLipidsBlood1997" class="csl-entry">
<div class="csl-left-margin">10. </div><div class="csl-right-inline">Clarke R, Frost C, Collins R, Appleby P, Peto R. <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2125600">Dietary lipids and blood cholesterol: Quantitative meta-analysis of metabolic ward studies</a>. <em>BMJ (Clinical research ed)</em>. 1997;314(7074):112-117.</div>
</div>
<div id="ref-brownawellCholesterolWhereScience2010" class="csl-entry">
<div class="csl-left-margin">11. </div><div class="csl-right-inline">Brownawell AM, Falk MC. Cholesterol: Where science and public health policy intersect. <em>Nutrition Reviews</em>. 2010;68(6):355-364. doi:<a href="https://doi.org/10.1111/j.1753-4887.2010.00294.x">10.1111/j.1753-4887.2010.00294.x</a></div>
</div>
<div id="ref-eckel2013AHAACC2014" class="csl-entry">
<div class="csl-left-margin">12. </div><div class="csl-right-inline">Eckel RH, Jakicic JM, Ard JD, et al. 2013 <span>AHA</span>/<span>ACC</span> guideline on lifestyle management to reduce cardiovascular risk: A report of the <span>American College</span> of <span>Cardiology</span>/<span>American Heart Association Task Force</span> on <span>Practice Guidelines</span>. <em>Journal of the American College of Cardiology</em>. 2014;63(25 Pt B):2960-2984. doi:<a href="https://doi.org/10.1016/j.jacc.2013.11.003">10.1016/j.jacc.2013.11.003</a></div>
</div>
<div id="ref-Vincent2019-yc" class="csl-entry">
<div class="csl-left-margin">13. </div><div class="csl-right-inline">Vincent MJ, Allen B, Palacios OM, Haber LT, Maki KC. Meta-regression analysis of the effects of dietary cholesterol intake on <span>LDL</span> and <span>HDL</span> cholesterol. <em>Am J Clin Nutr</em>. 2019;109(1):7-16. doi:<a href="https://doi.org/10.1093/ajcn/nqy273">10.1093/ajcn/nqy273</a></div>
</div>
<div id="ref-chenowethInfluenceDietaryCholesterol1981" class="csl-entry">
<div class="csl-left-margin">14. </div><div class="csl-right-inline">Chenoweth W, Ullmann M, Simpson R, Leveille G. Influence of dietary cholesterol and fat on serum lipids in men. <em>The Journal of Nutrition</em>. 1981;111(12):2069-2080. doi:<a href="https://doi.org/10.1093/jn/111.12.2069">10.1093/jn/111.12.2069</a></div>
</div>
<div id="ref-vorsterEggIntakeDoes1992" class="csl-entry">
<div class="csl-left-margin">15. </div><div class="csl-right-inline">Vorster HH, Benadé AJ, Barnard HC, et al. Egg intake does not change plasma lipoprotein and coagulation profiles. <em>The American Journal of Clinical Nutrition</em>. 1992;55(2):400-410. doi:<a href="https://doi.org/10.1093/ajcn/55.2.400">10.1093/ajcn/55.2.400</a></div>
</div>
<div id="ref-jeschFoodIngredientsThat2017" class="csl-entry">
<div class="csl-left-margin">16. </div><div class="csl-right-inline">Jesch ED, Carr TP. Food <span>Ingredients That Inhibit Cholesterol Absorption</span>. <em>Preventive Nutrition and Food Science</em>. 2017;22(2):67-80. doi:<a href="https://doi.org/10.3746/pnf.2017.22.2.67">10.3746/pnf.2017.22.2.67</a></div>
</div>
<div id="ref-kuangImpactEggNutrient2018" class="csl-entry">
<div class="csl-left-margin">17. </div><div class="csl-right-inline">Kuang H, Yang F, Zhang Y, Wang T, Chen G. The <span>Impact</span> of <span>Egg Nutrient Composition</span> and <span>Its Consumption</span> on <span>Cholesterol Homeostasis</span>. <em>Cholesterol</em>. 2018. doi:<a href="https://doi.org/10.1155/2018/6303810">10.1155/2018/6303810</a></div>
</div>
<div id="ref-altmanScandalPoorMedical1994" class="csl-entry">
<div class="csl-left-margin">18. </div><div class="csl-right-inline">Altman DG. The scandal of poor medical research. <em>BMJ</em>. 1994;308(6924):283-284. doi:<a href="https://doi.org/10.1136/bmj.308.6924.283">10.1136/bmj.308.6924.283</a></div>
</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2026,
  author = {Panda, Sir and Rafi, Zad},
  title = {Revisiting {Eggs} and {Dietary} {Cholesterol}},
  date = {2026-01-06},
  url = {https://lesslikely.com/posts/nutrition/revisiting-eggs.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2026" class="csl-entry quarto-appendix-citeas">
<div class="">Panda S, Rafi Z. Revisiting Eggs and Dietary
Cholesterol. <a href="https://lesslikely.com/posts/nutrition/revisiting-eggs.html">https://lesslikely.com/posts/nutrition/revisiting-eggs.html</a>.
Published January 6, 2026.</div>
</div></div></section></div> ]]></description>
  <category>nutrition</category>
  <guid>https://lesslikely.com/posts/nutrition/revisiting-eggs.html</guid>
  <pubDate>Tue, 06 Jan 2026 05:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700113/Site/eggs_media_reporting.png" medium="image" type="image/png"/>
</item>
<item>
  <title>Multi-Language Code Examples</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/statistics/code-examples.html</link>
  <description><![CDATA[ 





<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>This post demonstrates how to include Stata, Julia, and pseudocode in your statistical posts on Less Likely.</p>
</section>
<section id="stata-examples" class="level2">
<h2 class="anchored" data-anchor-id="stata-examples">Stata Examples</h2>
<p>Stata code can be included for syntax highlighting:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb1-1">* ============================================</span>
<span id="cb1-2">* Example: Linear Regression Analysis</span>
<span id="cb1-3">* ============================================</span>
<span id="cb1-4"></span>
<span id="cb1-5">* Load example dataset</span>
<span id="cb1-6"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sysuse</span> auto, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">clear</span></span>
<span id="cb1-7"></span>
<span id="cb1-8">* Descriptive <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">statistics</span></span>
<span id="cb1-9"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">summarize</span> price mpg <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">weight</span> foreign</span>
<span id="cb1-10"></span>
<span id="cb1-11">* Create a <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">scatter</span> plot</span>
<span id="cb1-12"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">scatter</span> price mpg, <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">title</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Price vs. MPG"</span>)</span>
<span id="cb1-13"></span>
<span id="cb1-14">* Run linear regression</span>
<span id="cb1-15"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">regress</span> price mpg <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">weight</span> foreign</span>
<span id="cb1-16"></span>
<span id="cb1-17">* Store <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">estimates</span></span>
<span id="cb1-18"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">estimates</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">store</span> model1</span>
<span id="cb1-19"></span>
<span id="cb1-20">* Display results with confidence intervals</span>
<span id="cb1-21"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">regress</span> price mpg <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">weight</span> foreign, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">level</span>(95)</span>
<span id="cb1-22"></span>
<span id="cb1-23">* Test joint significance</span>
<span id="cb1-24"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">test</span> mpg <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">weight</span></span>
<span id="cb1-25"></span>
<span id="cb1-26">* Predict <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fitted</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">values</span></span>
<span id="cb1-27"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">predict</span> price_hat</span>
<span id="cb1-28"></span>
<span id="cb1-29">* Calculate residuals</span>
<span id="cb1-30"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">predict</span> residuals, residuals</span>
<span id="cb1-31"></span>
<span id="cb1-32">* Plot residuals</span>
<span id="cb1-33"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">scatter</span> residuals price_hat, <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">///</span></span>
<span id="cb1-34">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">yline</span>(0) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">///</span></span>
<span id="cb1-35">  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">title</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Residual Plot"</span>)</span></code></pre></div></div>
<section id="advanced-stata-panel-data-analysis" class="level3">
<h3 class="anchored" data-anchor-id="advanced-stata-panel-data-analysis">Advanced Stata: Panel Data Analysis</h3>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb2-1">* ============================================</span>
<span id="cb2-2">* Panel Data Example</span>
<span id="cb2-3">* ============================================</span>
<span id="cb2-4"></span>
<span id="cb2-5">* Load panel dataset</span>
<span id="cb2-6"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">webuse</span> nlswork, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">clear</span></span>
<span id="cb2-7"></span>
<span id="cb2-8">* Declare panel structure</span>
<span id="cb2-9">xtset idcode <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">year</span></span>
<span id="cb2-10"></span>
<span id="cb2-11">* Summary <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">statistics</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">by</span> panel</span>
<span id="cb2-12"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">xtsum</span> ln_wage age</span>
<span id="cb2-13"></span>
<span id="cb2-14">* Fixed <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">effects</span> regression</span>
<span id="cb2-15"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">xtreg</span> ln_wage age tenure, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fe</span></span>
<span id="cb2-16"></span>
<span id="cb2-17">* Random <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">effects</span> regression</span>
<span id="cb2-18"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">xtreg</span> ln_wage age tenure, re</span>
<span id="cb2-19"></span>
<span id="cb2-20">* Hausman <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">test</span></span>
<span id="cb2-21"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">hausman</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fe</span> re</span></code></pre></div></div>
</section>
</section>
<section id="julia-examples" class="level2">
<h2 class="anchored" data-anchor-id="julia-examples">Julia Examples</h2>
<p>Julia code for statistical computing:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ============================================</span></span>
<span id="cb3-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Example: Linear Regression in Julia</span></span>
<span id="cb3-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ============================================</span></span>
<span id="cb3-4"></span>
<span id="cb3-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">using</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">DataFrames</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Statistics</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">GLM</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Plots</span></span>
<span id="cb3-6"></span>
<span id="cb3-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create sample data</span></span>
<span id="cb3-8">n <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span></span>
<span id="cb3-9">x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">randn</span>(n)</span>
<span id="cb3-10">y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.0</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.0</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.*</span> x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">randn</span>(n) <span class="op" 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-11"></span>
<span id="cb3-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create DataFrame</span></span>
<span id="cb3-13">df <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">DataFrame</span>(x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> x, y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> y)</span>
<span id="cb3-14"></span>
<span id="cb3-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fit linear model</span></span>
<span id="cb3-16">model <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(<span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">@formula</span>(y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> x), df)</span>
<span id="cb3-17"></span>
<span id="cb3-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display results</span></span>
<span id="cb3-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">println</span>(model)</span>
<span id="cb3-20"></span>
<span id="cb3-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Plot data and fitted line</span></span>
<span id="cb3-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scatter</span>(x, y, label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Data"</span>, alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>)</span>
<span id="cb3-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot!</span>(x, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">predict</span>(model), label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fitted Line"</span>, linewidth<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb3-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xlabel!</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"X"</span>)</span>
<span id="cb3-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ylabel!</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Y"</span>)</span>
<span id="cb3-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">title!</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Linear Regression"</span>)</span></code></pre></div></div>
<section id="advanced-julia-bootstrap-confidence-intervals" class="level3">
<h3 class="anchored" data-anchor-id="advanced-julia-bootstrap-confidence-intervals">Advanced Julia: Bootstrap Confidence Intervals</h3>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ============================================</span></span>
<span id="cb4-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Bootstrap Example</span></span>
<span id="cb4-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ============================================</span></span>
<span id="cb4-4"></span>
<span id="cb4-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">using</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Distributions</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">StatsBase</span></span>
<span id="cb4-6"></span>
<span id="cb4-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Define a function to bootstrap</span></span>
<span id="cb4-8"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bootstrap_mean</span>(data, n_bootstrap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>)</span>
<span id="cb4-9">    n <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(data)</span>
<span id="cb4-10">    bootstrap_means <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">zeros</span>(n_bootstrap)</span>
<span id="cb4-11"></span>
<span id="cb4-12">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n_bootstrap</span>
<span id="cb4-13">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Resample with replacement</span></span>
<span id="cb4-14">        sample <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rand</span>(data, n)</span>
<span id="cb4-15">        bootstrap_means[i] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(sample)</span>
<span id="cb4-16">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">end</span></span>
<span id="cb4-17"></span>
<span id="cb4-18">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> bootstrap_means</span>
<span id="cb4-19"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">end</span></span>
<span id="cb4-20"></span>
<span id="cb4-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Generate sample data</span></span>
<span id="cb4-22">data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">randn</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.0</span></span>
<span id="cb4-23"></span>
<span id="cb4-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Perform bootstrap</span></span>
<span id="cb4-25">bootstrap_samples <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bootstrap_mean</span>(data)</span>
<span id="cb4-26"></span>
<span id="cb4-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Calculate confidence interval</span></span>
<span id="cb4-28">ci_lower <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">quantile</span>(bootstrap_samples, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.025</span>)</span>
<span id="cb4-29">ci_upper <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">quantile</span>(bootstrap_samples, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.975</span>)</span>
<span id="cb4-30"></span>
<span id="cb4-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">println</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"95% Bootstrap CI: ["</span>, ci_lower, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>, ci_upper, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"]"</span>)</span>
<span id="cb4-32"></span>
<span id="cb4-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Plot bootstrap distribution</span></span>
<span id="cb4-34"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">histogram</span>(bootstrap_samples,</span>
<span id="cb4-35">         bins<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>,</span>
<span id="cb4-36">         label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Bootstrap Distribution"</span>,</span>
<span id="cb4-37">         xlabel<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample Mean"</span>,</span>
<span id="cb4-38">         ylabel<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Frequency"</span>)</span>
<span id="cb4-39"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vline!</span>([ci_lower, ci_upper],</span>
<span id="cb4-40">       label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"95% CI"</span>,</span>
<span id="cb4-41">       linewidth<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb4-42">       color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=:</span>red)</span></code></pre></div></div>
</section>
</section>
<section id="pseudocode-examples" class="level2">
<h2 class="anchored" data-anchor-id="pseudocode-examples">Pseudocode Examples</h2>
<section id="example-1-algorithm-block" class="level3">
<h3 class="anchored" data-anchor-id="example-1-algorithm-block">Example 1: Algorithm Block</h3>
<div class="algorithm">
<p><strong>Algorithm 1</strong> Bootstrap Confidence Interval</p>
<p><strong>Input:</strong> Data <img src="https://latex.codecogs.com/png.latex?X%20=%20%5C%7Bx_1,%20x_2,%20...,%20x_n%5C%7D">, statistic <img src="https://latex.codecogs.com/png.latex?%5Ctheta(X)">, confidence level <img src="https://latex.codecogs.com/png.latex?%5Calpha"></p>
<p><strong>Output:</strong> Confidence interval <img src="https://latex.codecogs.com/png.latex?%5B%5Ctheta_L,%20%5Ctheta_U%5D"></p>
<ol type="1">
<li><strong>for</strong> <img src="https://latex.codecogs.com/png.latex?b%20=%201"> <strong>to</strong> <img src="https://latex.codecogs.com/png.latex?B"> <strong>do</strong>
<ul>
<li>Draw bootstrap sample <img src="https://latex.codecogs.com/png.latex?X_b%5E*"> by sampling <img src="https://latex.codecogs.com/png.latex?n"> observations from <img src="https://latex.codecogs.com/png.latex?X"> with replacement</li>
<li>Calculate <img src="https://latex.codecogs.com/png.latex?%5Ctheta_b%5E*%20=%20%5Ctheta(X_b%5E*)"></li>
</ul></li>
<li><strong>end for</strong></li>
<li>Sort <img src="https://latex.codecogs.com/png.latex?%5C%7B%5Ctheta_1%5E*,%20%5Ctheta_2%5E*,%20...,%20%5Ctheta_B%5E*%5C%7D"> in ascending order</li>
<li>Set <img src="https://latex.codecogs.com/png.latex?%5Ctheta_L%20=%20%5Ctext%7Bquantile%7D(%5Ctheta%5E*,%20%5Calpha/2)"></li>
<li>Set <img src="https://latex.codecogs.com/png.latex?%5Ctheta_U%20=%20%5Ctext%7Bquantile%7D(%5Ctheta%5E*,%201-%5Calpha/2)"></li>
<li><strong>return</strong> <img src="https://latex.codecogs.com/png.latex?%5B%5Ctheta_L,%20%5Ctheta_U%5D"></li>
</ol>
</div>
</section>
<section id="example-2-simple-pseudocode-block" class="level3">
<h3 class="anchored" data-anchor-id="example-2-simple-pseudocode-block">Example 2: Simple Pseudocode Block</h3>
<pre class="pseudocode"><code>ALGORITHM: Linear Regression via Gradient Descent
INPUT: X (n × p design matrix), y (n × 1 response vector), learning rate α
OUTPUT: β (p × 1 coefficient vector)

1. Initialize β = 0, iteration = 0, maxiter = 1000
2. REPEAT until convergence OR iteration &gt; maxiter:
   a. Compute predictions: ŷ = Xβ
   b. Compute residuals: r = y - ŷ
   c. Compute gradient: ∇L = -2X'r/n
   d. Update parameters: β = β - α∇L
   e. iteration = iteration + 1
3. RETURN β</code></pre>
</section>
<section id="example-3-detailed-algorithm-with-comments" class="level3">
<h3 class="anchored" data-anchor-id="example-3-detailed-algorithm-with-comments">Example 3: Detailed Algorithm with Comments</h3>
<div class="algorithm">
<p><strong>Algorithm 2</strong> Maximum Likelihood Estimation</p>
<p><strong>Input:</strong> Data <img src="https://latex.codecogs.com/png.latex?X">, log-likelihood function <img src="https://latex.codecogs.com/png.latex?%5Cell(%5Ctheta%7CX)">, initial value <img src="https://latex.codecogs.com/png.latex?%5Ctheta_0"></p>
<p><strong>Output:</strong> <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Ctheta%7D_%7BMLE%7D"></p>
<ol type="1">
<li>Set <img src="https://latex.codecogs.com/png.latex?%5Ctheta%20%5Cleftarrow%20%5Ctheta_0">, <img src="https://latex.codecogs.com/png.latex?t%20%5Cleftarrow%200"></li>
<li><strong>while</strong> not converged <strong>do</strong>
<ul>
<li>Compute score function: <img src="https://latex.codecogs.com/png.latex?s(%5Ctheta)%20=%20%5Cnabla_%5Ctheta%20%5Cell(%5Ctheta%7CX)"></li>
<li>Compute Hessian: <img src="https://latex.codecogs.com/png.latex?H(%5Ctheta)%20=%20%5Cnabla%5E2_%5Ctheta%20%5Cell(%5Ctheta%7CX)"></li>
<li>Update: <img src="https://latex.codecogs.com/png.latex?%5Ctheta%20%5Cleftarrow%20%5Ctheta%20-%20H(%5Ctheta)%5E%7B-1%7Ds(%5Ctheta)"></li>
<li>Check convergence: <strong>if</strong> <img src="https://latex.codecogs.com/png.latex?%5C%7Cs(%5Ctheta)%5C%7C%20%3C%20%5Cepsilon"> <strong>then</strong> break</li>
<li><img src="https://latex.codecogs.com/png.latex?t%20%5Cleftarrow%20t%20+%201"></li>
<li><strong>if</strong> <img src="https://latex.codecogs.com/png.latex?t%20%3E%20%5Ctext%7Bmax%5C_iterations%7D"> <strong>then</strong> break</li>
</ul></li>
<li><strong>end while</strong></li>
<li>Compute standard errors: <img src="https://latex.codecogs.com/png.latex?%5Ctext%7BSE%7D(%5Chat%7B%5Ctheta%7D)%20=%20%5Csqrt%7B%5Ctext%7Bdiag%7D(-H(%5Chat%7B%5Ctheta%7D)%5E%7B-1%7D)%7D"></li>
<li><strong>return</strong> <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Ctheta%7D_%7BMLE%7D"></li>
</ol>
</div>
</section>
</section>
<section id="comparing-approaches" class="level2">
<h2 class="anchored" data-anchor-id="comparing-approaches">Comparing Approaches</h2>
<p>Here’s how the same analysis looks across languages:</p>
<section id="task-calculate-mean-and-95-ci" class="level3">
<h3 class="anchored" data-anchor-id="task-calculate-mean-and-95-ci">Task: Calculate Mean and 95% CI</h3>
<p><strong>R:</strong></p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">data <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>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb6-2">mean_val <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;">mean</span>(data)</span>
<span id="cb6-3">ci <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;">t.test</span>(data)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conf.int</span></code></pre></div></div>
<p><strong>Julia:</strong></p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb7-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">using</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Statistics</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">HypothesisTests</span></span>
<span id="cb7-2">data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">randn</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span></span>
<span id="cb7-3">mean_val <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(data)</span>
<span id="cb7-4">ci <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">confint</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">OneSampleTTest</span>(data))</span></code></pre></div></div>
<p><strong>Stata:</strong></p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb8-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">clear</span></span>
<span id="cb8-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">obs</span> 100</span>
<span id="cb8-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">generate</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">data</span> = rnormal(5, 2)</span>
<span id="cb8-4"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">mean</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">data</span></span></code></pre></div></div>
<p><strong>Python:</strong></p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb9-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> scipy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> stats</span>
<span id="cb9-3">data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.random.normal(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb9-4">mean_val <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.mean(data)</span>
<span id="cb9-5">ci <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> stats.t.interval(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(data)<span class="op" 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-6">                      loc<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>mean_val,</span>
<span id="cb9-7">                      scale<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>stats.sem(data))</span></code></pre></div></div>
</section>
</section>
<section id="best-practices" class="level2">
<h2 class="anchored" data-anchor-id="best-practices">Best Practices</h2>
<ol type="1">
<li><strong>Use syntax highlighting for display-only code</strong> - Most readers just need to see the code</li>
<li><strong>Execute code sparingly</strong> - Only execute when output is essential</li>
<li><strong>Document your setup</strong> - Note required packages and versions</li>
<li><strong>Test before publishing</strong> - Ensure code runs without errors</li>
<li><strong>Provide context</strong> - Explain what the code does and why</li>
</ol>
</section>
<section id="resources" class="level2">
<h2 class="anchored" data-anchor-id="resources">Resources</h2>
<ul>
<li><a href="https://quarto.org/docs/computations/stata.html">Quarto Stata Documentation</a></li>
<li><a href="https://quarto.org/docs/computations/julia.html">Quarto Julia Documentation</a></li>
<li><a href="https://highlightjs.org/static/demo/">Highlight.js Language Support</a></li>
</ul>
</section>
<section id="conclusion" class="level2">
<h2 class="anchored" data-anchor-id="conclusion">Conclusion</h2>
<p>With support for multiple languages, you can now share statistical methods and algorithms in the language that best suits your analysis and audience.</p>


<!-- -->

</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2026,
  author = {Panda, Sir and Rafi, Zad},
  title = {Multi-Language {Code} {Examples}},
  date = {2026-01-06},
  url = {https://lesslikely.com/posts/statistics/code-examples.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2026" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2026). <span>‘Multi-Language Code Examples’</span>.
<a href="https://lesslikely.com/posts/statistics/code-examples.html">https://lesslikely.com/posts/statistics/code-examples.html</a>.
</div></div></section></div> ]]></description>
  <category>statistics</category>
  <category>programming</category>
  <category>tutorial</category>
  <guid>https://lesslikely.com/posts/statistics/code-examples.html</guid>
  <pubDate>Tue, 06 Jan 2026 05:00:00 GMT</pubDate>
</item>
<item>
  <title>Confidence, Posteriors, and the Bootstrap</title>
  <dc:creator>Sir Panda</dc:creator>
  <link>https://lesslikely.com/posts/statistics/bootstrap.html</link>
  <description><![CDATA[ 





<hr>
<section id="the-power-of-the-bootstrap" class="level1">
<h1>The Power of the Bootstrap</h1>
<hr>
<p>The bootstrap<span class="citation" data-cites="Efron_1979 coxStatisticalThinking21st2017"><sup>1, 2</sup></span> is an incredibly powerful method of approximation. Indeed, frequentists are even able to approximate posterior distributions using it, In an excerpt from the paper below, Efron describes how these procedures are similar and gives examples using the parametric bootstrap.</p>
<hr>
<blockquote class="blockquote">
<p>The point of this brief note is to say that in some situations the bootstrap, in particular the parametric bootstrap, offers an easier path toward the calculation of Bayes posterior distributions. An important but somewhat under-appreciated article by Newton and Raftery (1994) made the same point using nonparametric bootstrapping. By “going parametric,” we can illustrate more explicitly the bootstrap/MCMC connection. The arguments here will be made mainly in terms of a simple example, with no attempt at the mathematical justifications seen in Newton and Raftery.</p>
<p>It is not really surprising that the bootstrap and MCMC share some overlapping territory. Both are general-purpose computer-based algorithmic methods for assessing statistical accuracy, and both enable the statistician to deal effectively with nuisance parameters, obtaining inferences for the interesting part of the problem. On the less salubrious side, both share the tendency of general-purpose algorithms toward overuse.</p>
<p>Of course the two methodologies operate in competing inferential realms: frequentist for the bootstrap, Bayesian for MCMC. Here, as in Newton and Raftery, we leap over that divide, bringing bootstrap calculations to bear on the Bayesian world. The working assumption is that we have a Bayesian prior in mind and the only question is how to compute its posterior distribution. Arguments about the merits of Bayesian versus frequentist analysis will not be taken up here, except for our main point that the two camps share some common ground.</p>
</blockquote>
<hr>
<p>However, they can not only approximate posterior distributions, but confidence distributions too. Confidence distributions are an incredibly dense and technical topic and is practically an umbrella term to refer to multiple concepts, for example, they can refer to confidence curves, confidence densities and deviance functions. For a definitive source to learn more about what they are, see the following<span class="citation" data-cites="coleSurprise2020 brownAssociationAntenatalExposure2017"><sup>3, 4</sup></span></p>
<hr>
<p>In a paper prepared for Efron’s Fisher lecture, he writes that confidence distributions may provide the key to syncretism between frequentist and bayesian motivations:</p>
<hr>
<blockquote class="blockquote">
<p>Fiducial distributions, or confidence densities, of- fer a way to finesse this difficulty. A good argument can be made that the confidence density is the posterior density for the parameter of interest, after all of the nuisance parameters have been integrated out in an objective way. If this argument turns out to be valid, then our progress in constructing approximate confidence intervals, and approximate confidence densities, could lead to an easier use of Bayesian thinking in practical problems. This is all quite speculative, but here is a safe prediction for the 21st century: statisticians will be asked to solve bigger and more complicated prob- lems. I believe that there is a good chance that objective Bayes methods will be developed for such problems, and that something like fiducial infer- ence will play an important role in this develop- ment. Maybe Fisher’s biggest blunder will become a big hit in the 21st century!</p>
</blockquote>
<hr>
<p>Indeed, some authors have shown that the bootstrap distribution is equal to the confidence distribution because it meets the definition of a confidence distribution.<span class="citation" data-cites="efronFisher21stCentury1998 efronAutomaticConstructionBootstrap2018 xieConfidenceDistributionFrequentist2013"><sup>5–7</sup></span>. Some have even referred to posteriors as a quick and dirty approximation to confidence distributions.<span class="citation" data-cites="fraserBayesPosteriorJust2011"><sup>8</sup></span></p>
<hr>
<pre><code>Properties of Confidence Distributions</code></pre>
<hr>
<p>Xie and Singh, as summarized by Fraser define these properties as:</p>
<hr>
<blockquote class="blockquote">
<p>The first is the classical definition CL and defines the confidence distribution function as the distribution function version of the confidence quantile function <img src="https://latex.codecogs.com/png.latex?%CE%B8"> ̃<img src="https://latex.codecogs.com/png.latex?%CE%B2">, where <img src="https://latex.codecogs.com/png.latex?(%E2%88%92%E2%88%9E,%CE%B8%20%CC%83%CE%B2(y0))"> is a <img src="https://latex.codecogs.com/png.latex?%CE%B2"> level confidence interval.</p>
</blockquote>
<hr>
<blockquote class="blockquote">
<p>The second definition (2.1) identifies a confidence distribution function <img src="https://latex.codecogs.com/png.latex?H(%CE%B8;y)"> as a distribution function in θ for each given y and as a pivot with a uniform distribution for eachθ. But this also closely identifies with what Fisher (1930) offered: fiducial but with Fisher’s promotion replaced by a claim that the argument is pure frequentist. Of course it is pure frequentist just as Fisher (1930) was pure frequentist, except for Fisher’s accompanying claim to having purer probabilities, which was then a direct confrontation to the Bayes aficionados of the time.</p>
</blockquote>
<hr>
<blockquote class="blockquote">
<p>The third definition (2.2) essentially gives just the quantile equivalent say <img src="https://latex.codecogs.com/png.latex?%CE%B8%20%CC%83u(y">) of the distribution function where u is Uniform (0,1). Aren’t confidence quantile and confidence upper bound just different labelling for the same object? Confidence distributions can have many properties: the distribution function should of course be <img src="https://latex.codecogs.com/png.latex?Uniform(0,1)">, but also it should inherit continuity when present in the model, should use all available information, and should generally be sensible. These properties aren’t really addressed in the authors’ proposal. A promotion of confidence distributions should acknowledge these inherent issues and also mention marginal and conditional conflicts as discussed in the literature.</p>
</blockquote>
<hr>
<p>The bootstrap distribution and the asymptotic consonance distribution would be defined as:</p>
<p><img src="https://latex.codecogs.com/png.latex?H_%7Bn%7D(%5Ctheta)=1-P%5Cleft(%5Chat%7B%5Ctheta%7D-%5Chat%7B%5Ctheta%7D%5E%7B*%7D%20%5Cleq%20%5Chat%7B%5Ctheta%7D-%5Ctheta%20%7C%20%5Cmathbf%7Bx%7D%5Cright)=P%5Cleft(%5Chat%7B%5Ctheta%7D%5E%7B*%7D%20%5Cleq%20%5Ctheta%20%7C%20%5Cmathbf%7Bx%7D%5Cright)"></p>
<hr>
<p>Efron writes,</p>
<hr>
<blockquote class="blockquote">
<p>As the authors point out, all of this has something to do with the bootstrap. Let <img src="https://latex.codecogs.com/png.latex?%CE%B8%CB%86%E2%88%97i,i=1,2,...,B"> represent B bootstrap replications ofθˆ, an estimator of parameter θ(possibly in the presence of nuisance parameters). The <img src="https://latex.codecogs.com/png.latex?%CE%B1">-th empirical quantile of the θˆ∗’s is then theupper endpoint of a first-order accurate-levelαconfidence interval. In this sense, the bootstrap distribution is an approximate confidence distribution. The BCa density, Efron &amp; Tibshirani (1998), improves the confidence accuracy by reweighting the <img src="https://latex.codecogs.com/png.latex?B%CE%B8%CB%86%E2%88%97"> values. Let Gˆbe this empirical cdf, and <img src="https://latex.codecogs.com/png.latex?z0"> and a be the bias correction and acceleration constants in my 1987 paper. Rather than equal weights 1/B, the BCa density puts weight proportional to <img src="https://latex.codecogs.com/png.latex?%CF%86(z%CE%B8i/(1+az%CE%B8i)%E2%88%92z0)(1+az%CE%B8i)2%CF%86(z%CE%B8i+z0)%5Bz%CE%B8i=%25%E2%88%921G%CB%86(%CE%B8%CB%86%E2%88%97i)%E2%88%92z0%5Don%CE%B8%CB%86%E2%88%97i">. The reweighted bootstrap distribution then becomes a second-order accurate confidence distribution. Efron (2012) discusses this construction in the context of objective Bayes inference.</p>
</blockquote>
<hr>
<p>Fraser, however, argues that the connection is nothing special</p>
<hr>
<blockquote class="blockquote">
<p>The bootstrap.The bootstrap as in Section 2.3 provides an approximation to the distributions described by a model, and in doing this the bootstrap can also eliminate the influence of nuisance parameters. It can be applied to statistics or to pivots, with faster effect using suitable pivots. It can be used with least squares, or with maximum like lihood statistics, or with statistical quantities, or anywhere where distributions are wanted. Ofcourse confidence calculations are just one such use but there are many others including of course testing. So there is no particular attachment of the bootstrap to confidence distribution functions other than providing an approximate means of calculation for such.</p>
</blockquote>
<hr>
<p>Certain bootstrap methods such as the <code>BCa</code> method and <code>t</code>-bootstrap method also yield second order accuracy of consonance distributions.</p>
<p><img src="https://latex.codecogs.com/png.latex?H_%7Bn%7D(%5Ctheta)=1-P%5Cleft(%5Cfrac%7B%5Chat%7B%5Ctheta%7D%5E%7B*%7D-%5Chat%7B%5Ctheta%7D%7D%7B%5Cwidehat%7BS%20E%7D%5E%7B*%7D%5Cleft(%5Chat%7B%5Ctheta%7D%5E%7B*%7D%5Cright)%7D%20%5Cleq%20%5Cfrac%7B%5Chat%7B%5Ctheta%7D-%5Ctheta%7D%7B%5Cwidehat%7BS%20E%7D(%5Chat%7B%5Ctheta%7D)%7D%20%7C%20%5Cmathbf%7Bx%7D%5Cright)"></p>
<p>Here, I demonstrate how to use these particular bootstrap methods to arrive at consonance curves and densities.</p>
<p>We’ll use the <code>Iris</code> dataset and construct a function that’ll yield a correlation coefficient and we will try to estimate the confidence intervals for them.</p>
<hr>
</section>
<section id="the-nonparametric-bootstrap" class="level1">
<h1>The Nonparametric Bootstrap</h1>
<hr>
<div class="cell" data-layout-align="center">
<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">iris <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> datasets<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>iris</span>
<span id="cb2-2">foo <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>(data, indices) {</span>
<span id="cb2-3">  dt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data[indices, ]</span>
<span id="cb2-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor</span>(dt[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], dt[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], <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;">"p"</span>))</span>
<span id="cb2-5">}</span></code></pre></div></div>
</div>
<hr>
<p>We can now use the <code>curve_boot()</code> method to construct a function. The default method used for this function is the “<code>Bca</code>” method provided by the <a href="https://cran.r-project.org/package=bcaboot"><code>bcaboot</code></a> package (also written by Efron).</p>
<hr>
<p>I will suppress the output of the function because it is unnecessarily long. But we’ve placed all the estimates into a list object called y.</p>
<p>The first item in the list will be the consonance distribution constructed by typical means, while the third item will be the bootstrap approximation to the consonance distribution.</p>
<hr>
<div class="cell" data-layout-align="center">
<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">ggplot2<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;">qplot</span>(boot<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;">boot</span>(iris, foo, <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>t, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"histogram"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_light</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/bootstrap_files/figure-html/unnamed-chunk-5-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
<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;">ggcurve</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> y[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]], <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;">"cd"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nullvalue =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</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;">"red"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_light</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/bootstrap_files/figure-html/unnamed-chunk-5-2.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>We can also print out a table for TeX documents</p>
<hr>
<div class="cell" data-layout-align="center">
<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;">ztable</span>(gg <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;">curve_table</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> y[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]]))</span></code></pre></div></div>
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: left; color: rgba(119, 119, 119, 255) !important;"></th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Lower Limit</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Upper Limit</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Interval Width</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Interval Level (%)</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">CDF</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">P-value</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">S-value (bits)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">2500</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.14</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.10</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.05</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">25.0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.62</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.75</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.42</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">5000</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.17</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.07</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.10</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">50.0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.75</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.50</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">7500</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.20</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.03</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.17</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">75.0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.88</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.25</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.00</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">8000</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.21</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.19</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">80.0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.90</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.20</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.32</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">8500</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.22</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.22</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">85.0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.92</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.15</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.74</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">9000</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.24</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.25</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">90.0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.95</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.10</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">3.32</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">9500</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.26</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.03</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.29</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">95.0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.98</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.05</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">4.32</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">9750</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.28</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.05</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.33</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">97.5</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.99</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.03</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">5.32</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">9900</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.30</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.38</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">99.0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">6.64</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<p>More bootstrap replications will lead to a smoother function. But for now, we can compare these two functions to see how similar they are.</p>
<hr>
<div class="cell" data-layout-align="center">
<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">result <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;">curve_from_se</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">estimate =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mean"</span>)</span>
<span id="cb6-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggcurve</span>(result[[<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;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nullvalue =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/bootstrap_files/figure-html/unnamed-chunk-7-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="576"></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>
<span id="cb7-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Odds ratio with SE (on log scale internally)</span></span>
<span id="cb7-3">result <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;">curve_from_se</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">estimate =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ratio"</span>)</span>
<span id="cb7-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 0.133</span></span>
<span id="cb7-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggcurve</span>(result[[<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;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nullvalue =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/bootstrap_files/figure-html/unnamed-chunk-7-2.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="576"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>If we wanted to look at the bootstrap standard errors, we could do so by loading the fifth item in the list</p>
<hr>
<hr>
<p>where in the top row, <code>theta</code> is the point estimate, and <code>sdboot</code> is the bootstrap estimate of the standard error, <code>sdjack</code> is the jacknife estimate of the standard error. <code>z0</code> is the bias correction value and <code>a</code> is the acceleration constant.</p>
<p>The values in the second row are essentially the internal standard errors of the estimates in the top row.</p>
<hr>
<p>One can also construct the confidence density, here I provide an example from the pvaluefunction R package The consonance curve and density are nearly identical. With more bootstrap replications, they are very likely to converge. [aadland2015ajcn]</p>
<hr>
<div class="cell" data-layout-align="center">
<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>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pvaluefunctions"</span>)</span>
<span id="cb8-2">result <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> bcaboot<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;">bcajack</span>(</span>
<span id="cb8-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> iris, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">B =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">func =</span> foo,</span>
<span id="cb8-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</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="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">99</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;">100</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">verbose =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb8-5">)</span>
<span id="cb8-6"></span>
<span id="cb8-7">bca <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>(result[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lims"</span>]][, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb8-8"></span>
<span id="cb8-9">ggplot2<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;">qplot</span>(bca<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>result...lims......<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"density"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb8-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_less</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/bootstrap_files/figure-html/unnamed-chunk-9-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
</section>
<section id="the-parametric-bootstrap" class="level1">
<h1>The Parametric Bootstrap</h1>
<hr>
<p>For the examples above, we mainly used nonparametric bootstrap methods. Here I show an example using the parametric <code>Bca</code> bootstrap and the results it yields.</p>
<hr>
<div class="cell" data-layout-align="center">
<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;">data</span>(diabetes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">package =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bcaboot"</span>)</span>
<span id="cb9-2">X <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> diabetes<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>x</span>
<span id="cb9-3">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;">scale</span>(diabetes<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">center =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">scale =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb9-4">lm.model <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>(y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> X <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-5">mu.hat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> lm.model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fitted.values</span>
<span id="cb9-6">sigma.hat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats<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;">sd</span>(lm.model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>residuals)</span>
<span id="cb9-7">t0 <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;">summary</span>(lm.model)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>adj.r.squared</span>
<span id="cb9-8">y.star <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;">sapply</span>(mu.hat, rnorm, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd =</span> sigma.hat)</span>
<span id="cb9-9">tt <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;">apply</span>(y.star, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(y) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> X <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="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>adj.r.squared)</span>
<span id="cb9-10">b.star <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> y.star <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%*%</span> X</span></code></pre></div></div>
</div>
<hr>
<p>Now, we’ll use the same function, but set the method to <code>bcapar</code> for the parametric method.</p>
<hr>
<div class="cell" data-layout-align="center">
<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">bcadf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (bcaboot<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;">bcapar</span>(</span>
<span id="cb10-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t0 =</span> t0, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</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="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">99</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;">100</span>),</span>
<span id="cb10-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tt =</span> tt, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bb =</span> b.star, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb10-4">)[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lims"</span>]][, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span></code></pre></div></div>
</div>
<hr>
<p>Now we can look at our outputs.</p>
<hr>
<div class="cell" data-layout-align="center">
<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">ggplot2<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;">qplot</span>((<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unlist</span>(bcadf)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"density"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb11-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_less</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/bootstrap_files/figure-html/unnamed-chunk-12-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>That concludes our demonstration of the bootstrap method to approximate consonance functions.</p>
<hr>
</section>
<section id="references" class="level1">
<h1>References</h1>
<hr>



</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" data-entry-spacing="2" data-line-spacing="2">
<div id="ref-Efron_1979" class="csl-entry">
1. Efron B. (1979). <span>“Bootstrap methods: Another look at the jackknife.”</span> <em>The Annals of Statistics</em>. <strong>7</strong>:1–26. doi: <a href="https://doi.org/10.1214/aos/1176344552">10.1214/aos/1176344552</a>. <a href="https://projecteuclid.org/journals/annals-of-statistics/volume-7/issue-1/Bootstrap-Methods-Another-Look-at-the-Jackknife/10.1214/aos/1176344552.full">https://projecteuclid.org/journals/annals-of-statistics/volume-7/issue-1/Bootstrap-Methods-Another-Look-at-the-Jackknife/10.1214/aos/1176344552.full</a>.
</div>
<div id="ref-coxStatisticalThinking21st2017" class="csl-entry">
2. Cox DR, Efron B. (2017). <span>“Statistical thinking for 21st century scientists.”</span> <em>Science Advances</em>. <strong>3</strong>:e1700768. doi: <a href="https://doi.org/10.1126/sciadv.1700768">10.1126/sciadv.1700768</a>.
</div>
<div id="ref-coleSurprise2020" class="csl-entry">
3. Cole SR, Edwards JK, Greenland S. (2020). <span>“Surprise!”</span> <em>American Journal of Epidemiology</em>. doi: <a href="https://doi.org/10/gg63md">10/gg63md</a>.
</div>
<div id="ref-brownAssociationAntenatalExposure2017" class="csl-entry">
4. Brown HK, Hussain-Shamsy N, Lunsky Y, Dennis C-LE, Vigod SN. (2017). <span>“The association between antenatal exposure to selective serotonin reuptake inhibitors and autism: <span>A</span> systematic review and meta-analysis.”</span> <em>The Journal of Clinical Psychiatry</em>. <strong>78</strong>:e48–e58. doi: <a href="https://doi.org/10.4088/JCP.15r10194">10.4088/JCP.15r10194</a>.
</div>
<div id="ref-efronFisher21stCentury1998" class="csl-entry">
5. Efron B. (1998). <span>“R. <span>A</span>. <span>Fisher</span> in the 21st century (<span>Invited</span> paper presented at the 1996 <span>R</span>. <span>A</span>. <span>Fisher Lecture</span>).”</span> <em>Statistical Science</em>. <strong>13</strong>:95–122. doi: <a href="https://doi.org/10/cxg354">10/cxg354</a>.
</div>
<div id="ref-efronAutomaticConstructionBootstrap2018" class="csl-entry">
6. Efron B, Narasimhan B. (2018). <span>“The automatic construction of bootstrap confidence intervals.”</span> :17.
</div>
<div id="ref-xieConfidenceDistributionFrequentist2013" class="csl-entry">
7. Xie M, Singh K. (2013). <span>“Confidence <span>Distribution</span>, the <span>Frequentist Distribution Estimator</span> of a <span>Parameter</span>: <span>A Review</span>.”</span> <em>International Statistical Review</em>. <strong>81</strong>:3–39. doi: <a href="https://doi.org/10.1111/insr.12000">10.1111/insr.12000</a>.
</div>
<div id="ref-fraserBayesPosteriorJust2011" class="csl-entry">
8. Fraser DaS. (2011). <span>“Is <span>Bayes Posterior</span> just <span>Quick</span> and <span>Dirty Confidence</span>?”</span> <em>Statistical Science</em>. <strong>26</strong>:299–316. doi: <a href="https://doi.org/10/df4n7n">10/df4n7n</a>.
</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2025,
  author = {Panda, Sir},
  title = {Confidence, {Posteriors,} and the {Bootstrap}},
  date = {2025-01-12},
  url = {https://lesslikely.com/posts/statistics/bootstrap.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2025" class="csl-entry quarto-appendix-citeas">
1. Panda S. (2025). <span>‘Confidence, Posteriors, and the
Bootstrap’</span>. <a href="https://lesslikely.com/posts/statistics/bootstrap.html">https://lesslikely.com/posts/statistics/bootstrap.html</a>.
</div></div></section></div> ]]></description>
  <category>statistics</category>
  <guid>https://lesslikely.com/posts/statistics/bootstrap.html</guid>
  <pubDate>Sun, 12 Jan 2025 05:00:00 GMT</pubDate>
  <media:content url="https://raw.githubusercontent.com/stan-dev/logos/master/logo.png" medium="image" type="image/png"/>
</item>
<item>
  <title>Your Models Are Neither Useful Nor Approximate</title>
  <dc:creator>Sir Panda</dc:creator>
  <link>https://lesslikely.com/posts/statistics/assumptions.html</link>
  <description><![CDATA[ 





<hr>
<blockquote class="blockquote">
<p><em>If the assumptions of a model are not derived from theory, and if predictions are not tested against reality, then deductions from the model must be quite shaky. However, without the model, the data cannot be used to answer the research question.</em> <strong><em>Indeed, the research hypothesis may not really be translatable into an empirical claim except as a statement about nominal significance levels of coefficients in a model.</em></strong> - <a href="https://www.jstor.org/stable/270939">David Freedman</a>, 1991</p>
</blockquote>
<hr>
<section id="statistical-models-as-approximations" class="level1">
<h1>Statistical Models as Approximations</h1>
<hr>
<p>Scientific inference is a highly complex process often accompanied by numerical outputs from statistical models. To some, such outputs are not convincing as they believe that anyone can lie with numbers, but the reality is that it is a lot easier to lie without them, making them crucial because if deployed correctly, they may be close approximations to reality. The presence of a statistical model can allow others to view an answer to a complex question from a numerical standpoint that many may be able to verify.</p>
<hr>
<p><img src="https://lesslikely.com/images/approximation.png" class="img-fluid"></p>
<hr>
<p>Unfortunately, there are rampant issues in the building, reporting, and interpretation of such statistical models, and such issues can lead to devastating policies. We have elsewhere reviewed proposals to reform terminology and improve interpretations of conventional statistics by emphasizing logical and information concepts over probability concepts (1–3), as the latter has continued to confuse even well-credentialed statisticians familiar with the misinterpretations.</p>
<hr>
</section>
<section id="what-goes-into-a-model" class="level1">
<h1>What Goes into a Model?</h1>
<hr>
<p>We here focus on how common descriptions of statistical outputs can be technically accurate yet still mislead when there is considerable uncertainty about what are known as background or auxiliary assumptions. Such uncertainty is typical in many contexts, where assumptions may include both mathematical and methodological ones:</p>
<p>For example, in the popular regression book by Gelman, the following assumptions are given for regression models in decreasing order of importance:</p>
<hr>
<ul>
<li>validity</li>
</ul>
<hr>
<ul>
<li>additivity and linearity</li>
</ul>
<hr>
<ul>
<li>independence of errors</li>
</ul>
<hr>
<ul>
<li>equal variance of errors</li>
</ul>
<hr>
<ul>
<li>normality of errors</li>
</ul>
<hr>
<p>This is typical to see in many regression modeling books, but important methodological assumptions underlying the model are rarely discussed such as:</p>
<hr>
<ul>
<li>patient outcomes are independent</li>
</ul>
<hr>
<ul>
<li>interactions and trends follow the regression model used for analysis (e.g., linear or logistic)</li>
</ul>
<hr>
<ul>
<li>no uncontrolled confounding</li>
</ul>
<hr>
<ul>
<li>subject-selection bias</li>
</ul>
<hr>
<ul>
<li>measurement error</li>
</ul>
<hr>
<ul>
<li>sparse-data bias</li>
</ul>
<hr>
<ul>
<li>no selective reporting of results* based on their P-values, interval estimates, or any other output – or if there is such selection, any bias it could produce has been adjusted for (or blocked) in the computation and presentation of the final results.</li>
</ul>
<hr>
<figure class="figure">
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1605000180/Site/pvalueassumptions.svg" alt="P-value assumptions" width="800" style="cursor: zoom-in" class="figure-img"></p>
<figcaption>
Conditional versus unconditional interpretations of P-values, S-values, and compatibility intervals (CIs). (A) Conditional interpretation, in which background model assumptions, such as no systematic error, are assumed to be correct; thus,the information provided by the P-value and S-value is targeted towards the test hypothesis. (B)Unconditional interpretation, in which no aspect of the statistical model is assumed to be correct; thus,the information provided by the P-value and S-value is targeted toward the entire test model.
</figcaption>
</figure>
<hr>
<p>In addition to these general statistical and methodological assumptions, many assume that the statistical model being fit is answering a proper scientific question that has been translated into a statistical one, with assumptions that match or approximate reality. When there is a disconnect between the scientific question and the statistical one being answered by the model, the analyst is committing a type-III error, and will produce statistical outputs with of little use, unless the assumption violations of the chosen and reported are interrogated/varied and considered in the overall analysis.</p>
<p>Many are not aware of what a type-III error is due to the focus on type-I and type-II errors. I paste the following definition from the APA dictionary, which I found myself agreeing with:</p>
<hr>
<blockquote class="blockquote">
<p>Type-III Error: the error that occurs when there is a discrepancy between the research focus and the hypothesis actually tested. For example, a Type III error would have happened if a researcher collected data on individual differences within a sample and determined the causes of variation but the question of interest concerned differences between populations. In other words, a Type III error involves providing the right answer for the wrong question. Also called Type 0 error.</p>
</blockquote>
<hr>
</section>
<section id="violation-of-assumptions" class="level1">
<h1>Violation of Assumptions</h1>
<hr>
<p>Misleading interpretations arise because the descriptions of such statistical outputs are conditional on such assumptions (i.e., they treat them as given/being true), and so do not factor uncertainty regarding the assumptions into their assessments. While various risk-assessment methods can incorporate additional sources in quantified uncertainties, such methods demand considerably more skilled user input than do conventional regression methods (5–9) and still do not account for unquantified sources of uncertainty. We thus present a more direct and nontechnical approach based on logic and associated language to honor assumption uncertainty, called deconditioning.</p>
<p>For example, suppose that a model assumes independence, a common assumption in many statistical models, but this violated due to the presence of a correlation, this will lead to P-values that are invalid, demonstrable by their failure to achieve asymptotic uniformity.</p>
<p>For example, a model that is approximately correct will generate P-values that are asymptotically uniform (a characteristic used to assess the validity of P-values)</p>
<hr>
<div class="cell" data-layout-align="center">
<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="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @title Simulation of valid P-values where test hypothesis is true</span></span>
<span id="cb1-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param X The first variable we are simulating</span></span>
<span id="cb1-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param Y The second variable we are simulating</span></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param n.sim # The number of simulations</span></span>
<span id="cb1-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param t The object storing the t-test results</span></span>
<span id="cb1-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param t.sim # Empty numeric vector to contain values</span></span>
<span id="cb1-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param n.samp # Sample size in each group</span></span>
<span id="cb1-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @NOTE The null hypothesis does not have to be 0, it can be any value.</span></span>
<span id="cb1-9"></span>
<span id="cb1-10">n.sim <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;">10000</span></span>
<span id="cb1-11">t.sim <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;">numeric</span>(n.sim)</span>
<span id="cb1-12">n.samp <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;">1000</span></span>
<span id="cb1-13"></span>
<span id="cb1-14"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <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>n.sim) {</span>
<span id="cb1-15">  X <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.samp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb1-16">  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.samp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb1-17">  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;">data.frame</span>(X, Y)</span>
<span id="cb1-18">  t <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;">t.test</span>(X, Y,</span>
<span id="cb1-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mu =</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;">paired =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb1-20">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">var.equal =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> df)</span>
<span id="cb1-21">  t.sim[i] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> t[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]]}</span></code></pre></div></div>
</div>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/assumptions_files/figure-html/unnamed-chunk-5-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<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="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @title Simulation of invalid P-values where test hypothesis is false</span></span>
<span id="cb2-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param n_simulations # The number of simulations</span></span>
<span id="cb2-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param p_values The object storing the t-test results</span></span>
<span id="cb2-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param p_value_data # Empty numeric vector to contain values</span></span>
<span id="cb2-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param n_subjects # Sample size in each group</span></span>
<span id="cb2-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param correlation # correlation to violate independence</span></span>
<span id="cb2-7"></span>
<span id="cb2-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(MASS)</span>
<span id="cb2-9">n_simulations <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;">1000</span></span>
<span id="cb2-10">n_subjects <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;">50</span></span>
<span id="cb2-11">correlation <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span></span>
<span id="cb2-12"></span>
<span id="cb2-13">generate_correlated_data <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>(n_subjects, correlation) {</span>
<span id="cb2-14">    Sigma <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;">matrix</span>(correlation, n_subjects, n_subjects) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-15">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diag</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> correlation, n_subjects)</span>
<span id="cb2-16">    data <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;">mvrnorm</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mu =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, n_subjects),</span>
<span id="cb2-17">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sigma =</span> Sigma)</span>
<span id="cb2-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(data)</span>
<span id="cb2-19">}</span>
<span id="cb2-20">run_simulation <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>(n_subjects, correlation) {</span>
<span id="cb2-21">    data <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;">generate_correlated_data</span>(n_subjects, correlation)</span>
<span id="cb2-22">    t_test_result <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;">t.test</span>(data[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, ], data[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, ])</span>
<span id="cb2-23">    t_test_p_value <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> t_test_result<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value</span>
<span id="cb2-24">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(t_test_p_value)</span>
<span id="cb2-25">}</span>
<span id="cb2-26">p_values <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;">replicate</span>(n_simulations, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">run_simulation</span>(n_subjects,</span>
<span id="cb2-27">    correlation))</span>
<span id="cb2-28">p_value_data <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;">PValue =</span> p_values)</span></code></pre></div></div>
</div>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/assumptions_files/figure-html/unnamed-chunk-7-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>Deconditioning shifts the logical status of assumptions in the description of results from what is assumed as given (conditioned on) to an integral part of what is being checked by common statistics. This shift makes clear that the results might be explained by violations of background assumptions rather than, or in addition to, failure of a targeted hypothesis. Such deconditioning does not change calculations; hence it does not change any P-value, interval estimate, or posterior distribution. Instead, it provides a different interpretation of these statistics, one arising naturally in thorough contextual discussions, but which deserves more emphasis in basic statistical practice, including teaching and presentations.</p>
<p>In philosophical accounts of theory testing, it is well recognized that an apparent violations of a hypothesis may instead be due to violation of background or auxiliary assumptions (10–13). Among these assumptions are researcher competence and integrity in the conduct and reporting of statistical analyses which have come under scrutiny in the “replication crisis”) as well as common statistical assumptions such as linearity, outcome independence, and effect homogeneity, and methodological assumptions such as no uncontrolled confounding or selection bias. Perhaps because of this generality, we have found that our recommendation to decondition inferences (present inferences using an unconditional interpretation) (1,3) is often difficult for statistically sophisticated readers to comprehend or accept, and is even resisted, misunderstood, and misrepresented by some reviewers</p>


</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@misc{panda2024,
  author = {Panda, Sir and Panda, Sir},
  title = {Your {Models} {Are} {Neither} {Useful} {Nor} {Approximate}},
  date = {2024-01-01},
  url = {https://lesslikely.com/posts/statistics/assumptions},
  langid = {en},
  abstract = {A discussion about models and the assumptions that
    underlie them.}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2024" class="csl-entry quarto-appendix-citeas">
1. Panda S, Panda S. (2024). <span>‘Your Models Are Neither Useful Nor
Approximate’</span>. Less Likely. <a href="https://lesslikely.com/posts/statistics/assumptions">https://lesslikely.com/posts/statistics/assumptions</a>.
</div></div></section></div> ]]></description>
  <category>statistics</category>
  <guid>https://lesslikely.com/posts/statistics/assumptions.html</guid>
  <pubDate>Mon, 01 Jan 2024 05:00:00 GMT</pubDate>
  <media:content url="https://lesslikely.com/images/approximation.png" medium="image" type="image/png" height="89" width="144"/>
</item>
<item>
  <title>Using Stata: Producing Consonance Functions</title>
  <dc:creator>Sir Panda</dc:creator>
  <link>https://lesslikely.com/posts/statistics/stata.html</link>
  <description><![CDATA[ 





<hr>
<p>Although <code>concurve</code> was originally designed to be used in <code>R</code>, it is possible to achieve very similar results in <code>Stata</code>. We can use some datasets that are built into <code>Stata</code> to show how to achieve this. I’ll use the <code>Statamarkdown</code> R package so that I can obtain Stata outputs using RMarkdown via my Stata 16 package.</p>
<p>First, let’s load the <em>auto2</em> dataset which contains data about cars and their characteristics.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb1-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sysuse</span> auto2</span>
<span id="cb1-2">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb1-3">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb1-4">#&gt; </span>
<span id="cb1-5">#&gt; </span>
<span id="cb1-6">#&gt; (1978 automobile <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">data</span>)</span></code></pre></div></div>
</div>
<hr>
<p>Browse the data set in your data browser to get more familiar with some of the variables. Let’s say we’re interested in the relationship between miles per gallon and price. We could fit a very simple linear model to assess that relationship.</p>
<p>First, let’s visualize the data with a scatter plot.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb2-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sysuse</span> auto2</span>
<span id="cb2-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">scatter</span> price mpg, mcolor(<span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">dkorange</span>) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">scale</span>(0.70)</span>
<span id="cb2-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">graph</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">export</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"scatter.svg"</span>, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span></span>
<span id="cb2-4">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb2-5">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb2-6">#&gt; </span>
<span id="cb2-7">#&gt; </span>
<span id="cb2-8">#&gt; (1978 automobile <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">data</span>)</span>
<span id="cb2-9">#&gt; </span>
<span id="cb2-10">#&gt; </span>
<span id="cb2-11">#&gt; file <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">scatter</span>.svg saved <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">as</span> SVG <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">format</span></span></code></pre></div></div>
</div>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/scatter.svg" style="width:150.0%;height:150.0%" class="figure-img"></p>
<figcaption>scatter</figcaption>
</figure>
</div>
<p>That’s what our data looks like. Clearly there seems to be an inverse relationship between miles per gallon and price.</p>
<p>Now we could fit a very simple linear model with miles per gallon being the predictor and price being the outcome and get some estimates of the relationship.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb3-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sysuse</span> auto2</span>
<span id="cb3-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">regress</span> price mpg</span>
<span id="cb3-3">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb3-4">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb3-5">#&gt; </span>
<span id="cb3-6">#&gt; </span>
<span id="cb3-7">#&gt; (1978 automobile <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">data</span>)</span>
<span id="cb3-8">#&gt; </span>
<span id="cb3-9">#&gt; </span>
<span id="cb3-10">#&gt;       Source |       SS           df       MS      Number <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">of</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">obs</span>   =        74</span>
<span id="cb3-11">#&gt; -------------+----------------------------------   <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">F</span>(1, 72)        =     20.26</span>
<span id="cb3-12">#&gt;        Model |   139449474         1   139449474   Prob &gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">F</span>        =    0.0000</span>
<span id="cb3-13">#&gt;     Residual |   495615923        72  6883554.48   R-squared       =    0.2196</span>
<span id="cb3-14">#&gt; -------------+----------------------------------   Adj R-squared   =    0.2087</span>
<span id="cb3-15">#&gt;        Total |   635065396        73  8699525.97   Root MSE        =    2623.7</span>
<span id="cb3-16">#&gt; </span>
<span id="cb3-17">#&gt; ------------------------------------------------------------------------------</span>
<span id="cb3-18">#&gt;        price | Coefficient  Std. err.      t    P&gt;|t|     [95% conf. interval]</span>
<span id="cb3-19">#&gt; -------------+----------------------------------------------------------------</span>
<span id="cb3-20">#&gt;          mpg |  -238.8943   53.07669    -4.50   0.000    -344.7008   -133.0879</span>
<span id="cb3-21">#&gt;        <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">_cons</span> |   11253.06   1170.813     9.61   0.000     8919.088    13587.03</span>
<span id="cb3-22">#&gt; ------------------------------------------------------------------------------</span></code></pre></div></div>
</div>
<hr>
<p>That’s what our output looks like.</p>
<p>Our output also gives us 95% consonance (confidence) intervals by default. But suppose we wished to fit a fractional polynomial model and graph it and get the confidence bands, here’s what we would do.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb4-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sysuse</span> auto2</span>
<span id="cb4-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">mfp</span>: <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">glm</span> price mpg</span>
<span id="cb4-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">twoway</span> (fpfitci price mpg, estcmd(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">glm</span>) fcolor(<span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">dkorange</span>%20) alcolor(%40))  || <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">scatter</span> price mpg, mcolor(<span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">dkorange</span>) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">scale</span>(0.75)</span>
<span id="cb4-4"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">graph</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">export</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mfp.svg"</span>, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span></span>
<span id="cb4-5">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb4-6">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb4-7">#&gt; </span>
<span id="cb4-8">#&gt; </span>
<span id="cb4-9">#&gt; (1978 automobile <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">data</span>)</span>
<span id="cb4-10">#&gt; </span>
<span id="cb4-11">#&gt; </span>
<span id="cb4-12">#&gt; Deviance <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">model</span> with <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">all</span> terms untransformed = 1373.079, 74 observations</span>
<span id="cb4-13">#&gt; </span>
<span id="cb4-14">#&gt; Variable     Model (vs.)   Deviance  Dev <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>.   P      Powers   (vs.)</span>
<span id="cb4-15">#&gt; ----------------------------------------------------------------------</span>
<span id="cb4-16">#&gt; mpg          Lin.   FP2    1373.079    19.565  0.000+   1         -2 -2</span>
<span id="cb4-17">#&gt;              FP1           1356.927     3.413  0.182    -2        </span>
<span id="cb4-18">#&gt;              Final         1356.927                     -2</span>
<span id="cb4-19">#&gt; </span>
<span id="cb4-20">#&gt; </span>
<span id="cb4-21">#&gt; Transformations <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">of</span> covariates:</span>
<span id="cb4-22">#&gt; </span>
<span id="cb4-23">#&gt; -&gt; <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">gen</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">double</span> Impg__1 = X^-2-.2204707671 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">e</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sample</span>) </span>
<span id="cb4-24">#&gt;    (where: X = mpg/10)</span>
<span id="cb4-25">#&gt; </span>
<span id="cb4-26">#&gt; Final multivariable fractional polynomial <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">model</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> price</span>
<span id="cb4-27">#&gt; --------------------------------------------------------------------</span>
<span id="cb4-28">#&gt;     Variable |    -----Initial-----          -----Final-----</span>
<span id="cb4-29">#&gt;              |   df     Select   Alpha    Status    df    Powers</span>
<span id="cb4-30">#&gt; -------------+------------------------------------------------------</span>
<span id="cb4-31">#&gt;          mpg |    4     1.0000   0.0500     <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span>      2     -2</span>
<span id="cb4-32">#&gt; --------------------------------------------------------------------</span>
<span id="cb4-33">#&gt; </span>
<span id="cb4-34">#&gt; Generalized linear models                         Number <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">of</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">obs</span>   =         74</span>
<span id="cb4-35">#&gt; Optimization     : ML                             Residual df     =         72</span>
<span id="cb4-36">#&gt;                                                   Scale parameter =    5533697</span>
<span id="cb4-37">#&gt; Deviance         =  398426217.4                   (1/df) Deviance =    5533697</span>
<span id="cb4-38">#&gt; Pearson          =  398426217.4                   (1/df) Pearson  =    5533697</span>
<span id="cb4-39">#&gt; </span>
<span id="cb4-40">#&gt; Variance <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>: <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">V</span>(u) = 1                       [Gaussian]</span>
<span id="cb4-41">#&gt; Link <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>    : g(u) = u                       [Identity]</span>
<span id="cb4-42">#&gt; </span>
<span id="cb4-43">#&gt;                                                   AIC             =    18.3909</span>
<span id="cb4-44">#&gt; Log likelihood   = -678.4632599                   BIC             =   3.98e+08</span>
<span id="cb4-45">#&gt; </span>
<span id="cb4-46">#&gt; ------------------------------------------------------------------------------</span>
<span id="cb4-47">#&gt;              |                 OIM</span>
<span id="cb4-48">#&gt;        price | Coefficient  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">std</span>. err.      z    P&gt;|z|     [95% conf. interval]</span>
<span id="cb4-49">#&gt; -------------+----------------------------------------------------------------</span>
<span id="cb4-50">#&gt;      Impg__1 |   13163.85   2013.016     6.54   0.000      9218.41    17109.29</span>
<span id="cb4-51">#&gt;        <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">_cons</span> |   5538.395   289.7737    19.11   0.000     4970.449    6106.341</span>
<span id="cb4-52">#&gt; ------------------------------------------------------------------------------</span>
<span id="cb4-53">#&gt; Deviance = 1356.927.</span>
<span id="cb4-54">#&gt; </span>
<span id="cb4-55">#&gt; </span>
<span id="cb4-56">#&gt; file <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">mfp</span>.svg saved <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">as</span> SVG <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">format</span></span></code></pre></div></div>
</div>
<hr>
<p>That’s what our model looks graphed.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/mfp.svg" style="width:150.0%;height:150.0%" class="figure-img"></p>
<figcaption>fractional polynomial model</figcaption>
</figure>
</div>
<p>Now suppose we got a single estimate (point or interval) for a parameter, and we wanted all the intervals for it at every level.</p>
<p>Here’s the code that we’ll be using to achieve that in Stata.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<pre><code>#&gt; Can not set Stata directory, try using -statapath()- option
#&gt; r(601);
#&gt; 
#&gt; 
#&gt; (1978 automobile data)
#&gt; 
#&gt; 
#&gt; N Clusters: 8
#&gt; Stata dir:  /Applications/StataNow/StataMP.app/Contents/MacOS/StataMP
#&gt; 
#&gt; -initialize- invalid parallel subcommand (help parallel)
#&gt; r(198);
#&gt; 
#&gt; r(198);</code></pre>
</div>
<hr>
<p>That’s a lot and may seem intimidating at first, but I’ll explain it line by line.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb6-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">postfile</span> topost <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">level</span> pvalue svalue lointerval upinterval <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> my_new_data, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span></span>
<span id="cb6-2">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb6-3">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span></code></pre></div></div>
</div>
<hr>
<p>“<strong>postfile</strong>” is the command that will be responsible for pasting the data from our overall loop into a new dataset. Here, we are telling <code>Stata</code> that the internal <code>Stata</code> memory used to hold these results (the post) will be named “<strong>topost</strong>” and that it will have five variables, “<strong>level</strong>”, “<strong>pvalue</strong>”, “<strong>svalue</strong>”, “<strong>lointerval</strong>”, and “<strong>upinterval</strong>.”</p>
<ul>
<li><p>“<strong>level</strong>” will contain the consonance level that corresponds to the limits of the interval, with “<strong>lointerval</strong>” being the lower bound of the interval and “<strong>upinterval</strong>” being the upper bound.</p></li>
<li><p>“<strong>pvalue</strong>”is computed by taking 1 - “<strong>level</strong>”, which is alpha.</p></li>
<li><p>“<strong>svalue</strong>”is computed by taking the <img src="https://latex.codecogs.com/png.latex?-log_%7B2%7D"> of the computed P-value, and this column will be used to plot the surprisal function.</p></li>
<li><p>“<strong>my_new_data</strong>” is the filename that we’ve assigned to our new dataset.</p></li>
<li><p>“<strong>replace</strong>” indicates that if there is an existing filename that already exists, we’re willing to relace it.</p></li>
</ul>
<p>Here are the next few major lines</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<pre><code>#&gt; Can not set Stata directory, try using -statapath()- option
#&gt; r(601);
#&gt; 
#&gt; 
#&gt;   6.         }
#&gt; no variables defined
#&gt; r(111);
#&gt; 
#&gt; r(111);</code></pre>
</div>
<hr>
<p>The command “<strong>forvalues</strong>” is responsible for taking a set of numbers that we provide it, and running the contents within the braces through those numbers. So here, we’ve set the local macro “<strong>i</strong>” to contain numbers between 10 and 99.99 for our consonance levels. Why 10? <code>Stata</code> cannot compute consonance intervals lower than 10%.</p>
<p>Our next line contains the actual contents of what we want to do. Here, it says that we will run a simple linear regression where mpg is the predictor and where price is the outcome, and that the outputs for each loop will be suppressed, hence the “<strong>quiet</strong>.”</p>
<p>Then, we have the command “<strong>level</strong>” with the local macro “<strong>i</strong>” inside of it. As you may already know, “<strong>level</strong>” dictates the consonance level that <code>Stata</code> provides us. By default, this is set to 95%, but here, we’ve set it “<strong>i</strong>”, which we established via “<strong>forvalues</strong>” as being set to numbers between 10 and 99.</p>
<p>The next line two lines</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<pre><code>#&gt; Can not set Stata directory, try using -statapath()- option
#&gt; r(601);</code></pre>
</div>
<hr>
<p>indicate that we will take variables of a certain class r(), (this class contains the interval bounds we need) and place them within a matrix called E. Then we will list the contents of this matrix.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb9-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">post</span> topost (<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`i'</span>) (1-<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`i'</span>/100) ( <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ln</span>(1-<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`i'</span>/100)/<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ln</span>(2) * -1) (E[5,1]) (E[6,1])</span>
<span id="cb9-2">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb9-3">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb9-4">#&gt; </span>
<span id="cb9-5">#&gt; </span>
<span id="cb9-6">#&gt; <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">post</span> topost <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> found</span>
<span id="cb9-7">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(111);</span>
<span id="cb9-8">#&gt; </span>
<span id="cb9-9">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(111);</span></code></pre></div></div>
</div>
<hr>
<p>From the contents of this matrix list, we will take the estimates from the <em>fifth</em> and <em>sixth</em> rows (look at the last two paranthesis of this line of code above and then the image below) in the <em>first</em> column which contain our consonance limits, with the fifth row containing the lower bound of the interval and the sixth containing the upper bound.</p>
<figure class="figure">
<p><img src="https://lesslikely.com/images/matrix.png" width="700" style="cursor: zoom-in" class="figure-img"></p>
<figcaption>
Trace plot of imputed datasets.
</figcaption>
</figure>
<figure class="figure">
<p><img src="https://lesslikely.com/images/matrix.png" width="700" style="cursor: zoom-in" class="figure-img"></p>
<figcaption>
Trace plot of imputed datasets.
</figcaption>
</figure>
<p><img src="https://lesslikely.com/images/matrix.png" style="width:150.0%;height:150.0%"></p>
<p>We will place the contents from the fifth row into the second variable we set originally for our new dataset, which was “<strong>lointerval</strong>.” The contents of the sixth row will be placed into “<strong>upinterval</strong>.”</p>
<p>All potential values of “<strong>i</strong>” (10-99) will be placed into the first variable that we set, “<strong>level</strong>”. From this first variable, we can compute the second variable we set up, which was “<strong>Pvalue</strong>” and we’ve done that here by subtracting “<strong>level</strong>” from 1 and then dividing the whole equation by 100, so that our P-value can be on the proper scale. Our third variable, which is the longest, computes the “<strong>Svalue</strong>” by using the previous variable, the “<strong>Pvalue</strong>” and taking the <img src="https://latex.codecogs.com/png.latex?-log_%7B2%7D"> of it.</p>
<p>The relationships between the variables on this line and the variables we set up in the very first line are dictated by the order of the commands we have set, and therefore they correspond to the same order.</p>
<p>“post topost” is writing the results from each loop as new observations in this data structure.</p>
<p>With that, our loop has concluded, and we can now tell <code>Stata</code> that “post” is no longer needed</p>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb10-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">postclose</span> topost</span>
<span id="cb10-2">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb10-3">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb10-4">#&gt; </span>
<span id="cb10-5">#&gt; </span>
<span id="cb10-6">#&gt; <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">post</span> topost <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> found</span>
<span id="cb10-7">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(111);</span>
<span id="cb10-8">#&gt; </span>
<span id="cb10-9">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(111);</span></code></pre></div></div>
</div>
<p>We then tell <code>Stata</code> to clear its memory to make room for the new dataset we just created and we can list the contents of this new dataset.</p>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb11-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">use</span> my_new_data, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">clear</span></span>
<span id="cb11-2"><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">list</span></span>
<span id="cb11-3">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb11-4">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span></code></pre></div></div>
</div>
<p>Now we have an actual dataset with all the consonance intervals at all the levels we wanted, ranging from 10% all the way up to 99%.</p>
<p>In order to get a function, we’ll need to be able to graph these results, and that can be tricky since for each observation we have one y value (the consonance level), and two x values, the lower bound of the interval and the upper bound of the interval.</p>
<p>So a typical scatterplot will not work, since <code>Stata</code> will only accept one x value. To bypass this, we’ll have to use a paired-coordinate scatterplot which will allow us to plot two different y variables and two different x variables.</p>
<p>Of course, we don’t need two y variables, so we can set both options to the variable “<strong>level</strong>”, and then we can set our first x variable to “<strong>lointerval</strong>” and the second x variable to “<strong>upinterval</strong>.”</p>
<p>This can all be done with the following commands, which will also allow us to set the title and subtitle of the graph, along with the titles of the axes.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb12-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">twoway</span> (pcscatter <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">level</span> lointerval <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">level</span> upinterval), <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">///</span></span>
<span id="cb12-2"><span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">ytitle</span>(Consonance Level (%)) <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">xtitle</span>(Consonance Limits) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">///</span></span>
<span id="cb12-3"><span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">title</span>(Consonance Curve) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">///</span></span>
<span id="cb12-4"><span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">subtitle</span>(A <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> comprised <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">of</span> several consonance intervals <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">at</span> various <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">levels</span>.)</span>
<span id="cb12-5">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb12-6">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb12-7">#&gt; </span>
<span id="cb12-8">#&gt; </span>
<span id="cb12-9">#&gt; <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">variable</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">level</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> found</span>
<span id="cb12-10">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(111);</span>
<span id="cb12-11">#&gt; </span>
<span id="cb12-12">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(111);</span></code></pre></div></div>
</div>
<hr>
<p>However, I would recommend using the menu to customize the plots as much as possible. Simply go to the <strong>Graphics</strong> menu and select <strong>Twoway Graphs</strong>. Then create a new plot definition, and select the <strong>Advanced plots</strong> and choose a paired coordinate scatterplot and fill in the y variables, both of which will be “<strong>levels</strong>” and the x variables, which will be “<strong>lointerval</strong>” and “<strong>upinterval</strong>”.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-20-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img"></p>
</figure>
</div>
<p>So now, here’s what our confidence/consonance function looks like.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb13-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">clear</span></span>
<span id="cb13-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sysuse</span> auto2</span>
<span id="cb13-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">postfile</span> topost <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">level</span> pvalue svalue lointerval upinterval <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> my_new_data, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span></span>
<span id="cb13-4"></span>
<span id="cb13-5"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">forvalues</span> i = 10/99.9 {</span>
<span id="cb13-6">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">quietly</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">regress</span> price <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">weight</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">level</span>(<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`i'</span>)</span>
<span id="cb13-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span> E = <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">table</span>)</span>
<span id="cb13-8">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">quietly</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">list</span> E</span>
<span id="cb13-9">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">post</span> topost (<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`i'</span>) (1-<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`i'</span>/100) ( <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ln</span>(1-<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`i'</span>/100)/<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ln</span>(2) * -1) (E[5,1]) (E[6,1])</span>
<span id="cb13-10">    }</span>
<span id="cb13-11"></span>
<span id="cb13-12"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">postclose</span> topost</span>
<span id="cb13-13"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">use</span> my_new_data, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">clear</span></span>
<span id="cb13-14"></span>
<span id="cb13-15"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">twoway</span> (pcscatter pvalue lointerval pvalue upinterval, mcolor(<span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">maroon</span>)), <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">ytitle</span>(Consonance Level (%)) <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">xtitle</span>(Consonance Limits) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">scale</span>(0.75) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">///</span></span>
<span id="cb13-16"><span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">title</span>(Consonance Curve) <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">subtitle</span>(A <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> comprised <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">of</span> several consonance intervals <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">at</span> various <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">levels</span>.)</span>
<span id="cb13-17"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">graph</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">export</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"confidence.svg"</span>, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span></span>
<span id="cb13-18">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb13-19">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb13-20">#&gt; </span>
<span id="cb13-21">#&gt; </span>
<span id="cb13-22">#&gt; </span>
<span id="cb13-23">#&gt; (1978 automobile <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">data</span>)</span>
<span id="cb13-24">#&gt; </span>
<span id="cb13-25">#&gt; </span>
<span id="cb13-26">#&gt;   6.     }</span>
<span id="cb13-27">#&gt; </span>
<span id="cb13-28">#&gt; </span>
<span id="cb13-29">#&gt; </span>
<span id="cb13-30">#&gt; </span>
<span id="cb13-31">#&gt; file confidence.svg saved <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">as</span> SVG <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">format</span></span></code></pre></div></div>
</div>
<hr>
<p><img src="https://lesslikely.com/images/confidence.svg" class="img-fluid"></p>
<hr>
<p>Pretty neat, eh? And below is what our surprisal function looks like, which is simply the <img src="https://latex.codecogs.com/png.latex?-%5Clog_%7B2%7D">(<em>p</em>) transformation of the observed P-value. For a more comprehensive discussion on surprisals, <a href="">see this page</a> and check out some of the references at the bottom.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb14-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">clear</span></span>
<span id="cb14-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sysuse</span> auto2</span>
<span id="cb14-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">postfile</span> topost <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">level</span> pvalue svalue lointerval upinterval <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> my_new_data, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span></span>
<span id="cb14-4"></span>
<span id="cb14-5"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">forvalues</span> i = 10/99.9 {</span>
<span id="cb14-6">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">quietly</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">regress</span> price <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">weight</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">level</span>(<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`i'</span>)</span>
<span id="cb14-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span> E = <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">table</span>)</span>
<span id="cb14-8">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">quietly</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">list</span> E</span>
<span id="cb14-9">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">post</span> topost (<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`i'</span>) (1-<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`i'</span>/100) ( <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ln</span>(1-<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`i'</span>/100)/<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ln</span>(2) * -1) (E[5,1]) (E[6,1])</span>
<span id="cb14-10">    }</span>
<span id="cb14-11"></span>
<span id="cb14-12"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">postclose</span> topost</span>
<span id="cb14-13"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">use</span> my_new_data, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">clear</span></span>
<span id="cb14-14"></span>
<span id="cb14-15"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">twoway</span> (pcscatter svalue lointerval svalue upinterval, mcolor(<span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">maroon</span>)), <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">ytitle</span>(Consonance Level (%)) <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">xtitle</span>(Consonance Limits)  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">scale</span>( 0.75) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">///</span></span>
<span id="cb14-16"><span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">title</span>(Surprisal Curve) <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">subtitle</span>(A <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> comprised <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">of</span> several consonance intervals <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">at</span> various <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">levels</span>.)</span>
<span id="cb14-17"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">graph</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">export</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"surprisal.svg"</span>, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span></span>
<span id="cb14-18">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb14-19">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb14-20">#&gt; </span>
<span id="cb14-21">#&gt; </span>
<span id="cb14-22">#&gt; </span>
<span id="cb14-23">#&gt; (1978 automobile <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">data</span>)</span>
<span id="cb14-24">#&gt; </span>
<span id="cb14-25">#&gt; </span>
<span id="cb14-26">#&gt;   6.     }</span>
<span id="cb14-27">#&gt; </span>
<span id="cb14-28">#&gt; </span>
<span id="cb14-29">#&gt; </span>
<span id="cb14-30">#&gt; </span>
<span id="cb14-31">#&gt; file surprisal.svg saved <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">as</span> SVG <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">format</span></span></code></pre></div></div>
</div>
<hr>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://stat.lesslikely.com/concurve/articles/surprisal.svg" style="width:150.0%;height:150.0%" class="figure-img"></p>
<figcaption>Surprisal Function</figcaption>
</figure>
</div>
<hr>
<p>It’s clear that in both plots, we’re missing values of intervals with a confidence/consonance level of less than 10%, but unfortunately, this is the best <code>Stata</code> can do, and what we’ll have to work with. It may not look as pretty as an output from <code>R</code>, but it’s far more useful than blankly staring at a 95% interval and thinking that it is the only piece of information we have regarding compatibility of different effect estimates.</p>
<p>The code that I have pasted above can be used for most commands in <code>Stata</code> that have an option to calculate a consonance level. Thus, if there’s an option for “<strong>level</strong>”, then the commands above will work to produce a data set of several consonance intervals. Though I am seriously hoping that a Stata expert will see this post and point out how I am wrong.</p>
<p>Now, suppose we wished to fit a generalized linear model, here’s what our code would look like.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<pre><code>#&gt; Can not set Stata directory, try using -statapath()- option
#&gt; r(601);
#&gt; 
#&gt; 
#&gt; 
#&gt; (1978 automobile data)
#&gt; 
#&gt; 
#&gt;   6.     }
#&gt; 
#&gt; 
#&gt; 
#&gt; 
#&gt;      +---------------------------------------------------+
#&gt;      | level   pvalue     svalue   lointer~l   upinter~l |
#&gt;      |---------------------------------------------------|
#&gt;   1. |    10       .9   .1520031    -245.564   -232.2247 |
#&gt;   2. |    11      .89   .1681228   -246.2351   -231.5536 |
#&gt;   3. |    12      .88   .1844246   -246.9073   -230.8814 |
#&gt;   4. |    13      .87   .2009127   -247.5808   -230.2079 |
#&gt;   5. |    14      .86   .2175914   -248.2557    -229.533 |
#&gt;      |---------------------------------------------------|
#&gt;   6. |    15      .85   .2344653   -248.9321   -228.8566 |
#&gt;   7. |    16      .84   .2515388   -249.6102   -228.1785 |
#&gt;   8. |    17      .83   .2688168     -250.29   -227.4987 |
#&gt;   9. |    18      .82   .2863042   -250.9717    -226.817 |
#&gt;  10. |    19      .81   .3040062   -251.6554   -226.1333 |
#&gt;      |---------------------------------------------------|
#&gt;  11. |    20       .8   .3219281   -252.3412   -225.4475 |
#&gt;  12. |    21      .79   .3400754   -253.0292   -224.7595 |
#&gt;  13. |    22      .78    .358454   -253.7197    -224.069 |
#&gt;  14. |    23      .77   .3770697   -254.4126   -223.3761 |
#&gt;  15. |    24      .76   .3959287   -255.1083   -222.6804 |
#&gt;      |---------------------------------------------------|
#&gt;  16. |    25      .75   .4150375   -255.8067    -221.982 |
#&gt;  17. |    26      .74   .4344028    -256.508   -221.2807 |
#&gt;  18. |    27      .73   .4540316   -257.2125   -220.5762 |
#&gt;  19. |    28      .72   .4739312   -257.9202   -219.8685 |
#&gt;  20. |    29      .71   .4941091   -258.6312   -219.1575 |
#&gt;      |---------------------------------------------------|
#&gt;  21. |    30       .7   .5145732   -259.3459   -218.4428 |
#&gt;  22. |    31      .69   .5353317   -260.0642   -217.7244 |
#&gt;  23. |    32      .68   .5563933   -260.7865   -217.0022 |
#&gt;  24. |    33      .67    .577767   -261.5129   -216.2758 |
#&gt;  25. |    34      .66   .5994621   -262.2435   -215.5452 |
#&gt;      |---------------------------------------------------|
#&gt;  26. |    35      .65   .6214884   -262.9785   -214.8102 |
#&gt;  27. |    36      .64   .6438562   -263.7183   -214.0704 |
#&gt;  28. |    37      .63   .6665763   -264.4628   -213.3259 |
#&gt;  29. |    38      .62   .6896599   -265.2124   -212.5762 |
#&gt;  30. |    39      .61   .7131189   -265.9673   -211.8213 |
#&gt;      |---------------------------------------------------|
#&gt;  31. |    40       .6   .7369656   -266.7278   -211.0609 |
#&gt;  32. |    41      .59   .7612131    -267.494   -210.2947 |
#&gt;  33. |    42      .58   .7858752   -268.2662   -209.5225 |
#&gt;  34. |    43      .57   .8109662   -269.0446    -208.744 |
#&gt;  35. |    44      .56   .8365012   -269.8297    -207.959 |
#&gt;      |---------------------------------------------------|
#&gt;  36. |    45      .55   .8624965   -270.6215   -207.1672 |
#&gt;  37. |    46      .54   .8889687   -271.4204   -206.3683 |
#&gt;  38. |    47      .53   .9159358   -272.2268   -205.5619 |
#&gt;  39. |    48      .52   .9434165    -273.041   -204.7477 |
#&gt;  40. |    49      .51   .9714308   -273.8633   -203.9254 |
#&gt;      |---------------------------------------------------|
#&gt;  41. |    50       .5          1    -274.694   -203.0947 |
#&gt;  42. |    51      .49   1.029146   -275.5337    -202.255 |
#&gt;  43. |    52      .48   1.058894   -276.3825   -201.4061 |
#&gt;  44. |    53      .47   1.089267   -277.2411   -200.5475 |
#&gt;  45. |    54      .46   1.120294   -278.1099   -199.6788 |
#&gt;      |---------------------------------------------------|
#&gt;  46. |    55      .45   1.152003   -278.9893   -198.7994 |
#&gt;  47. |    56      .44   1.184425   -279.8798   -197.9089 |
#&gt;  48. |    57      .43   1.217591    -280.782   -197.0067 |
#&gt;  49. |    58      .42   1.251539   -281.6965   -196.0922 |
#&gt;  50. |    59      .41   1.286304   -282.6239   -195.1648 |
#&gt;      |---------------------------------------------------|
#&gt;  51. |    60       .4   1.321928   -283.5648   -194.2239 |
#&gt;  52. |    61      .39   1.358454     -284.52   -193.2687 |
#&gt;  53. |    62      .38   1.395929   -285.4902   -192.2985 |
#&gt;  54. |    63      .37   1.434403   -286.4762   -191.3125 |
#&gt;  55. |    64      .36   1.473931   -287.4789   -190.3098 |
#&gt;      |---------------------------------------------------|
#&gt;  56. |    65      .35   1.514573   -288.4992   -189.2894 |
#&gt;  57. |    66      .34   1.556393   -289.5383   -188.2504 |
#&gt;  58. |    67      .33   1.599462   -290.5971   -187.1916 |
#&gt;  59. |    68      .32   1.643856   -291.6769   -186.1118 |
#&gt;  60. |    69      .31    1.68966    -292.779   -185.0097 |
#&gt;      |---------------------------------------------------|
#&gt;  61. |    70       .3   1.736966   -293.9048   -183.8839 |
#&gt;  62. |    71      .29   1.785875   -295.0559   -182.7328 |
#&gt;  63. |    72      .28   1.836501   -296.2341   -181.5546 |
#&gt;  64. |    73      .27   1.888969   -297.4413   -180.3474 |
#&gt;  65. |    74      .26   1.943416   -298.6794   -179.1092 |
#&gt;      |---------------------------------------------------|
#&gt;  66. |    75      .25          2   -299.9511   -177.8376 |
#&gt;  67. |    76      .24   2.058894   -301.2588   -176.5299 |
#&gt;  68. |    77      .23   2.120294   -302.6054   -175.1833 |
#&gt;  69. |    78      .22   2.184425   -303.9944   -173.7943 |
#&gt;  70. |    79      .21   2.251539   -305.4294   -172.3592 |
#&gt;      |---------------------------------------------------|
#&gt;  71. |    80       .2   2.321928   -306.9149   -170.8738 |
#&gt;  72. |    81      .19   2.395929   -308.4555   -169.3331 |
#&gt;  73. |    82      .18   2.473931   -310.0572   -167.7315 |
#&gt;  74. |    83      .17   2.556393   -311.7264   -166.0623 |
#&gt;  75. |    84      .16   2.643856   -313.4709   -164.3178 |
#&gt;      |---------------------------------------------------|
#&gt;  76. |    85      .15   2.736966   -315.2999   -162.4888 |
#&gt;  77. |    86      .14   2.836501   -317.2245   -160.5642 |
#&gt;  78. |    87      .13   2.943416   -319.2578   -158.5308 |
#&gt;  79. |    88      .12   3.058894   -321.4166   -156.3721 |
#&gt;  80. |    89      .11   3.184425   -323.7211   -154.0676 |
#&gt;      |---------------------------------------------------|
#&gt;  81. |    90       .1   3.321928   -326.1977    -151.591 |
#&gt;  82. |    91      .09   3.473931   -328.8804   -148.9082 |
#&gt;  83. |    92      .08   3.643856    -331.815   -145.9737 |
#&gt;  84. |    93      .07   3.836501   -335.0646   -142.7241 |
#&gt;  85. |    94      .06   4.058894   -338.7206   -139.0681 |
#&gt;      |---------------------------------------------------|
#&gt;  86. |    95      .05   4.321928   -342.9227    -134.866 |
#&gt;  87. |    96      .04   4.643856   -347.9005   -129.8882 |
#&gt;  88. |    97      .03   5.058894   -354.0756   -123.7131 |
#&gt;  89. |    98      .02   5.643856   -362.3692   -115.4195 |
#&gt;  90. |    99      .01   6.643856   -375.6108   -102.1779 |
#&gt;      +---------------------------------------------------+
#&gt; 
#&gt; 
#&gt; command ytitle is unrecognized
#&gt; r(199);
#&gt; 
#&gt; r(199);</code></pre>
</div>
<hr>
<p>We simply replace the first line within the loop with our intended command, just as I’ve replaced</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb16-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">regress</span> price mpg</span>
<span id="cb16-2">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb16-3">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb16-4">#&gt; </span>
<span id="cb16-5">#&gt; </span>
<span id="cb16-6">#&gt; no variables defined</span>
<span id="cb16-7">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(111);</span>
<span id="cb16-8">#&gt; </span>
<span id="cb16-9">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(111);</span></code></pre></div></div>
</div>
<hr>
<p>with</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb17-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">glm</span> price mpg</span>
<span id="cb17-2">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb17-3">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb17-4">#&gt; </span>
<span id="cb17-5">#&gt; </span>
<span id="cb17-6">#&gt; <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">variable</span> price <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> found</span>
<span id="cb17-7">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(111);</span>
<span id="cb17-8">#&gt; </span>
<span id="cb17-9">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(111);</span></code></pre></div></div>
</div>
<hr>
<p>If we wanted fit something more complex, like a multilevel mixed model that used restricted maximum likelihood, here’s what our code would look like:</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<pre><code>#&gt; Can not set Stata directory, try using -statapath()- option
#&gt; r(601);
#&gt; 
#&gt; 
#&gt; 
#&gt; (1978 automobile data)
#&gt; 
#&gt; 
#&gt;   6.     }
#&gt; variable outcome not found
#&gt; r(111);
#&gt; 
#&gt; r(111);</code></pre>
</div>
<hr>
<p>Basically, our code doesn’t really change that much and with only a few lines of it, we are able to produce graphical tools that can better help us interpret the wide range of effect sizes that are compatible with the model and its assumptions.</p>
<hr>
<section id="using-the-cifunction-command-for-confidence-interval-functions" class="level2">
<h2 class="anchored" data-anchor-id="using-the-cifunction-command-for-confidence-interval-functions">Using the <code>cifunction</code> Command for Confidence Interval Functions</h2>
<p>An alternative approach to producing confidence interval functions in Stata is to use the <code>cifunction</code> command, which computes and graphically displays all possible confidence intervals around a point estimate.</p>
<p>The <code>cifunction</code> command is an immediate command that allows you to specify a point estimate and standard error, and it will produce a confidence interval function (also called a confidence curve, P-value function, or consonance interval).</p>
<section id="syntax" class="level3">
<h3 class="anchored" data-anchor-id="syntax">Syntax</h3>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb19-1">cifunction #b , se(#) [ df(#) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">eform</span> figure[(twoway_options)] <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">saving</span>(filename, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span>) ]</span></code></pre></div></div>
<p>Where <code>#b</code> can be specified as a coefficient or exponentiated value (e.g., OR, HR, IRR).</p>
</section>
<section id="options" class="level3">
<h3 class="anchored" data-anchor-id="options">Options</h3>
<ul>
<li><strong>se(#)</strong>: specifies the standard error of the estimate (required)</li>
<li><strong>df(#)</strong>: specify the degrees of freedom if #b is t-distributed</li>
<li><strong>eform</strong>: indicate that the coefficient is exponentiated (e.g., OR, RR, IRR)</li>
<li><strong>figure[(twoway_options)]</strong>: produces a confidence interval function plot</li>
<li><strong>saving(filename, replace)</strong>: save results to filename</li>
</ul>
</section>
<section id="example-1-simple-risk-ratio" class="level3">
<h3 class="anchored" data-anchor-id="example-1-simple-risk-ratio">Example 1: Simple Risk Ratio</h3>
<p>Reproduce a confidence interval function for a risk ratio of 2.0 with p-value of 0.05. First, we use <code>getregstats</code> to get the standard error:</p>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb20-1">getregstats 2.0, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">p</span>(0.05) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mod</span>(rr)</span>
<span id="cb20-2">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb20-3">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb20-4">#&gt; </span>
<span id="cb20-5">#&gt; </span>
<span id="cb20-6">#&gt; </span>
<span id="cb20-7">#&gt; </span>
<span id="cb20-8">#&gt; ------------------------------------------------------------------------------</span>
<span id="cb20-9">#&gt;              | Risk Ratio   Std. Err.      z    P&gt;|z|     [95% Conf. Interval]</span>
<span id="cb20-10">#&gt; -------------+----------------------------------------------------------------</span>
<span id="cb20-11">#&gt;    Estimates |          2    .707306    -1.96   0.050            1           4</span>
<span id="cb20-12">#&gt; ------------------------------------------------------------------------------</span></code></pre></div></div>
</div>
<p>Then use <code>cifunction</code> specifying the point estimate and standard error. We modify the figure to improve presentation:</p>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb21-1">cifunction 2.0, se(.707306) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">eform</span> fig(<span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">xscale</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>) xlab(0.5 1 2 5 10) <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">xtitle</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Risk Ratio (Log Scale)"</span>))</span>
<span id="cb21-2">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb21-3">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span></code></pre></div></div>
</div>
</section>
<section id="example-2-multiple-rate-ratios-by-age-group" class="level3">
<h3 class="anchored" data-anchor-id="example-2-multiple-rate-ratios-by-age-group">Example 2: Multiple Rate Ratios by Age Group</h3>
<p>For multiple estimates across age groups from the <code>dollhill3</code> dataset:</p>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb22-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">webuse</span> dollhill3, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">clear</span></span>
<span id="cb22-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">poisson</span> deaths smokes <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> agecat==1, exposure(pyears) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">irr</span></span>
<span id="cb22-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">poisson</span> deaths smokes <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> agecat==2, exposure(pyears) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">irr</span></span>
<span id="cb22-4"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">poisson</span> deaths smokes <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> agecat==3, exposure(pyears) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">irr</span></span>
<span id="cb22-5"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">poisson</span> deaths smokes <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> agecat==4, exposure(pyears) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">irr</span></span>
<span id="cb22-6">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb22-7">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb22-8">#&gt; </span>
<span id="cb22-9">#&gt; </span>
<span id="cb22-10">#&gt; (Doll and Hill (1966))</span>
<span id="cb22-11">#&gt; </span>
<span id="cb22-12">#&gt; </span>
<span id="cb22-13">#&gt; Iteration 0:  Log likelihood = -4.0705386  </span>
<span id="cb22-14">#&gt; Iteration 1:  Log likelihood = -3.9613823  </span>
<span id="cb22-15">#&gt; Iteration 2:  Log likelihood = -3.9612634  </span>
<span id="cb22-16">#&gt; Iteration 3:  Log likelihood = -3.9612634  </span>
<span id="cb22-17">#&gt; </span>
<span id="cb22-18">#&gt; Poisson regression                                      Number <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">of</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">obs</span> =      2</span>
<span id="cb22-19">#&gt;                                                         LR <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">chi2</span>(1)    =   9.73</span>
<span id="cb22-20">#&gt;                                                         Prob &gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">chi2</span>   = 0.0018</span>
<span id="cb22-21">#&gt; Log likelihood = -3.9612634                             Pseudo R2     = 0.5511</span>
<span id="cb22-22">#&gt; </span>
<span id="cb22-23">#&gt; ------------------------------------------------------------------------------</span>
<span id="cb22-24">#&gt;       deaths |        IRR   Std. err.      z    P&gt;|z|     [95% conf. interval]</span>
<span id="cb22-25">#&gt; -------------+----------------------------------------------------------------</span>
<span id="cb22-26">#&gt;       smokes |   5.736638   4.181258     2.40   0.017     1.374811    23.93712</span>
<span id="cb22-27">#&gt;        <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">_cons</span> |   .0001064   .0000753   -12.94   0.000     .0000266    .0004256</span>
<span id="cb22-28">#&gt;   <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ln</span>(pyears) |          1  (exposure)</span>
<span id="cb22-29">#&gt; ------------------------------------------------------------------------------</span>
<span id="cb22-30">#&gt; Note: <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">_cons</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">estimates</span> baseline incidence rate.</span>
<span id="cb22-31">#&gt; </span>
<span id="cb22-32">#&gt; </span>
<span id="cb22-33">#&gt; Iteration 0:  Log likelihood = -5.4793565  </span>
<span id="cb22-34">#&gt; Iteration 1:  Log likelihood = -5.4104407  </span>
<span id="cb22-35">#&gt; Iteration 2:  Log likelihood =   -5.41027  </span>
<span id="cb22-36">#&gt; Iteration 3:  Log likelihood =   -5.41027  </span>
<span id="cb22-37">#&gt; </span>
<span id="cb22-38">#&gt; Poisson regression                                      Number <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">of</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">obs</span> =      2</span>
<span id="cb22-39">#&gt;                                                         LR <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">chi2</span>(1)    =   7.59</span>
<span id="cb22-40">#&gt;                                                         Prob &gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">chi2</span>   = 0.0059</span>
<span id="cb22-41">#&gt; Log likelihood = -5.41027                               Pseudo R2     = 0.4123</span>
<span id="cb22-42">#&gt; </span>
<span id="cb22-43">#&gt; ------------------------------------------------------------------------------</span>
<span id="cb22-44">#&gt;       deaths |        IRR   Std. err.      z    P&gt;|z|     [95% conf. interval]</span>
<span id="cb22-45">#&gt; -------------+----------------------------------------------------------------</span>
<span id="cb22-46">#&gt;       smokes |   2.138812   .6520701     2.49   0.013     1.176691    3.887609</span>
<span id="cb22-47">#&gt;        <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">_cons</span> |   .0011243   .0003246   -23.52   0.000     .0006385    .0019798</span>
<span id="cb22-48">#&gt;   <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ln</span>(pyears) |          1  (exposure)</span>
<span id="cb22-49">#&gt; ------------------------------------------------------------------------------</span>
<span id="cb22-50">#&gt; Note: <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">_cons</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">estimates</span> baseline incidence rate.</span>
<span id="cb22-51">#&gt; </span>
<span id="cb22-52">#&gt; </span>
<span id="cb22-53">#&gt; Iteration 0:  Log likelihood = -6.2456963  </span>
<span id="cb22-54">#&gt; Iteration 1:  Log likelihood = -6.1713863  </span>
<span id="cb22-55">#&gt; Iteration 2:  Log likelihood =  -6.171298  </span>
<span id="cb22-56">#&gt; Iteration 3:  Log likelihood =  -6.171298  </span>
<span id="cb22-57">#&gt; </span>
<span id="cb22-58">#&gt; Poisson regression                                      Number <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">of</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">obs</span> =      2</span>
<span id="cb22-59">#&gt;                                                         LR <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">chi2</span>(1)    =   4.01</span>
<span id="cb22-60">#&gt;                                                         Prob &gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">chi2</span>   = 0.0453</span>
<span id="cb22-61">#&gt; Log likelihood = -6.171298                              Pseudo R2     = 0.2450</span>
<span id="cb22-62">#&gt; </span>
<span id="cb22-63">#&gt; ------------------------------------------------------------------------------</span>
<span id="cb22-64">#&gt;       deaths |        IRR   Std. err.      z    P&gt;|z|     [95% conf. interval]</span>
<span id="cb22-65">#&gt; -------------+----------------------------------------------------------------</span>
<span id="cb22-66">#&gt;       smokes |    1.46824    .295728     1.91   0.057     .9893522     2.17893</span>
<span id="cb22-67">#&gt;        <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">_cons</span> |   .0049037   .0009267   -28.14   0.000     .0033858    .0071021</span>
<span id="cb22-68">#&gt;   <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ln</span>(pyears) |          1  (exposure)</span>
<span id="cb22-69">#&gt; ------------------------------------------------------------------------------</span>
<span id="cb22-70">#&gt; Note: <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">_cons</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">estimates</span> baseline incidence rate.</span>
<span id="cb22-71">#&gt; </span>
<span id="cb22-72">#&gt; </span>
<span id="cb22-73">#&gt; Iteration 0:  Log likelihood = -6.1640322  </span>
<span id="cb22-74">#&gt; Iteration 1:  Log likelihood = -6.1203079  </span>
<span id="cb22-75">#&gt; Iteration 2:  Log likelihood = -6.1202768  </span>
<span id="cb22-76">#&gt; Iteration 3:  Log likelihood = -6.1202768  </span>
<span id="cb22-77">#&gt; </span>
<span id="cb22-78">#&gt; Poisson regression                                      Number <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">of</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">obs</span> =      2</span>
<span id="cb22-79">#&gt;                                                         LR <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">chi2</span>(1)    =   2.43</span>
<span id="cb22-80">#&gt;                                                         Prob &gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">chi2</span>   = 0.1189</span>
<span id="cb22-81">#&gt; Log likelihood = -6.1202768                             Pseudo R2     = 0.1658</span>
<span id="cb22-82">#&gt; </span>
<span id="cb22-83">#&gt; ------------------------------------------------------------------------------</span>
<span id="cb22-84">#&gt;       deaths |        IRR   Std. err.      z    P&gt;|z|     [95% conf. interval]</span>
<span id="cb22-85">#&gt; -------------+----------------------------------------------------------------</span>
<span id="cb22-86">#&gt;       smokes |    1.35606   .2748845     1.50   0.133     .9114509    2.017551</span>
<span id="cb22-87">#&gt;        <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">_cons</span> |   .0108317    .002047   -23.95   0.000     .0074789    .0156877</span>
<span id="cb22-88">#&gt;   <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ln</span>(pyears) |          1  (exposure)</span>
<span id="cb22-89">#&gt; ------------------------------------------------------------------------------</span>
<span id="cb22-90">#&gt; Note: <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">_cons</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">estimates</span> baseline incidence rate.</span></code></pre></div></div>
</div>
<p>Then we can use <code>cifunction</code> with multiple estimates:</p>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb23-1">cifunction 5.736638 2.138812 1.46824 1.35606, <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">///</span></span>
<span id="cb23-2">  se(4.181258 .6520701 .295728 .2748845) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">eform</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">///</span></span>
<span id="cb23-3">  fig(<span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">xscale</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">xlabel</span>(.3 .5 1 2 5 10 20 50 100) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">///</span></span>
<span id="cb23-4">      <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">legend</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">label</span>(1 <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"35-44"</span>) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">label</span>(2 <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"45-54"</span>) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">label</span>(3 <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"55-64"</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">///</span></span>
<span id="cb23-5">             <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">label</span>(4 <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"65-74"</span>) <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">title</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Age Group"</span>, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">size</span>(small))) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">///</span></span>
<span id="cb23-6">      <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">xtitle</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rate Ratio (Log Scale)"</span>))</span>
<span id="cb23-7">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb23-8">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span></code></pre></div></div>
</div>
</section>
<section id="example-3-comparing-crude-and-pooled-estimates" class="level3">
<h3 class="anchored" data-anchor-id="example-3-comparing-crude-and-pooled-estimates">Example 3: Comparing Crude and Pooled Estimates</h3>
<p>Using case-control data to compare crude and pooled odds ratios:</p>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<pre><code>#&gt; Can not set Stata directory, try using -statapath()- option
#&gt; r(601);
#&gt; 
#&gt; 
#&gt; 
#&gt;                                                          Proportion
#&gt;                  |   Exposed   Unexposed  |      Total      exposed
#&gt; -----------------+------------------------+------------------------
#&gt;            Cases |        10          36  |         46       0.2174
#&gt;         Controls |         5          40  |         45       0.1111
#&gt; -----------------+------------------------+------------------------
#&gt;            Total |        15          76  |         91       0.1648
#&gt;                  |                        |
#&gt;                  |      Point estimate    |    [95% conf. interval]
#&gt;                  |------------------------+------------------------
#&gt;       Odds ratio |         2.222222       |      .69377    7.118025 (Woolf)
#&gt;  Attr. frac. ex. |              .55       |      -.4414    .8595116 (Woolf)
#&gt;  Attr. frac. pop |         .1195652       |
#&gt;                  +-------------------------------------------------
#&gt;                                chi2(1) =     1.87  Pr&gt;chi2 = 0.1719
#&gt; 
#&gt; 
#&gt;                                                          Proportion
#&gt;                  |   Exposed   Unexposed  |      Total      exposed
#&gt; -----------------+------------------------+------------------------
#&gt;            Cases |        18          78  |         96       0.1875
#&gt;         Controls |         7          86  |         93       0.0753
#&gt; -----------------+------------------------+------------------------
#&gt;            Total |        25         164  |        189       0.1323
#&gt;                  |                        |
#&gt;                  |      Point estimate    |    [95% conf. interval]
#&gt;                  |------------------------+------------------------
#&gt;       Odds ratio |         2.835165       |    1.123936    7.151794 (Woolf)
#&gt;  Attr. frac. ex. |         .6472868       |    .1102698    .8601749 (Woolf)
#&gt;  Attr. frac. pop |         .1213663       |
#&gt;                  +-------------------------------------------------
#&gt;                                chi2(1) =     5.18  Pr&gt;chi2 = 0.0228
#&gt; 
#&gt; 
#&gt; 
#&gt; ------------------------------------------------------------------------------
#&gt;              | Odds Ratio   Std. Err.      z    P&gt;|z|     [95% Conf. Interval]
#&gt; -------------+----------------------------------------------------------------
#&gt;    Estimates |   2.835165   1.338429     2.21   0.027     1.123936    7.151794
#&gt; ------------------------------------------------------------------------------
#&gt; 
#&gt; 
#&gt; 
#&gt; ------------------------------------------------------------------------------
#&gt;              | Odds Ratio   Std. Err.      z    P&gt;|z|     [95% Conf. Interval]
#&gt; -------------+----------------------------------------------------------------
#&gt;    Estimates |   2.222222   1.319891     1.34   0.179     .6937698    7.118025
#&gt; ------------------------------------------------------------------------------</code></pre>
</div>
<p>Then compare them with <code>cifunction</code>:</p>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<pre><code>#&gt; Can not set Stata directory, try using -statapath()- option
#&gt; r(601);</code></pre>
</div>
</section>
<section id="output-from-cifunction" class="level3">
<h3 class="anchored" data-anchor-id="output-from-cifunction">Output from <code>cifunction</code></h3>
<p>The <code>cifunction</code> command produces and stores several variables when the <code>saving()</code> option is specified:</p>
<ul>
<li><strong>cilev</strong>: sequencing range of CIs (from 0 to 99.99)</li>
<li><strong>plev</strong>: sequencing range of P-values (from 0.0001 to 1.0)</li>
<li><strong>sval</strong>: S-values computed for respective plev values</li>
<li><strong>lcl(#)</strong>: computed lower confidence limits</li>
<li><strong>ucl(#)</strong>: computed upper confidence limits</li>
</ul>
</section>
<section id="references-for-cifunction" class="level3">
<h3 class="anchored" data-anchor-id="references-for-cifunction">References for <code>cifunction</code></h3>
<ul>
<li>Birnbaum, A. 1961. Confidence curves: An omnibus technique for estimation and testing statistical hypotheses. <em>Journal of the American Statistical Association</em> 56: 246-249.</li>
<li>Folks, J. F. 1981. Ideas of Statistics. New York: John Wiley &amp; Sons.</li>
<li>Greenland, S. 2019. Valid P-Values Behave Exactly as They Should: Some Misleading Criticisms of P-Values and Their Resolution With S-Values. <em>The American Statistician</em> 73(sup1): 106-114.</li>
<li>Sullivan, K. M., and Foster, D. 1990. Confidence curves versus confidence intervals. <em>American Journal of Public Health</em> 80(4): 452-453.</li>
</ul>
<hr>
</section>
</section>
<section id="cite-r-packages" class="level1">
<h1>Cite R Packages</h1>
<div class="cell" data-layout-align="center" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb26-1">about</span>
<span id="cb26-2">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb26-3">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb26-4">#&gt; </span>
<span id="cb26-5">#&gt; </span>
<span id="cb26-6">#&gt; </span>
<span id="cb26-7">#&gt; StataNow/MP 19.5 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> Mac (Apple Silicon)</span>
<span id="cb26-8">#&gt; Revision 28 Jan 2026</span>
<span id="cb26-9">#&gt; Copyright 1985-2025 StataCorp LLC</span>
<span id="cb26-10">#&gt; </span>
<span id="cb26-11">#&gt; Total physical <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">memory</span>: 48.01 GB</span>
<span id="cb26-12">#&gt; </span>
<span id="cb26-13">#&gt; Stata license: Single-user 2-core , expiring  6 Feb 2027</span>
<span id="cb26-14">#&gt; Serial number: 501909358563</span>
<span id="cb26-15">#&gt;   Licensed to: Zad Rafi</span>
<span id="cb26-16">#&gt;                Hunter</span></code></pre></div></div>
</div>
</section>
<section id="session-info" class="level1">
<h1>Session info</h1>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">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;">sessionInfo</span>()</span>
<span id="cb27-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(si, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">RNG =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">locale =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb27-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; R version 4.5.2 (2025-10-31)</span></span>
<span id="cb27-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Platform: aarch64-apple-darwin20</span></span>
<span id="cb27-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Running under: macOS Tahoe 26.3</span></span>
<span id="cb27-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb27-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Matrix products: default</span></span>
<span id="cb27-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib </span></span>
<span id="cb27-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1</span></span>
<span id="cb27-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb27-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Random number generation:</span></span>
<span id="cb27-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  RNG:     Mersenne-Twister </span></span>
<span id="cb27-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Normal:  Inversion </span></span>
<span id="cb27-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Sample:  Rejection </span></span>
<span id="cb27-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  </span></span>
<span id="cb27-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; locale:</span></span>
<span id="cb27-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] C.UTF-8/C.UTF-8/C.UTF-8/C/C.UTF-8/C.UTF-8</span></span>
<span id="cb27-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb27-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; time zone: America/New_York</span></span>
<span id="cb27-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; tzcode source: internal</span></span>
<span id="cb27-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb27-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attached base packages:</span></span>
<span id="cb27-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1] splines   grid      stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     </span></span>
<span id="cb27-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb27-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; other attached packages:</span></span>
<span id="cb27-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1] cli_3.6.5             texPreview_2.1.0      tinytex_0.58          rmarkdown_2.30        brms_2.23.0          </span></span>
<span id="cb27-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [6] bootImpute_1.3.0      knitr_1.51            boot_1.3-32           gtsummary_2.5.0       reshape2_1.4.5       </span></span>
<span id="cb27-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [11] ProfileLikelihood_1.3 ImputeRobust_1.3-1    gamlss_5.5-0          gamlss.dist_6.1-1     gamlss.data_6.0-7    </span></span>
<span id="cb27-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [16] mvtnorm_1.3-3         performance_0.15.3    summarytools_1.1.5    tidybayes_3.0.7       htmltools_0.5.9      </span></span>
<span id="cb27-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [21] Statamarkdown_0.9.6   car_3.1-3             carData_3.0-6         qqplotr_0.0.7         ggcorrplot_0.1.4.1   </span></span>
<span id="cb27-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [26] mitml_0.4-5           pbmcapply_1.5.1       Amelia_1.8.3          Rcpp_1.1.1            blogdown_1.23        </span></span>
<span id="cb27-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [31] doParallel_1.0.17     iterators_1.0.14      foreach_1.5.2         lattice_0.22-7        bayesplot_1.15.0     </span></span>
<span id="cb27-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [36] wesanderson_0.3.7     VIM_7.0.0             colorspace_2.1-2      here_1.0.2            progress_1.2.3       </span></span>
<span id="cb27-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [41] loo_2.9.0             mi_1.2                Matrix_1.7-4          broom_1.0.12          yardstick_1.3.2      </span></span>
<span id="cb27-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [46] svglite_2.2.2         Cairo_1.7-0           cowplot_1.2.0         mgcv_1.9-4            nlme_3.1-168         </span></span>
<span id="cb27-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [51] xfun_0.56             broom.mixed_0.2.9.6   reticulate_1.44.1     kableExtra_1.4.0      posterior_1.6.1      </span></span>
<span id="cb27-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [56] checkmate_2.3.3       parallelly_1.46.1     miceFast_0.8.5        randomForest_4.7-1.2  missForest_1.6.1     </span></span>
<span id="cb27-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [61] miceadds_3.18-36      quantreg_6.1          SparseM_1.84-2        MCMCpack_1.7-1        MASS_7.3-65          </span></span>
<span id="cb27-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [66] coda_0.19-4.1         latex2exp_0.9.8       rstan_2.32.7          StanHeaders_2.32.10   lubridate_1.9.4      </span></span>
<span id="cb27-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [71] forcats_1.0.1         stringr_1.6.0         dplyr_1.1.4           purrr_1.2.1           readr_2.1.6          </span></span>
<span id="cb27-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [76] tibble_3.3.1          ggplot2_4.0.1         tidyverse_2.0.0       ggtext_0.1.2          concurve_3.0.0       </span></span>
<span id="cb27-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [81] showtext_0.9-7        showtextdb_3.0        sysfonts_0.8.9        future.apply_1.20.1   future_1.69.0        </span></span>
<span id="cb27-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [86] tidyr_1.3.2           magrittr_2.0.4        mice_3.19.0           rms_8.1-0             Hmisc_5.2-5          </span></span>
<span id="cb27-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb27-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; loaded via a namespace (and not attached):</span></span>
<span id="cb27-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   [1] dichromat_2.0-0.1       nnet_7.3-20             TH.data_1.1-5           vctrs_0.7.1             digest_0.6.39          </span></span>
<span id="cb27-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   [6] png_0.1-8               shape_1.4.6.1           proxy_0.4-29            magick_2.9.0            fontLiberation_0.1.0   </span></span>
<span id="cb27-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [11] withr_3.0.2             ggpubr_0.6.2            survival_3.8-6          doRNG_1.8.6.2           emmeans_2.0.1          </span></span>
<span id="cb27-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [16] MatrixModels_0.5-4      systemfonts_1.3.1       ragg_1.5.0              zoo_1.8-15              V8_8.0.1               </span></span>
<span id="cb27-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [21] ggdist_3.3.3            DEoptimR_1.1-4          Formula_1.2-5           prettyunits_1.2.0       rematch2_2.1.2         </span></span>
<span id="cb27-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [26] httr_1.4.7              otel_0.2.0              rstatix_0.7.3           globals_0.19.0          ps_1.9.1               </span></span>
<span id="cb27-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [31] rstudioapi_0.18.0       extremevalues_2.4.1     pan_1.9                 generics_0.1.4          processx_3.8.6         </span></span>
<span id="cb27-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [36] base64enc_0.1-6         curl_7.0.0              mitools_2.4             lgr_0.5.2               desc_1.4.3             </span></span>
<span id="cb27-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [41] xtable_1.8-4            svUnit_1.0.8            pracma_2.4.6            evaluate_1.0.5          hms_1.1.4              </span></span>
<span id="cb27-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [46] glmnet_4.1-10           rcartocolor_2.1.2       lmtest_0.9-40           palmerpenguins_0.1.1    robustbase_0.99-6      </span></span>
<span id="cb27-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [51] matrixStats_1.5.0       svgPanZoom_0.3.4        class_7.3-23            pillar_1.11.1           caTools_1.18.3         </span></span>
<span id="cb27-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [56] compiler_4.5.2          stringi_1.8.7           paradox_1.0.1           jomo_2.7-6              minqa_1.2.8            </span></span>
<span id="cb27-58"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [61] plyr_1.8.9              crayon_1.5.3            abind_1.4-8             metadat_1.4-0           sp_2.2-0               </span></span>
<span id="cb27-59"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [66] mathjaxr_2.0-0          rapportools_1.2         twosamples_2.0.1        sandwich_3.1-1          whisker_0.4.1          </span></span>
<span id="cb27-60"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [71] codetools_0.2-20        multcomp_1.4-29         textshaping_1.0.4       bcaboot_0.2-3           openssl_2.3.4          </span></span>
<span id="cb27-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [76] flextable_0.9.10        QuickJSR_1.9.0          e1071_1.7-17            gridtext_0.1.5          lme4_1.1-38            </span></span>
<span id="cb27-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [81] fs_1.6.6                itertools_0.1-3         listenv_0.10.0          Rdpack_2.6.5            pkgbuild_1.4.8         </span></span>
<span id="cb27-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [86] estimability_1.5.1      ggsignif_0.6.4          callr_3.7.6             tzdb_0.5.0              pkgconfig_2.0.3        </span></span>
<span id="cb27-64"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [91] tools_4.5.2             rbibutils_2.4.1         viridisLite_0.4.2       DBI_1.2.3               numDeriv_2016.8-1.1    </span></span>
<span id="cb27-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [96] fastmap_1.2.0           scales_1.4.0            officer_0.7.3           opdisDownsampling_1.0.1 insight_1.4.5          </span></span>
<span id="cb27-66"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [ reached 'max' / getOption("max.print") -- omitted 64 entries ]</span></span></code></pre></div></div>
</div>


</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@misc{panda2024,
  author = {Panda, Sir},
  title = {Using {Stata:} {Producing} {Consonance} {Functions}},
  date = {2024-01-01},
  url = {https://lesslikely.com/posts/statistics/stata},
  langid = {en},
  abstract = {A simple guide on how to produce consonance functions in
    Stata.}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2024" class="csl-entry quarto-appendix-citeas">
1. Panda S. (2024). <span>‘Using Stata: Producing Consonance
Functions’</span>. Less Likely. <a href="https://lesslikely.com/posts/statistics/stata">https://lesslikely.com/posts/statistics/stata</a>.
</div></div></section></div> ]]></description>
  <category>statistics</category>
  <guid>https://lesslikely.com/posts/statistics/stata.html</guid>
  <pubDate>Mon, 01 Jan 2024 05:00:00 GMT</pubDate>
  <media:content url="https://raw.githubusercontent.com/stan-dev/logos/master/logo.png" medium="image" type="image/png"/>
</item>
<item>
  <title>Simulation of a Two-Group Parallel-Arm RCT with Interim Analyses</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/statistics/interim_analyses.html</link>
  <description><![CDATA[ 





<hr>
<p>Recently <a href="https://twitter.com/ADAlthousePhD">Andrew Althouse</a> informed me that he was going to simulate a two-group parallel-arm randomized trial with interim analyses using the <a href="https://CRAN.R-project.org/package=rpact"><code>rpact</code></a> <code>R</code> package, so I offered to also help in constructing the <code>R</code> code to do so. He already has a number of <code>R</code> scripts on his GitHub repo for doing similar simulations, which can be <a href="https://github.com/aalthous/RCT-Simulation-v1">viewed here</a> and a number of tweets explaining these simulations. For this example, his goal was to simulate a trial where the outcome was binary and the probability of death for each group could be tuned in addition to:</p>
<hr>
<ul>
<li>the total number of participants</li>
</ul>
<hr>
<ul>
<li>the number of interim analyses</li>
</ul>
<hr>
<ul>
<li>the schedule of the interim analyses</li>
</ul>
<hr>
<ul>
<li>the group-sequential design used</li>
</ul>
<hr>
<p>along with the usual trial analysis parameters such as:</p>
<hr>
<ul>
<li>the <img src="https://latex.codecogs.com/png.latex?%5Calpha">-level</li>
</ul>
<hr>
<ul>
<li>the type of test (1-sided vs.&nbsp;2-sided).</li>
</ul>
<hr>
<p>The goal was to be able to produce a table of various statistics such as:</p>
<hr>
<ul>
<li>the odds ratio</li>
</ul>
<hr>
<ul>
<li>the confidence limits</li>
</ul>
<hr>
<ul>
<li>the <img src="https://latex.codecogs.com/png.latex?P">-value</li>
</ul>
<hr>
<ul>
<li>the number of successes</li>
</ul>
<hr>
<p>for each of the interim analyses specified.</p>
<hr>
<p>The function below is a reflection of our efforts to do so, and also returns several plots from the <a href="https://CRAN.R-project.org/package=rpact"><code>rpact</code></a> package for the design that is chosen along with a plot comparing the design to other designs. In order to get similar results, you will need to load the <code>R</code> function first, and then simply enter the proper inputs. While there may be more efficient ways to write the code, for example using <code>lapply()</code> instead of for loops, we have chosen not to do so, and we have also tried to minimize the number of <code>R</code> packages necessary for the function to work but the following will be required:</p>
<hr>
<ul>
<li><a href="https://CRAN.R-project.org/package=rpact"><code>rpact</code></a></li>
</ul>
<hr>
<ul>
<li><a href="https://CRAN.R-project.org/package=stringr"><code>stringr</code></a></li>
</ul>
<hr>
<p>You can quickly install and load both using:</p>
<hr>
<hr>
<section id="setting-up-the-function" class="level1">
<h1>Setting up the Function</h1>
<hr>
<div class="cell" data-layout-align="center">
<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="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @title Simulation of a Two-Group Parallel-Arm Trial With Interim Analyses</span></span>
<span id="cb1-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @docType Custom function for simulation from the rpact package</span></span>
<span id="cb1-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @author Andrew Althouse with edits by Zad Rafi</span></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' </span><span class="al" style="color: #AD0000;
background-color: null;
font-style: inherit;">NOTE</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">: If you want to confirm "type 1 error" under different stopping rules,</span></span>
<span id="cb1-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' make death = in the two treatment arms (e.g. no treatment effect)</span></span>
<span id="cb1-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' </span><span class="al" style="color: #AD0000;
background-color: null;
font-style: inherit;">NOTE</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">: I have set this one up to test the power for a treatment that would reduce mortality</span></span>
<span id="cb1-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' from 40% in control group (1) to 30% in treatment group (2)</span></span>
<span id="cb1-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' </span><span class="al" style="color: #AD0000;
background-color: null;
font-style: inherit;">NOTE</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">: Trial Design Parameters - Part 1</span></span>
<span id="cb1-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' Here we will specify the basics: total N patients to enroll, and death rate for each treatment arm</span></span>
<span id="cb1-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' </span><span class="al" style="color: #AD0000;
background-color: null;
font-style: inherit;">NOTE</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">: Trial Design Parameters - Part 2</span></span>
<span id="cb1-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' Here we will define the interim analysis strategy and stopping rules</span></span>
<span id="cb1-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' For this trial we will include provisions for efficacy stopping only (no pre-specified futility stopping)</span></span>
<span id="cb1-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' We will use the rpact package to compute the stopping/success thresholds at the interim and final analysis</span></span>
<span id="cb1-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' </span><span class="al" style="color: #AD0000;
background-color: null;
font-style: inherit;">NOTE</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">: Required packages: rpact and stringr</span></span>
<span id="cb1-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param nSims # The number of simulations, the default is 1000</span></span>
<span id="cb1-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param nPatients # here is where you specify the planned max number of patients you want included in each RCT</span></span>
<span id="cb1-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param death1 # here is where you specify the event rate for patients receiving 'treatment 1' in these trial</span></span>
<span id="cb1-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param death2 # here is where you specify the event rate for patients receiving 'treatment 2' in these trials</span></span>
<span id="cb1-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param nLooks # here is where you put the number of looks that will take place (INCLUDING the final analysis)</span></span>
<span id="cb1-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param analyses_scheduled # schedule of interim analyses</span></span>
<span id="cb1-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param sided # Whether the test is 1-sided or 2-sided</span></span>
<span id="cb1-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param alpha # Specified alpha level, the default is 0.05</span></span>
<span id="cb1-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param informationRates #</span></span>
<span id="cb1-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param trials # The total number of trials you wish to load in the table results.</span></span>
<span id="cb1-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param typeOfDesign # The type of design.</span></span>
<span id="cb1-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param seed # Argument to set the seed for the simulations</span></span>
<span id="cb1-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @return list of dataframes and plots</span></span>
<span id="cb1-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @example See below this code block</span></span>
<span id="cb1-29">interim_sim <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>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">death1 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">death2 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>,</span>
<span id="cb1-30">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nLooks =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">analyses_scheduled =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.50</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb1-31">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sided =</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;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>,</span>
<span id="cb1-32">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">informationRates =</span> analyses_scheduled,</span>
<span id="cb1-33">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">typeOfDesign =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"asOF"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nSims =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trials =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb1-34">                        <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;">1031</span>) {</span>
<span id="cb1-35"></span>
<span id="cb1-36">efficacy_thresholds <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;">numeric</span>(nLooks)</span>
<span id="cb1-37">design <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;">getDesignGroupSequential</span>(</span>
<span id="cb1-38">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sided =</span> sided, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> alpha,</span>
<span id="cb1-39">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">informationRates =</span> analyses_scheduled,</span>
<span id="cb1-40">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">typeOfDesign =</span> typeOfDesign)</span>
<span id="cb1-41">design_2 <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;">getDesignGroupSequential</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">typeOfDesign =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P"</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pocock</span></span>
<span id="cb1-42">design_3 <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;">getDesignGroupSequential</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">typeOfDesign =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"asP"</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Alpha-spending Pocock</span></span>
<span id="cb1-43">design_4 <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;">getDesignGroupSequential</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">typeOfDesign =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OF"</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># O'Brien-Fleming</span></span>
<span id="cb1-44">designSet <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;">getDesignSet</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">designs =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(design, design_2,</span>
<span id="cb1-45">                                      design_3, design_4),</span>
<span id="cb1-46">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">variedParameters =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"typeOfDesign"</span>)</span>
<span id="cb1-47"></span>
<span id="cb1-48"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">RNGkind</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"L'Ecuyer-CMRG"</span>)</span>
<span id="cb1-49"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(seed)</span>
<span id="cb1-50"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (j <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>nLooks) {</span>
<span id="cb1-51">  efficacy_thresholds[j] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> design<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>stageLevels[j]</span>
<span id="cb1-52">}</span>
<span id="cb1-53"></span>
<span id="cb1-54">analyses_nPatients <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> analyses_scheduled <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> nPatients</span>
<span id="cb1-55">efficacy_thresholds</span>
<span id="cb1-56">pb <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;">txtProgressBar</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">min =</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;">max =</span> nSims, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">initial =</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;">style =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb1-57">trialnum <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;">numeric</span>(nSims)</span>
<span id="cb1-58">or <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="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> nLooks, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> nSims))</span>
<span id="cb1-59">lcl <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="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> nLooks, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> nSims))</span>
<span id="cb1-60">ucl <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="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> nLooks, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> nSims))</span>
<span id="cb1-61">pval <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="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> nLooks, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> nSims))</span>
<span id="cb1-62">success <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="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> nLooks, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> nSims))</span>
<span id="cb1-63"></span>
<span id="cb1-64">strings <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OR_%d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LCL_%d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UCL_%d"</span>,</span>
<span id="cb1-65">             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pval_%d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Success_%d"</span>)</span>
<span id="cb1-66"></span>
<span id="cb1-67"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(or) <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;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OR_%d"</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>nLooks))</span>
<span id="cb1-68"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(lcl) <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;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LCL_%d"</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>nLooks))</span>
<span id="cb1-69"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(ucl) <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;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UCL_%d"</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>nLooks))</span>
<span id="cb1-70"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(pval) <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;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pval_%d"</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>nLooks))</span>
<span id="cb1-71"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(success) <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;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Success_%d"</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>nLooks))</span>
<span id="cb1-72">overall_success <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;">numeric</span>(nSims)</span>
<span id="cb1-73">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;">data.frame</span>(trialnum, or, lcl, ucl,</span>
<span id="cb1-74">                 pval, success, overall_success)</span>
<span id="cb1-75"></span>
<span id="cb1-76"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">RNGkind</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"L'Ecuyer-CMRG"</span>)</span>
<span id="cb1-77"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(seed)</span>
<span id="cb1-78">time <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;">system.time</span>(</span>
<span id="cb1-79"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <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>nSims) {</span>
<span id="cb1-80">  trialnum[i] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> i</span>
<span id="cb1-81">  pid <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;">seq</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, nPatients, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb1-82">  treatment <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;">rep</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;">2</span>, nPatients <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;">2</span>)</span>
<span id="cb1-83">  deathprob <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;">numeric</span>(nPatients)</span>
<span id="cb1-84">  deathprob[treatment <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="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> death1</span>
<span id="cb1-85">  deathprob[treatment <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;">2</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> death2</span>
<span id="cb1-86">  death <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;">rbinom</span>(nPatients, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, deathprob)</span>
<span id="cb1-87">  trialdata <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="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cbind</span>(pid, treatment, death))</span>
<span id="cb1-88"></span>
<span id="cb1-89">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (j <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>nLooks) {</span>
<span id="cb1-90">    analysisdata <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;">subset</span>(trialdata, pid <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> analyses_nPatients[j])</span>
<span id="cb1-91">    model <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;">glm</span>(death <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment,</span>
<span id="cb1-92">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">binomial</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">link =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"logit"</span>),</span>
<span id="cb1-93">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> analysisdata)</span>
<span id="cb1-94">    or[i, j] <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;">exp</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(model)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>coefficients[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb1-95">    lcl[i, j] <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;">exp</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">confint.default</span>((model))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb1-96">    ucl[i, j] <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;">exp</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">confint.default</span>((model))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb1-97">    pval[i, j] <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;">summary</span>(model)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>coefficients[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>]</span>
<span id="cb1-98">    success[i, j] <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>(or[i, j] <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;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> pval[i, j] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> efficacy_thresholds[j], <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;">0</span>)</span>
<span id="cb1-99">  }</span>
<span id="cb1-100">  overall_success[i] <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;">0</span></span>
<span id="cb1-101">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (j <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>nLooks) {</span>
<span id="cb1-102">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (success[i, j] <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-103">      overall_success[i] <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;">1</span></span>
<span id="cb1-104">    }</span>
<span id="cb1-105">  }</span>
<span id="cb1-106">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setTxtProgressBar</span>(pb, i)</span>
<span id="cb1-107">})</span>
<span id="cb1-108"></span>
<span id="cb1-109">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;">data.frame</span>(trialnum, or, lcl, ucl, pval,</span>
<span id="cb1-110">                 success, overall_success)</span>
<span id="cb1-111">simulation_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;">data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vector</span>(),</span>
<span id="cb1-112">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> nPatients, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(df))))</span>
<span id="cb1-113"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(simulation_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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"trialnum"</span>, (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">do.call</span>(</span>
<span id="cb1-114">  rbind,</span>
<span id="cb1-115">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</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;">length</span>(strings),</span>
<span id="cb1-116">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FUN =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(j) {</span>
<span id="cb1-117">      (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">do.call</span>(rbind, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</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>nLooks,</span>
<span id="cb1-118">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FUN =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i) ((<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(strings, i)))</span>
<span id="cb1-119">      )[]))[, j]</span>
<span id="cb1-120">    }</span>
<span id="cb1-121">  )</span>
<span id="cb1-122">)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"overall_success"</span>)</span>
<span id="cb1-123">simulation_results[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(df), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(simulation_results))] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (df[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(</span>
<span id="cb1-124">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(df),</span>
<span id="cb1-125">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(simulation_results)</span>
<span id="cb1-126">)])</span>
<span id="cb1-127">simulation_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;">as.data.frame</span>(simulation_results)</span>
<span id="cb1-128"></span>
<span id="cb1-129">outputs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> simulation_results[, <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;">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;">length</span>(simulation_results))]</span>
<span id="cb1-130"></span>
<span id="cb1-131">cols <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.character</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>nLooks)</span>
<span id="cb1-132">rows <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.character</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;">length</span>(strings))</span>
<span id="cb1-133">interim <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;">matrix</span>(</span>
<span id="cb1-134">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(strings), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> nLooks,</span>
<span id="cb1-135">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dimnames =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>((rows), (cols)),</span>
<span id="cb1-136">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(strings) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> nLooks)))</span>
<span id="cb1-137"></span>
<span id="cb1-138"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> cols) {</span>
<span id="cb1-139">  interim[, i] <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;">str_subset</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(outputs), i)</span>
<span id="cb1-140">}</span>
<span id="cb1-141"></span>
<span id="cb1-142"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(interim) <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;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Interim_Look_%d"</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>nLooks))</span>
<span id="cb1-143"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(simulation_results)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TrialNum"</span>)</span>
<span id="cb1-144"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(simulation_results)[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(simulation_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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Overall_Success"</span>)</span>
<span id="cb1-145">simulation_results_trials <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;">head</span>(simulation_results, trials)</span>
<span id="cb1-146">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="cb1-147">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(design),</span>
<span id="cb1-148">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(time),</span>
<span id="cb1-149">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(design, <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="cb1-150">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_light</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-151">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb1-152">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb1-153">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>)</span>
<span id="cb1-154">    ),</span>
<span id="cb1-155">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(designSet, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</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="cb1-156">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_light</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-157">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb1-158">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb1-159">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>)</span>
<span id="cb1-160">    ),</span>
<span id="cb1-161">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(overall_success),</span>
<span id="cb1-162">  simulation_results_trials)</span>
<span id="cb1-163"></span>
<span id="cb1-164"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(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;">c</span>(</span>
<span id="cb1-165">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Design Summary"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time to complete simulation"</span>,</span>
<span id="cb1-166">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Main Design Plot"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plot of Various Designs"</span>,</span>
<span id="cb1-167">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Table of Overall Success"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Simulation Results"</span>)</span>
<span id="cb1-168"></span>
<span id="cb1-169"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(results)</span>
<span id="cb1-170">}</span></code></pre></div></div>
</div>
<hr>
</section>
<section id="a-simulated-example" class="level1">
<h1>A Simulated Example</h1>
<hr>
<div class="cell" data-layout-align="center">
<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">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;">interim_sim</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nPatients =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">death1 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">death2 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>,</span>
<span id="cb2-2">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nLooks =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">analyses_scheduled =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.50</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb2-3">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sided =</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;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.025</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">typeOfDesign =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"asOF"</span>,</span>
<span id="cb2-4">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">informationRates =</span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.50</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb2-5">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nSims =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trials =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</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;">1031</span>)</span></code></pre></div></div>
</div>
<hr>
<hr>
</section>
<section id="examining-the-results" class="level1">
<h1>Examining the Results</h1>
<div class="cell" data-layout-align="center">
<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">results[<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;">5</span>]</span>
<span id="cb3-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; $`Design Summary`</span></span>
<span id="cb3-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb3-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; $`Time to complete simulation`</span></span>
<span id="cb3-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    user  system elapsed </span></span>
<span id="cb3-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   5.865   0.703   6.744 </span></span>
<span id="cb3-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb3-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; $`Main Design Plot`</span></span>
<span id="cb3-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; NULL</span></span>
<span id="cb3-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb3-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; $`Plot of Various Designs`</span></span>
<span id="cb3-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; NULL</span></span>
<span id="cb3-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb3-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; $`Table of Overall Success`</span></span>
<span id="cb3-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; overall_success</span></span>
<span id="cb3-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0   1 </span></span>
<span id="cb3-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 134 866</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<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>
<span id="cb4-2">table_results <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> results[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>]]</span>
<span id="cb4-3"></span>
<span id="cb4-4">table_results[ , <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</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;">21</span>] <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;">round</span>((table_results[ , <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</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;">21</span>]), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb4-5"></span>
<span id="cb4-6">table_results<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>TrialNum <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;">row.names</span>(table_results)</span>
<span id="cb4-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">row.names</span>(table_results) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb4-8"></span>
<span id="cb4-9"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(table_results)){</span>
<span id="cb4-10">  table_results[,i] <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;">cell_spec</span>(table_results[,i], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#777"</span>)</span>
<span id="cb4-11">}</span>
<span id="cb4-12"></span>
<span id="cb4-13">table_results <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> table_results[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(table_results))]</span></code></pre></div></div>
</div>
<hr>
<p>To examine the results, I used the kableExtra package, though this is not necessary, and simply using the following script will suffice</p>
<hr>
<div class="cell" data-layout-align="center">
<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">table_results <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> results[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>]]</span>
<span id="cb5-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">View</span>(table_results)</span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="lightable-classic caption-top table table-sm table-striped small">
<colgroup>
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
</colgroup>
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; empty-cells: hide;"></th>
<th colspan="5" data-quarto-table-cell-role="th" style="text-align: center; padding-bottom: 0; padding-left: 3px; padding-right: 3px; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><div style="border-bottom: 1px solid #111111; margin-bottom: -1px; ">
Interim_Look_1
</div></th>
<th colspan="5" data-quarto-table-cell-role="th" style="text-align: center; padding-bottom: 0; padding-left: 3px; padding-right: 3px; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><div style="border-bottom: 1px solid #111111; margin-bottom: -1px; ">
Interim_Look_2
</div></th>
<th colspan="5" data-quarto-table-cell-role="th" style="text-align: center; padding-bottom: 0; padding-left: 3px; padding-right: 3px; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><div style="border-bottom: 1px solid #111111; margin-bottom: -1px; ">
Interim_Look_3
</div></th>
<th colspan="5" data-quarto-table-cell-role="th" style="text-align: center; padding-bottom: 0; padding-left: 3px; padding-right: 3px; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><div style="border-bottom: 1px solid #111111; margin-bottom: -1px; ">
Interim_Look_4
</div></th>
<th data-quarto-table-cell-role="th" style="text-align: center; empty-cells: hide;"></th>
</tr>
<tr class="even">
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">TrialNum</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">OR_1</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">LCL_1</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">UCL_1</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">Pval_1</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">Success_1</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">OR_2</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">LCL_2</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">UCL_2</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">Pval_2</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">Success_2</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">OR_3</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">LCL_3</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">UCL_3</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">Pval_3</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">Success_3</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">OR_4</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">LCL_4</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">UCL_4</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">Pval_4</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">Success_4</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;">Overall_Success</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.936</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.565</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.55</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.797</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.868</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.601</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.255</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.453</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.036</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.767</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.398</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.818</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.891</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.687</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.157</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.387</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
</tr>
<tr class="even">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">2</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.87</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.519</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.459</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.598</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.757</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.525</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.092</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.136</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.745</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.551</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.007</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.056</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.721</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.555</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.936</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.014</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="odd">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">3</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.59</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.35</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.996</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.048</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.555</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.382</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.806</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.002</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.676</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.5</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.916</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.011</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.686</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.529</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.89</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.005</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="even">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">4</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.652</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.385</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.103</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.111</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.671</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.461</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.976</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.037</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.725</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.533</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.988</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.042</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.75</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.576</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.976</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.032</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
</tr>
<tr class="odd">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">5</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.674</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.398</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.142</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.143</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.763</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.526</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.108</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.155</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.835</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.617</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.132</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.246</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.764</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.587</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.994</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.045</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
</tr>
<tr class="even">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">6</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.525</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.309</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.892</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.017</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.622</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.427</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.907</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.014</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.668</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.491</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.909</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.01</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.625</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.479</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.815</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.001</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="odd">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">7</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.742</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.433</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.269</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.275</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.769</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.525</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.125</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.175</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.76</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.558</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.037</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.083</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.719</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.551</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.938</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.015</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="even">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">8</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.661</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.394</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.108</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.116</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.437</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.301</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.632</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.535</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.397</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.721</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.551</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.425</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.714</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="odd">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">9</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.288</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.76</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">2.183</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.348</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.113</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.769</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.612</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.571</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.87</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.645</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.173</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.361</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.771</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.596</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.999</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.049</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
</tr>
<tr class="even">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">10</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.783</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.466</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.316</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.356</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.701</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.484</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.015</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.06</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.655</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.482</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.89</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.007</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.614</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.472</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.798</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="odd">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">11</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.577</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.344</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.968</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.037</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.639</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.444</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.921</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.016</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.56</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.415</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.754</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.577</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.446</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.748</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="even">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">12</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.538</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.315</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.919</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.023</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.629</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.434</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.913</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.015</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.576</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.426</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.78</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.561</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.431</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.731</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="odd">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">13</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.79</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.474</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.315</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.364</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.763</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.531</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.095</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.142</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.789</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.588</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.06</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.115</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.791</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.611</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.025</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.076</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
</tr>
<tr class="even">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">14</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.535</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.318</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.902</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.019</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.69</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.477</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.999</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.049</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.583</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.43</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.792</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.001</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.621</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.477</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.809</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="odd">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">15</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.695</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.419</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.152</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.158</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.744</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.516</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.073</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.114</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.73</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.541</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.985</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.04</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.64</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.493</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.83</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.001</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="even">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">16</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.116</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.657</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.896</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.685</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.763</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.526</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.108</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.155</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.69</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.509</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.935</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.017</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.69</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.532</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.896</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.005</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="odd">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">17</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.533</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.32</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.886</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.015</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.585</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.407</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.839</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.004</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.679</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.504</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.913</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.011</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.622</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.48</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.806</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="even">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">18</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.613</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.364</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.033</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.066</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.692</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.478</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.05</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.78</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.577</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.055</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.107</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.705</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.543</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.914</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.008</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="odd">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">19</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.841</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.502</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.409</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.511</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.768</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.531</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1.11</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.16</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.685</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.506</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.927</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.014</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.665</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.511</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.864</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.002</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
<tr class="even">
<td style="text-align: center; font-weight: bold; color: rgba(102, 102, 102, 255) !important;"><span style="     color: rgba(119, 119, 119, 255) !important;">20</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.275</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.159</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.476</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.449</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.31</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.651</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.498</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.369</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.672</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.498</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.384</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0.646</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">0</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
<td style="text-align: center;"><span style="     color: rgba(119, 119, 119, 255) !important;">1</span></td>
</tr>
</tbody><tfoot>
<tr class="odd">
<td style="text-align: center; padding: 0;"><span style="text-decoration: underline;">Abbreviations: </span></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
</tr>
<tr class="even">
<td style="text-align: center; padding: 0;"><sup></sup> TrialNum: Trial Number | OR: Odds Ratio | LCL: Lower Confidence Level | UCL: Upper Confidence Level | Pval: P-value</td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
</tr>
</tfoot>

</table>
</div>
</div>
</div>
<hr>
</section>
<section id="statistical-environment" class="level1">
<h1>Statistical Environment</h1>
<hr>
<p>The analyses were run on:</p>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#&gt;  setting  value
#&gt;  version  R version 4.5.2 (2025-10-31)
#&gt;  os       macOS Tahoe 26.3
#&gt;  system   aarch64, darwin20
#&gt;  ui       X11
#&gt;  language (EN)
#&gt;  collate  C.UTF-8
#&gt;  ctype    C.UTF-8
#&gt;  tz       America/New_York
#&gt;  date     2026-01-07
#&gt;  pandoc   3.8.3 @ /opt/homebrew/bin/ (via rmarkdown)
#&gt;  quarto   1.8.26 @ /Applications/quarto/bin/quarto
#&gt; 
#&gt; ─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#&gt;  ! package           * version    date (UTC) lib source
#&gt;    abind               1.4-8      2024-09-12 [1] CRAN (R 4.5.0)
#&gt;    Amelia            * 1.8.3      2024-11-08 [1] CRAN (R 4.5.0)
#&gt;    arm                 1.14-4     2024-04-01 [1] CRAN (R 4.5.0)
#&gt;    arrayhelpers        1.1-0      2020-02-04 [1] CRAN (R 4.5.0)
#&gt;    askpass             1.2.1      2024-10-04 [1] CRAN (R 4.5.0)
#&gt;    backports           1.5.0      2024-05-23 [1] CRAN (R 4.5.0)
#&gt;    base              * 4.5.2      2025-11-01 [?] local
#&gt;    base64enc           0.1-3      2015-07-28 [1] CRAN (R 4.5.0)
#&gt;    bayesplot         * 1.15.0     2025-12-12 [1] CRAN (R 4.5.2)
#&gt;    bcaboot             0.2-3      2021-05-09 [1] CRAN (R 4.5.0)
#&gt;    bitops              1.0-9      2024-10-03 [1] CRAN (R 4.5.0)
#&gt;    blogdown          * 1.22.2     2026-01-06 [1] Github (rstudio/blogdown@18ea707)
#&gt;    boot              * 1.3-32     2025-08-29 [1] CRAN (R 4.5.0)
#&gt;    bootImpute        * 1.3.0      2025-12-15 [1] CRAN (R 4.5.2)
#&gt;    bridgesampling      1.2-1      2025-11-19 [1] CRAN (R 4.5.2)
#&gt;    brms              * 2.23.0     2025-09-09 [1] CRAN (R 4.5.0)
#&gt;    Brobdingnag         1.2-9      2022-10-19 [1] CRAN (R 4.5.0)
#&gt;    broom             * 1.0.11     2025-12-04 [1] CRAN (R 4.5.2)
#&gt;    broom.mixed       * 0.2.9.6    2024-10-15 [1] CRAN (R 4.5.0)
#&gt;    Cairo             * 1.7-0      2025-10-29 [1] CRAN (R 4.5.0)
#&gt;    car               * 3.1-3      2024-09-27 [1] CRAN (R 4.5.0)
#&gt;    carData           * 3.0-5      2022-01-06 [1] CRAN (R 4.5.0)
#&gt;    caTools             1.18.3     2024-09-04 [1] CRAN (R 4.5.0)
#&gt;    checkmate         * 2.3.3      2025-08-18 [1] CRAN (R 4.5.0)
#&gt;    class               7.3-23     2025-01-01 [1] CRAN (R 4.5.0)
#&gt;    cli               * 3.6.5      2025-04-23 [1] CRAN (R 4.5.0)
#&gt;    clipr               0.8.0      2022-02-22 [1] CRAN (R 4.5.0)
#&gt;    cluster             2.1.8.1    2025-03-12 [1] CRAN (R 4.5.0)
#&gt;    coda              * 0.19-4.1   2024-01-31 [1] CRAN (R 4.5.0)
#&gt;    codetools           0.2-20     2024-03-31 [1] CRAN (R 4.5.0)
#&gt;    colorspace        * 2.1-2      2025-09-22 [1] CRAN (R 4.5.0)
#&gt;  P compiler            4.5.2      2025-11-01 [1] local
#&gt;    concurve          * 2.7.7      2026-01-04 [1] Github (zadrafi/concurve@088c0ca)
#&gt;    cowplot           * 1.2.0      2025-07-07 [1] CRAN (R 4.5.0)
#&gt;    crayon              1.5.3      2024-06-20 [1] CRAN (R 4.5.0)
#&gt;    curl                7.0.0      2025-08-19 [1] CRAN (R 4.5.0)
#&gt;    data.table          1.18.0     2025-12-24 [1] CRAN (R 4.5.2)
#&gt;  P datasets          * 4.5.2      2025-11-01 [1] local
#&gt;    DBI                 1.2.3      2024-06-02 [1] CRAN (R 4.5.0)
#&gt;    DEoptimR            1.1-4      2025-07-27 [1] CRAN (R 4.5.0)
#&gt;    desc                1.4.3      2023-12-10 [1] CRAN (R 4.5.0)
#&gt;    details             0.4.0      2025-02-09 [1] CRAN (R 4.5.0)
#&gt;    dichromat           2.0-0.1    2022-05-02 [1] CRAN (R 4.5.0)
#&gt;    digest              0.6.39     2025-11-19 [1] CRAN (R 4.5.2)
#&gt;    distributional      0.5.0      2024-09-17 [1] CRAN (R 4.5.0)
#&gt;    doParallel        * 1.0.17     2022-02-07 [1] CRAN (R 4.5.0)
#&gt;    doRNG               1.8.6.2    2025-04-02 [1] CRAN (R 4.5.0)
#&gt;    dplyr             * 1.1.4      2023-11-17 [1] CRAN (R 4.5.0)
#&gt;    e1071               1.7-17     2025-12-18 [1] CRAN (R 4.5.2)
#&gt;    emmeans             2.0.1      2025-12-16 [1] CRAN (R 4.5.2)
#&gt;    estimability        1.5.1      2024-05-12 [1] CRAN (R 4.5.0)
#&gt;    evaluate            1.0.5      2025-08-27 [1] CRAN (R 4.5.0)
#&gt;    extremevalues       2.4.1      2024-12-17 [1] CRAN (R 4.5.0)
#&gt;    farver              2.1.2      2024-05-13 [1] CRAN (R 4.5.0)
#&gt;    fastmap             1.2.0      2024-05-15 [1] CRAN (R 4.5.0)
#&gt;    flextable           0.9.10     2025-08-24 [1] CRAN (R 4.5.0)
#&gt;    fontBitstreamVera   0.1.1      2017-02-01 [1] CRAN (R 4.5.0)
#&gt;    fontLiberation      0.1.0      2016-10-15 [1] CRAN (R 4.5.0)
#&gt;    fontquiver          0.2.1      2017-02-01 [1] CRAN (R 4.5.0)
#&gt;    forcats           * 1.0.1      2025-09-25 [1] CRAN (R 4.5.0)
#&gt;    foreach           * 1.5.2      2022-02-02 [1] CRAN (R 4.5.0)
#&gt;    foreign             0.8-90     2025-03-31 [1] CRAN (R 4.5.0)
#&gt;    Formula             1.2-5      2023-02-24 [1] CRAN (R 4.5.0)
#&gt;    fs                  1.6.6      2025-04-12 [1] CRAN (R 4.5.0)
#&gt;    furrr               0.3.1      2022-08-15 [1] CRAN (R 4.5.0)
#&gt;    future            * 1.68.0     2025-11-17 [1] CRAN (R 4.5.2)
#&gt;    future.apply      * 1.20.1     2025-12-09 [1] CRAN (R 4.5.2)
#&gt;    gamlss            * 5.5-0      2025-08-19 [1] CRAN (R 4.5.0)
#&gt;    gamlss.data       * 6.0-7      2025-09-04 [1] CRAN (R 4.5.0)
#&gt;    gamlss.dist       * 6.1-1      2023-08-23 [1] CRAN (R 4.5.0)
#&gt;    gdtools             0.4.4      2025-10-06 [1] CRAN (R 4.5.0)
#&gt;    generics            0.1.4      2025-05-09 [1] CRAN (R 4.5.0)
#&gt;    ggcorrplot        * 0.1.4.1    2023-09-05 [1] CRAN (R 4.5.0)
#&gt;    ggdist              3.3.3      2025-04-23 [1] CRAN (R 4.5.0)
#&gt;    ggplot2           * 4.0.1      2025-11-14 [1] CRAN (R 4.5.2)
#&gt;    ggpubr              0.6.2      2025-10-17 [1] CRAN (R 4.5.0)
#&gt;    ggsignif            0.6.4      2022-10-13 [1] CRAN (R 4.5.0)
#&gt;    ggtext            * 0.1.2      2022-09-16 [1] CRAN (R 4.5.0)
#&gt;    glmnet              4.1-10     2025-07-17 [1] CRAN (R 4.5.0)
#&gt;    globals             0.18.0     2025-05-08 [1] CRAN (R 4.5.0)
#&gt;    glue                1.8.0      2024-09-30 [1] CRAN (R 4.5.0)
#&gt;  P graphics          * 4.5.2      2025-11-01 [1] local
#&gt;  P grDevices         * 4.5.2      2025-11-01 [1] local
#&gt;  P grid              * 4.5.2      2025-11-01 [1] local
#&gt;    gridExtra           2.3        2017-09-09 [1] CRAN (R 4.5.0)
#&gt;    gridtext            0.1.5      2022-09-16 [1] CRAN (R 4.5.0)
#&gt;    gtable              0.3.6      2024-10-25 [1] CRAN (R 4.5.0)
#&gt;    gtsummary         * 2.5.0      2025-12-05 [1] CRAN (R 4.5.2)
#&gt;    here              * 1.0.2      2025-09-15 [1] CRAN (R 4.5.0)
#&gt;    Hmisc             * 5.2-4      2025-10-05 [1] CRAN (R 4.5.0)
#&gt;    hms                 1.1.4      2025-10-17 [1] CRAN (R 4.5.0)
#&gt;    htmlTable           2.4.3      2024-07-21 [1] CRAN (R 4.5.0)
#&gt;    htmltools         * 0.5.9      2025-12-04 [1] CRAN (R 4.5.2)
#&gt;    htmlwidgets         1.6.4      2023-12-06 [1] CRAN (R 4.5.0)
#&gt;    httr                1.4.7      2023-08-15 [1] CRAN (R 4.5.0)
#&gt;    ImputeRobust      * 1.3-1      2018-11-30 [1] CRAN (R 4.5.0)
#&gt;    inline              0.3.21     2025-01-09 [1] CRAN (R 4.5.0)
#&gt;    insight             1.4.4      2025-12-06 [1] CRAN (R 4.5.2)
#&gt;    iterators         * 1.0.14     2022-02-05 [1] CRAN (R 4.5.0)
#&gt;    itertools           0.1-3      2014-03-12 [1] CRAN (R 4.5.0)
#&gt;    jomo                2.7-6      2023-04-15 [1] CRAN (R 4.5.0)
#&gt;    jsonlite            2.0.0      2025-03-27 [1] CRAN (R 4.5.0)
#&gt;    kableExtra        * 1.4.0      2024-01-24 [1] CRAN (R 4.5.0)
#&gt;    km.ci               0.5-6      2022-04-06 [1] CRAN (R 4.5.0)
#&gt;    KMsurv              0.1-6      2025-05-20 [1] CRAN (R 4.5.0)
#&gt;    knitr             * 1.51       2025-12-20 [1] CRAN (R 4.5.2)
#&gt;    laeken              0.5.3      2024-01-25 [1] CRAN (R 4.5.0)
#&gt;    latex2exp         * 0.9.6      2022-11-28 [1] CRAN (R 4.5.0)
#&gt;    lattice           * 0.22-7     2025-04-02 [1] CRAN (R 4.5.0)
#&gt;    lifecycle           1.0.4      2023-11-07 [1] CRAN (R 4.5.0)
#&gt;    listenv             0.10.0     2025-11-02 [1] CRAN (R 4.5.0)
#&gt;    lme4                1.1-38     2025-12-02 [1] CRAN (R 4.5.2)
#&gt;    lmtest              0.9-40     2022-03-21 [1] CRAN (R 4.5.0)
#&gt;    loo               * 2.9.0      2025-12-23 [1] CRAN (R 4.5.2)
#&gt;    lubridate         * 1.9.4      2024-12-08 [1] CRAN (R 4.5.0)
#&gt;    magick              2.9.0      2025-09-08 [1] CRAN (R 4.5.0)
#&gt;    magrittr          * 2.0.4      2025-09-12 [1] CRAN (R 4.5.0)
#&gt;    MASS              * 7.3-65     2025-02-28 [1] CRAN (R 4.5.0)
#&gt;    mathjaxr            2.0-0      2025-12-01 [1] CRAN (R 4.5.2)
#&gt;    Matrix            * 1.7-4      2025-08-28 [1] CRAN (R 4.5.0)
#&gt;    MatrixModels        0.5-4      2025-03-26 [1] CRAN (R 4.5.0)
#&gt;    matrixStats         1.5.0      2025-01-07 [1] CRAN (R 4.5.0)
#&gt;    mcmc                0.9-8      2023-11-16 [1] CRAN (R 4.5.0)
#&gt;    MCMCpack          * 1.7-1      2024-08-27 [1] CRAN (R 4.5.0)
#&gt;    metadat             1.4-0      2025-02-04 [1] CRAN (R 4.5.0)
#&gt;    metafor             4.8-0      2025-01-28 [1] CRAN (R 4.5.0)
#&gt;  P methods           * 4.5.2      2025-11-01 [1] local
#&gt;    mgcv              * 1.9-4      2025-11-07 [1] CRAN (R 4.5.0)
#&gt;    mi                * 1.2        2025-09-02 [1] CRAN (R 4.5.0)
#&gt;    mice              * 3.19.0     2025-12-10 [1] CRAN (R 4.5.2)
#&gt;    miceadds          * 3.18-36    2025-09-12 [1] CRAN (R 4.5.0)
#&gt;    miceFast          * 0.8.5      2025-02-03 [1] CRAN (R 4.5.0)
#&gt;    minqa               1.2.8      2024-08-17 [1] CRAN (R 4.5.0)
#&gt;    missForest        * 1.6.1      2025-10-26 [1] CRAN (R 4.5.0)
#&gt;    mitml             * 0.4-5      2023-03-08 [1] CRAN (R 4.5.0)
#&gt;    mitools             2.4        2019-04-26 [1] CRAN (R 4.5.0)
#&gt;    multcomp            1.4-29     2025-10-20 [1] CRAN (R 4.5.0)
#&gt;    mvtnorm           * 1.3-3      2025-01-10 [1] CRAN (R 4.5.0)
#&gt;    nlme              * 3.1-168    2025-03-31 [1] CRAN (R 4.5.0)
#&gt;    nloptr              2.2.1      2025-03-17 [1] CRAN (R 4.5.0)
#&gt;    nnet                7.3-20     2025-01-01 [1] CRAN (R 4.5.0)
#&gt;    numDeriv            2016.8-1.1 2019-06-06 [1] CRAN (R 4.5.0)
#&gt;    officer             0.7.2      2025-12-04 [1] CRAN (R 4.5.2)
#&gt;    opdisDownsampling   1.0.1      2024-04-15 [1] CRAN (R 4.5.0)
#&gt;    openssl             2.3.4      2025-09-30 [1] CRAN (R 4.5.0)
#&gt;    otel                0.2.0      2025-08-29 [1] CRAN (R 4.5.0)
#&gt;    pan                 1.9        2023-12-07 [1] CRAN (R 4.5.0)
#&gt;    pander              0.6.6      2025-03-01 [1] CRAN (R 4.5.0)
#&gt;  P parallel          * 4.5.2      2025-11-01 [1] local
#&gt;    parallelly        * 1.46.0     2025-12-12 [1] CRAN (R 4.5.2)
#&gt;    pbmcapply         * 1.5.1      2022-04-28 [1] CRAN (R 4.5.0)
#&gt;    performance       * 0.15.3     2025-12-01 [1] CRAN (R 4.5.2)
#&gt;    pillar              1.11.1     2025-09-17 [1] CRAN (R 4.5.0)
#&gt;    pkgbuild            1.4.8      2025-05-26 [1] CRAN (R 4.5.0)
#&gt;    pkgconfig           2.0.3      2019-09-22 [1] CRAN (R 4.5.0)
#&gt;    plyr                1.8.9      2023-10-02 [1] CRAN (R 4.5.0)
#&gt;    png                 0.1-8      2022-11-29 [1] CRAN (R 4.5.0)
#&gt;    polspline           1.1.25     2024-05-10 [1] CRAN (R 4.5.0)
#&gt;    posterior         * 1.6.1      2025-02-27 [1] CRAN (R 4.5.0)
#&gt;    pracma              2.4.6      2025-10-22 [1] CRAN (R 4.5.0)
#&gt;    prettyunits         1.2.0      2023-09-24 [1] CRAN (R 4.5.0)
#&gt;    ProfileLikelihood * 1.3        2023-08-25 [1] CRAN (R 4.5.0)
#&gt;    progress          * 1.2.3      2023-12-06 [1] CRAN (R 4.5.0)
#&gt;    proxy               0.4-29     2025-12-29 [1] CRAN (R 4.5.2)
#&gt;    pryr                0.1.6      2023-01-17 [1] CRAN (R 4.5.0)
#&gt;    purrr             * 1.2.0      2025-11-04 [1] CRAN (R 4.5.0)
#&gt;    qqconf              1.3.2      2023-04-14 [1] CRAN (R 4.5.0)
#&gt;    qqplotr           * 0.0.7      2025-09-05 [1] CRAN (R 4.5.0)
#&gt;    quantreg          * 6.1        2025-03-10 [1] CRAN (R 4.5.0)
#&gt;    QuickJSR            1.8.1      2025-09-20 [1] CRAN (R 4.5.0)
#&gt;    R6                  2.6.1      2025-02-15 [1] CRAN (R 4.5.0)
#&gt;    ragg                1.5.0      2025-09-02 [1] CRAN (R 4.5.0)
#&gt;    randomForest      * 4.7-1.2    2024-09-22 [1] CRAN (R 4.5.0)
#&gt;    ranger              0.17.0     2024-11-08 [1] CRAN (R 4.5.0)
#&gt;    rappdirs            0.3.3      2021-01-31 [1] CRAN (R 4.5.0)
#&gt;    rapportools         1.2        2025-02-28 [1] CRAN (R 4.5.0)
#&gt;    rbibutils           2.4        2025-11-07 [1] CRAN (R 4.5.0)
#&gt;    RColorBrewer        1.1-3      2022-04-03 [1] CRAN (R 4.5.0)
#&gt;    Rcpp              * 1.1.0      2025-07-02 [1] CRAN (R 4.5.0)
#&gt;    RcppParallel        5.1.11-1   2025-08-27 [1] CRAN (R 4.5.0)
#&gt;    Rdpack              2.6.4      2025-04-09 [1] CRAN (R 4.5.0)
#&gt;    readr             * 2.1.6      2025-11-14 [1] CRAN (R 4.5.2)
#&gt;    reformulas          0.4.3      2025-12-17 [1] CRAN (R 4.5.2)
#&gt;    rematch2            2.1.2      2020-05-01 [1] CRAN (R 4.5.0)
#&gt;    reshape2          * 1.4.5      2025-11-12 [1] CRAN (R 4.5.0)
#&gt;    reticulate        * 1.44.1     2025-11-14 [1] CRAN (R 4.5.2)
#&gt;    rlang               1.1.6      2025-04-11 [1] CRAN (R 4.5.0)
#&gt;    rmarkdown         * 2.30       2025-09-28 [1] CRAN (R 4.5.0)
#&gt;    rms               * 8.1-0      2025-10-14 [1] CRAN (R 4.5.0)
#&gt;    rngtools            1.5.2      2021-09-20 [1] CRAN (R 4.5.0)
#&gt;    robustbase          0.99-6     2025-09-04 [1] CRAN (R 4.5.0)
#&gt;    rpact             * 4.3.0      2025-12-16 [1] CRAN (R 4.5.2)
#&gt;    rpart               4.1.24     2025-01-07 [1] CRAN (R 4.5.0)
#&gt;    rprojroot           2.1.1      2025-08-26 [1] CRAN (R 4.5.0)
#&gt;    rstan             * 2.32.7     2025-03-10 [1] CRAN (R 4.5.0)
#&gt;    rstantools          2.5.0      2025-09-01 [1] CRAN (R 4.5.0)
#&gt;    rstatix             0.7.3      2025-10-18 [1] CRAN (R 4.5.0)
#&gt;    rstudioapi          0.17.1     2024-10-22 [1] CRAN (R 4.5.0)
#&gt;    S7                  0.2.1      2025-11-14 [1] CRAN (R 4.5.2)
#&gt;    sandwich            3.1-1      2024-09-15 [1] CRAN (R 4.5.0)
#&gt;    scales              1.4.0      2025-04-24 [1] CRAN (R 4.5.0)
#&gt;    sessioninfo         1.2.3      2025-02-05 [1] CRAN (R 4.5.0)
#&gt;    shape               1.4.6.1    2024-02-23 [1] CRAN (R 4.5.0)
#&gt;    showtext          * 0.9-7      2024-03-02 [1] CRAN (R 4.5.0)
#&gt;    showtextdb        * 3.0        2020-06-04 [1] CRAN (R 4.5.0)
#&gt;    sp                  2.2-0      2025-02-01 [1] CRAN (R 4.5.0)
#&gt;    SparseM           * 1.84-2     2024-07-17 [1] CRAN (R 4.5.0)
#&gt;  P splines           * 4.5.2      2025-11-01 [1] local
#&gt;    StanHeaders       * 2.32.10    2024-07-15 [1] CRAN (R 4.5.0)
#&gt;    Statamarkdown     * 0.9.6      2026-01-06 [1] Github (Hemken/Statamarkdown@dc936d8)
#&gt;  P stats             * 4.5.2      2025-11-01 [1] local
#&gt;  P stats4            * 4.5.2      2025-11-01 [1] local
#&gt;    stringi             1.8.7      2025-03-27 [1] CRAN (R 4.5.0)
#&gt;    stringr           * 1.6.0      2025-11-04 [1] CRAN (R 4.5.0)
#&gt;    summarytools      * 1.1.4      2025-04-29 [1] CRAN (R 4.5.0)
#&gt;    survival            3.8-3      2024-12-17 [1] CRAN (R 4.5.0)
#&gt;    survminer           0.5.1      2025-09-02 [1] CRAN (R 4.5.0)
#&gt;    survMisc            0.5.6      2022-04-07 [1] CRAN (R 4.5.0)
#&gt;    svglite           * 2.2.2      2025-10-21 [1] CRAN (R 4.5.0)
#&gt;    svgPanZoom          0.3.4      2020-02-15 [1] CRAN (R 4.5.0)
#&gt;    svUnit              1.0.8      2025-08-26 [1] CRAN (R 4.5.0)
#&gt;    sysfonts          * 0.8.9      2024-03-02 [1] CRAN (R 4.5.0)
#&gt;    systemfonts         1.3.1      2025-10-01 [1] CRAN (R 4.5.0)
#&gt;  P tcltk               4.5.2      2025-11-01 [1] local
#&gt;    tensorA             0.36.2.1   2023-12-13 [1] CRAN (R 4.5.0)
#&gt;    texPreview        * 2.1.0      2024-01-24 [1] CRAN (R 4.5.0)
#&gt;    textshaping         1.0.4      2025-10-10 [1] CRAN (R 4.5.0)
#&gt;    TH.data             1.1-5      2025-11-17 [1] CRAN (R 4.5.2)
#&gt;    tibble            * 3.3.0      2025-06-08 [1] CRAN (R 4.5.0)
#&gt;    tidybayes         * 3.0.7      2024-09-15 [1] CRAN (R 4.5.0)
#&gt;    tidyr             * 1.3.2      2025-12-19 [1] CRAN (R 4.5.2)
#&gt;    tidyselect          1.2.1      2024-03-11 [1] CRAN (R 4.5.0)
#&gt;    tidyverse         * 2.0.0      2023-02-22 [1] CRAN (R 4.5.0)
#&gt;    timechange          0.3.0      2024-01-18 [1] CRAN (R 4.5.0)
#&gt;    tinytex           * 0.58       2025-11-19 [1] CRAN (R 4.5.2)
#&gt;  P tools               4.5.2      2025-11-01 [1] local
#&gt;    twosamples          2.0.1      2023-06-23 [1] CRAN (R 4.5.0)
#&gt;    tzdb                0.5.0      2025-03-15 [1] CRAN (R 4.5.0)
#&gt;  P utils             * 4.5.2      2025-11-01 [1] local
#&gt;    uuid                1.2-1      2024-07-29 [1] CRAN (R 4.5.0)
#&gt;    V8                  8.0.1      2025-10-10 [1] CRAN (R 4.5.0)
#&gt;    vcd                 1.4-13     2024-09-16 [1] CRAN (R 4.5.0)
#&gt;    vctrs               0.6.5      2023-12-01 [1] CRAN (R 4.5.0)
#&gt;    VIM               * 6.2.6      2025-09-18 [1] CRAN (R 4.5.0)
#&gt;    viridisLite         0.4.2      2023-05-02 [1] CRAN (R 4.5.0)
#&gt;    wesanderson       * 0.3.7      2023-10-31 [1] CRAN (R 4.5.0)
#&gt;    whisker             0.4.1      2022-12-05 [1] CRAN (R 4.5.0)
#&gt;    withr               3.0.2      2024-10-28 [1] CRAN (R 4.5.0)
#&gt;    xfun              * 0.55       2025-12-16 [1] CRAN (R 4.5.2)
#&gt;    xml2                1.5.1      2025-12-01 [1] CRAN (R 4.5.2)
#&gt;    xtable              1.8-4      2019-04-21 [1] CRAN (R 4.5.0)
#&gt;    yaml                2.3.12     2025-12-10 [1] CRAN (R 4.5.2)
#&gt;    yardstick         * 1.3.2      2025-01-22 [1] CRAN (R 4.5.0)
#&gt;    zip                 2.3.3      2025-05-13 [1] CRAN (R 4.5.0)
#&gt;    zoo                 1.8-15     2025-12-15 [1] CRAN (R 4.5.2)
#&gt; 
#&gt;  [1] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
#&gt; 
#&gt;  * ── Packages attached to the search path.
#&gt;  P ── Loaded and on-disk path mismatch.
#&gt; 
#&gt; ─ External software ────────────────────────────────────────────────────────────────────────────────────────────────────────────
#&gt;  setting        value
#&gt;  cairo          1.17.6
#&gt;  cairoFT
#&gt;  pango          1.50.14
#&gt;  png            1.6.44
#&gt;  jpeg           9.5
#&gt;  tiff           LIBTIFF, Version 4.5.0
#&gt;  tcl            8.6.13
#&gt;  curl           8.7.1
#&gt;  zlib           1.2.12
#&gt;  bzlib          1.0.8, 13-Jul-2019
#&gt;  xz             5.6.3
#&gt;  deflate        1.23
#&gt;  PCRE           10.44 2024-06-07
#&gt;  ICU            76.1
#&gt;  TRE            TRE 0.8.0 R_fixes (BSD)
#&gt;  iconv          Apple or GNU libiconv 1.11 /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libR.dylib
#&gt;  readline       5.2
#&gt;  BLAS           /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
#&gt;  lapack         /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib
#&gt;  lapack_version 3.12.1
#&gt; 
#&gt; ─ Python configuration ─────────────────────────────────────────────────────────────────────────────────────────────────────────
#&gt;  Python is not available
#&gt; 
#&gt; ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#&gt; $RNGkind
#&gt; [1] "L'Ecuyer-CMRG" "Inversion"     "Rejection"</code></pre>
</div>
<hr>
</section>
<section id="article-citation" class="level1">
<h1>Article Citation</h1>
<p><span class="citation" data-cites="wassmer2018"><sup>1</sup></span></p>



</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" data-entry-spacing="2" data-line-spacing="2">
<div id="ref-wassmer2018" class="csl-entry">
1. Wassmer G, Pahlke F. (2018). <span>“Rpact: Confirmatory adaptive clinical trial design and analysis.”</span> doi: <a href="https://doi.org/10.32614/cran.package.rpact">10.32614/cran.package.rpact</a>. <a href="http://dx.doi.org/10.32614/cran.package.rpact">http://dx.doi.org/10.32614/cran.package.rpact</a>.
</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@misc{panda2021,
  author = {Panda, Sir and Rafi, Zad},
  title = {Simulation of a {Two-Group} {Parallel-Arm} {RCT} with
    {Interim} {Analyses}},
  date = {2021-02-01},
  url = {https://lesslikely.com/posts/statistics/interim-analysis},
  langid = {en},
  abstract = {A simulation of a two-group parallel-arm randomized trial
    with interim analysis using the rpact package.}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2021" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2021). <span>‘Simulation of a Two-Group
Parallel-Arm RCT with Interim Analyses’</span>. Less Likely. <a href="https://lesslikely.com/posts/statistics/interim-analysis">https://lesslikely.com/posts/statistics/interim-analysis</a>.
</div></div></section></div> ]]></description>
  <category>statistics</category>
  <guid>https://lesslikely.com/posts/statistics/interim_analyses.html</guid>
  <pubDate>Mon, 01 Feb 2021 05:00:00 GMT</pubDate>
  <media:content url="https://lesslikely.com/images/norm.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>Tables, Graphs, and Computations from Rafi &amp; Greenland (2020)</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/statistics/RG2020BMC.html</link>
  <description><![CDATA[ 





<center>
<img src="https://res.cloudinary.com/less-likely/image/upload/v1602038429/Site/confidencecurve.svg" width="100" style="cursor: zoom-in" align="right">
</center>
<hr>
<p>The following post provides <em>some</em> of the code that was used to construct the figures and tables from <a href="https://doi.org/10.1186/s12874-020-01105-9">Rafi &amp; Greenland, 2020</a><span class="citation" data-cites="rafiSemanticCognitiveTools2020"><sup>1</sup></span>. An enhanced PDF version of the paper can be <a href="https://rdcu.be/b789P">found here</a>. For further discussion of the computations, see the appendix of the <a href="https://static-content.springer.com/esm/art%3A10.1186%2Fs12874-020-01105-9/MediaObjects/12874_2020_1105_MOESM1_ESM.pdf">main paper</a>, along with our <a href="https://arxiv.org/pdf/2008.12991.pdf">technical supplement</a>.<span class="citation" data-cites="greenlandTechnicalIssuesInterpretation2020"><sup>2</sup></span></p>
<hr>
<blockquote class="blockquote">
<p><strong>Disclaimer:</strong> I am responsible for all the code and mistakes below, and none of them can be attributed to my coauthors or my fellow package developers.</p>
</blockquote>
<hr>
<p>In order to recreate the functions, I would recommend installing the latest version of <a href="https://data.lesslikely.com/concurve/"><code>concurve</code></a> from <a href="https://cran.r-project.org/package=concurve">CRAN</a>, as it has patched some issues with graphing when the outcome is binary. Use the script below to get the latest version and load the <code>R</code> package. A number of other <code>R</code> packages are also used in this post, which are listed below.</p>
<hr>
<div class="cell" data-layout-align="center">
<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;">"concurve"</span>)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concurve"</span>)</span></code></pre></div></div>
</div>
<hr>
<section id="valid-p-values-are-uniform-under-the-null-model" class="level2">
<h2 class="anchored" data-anchor-id="valid-p-values-are-uniform-under-the-null-model">Valid <img src="https://latex.codecogs.com/png.latex?P">-values Are Uniform Under the Null Model</h2>
<hr>
<p>Here we show that valid <img src="https://latex.codecogs.com/png.latex?P">-values have specific properties, when the null model is true. We first generate two variables (<img src="https://latex.codecogs.com/png.latex?Y">, <img src="https://latex.codecogs.com/png.latex?X">) that come from the same normal distribution with a <img src="https://latex.codecogs.com/png.latex?%5Cmu"> of 0 and <img src="https://latex.codecogs.com/png.latex?%5Csigma"> of 1, each with a total of <code>1000</code> observations. We assume that there is no relationship between these two variables. We run a simple t-test between <img src="https://latex.codecogs.com/png.latex?Y"> and <img src="https://latex.codecogs.com/png.latex?X"> and iterate this <code>100000</code> times and compute <code>100000</code> <img src="https://latex.codecogs.com/png.latex?P">-values to see the overall distribution of the <img src="https://latex.codecogs.com/png.latex?P">-values, which we then plot using a histogram./</p>
<hr>
<div class="cell" data-layout-align="center">
<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;">RNGkind</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"L'Ecuyer-CMRG"</span>)</span>
<span id="cb2-2">set.seed <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;">1031</span></span>
<span id="cb2-3">n.sim <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>
<span id="cb2-4">t.sim <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;">numeric</span>(n.sim)</span>
<span id="cb2-5">n.samp <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;">1000</span></span>
<span id="cb2-6"></span>
<span id="cb2-7"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <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>n.sim) {</span>
<span id="cb2-8">    X <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.samp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb2-9">    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.samp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb2-10">    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;">data.frame</span>(X, Y)</span>
<span id="cb2-11">    t <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;">t.test</span>(X, Y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> df)</span>
<span id="cb2-12">    t.sim[i] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> t[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]]</span>
<span id="cb2-13">}</span>
<span id="cb2-14"></span>
<span id="cb2-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</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> t.sim)) <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;">geom_histogram</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bins =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</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;">"black"</span>,</span>
<span id="cb2-16">    <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;">"#99c7c7"</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.25</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;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Distribution of P-values Under the Null"</span>,</span>
<span id="cb2-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P-value"</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;">scale_x_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-4-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>This can also be shown using the <a href="https://cran.r-project.org/package=TeachingDemos"><code>TeachingDemos</code></a> <code>R</code> package, which has a function dedicated to showing this phenomenon.</p>
<hr>
<div class="cell" data-layout-align="center">
<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>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TeachingDemos"</span>)</span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">RNGkind</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"L'Ecuyer-CMRG"</span>)</span>
<span id="cb3-3">set.seed <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;">1031</span></span>
<span id="cb3-4">obs_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;">Pvalue.norm.sim</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mu =</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;">mu0 =</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;">sigma =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb3-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sigma0 =</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;">test =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"t"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alternative =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"two.sided"</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.05</span>,</span>
<span id="cb3-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">B =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e+05</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-5-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
<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;">ggplot</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</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> obs_p)) <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;">geom_histogram</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bins =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</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;">"black"</span>,</span>
<span id="cb4-2">    <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;">"#99c7c7"</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.25</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;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Distribution of P-values Under the Null"</span>,</span>
<span id="cb4-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P-value"</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;">scale_x_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-5-2.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>As you can see, when the null model is true, the distribution of <img src="https://latex.codecogs.com/png.latex?P">-values is uniform. Valid <img src="https://latex.codecogs.com/png.latex?P">-values are uniform under the null hypothesis and their corresponding <img src="https://latex.codecogs.com/png.latex?S">-values are exponentially distributed. We run the same simulation as before, but then convert the obtained <img src="https://latex.codecogs.com/png.latex?P">-values into <img src="https://latex.codecogs.com/png.latex?S">-values, to see how they are distributed.</p>
<hr>
<div class="cell" data-layout-align="center">
<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;">RNGkind</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"L'Ecuyer-CMRG"</span>)</span>
<span id="cb5-2">set.seed <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;">1031</span></span>
<span id="cb5-3">n.sim <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>
<span id="cb5-4">t.sim <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;">numeric</span>(n.sim)</span>
<span id="cb5-5">n.samp <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;">1000</span></span>
<span id="cb5-6"></span>
<span id="cb5-7"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <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>n.sim) {</span>
<span id="cb5-8">    X <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.samp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb5-9">    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.samp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb5-10">    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;">data.frame</span>(X, Y)</span>
<span id="cb5-11">    t <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;">t.test</span>(X, Y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> df)</span>
<span id="cb5-12">    t.sim[i] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> t[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]]</span>
<span id="cb5-13">}</span>
<span id="cb5-14"></span>
<span id="cb5-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</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> <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;">log2</span>(t.sim))) <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;">geom_histogram</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bins =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>,</span>
<span id="cb5-16">    <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;">"black"</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;">"#d46c5b"</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.5</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;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Distribution of S-values Under the Null"</span>,</span>
<span id="cb5-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"S-value (Bits of Information)"</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;">theme_bw</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-6-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
</section>
<section id="posterior-predictive-p-values" class="level2">
<h2 class="anchored" data-anchor-id="posterior-predictive-p-values">Posterior Predictive <img src="https://latex.codecogs.com/png.latex?P">-values</h2>
<hr>
<p>Despite the name, posterior predictive <img src="https://latex.codecogs.com/png.latex?P">-values are not considered valid frequentist <img src="https://latex.codecogs.com/png.latex?P">-values because they do not meet the uniformity criterion, instead they are pulled towards the parameter value <code>0.5</code>. For further discussion, see our <a href="https://arxiv.org/pdf/2008.12991.pdf">technical supplement</a> along with <a href="https://doi.org/10.1080/00031305.2018.1529625">Greenland (2019)</a> for comprehensive theoretical discussions.<span class="citation" data-cites="greenlandValidPvaluesBehave2019 greenlandTechnicalIssuesInterpretation2020"><sup>2, 3</sup></span></p>
<p>A quick excerpt from our main paper and the technical supplement explains why this is not the case,</p>
<hr>
<blockquote class="blockquote">
<p>As discussed in the Supplement, in Bayesian settings one may see certain <img src="https://latex.codecogs.com/png.latex?P">-values that are not valid frequentist <img src="https://latex.codecogs.com/png.latex?P">-values, the primary example being the posterior predictive <img src="https://latex.codecogs.com/png.latex?P">-value<span class="citation" data-cites="bayarriValuesCompositeNull2000"><sup>4</sup></span>;<span class="citation" data-cites="robinsAsymptoticDistributionValues2000"><sup>5</sup></span>; unfortunately, the negative logs of such invalid <img src="https://latex.codecogs.com/png.latex?P">-values do not measure surprisal at the statistic given the model, and so are not valid <img src="https://latex.codecogs.com/png.latex?S">-values.</p>
<p>The decision rule “reject <strong>H</strong> if <img src="https://latex.codecogs.com/png.latex?p%5Cleq"> <img src="https://latex.codecogs.com/png.latex?%5Calpha">” will reject <strong>H</strong> 100<img src="https://latex.codecogs.com/png.latex?%5Calpha">% of the time under sampling from a model <strong>M</strong> obeying <strong>H</strong> (i.e., the Type-1 error rate of the test will be <img src="https://latex.codecogs.com/png.latex?%5Calpha">) provided the random variable <img src="https://latex.codecogs.com/png.latex?P"> corresponding to <img src="https://latex.codecogs.com/png.latex?p"> is valid (uniform under the model <strong>M</strong> used to compute it), but not necessarily otherwise<span class="citation" data-cites="kuffnerWhyArePvalues2019"><sup>6</sup></span>. This is one reason why frequentist writers reject invalid <img src="https://latex.codecogs.com/png.latex?P">-values (such as posterior predictive <img src="https://latex.codecogs.com/png.latex?P">-values, which highly concentrate around 0.50) and devote considerable technical coverage to uniform <img src="https://latex.codecogs.com/png.latex?P">-values<span class="citation" data-cites="kuffnerWhyArePvalues2019"><sup>6</sup></span>;<span class="citation" data-cites="robinsAsymptoticDistributionValues2000"><sup>5</sup></span>;<span class="citation" data-cites="bayarriValuesCompositeNull2000"><sup>4</sup></span>. A valid <img src="https://latex.codecogs.com/png.latex?P">-value (“U-value”) translates into an exponentially distributed <img src="https://latex.codecogs.com/png.latex?S">-value with a mean of 1 nat or <img src="https://latex.codecogs.com/png.latex?%5Clog_%7B2%7D(e)=1.443"> bits where <img src="https://latex.codecogs.com/png.latex?e"> is the base of the natural logs.</p>
<p>Uniformity is also central to the “refutational information” interpretation of the <img src="https://latex.codecogs.com/png.latex?S">-value used here, for it is necessary to ensure that the <img src="https://latex.codecogs.com/png.latex?P">-value <img src="https://latex.codecogs.com/png.latex?p"> from which <img src="https://latex.codecogs.com/png.latex?s"> is derived is in fact the percentile of the observed value of the test statistic in the distribution of the statistic under <strong>M</strong>, thus making small <img src="https://latex.codecogs.com/png.latex?p"> surprising under <strong>M</strong> and making <img src="https://latex.codecogs.com/png.latex?s"> the corresponding degree of surprise. Because posterior predictive <img src="https://latex.codecogs.com/png.latex?P">-values do not translate into sampling percentiles of the statistic under the hypothesis (in fact, they are pulled toward 0.5 from the correct percentiles)<span class="citation" data-cites="robinsAsymptoticDistributionValues2000"><sup>5</sup></span>;<span class="citation" data-cites="bayarriValuesCompositeNull2000"><sup>4</sup></span>, the resulting negative log does not measure surprisal at the statistic given <strong>M</strong>, and so is not a valid <img src="https://latex.codecogs.com/png.latex?S">-value in our terms.</p>
</blockquote>
<hr>
<p>And indeed, we can show this phenomenon below with simulations. Here we fit a simple Bayesian regression model with a weakly informative prior <code>normal(0, 10)</code> using <a href="https://mc-stan.org/rstanarm"><code>rstanarm</code></a>, where both the predictor and response variable come from the same distribution and have the same location and scale parameters (<img src="https://latex.codecogs.com/png.latex?%5Cmu%20=%200">, <img src="https://latex.codecogs.com/png.latex?%5Csigma%20=%201">. We then calculate the observed test statistics, along with their distributions, and convert them into posterior predictive <img src="https://latex.codecogs.com/png.latex?P">-values and plot them using <a href="https://mc-stan.org/bayesplot"><code>Bayesplot</code></a> functions. Then, we iterate this <code>1000</code> times to examine the distribution of posterior predictive <img src="https://latex.codecogs.com/png.latex?P">-values and compare them to standard <img src="https://latex.codecogs.com/png.latex?P">-values that are known to be uniform.</p>
<p>But first, we’ll generate the distribution of the test statistic from one model.</p>
<hr>
<div class="cell" data-layout-align="center">
<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;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bayesplot"</span>)</span>
<span id="cb6-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rstan"</span>)</span>
<span id="cb6-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rstanarm"</span>)</span>
<span id="cb6-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rstan_options</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">auto_write =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb6-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">options</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mc.cores =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb6-6">teal <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#99c7c7"</span>)</span>
<span id="cb6-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">color_scheme_set</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"teal"</span>)</span>
<span id="cb6-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">RNGkind</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"L'Ecuyer-CMRG"</span>)</span>
<span id="cb6-9">n.samp <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>
<span id="cb6-10">X <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.samp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb6-11">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.samp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb6-12">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;">data.frame</span>(X, Y)</span>
<span id="cb6-13">mod1 <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;">stan_glm</span>(Y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> X, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> df, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">chains =</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;">cores =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">refresh =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb6-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prior =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">normal</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;">10</span>))</span>
<span id="cb6-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `if (!prior_dist_name %in% unlist(ok_dists)) ...`:</span></span>
<span id="cb6-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! argument is of length zero</span></span>
<span id="cb6-17">yrep <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;">posterior_predict</span>(mod1)</span>
<span id="cb6-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb6-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'mod1' not found</span></span>
<span id="cb6-20"></span>
<span id="cb6-21">h <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;">ppc_stat</span>(Y, yrep, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stat =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"median"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">freq =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">binwidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Distribution of Posterior Test Statistic"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</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;">yaxis_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">on =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb6-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb6-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'yrep' not found</span></span>
<span id="cb6-26"></span>
<span id="cb6-27">values_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> h[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plot_env"</span>]][[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T_yrep"</span>]]</span>
<span id="cb6-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb6-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'h' not found</span></span>
<span id="cb6-30">prob_to_find <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> h[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plot_env"</span>]][[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T_y"</span>]]</span>
<span id="cb6-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb6-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'h' not found</span></span>
<span id="cb6-33">quantInv <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>(distr, value) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ecdf</span>(distr)(value)</span>
<span id="cb6-34">posterior_p_value <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;">quantInv</span>(values_all, prob_to_find)</span>
<span id="cb6-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb6-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'values_all' not found</span></span>
<span id="cb6-37"></span>
<span id="cb6-38">l <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;">ppc_stat_2d</span>(Y, yrep) <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;">theme_bw</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;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Distribution of Posterior Test Statistic"</span>)</span>
<span id="cb6-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb6-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'yrep' not found</span></span>
<span id="cb6-41"></span>
<span id="cb6-42"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(h)</span>
<span id="cb6-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `h()`:</span></span>
<span id="cb6-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! error in evaluating the argument 'x' in selecting a method for function 'plot': object 'h' not found</span></span>
<span id="cb6-45"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(l)</span>
<span id="cb6-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `h()`:</span></span>
<span id="cb6-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! error in evaluating the argument 'x' in selecting a method for function 'plot': object 'l' not found</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<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;">print</span>(prob_to_find)</span>
<span id="cb7-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `h()`:</span></span>
<span id="cb7-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! error in evaluating the argument 'x' in selecting a method for function 'print': object 'prob_to_find' not found</span></span></code></pre></div></div>
</div>
<hr>
<p>The above is the posterior predictive test statistic for one model, along with it’s distribution. Now let’s iterate this process, convert them into posterior predictive <img src="https://latex.codecogs.com/png.latex?P">-values, and generate their distribution.</p>
<hr>
<div class="cell" data-layout-align="center">
<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;">rstan_options</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">auto_write =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb8-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">options</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mc.cores =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb8-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">RNGkind</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"L'Ecuyer-CMRG"</span>)</span>
<span id="cb8-4">set.seed <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;">1031</span></span>
<span id="cb8-5">n.sim <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>
<span id="cb8-6">ppp <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;">numeric</span>(n.sim)</span>
<span id="cb8-7">n.samp <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;">1000</span></span>
<span id="cb8-8"></span>
<span id="cb8-9">quantInv <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>(distr, value) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ecdf</span>(distr)(value)</span>
<span id="cb8-10"></span>
<span id="cb8-11"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <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="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(ppp)) {</span>
<span id="cb8-12">    X <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.samp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb8-13">    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.samp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb8-14">    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;">data.frame</span>(X, Y)</span>
<span id="cb8-15">    mod1 <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;">stan_glm</span>(Y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> X, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> df, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">chains =</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;">cores =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb8-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">iter =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">refresh =</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;">prior =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">normal</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;">10</span>))</span>
<span id="cb8-17">    yrep <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;">posterior_predict</span>(mod1)</span>
<span id="cb8-18">    h <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;">ppc_stat</span>(Y, yrep, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stat =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"median"</span>)</span>
<span id="cb8-19">    values_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> h[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plot_env"</span>]][[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T_yrep"</span>]]</span>
<span id="cb8-20">    prob_to_find <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> h[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plot_env"</span>]][[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T_y"</span>]]</span>
<span id="cb8-21">    posterior_p_value <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;">quantInv</span>(values_all, prob_to_find)</span>
<span id="cb8-22">    ppp[i] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> posterior_p_value</span>
<span id="cb8-23">}</span>
<span id="cb8-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `if (!prior_dist_name %in% unlist(ok_dists)) ...`:</span></span>
<span id="cb8-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! argument is of length zero</span></span>
<span id="cb8-26"></span>
<span id="cb8-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</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> ppp)) <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;">geom_histogram</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bins =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</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;">"black"</span>,</span>
<span id="cb8-28">    <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;">"#99c7c7"</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.25</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;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Distribution of Posterior Predictive P-values"</span>,</span>
<span id="cb8-29">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"From Simulation of 1000 Simple Linear Regressions"</span>,</span>
<span id="cb8-30">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Posterior Predictive P-value"</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;">scale_x_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb8-31">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.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;">theme_bw</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-8-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>We can also show this in <code>Stata 16.1</code>, using their new <code>bayesstats ppvalues</code> command which generates posterior predictive <img src="https://latex.codecogs.com/png.latex?P">-values.</p>
<hr>
<div class="cell" data-layout-align="center" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb9-1"></span>
<span id="cb9-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">obs</span> 100</span>
<span id="cb9-3"></span>
<span id="cb9-4"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">generate</span> x = rnormal(0, 1)</span>
<span id="cb9-5"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">generate</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">y</span> = rnormal(0, 1)</span>
<span id="cb9-6"></span>
<span id="cb9-7">parallel initialize 8, f</span>
<span id="cb9-8">bayesmh <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">y</span> x, likelihood(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">normal</span>({<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span>})) prior({<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span>}, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">normal</span>(0, 10))</span>
<span id="cb9-9">prior({<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">y</span>:}, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">normal</span>(0, 10)) rseed(1031) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">saving</span>(coutput_pred, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span>) mcmcsize(1000)</span>
<span id="cb9-10"></span>
<span id="cb9-11">bayespredict (<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">mean</span>:@mean({_resid})) (<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span>:@variance({_resid})),</span>
<span id="cb9-12">rseed(1031) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">saving</span>(coutput_pred, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span>)</span>
<span id="cb9-13">bayesstats ppvalues {<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">mean</span>} <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> coutput_pred</span></code></pre></div></div>
</div>
<hr>
<p>As we can see from the <code>R</code> plot above, the test statistics are are generally concentrated around <code>0.5</code> and the distribution (as shown above via the <code>R</code> code) hardly resembles the uniform distribution of <img src="https://latex.codecogs.com/png.latex?P">-value under the null model. Further, the base-2 log transformation of posterior predictive <img src="https://latex.codecogs.com/png.latex?P">-values is not exponentially distributed, making them invalid <img src="https://latex.codecogs.com/png.latex?S">-values in our terms.</p>
<hr>
<div class="cell" data-layout-align="center">
<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"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</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> (<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;">log2</span>(ppp)))) <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;">geom_histogram</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bins =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>,</span>
<span id="cb10-2">    <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;">"black"</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;">"#d46c5b"</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.25</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;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Distribution of -log2(Posterior Predictive P-values)"</span>,</span>
<span id="cb10-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"S-values Produced From Posterior Predictive P-values"</span>,</span>
<span id="cb10-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-log2(Posterior Predictive P-value)"</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;">theme_bw</span>()</span>
<span id="cb10-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `geom_histogram()`:</span></span>
<span id="cb10-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! Problem while computing stat.</span></span>
<span id="cb10-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ℹ Error occurred in the 1st layer.</span></span>
<span id="cb10-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Caused by error in `seq_len()`:</span></span>
<span id="cb10-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! argument must be coercible to non-negative integer</span></span></code></pre></div></div>
</div>
<hr>
</section>
<section id="table-1-some-p-values-s-values-maximum-likelihood-ratios-and-likelihood-ratio-statistics" class="level2">
<h2 class="anchored" data-anchor-id="table-1-some-p-values-s-values-maximum-likelihood-ratios-and-likelihood-ratio-statistics">Table 1: Some <img src="https://latex.codecogs.com/png.latex?P">-values, <img src="https://latex.codecogs.com/png.latex?S">-values, Maximum Likelihood Ratios, and Likelihood Ratio Statistics</h2>
<hr>
<p>Here, we look at some common <img src="https://latex.codecogs.com/png.latex?P">-values, and how they correspond to other information statistics and likelihood measures.</p>
<hr>
<div class="cell" data-layout-align="center">
<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">pvalue <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;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.99</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.025</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.005</span>,</span>
<span id="cb11-2">    <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-04</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"5 sigma (~ 2.9 in 10 million)"</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1 in 100 million (GWAS)"</span>),</span>
<span id="cb11-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"6 sigma (~ 1 in a billion)"</span>))</span>
<span id="cb11-4"></span>
<span id="cb11-5">svalue <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;">round</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="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log2</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.99</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.025</span>,</span>
<span id="cb11-6">    <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.005</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-04</span>)), <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">21.7</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">26.6</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">29.9</span>), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb11-7"></span>
<span id="cb11-8">pvalue[<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;">10</span>] <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;">formatC</span>(pvalue[<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;">10</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"e"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb11-9"></span>
<span id="cb11-10">mlr <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;">round</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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.01</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.26</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.94</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.87</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">6.83</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">12.3</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">27.6</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">51.4</span>,</span>
<span id="cb11-11">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1935</span>, (<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.2</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;">10</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;">5</span>)), (<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.4</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;">10</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;">7</span>)), (<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.3</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;">10</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;">8</span>))), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb11-12"></span>
<span id="cb11-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># likelihood ratio statistic</span></span>
<span id="cb11-14"></span>
<span id="cb11-15">lr <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;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.00016</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.016</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.45</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.32</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.71</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.84</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.02</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">6.63</span>,</span>
<span id="cb11-16">    <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">7.88</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">15.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">26.3</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">32.8</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">37.4</span>), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb11-17"></span>
<span id="cb11-18">table1 <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>(pvalue, svalue, mlr, lr)</span>
<span id="cb11-19"></span>
<span id="cb11-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(table1) <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P-value (compatibility)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"S-value (bits)"</span>,</span>
<span id="cb11-21">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Maximum Likelihood Ratio"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Deviance Statistic 2ln(MLR)"</span>)</span>
<span id="cb11-22"></span>
<span id="cb11-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kbl</span>(table1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"html"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">padding =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">longtable =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb11-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#777"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">row_spec</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row =</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;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#777"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bold =</span> T) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-26">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">column_spec</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">column =</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;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#777"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bold =</span> F) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">full_width =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">html_font =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Cambria"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lightable_options =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"basic"</span>,</span>
<span id="cb11-28">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">font_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fixed_thead =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">enabled =</span> F)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-29">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">footnote</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">general_title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Abbreviations: "</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title_format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"underline"</span>,</span>
<span id="cb11-30">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">general =</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;">"Table 1 $P$-values                  and binary $S$-values, with corresponding maximum-likelihood ratios (MLR) and deviance (likelihood-ratio) statistics for a simple test hypothesis H under background assumptions A"</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<table class="lightable-classic caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: left; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">P-value (compatibility)</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">S-value (bits)</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Maximum Likelihood Ratio</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Deviance Statistic 2ln(MLR)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.99</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.00e+00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.00</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.9</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.15</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.01e+00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.02</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.5</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.26e+00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.45</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.25</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.94e+00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.32</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.1</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">3.32</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">3.87e+00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.71</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.05</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">4.32</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">6.83e+00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">3.84</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.025</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.32</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.23e+01</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.02</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">6.64</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.76e+01</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">6.63</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.005</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">7.64</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.14e+01</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">7.88</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">1e-04</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">13.29</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.94e+03</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">15.10</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">5 sigma (~ 2.9 in 10 million)</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">21.70</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.20e+05</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">26.30</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">1 in 100 million (GWAS)</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">26.60</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.40e+07</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">32.80</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">6 sigma (~ 1 in a billion)</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">29.90</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.30e+08</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">37.40</td>
</tr>
</tbody><tfoot>
<tr class="odd">
<td style="text-align: left; padding: 0;"><span style="text-decoration: underline;">Abbreviations: </span></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
</tr>
<tr class="even">
<td style="text-align: left; padding: 0;"><sup></sup> Table 1 $P$-values and binary $S$-values, with corresponding maximum-likelihood ratios (MLR) and deviance (likelihood-ratio) statistics for a simple test hypothesis H under background assumptions A</td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
</tr>
</tfoot>

</table>
</div>
</div>
<hr>
<p>For further discussion of 5 and 6 sigma cutoffs, see<span class="citation" data-cites="cousinsJeffreysLindleyParadox2017"><sup>7</sup></span>.</p>
<hr>
</section>
<section id="frequentist-interval-estimate-percentiles" class="level2">
<h2 class="anchored" data-anchor-id="frequentist-interval-estimate-percentiles">Frequentist Interval Estimate Percentiles</h2>
</section>
<section id="refer-to-long-run-coverage" class="level2">
<h2 class="anchored" data-anchor-id="refer-to-long-run-coverage">Refer to Long-Run Coverage</h2>
<hr>
<p>Here we simulate a study where one group with 100 participants has an <img src="https://latex.codecogs.com/png.latex?%5Cmu"> of <code>100</code> with a <img src="https://latex.codecogs.com/png.latex?%5Csigma"> of <code>20</code> and the second group has the same number of participants but an average of <code>80</code> and a standard deviation of <code>20.</code> We compare them using a Welch’s <img src="https://latex.codecogs.com/png.latex?t">-test and generate 95% compatibility intervals several times, specifically <code>100</code> times, and then plot them. Since we know the mean difference is <code>20</code>, we wish to see how often the interval estimates cover this true parameter value.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-12-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="1056"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>This shows that the intervals tend to vary simply as a result of randomness, and that the proper interpretation of the attached percentile is about long run coverage of the true parameter. However, this does not preclude interpretation of a single interval estimate from a study.<span class="citation" data-cites="coxChapterIntervalEstimation1974"><sup>8</sup></span> As we write in the <em>Replace unrealistic “confidence” claims with compatibility measures</em> section of our paper.<span class="citation" data-cites="rafiSemanticCognitiveTools2020"><sup>1</sup></span></p>
<hr>
<blockquote class="blockquote">
<p>The fact that “confidence” refers to the procedure behavior, not the reported interval, seems to be lost on most researchers. Remarking on this subtlety, when Jerzy Neyman discussed his confidence concept in 1934 at a meeting of the Royal Statistical Society, Arthur Bowley replied, “I am not at all sure that the ‘confidence’ is not a confidence trick.”<span class="citation" data-cites="bowleyDiscussionDrNeyman1934"><sup>9</sup></span>. And indeed, 40 years later, Cox and Hinkley warned, “interval estimates cannot be taken as probability statements about parameters, and foremost is the interpretation ‘such and such parameter values are consistent with the data.’”<span class="citation" data-cites="coxChapterIntervalEstimation1974"><sup>8</sup></span>. Unfortunately, the word “consistency” is used for several other concepts in statistics, while in logic it refers to an absolute condition (of noncontradiction); thus, its use in place of “confidence” would risk further confusion.</p>
<p>To address the problems above, we exploit the fact that a 95% CI summarizes the results of varying the test hypothesis H over a range of parameter values, displaying all values for which <img src="https://latex.codecogs.com/png.latex?p"> &gt; 0.05<span class="citation" data-cites="coxPrinciplesStatisticalInference2006"><sup>10</sup></span> and hence <img src="https://latex.codecogs.com/png.latex?s"> &lt; 4.32 bits<span class="citation" data-cites="greenlandValidPvaluesBehave2019"><sup>3</sup></span>;<span class="citation" data-cites="amrheinInferentialStatisticsDescriptive2019"><sup>11</sup></span>. Thus the CI contains a range of parameter values that are more compatible with the data than are values outside the interval, under the background assumptions<span class="citation" data-cites="greenlandValidPvaluesBehave2019"><sup>3</sup></span>;<span class="citation" data-cites="greenlandStatisticalTestsValues2016"><sup>12</sup></span>. Unconditionally (and thus even if the background assumptions are uncertain), the interval shows the values of the parameter which, when combined with the background assumptions, produce a test model that is “highly compatible” with the data in the sense of having less than 4.32 bits of information against it. We thus refer to CI as compatibility intervals rather than confidence intervals<span class="citation" data-cites="greenlandAreConfidenceIntervals2019"><sup>13</sup></span>;<span class="citation" data-cites="greenlandValidPvaluesBehave2019"><sup>3</sup></span>;<span class="citation" data-cites="amrheinInferentialStatisticsDescriptive2019"><sup>11</sup></span>; their abbreviation remains “CI.” We reject calling these intervals “uncertainty intervals,” because they do not capture uncertainty about background assumptions<span class="citation" data-cites="greenlandAreConfidenceIntervals2019"><sup>13</sup></span>.</p>
</blockquote>
<hr>
<p>Indeed, this also has to do with our paper on deemphasizing the model assumptions that are often behind common statistical outputs, and why it is necessary to treat them as uncertain, rather than given.<span class="citation" data-cites="greenlandAidScientificInference2020"><sup>14</sup></span> For example, a 95% interval estimate is assumed to be free of bias in its construction, however, it’s coverage claims are no longer so, once there are systematic errors in play. Many of these common, classical statistical procedures are designed to deal with random variation, and less so with bias (a relatively new field, with shiny new methods).</p>
<hr>
</section>
<section id="brown-et-al.-2017-reanalysis" class="level1">
<h1>Brown et al.&nbsp;(2017) Reanalysis</h1>
<hr>
<p>Taken from the <a href="https://doi.org/10.1001/jama.2017.3415">Brown et al.&nbsp;data.</a><span class="citation" data-cites="brownAssociationSerotonergicAntidepressant2017 brownAssociationAntenatalExposure2017"><sup>15, 16</sup></span></p>
<p>Here we take the reported statistics from the Brown et al.&nbsp;studies in order to run statistical tests of different alternative test hypotheses and use those results to construct various functions.</p>
<p>We calculate the standard errors from the point estimate and the confidence (compatibility) limits.</p>
<hr>
<div class="cell" data-layout-align="center">
<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">se <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;">log</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.59</span><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.997</span>)<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;">3.92</span></span>
<span id="cb12-2"></span>
<span id="cb12-3">logUL <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;">log</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.59</span>)</span>
<span id="cb12-4">logLL <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;">log</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.997</span>)</span>
<span id="cb12-5"></span>
<span id="cb12-6">logpoint <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;">log</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.61</span>)</span>
<span id="cb12-7"></span>
<span id="cb12-8">logpoint <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;">1.96</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> se)</span>
<span id="cb12-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 0.954</span></span>
<span id="cb12-10">logpoint <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;">1.96</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> se)</span>
<span id="cb12-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] -0.0011</span></span></code></pre></div></div>
</div>
<hr>
<section id="table-2-p-values-s-values-and-likelihoods-for-targeted-hypotheses-about-hazard-ratios-for-brown-et-al." class="level2">
<h2 class="anchored" data-anchor-id="table-2-p-values-s-values-and-likelihoods-for-targeted-hypotheses-about-hazard-ratios-for-brown-et-al.">Table 2: <img src="https://latex.codecogs.com/png.latex?P">-values, <img src="https://latex.codecogs.com/png.latex?S">-values, and Likelihoods for Targeted Hypotheses About Hazard Ratios for <a href="https://doi.org/10.1001/jama.2017.3415">Brown et al.</a></h2>
<hr>
<div class="cell" data-layout-align="center">
<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">testhypothesis <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Halving of hazard"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No effect (null)"</span>,</span>
<span id="cb13-2">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Point estimate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Doubling of hazard"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Tripling of hazard"</span>,</span>
<span id="cb13-3">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Quintupling of hazard"</span>)</span>
<span id="cb13-4"></span>
<span id="cb13-5">hazardratios <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;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.61</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb13-6">pvals <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;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.6e-06</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.37</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.2e-06</span>)</span>
<span id="cb13-7">svals <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;">round</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;">log2</span>(pvals), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb13-8">mlr2 <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;">c</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;">10</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;">5</span>), <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">6.77</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.49</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">26.2</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;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</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;">4</span>))</span>
<span id="cb13-9">lr <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;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>((((<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span><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;">1.61</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>se)<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;">2</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;">2</span>)), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>((((<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.61</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>se)<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;">2</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;">2</span>)),</span>
<span id="cb13-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>((((<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.61</span><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;">1.61</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>se)<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;">2</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;">2</span>)), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>((((<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><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;">1.61</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>se)<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;">2</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;">2</span>)),</span>
<span id="cb13-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>((((<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(<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;">/</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.61</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>se)<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;">2</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;">2</span>)), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>((((<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</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;">/</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.61</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>se)<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;">2</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;">2</span>))),</span>
<span id="cb13-12">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb13-13"></span>
<span id="cb13-14">LR <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;">formatC</span>(lr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"e"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb13-15"></span>
<span id="cb13-16">table2 <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>(testhypothesis, hazardratios, pvals, svals,</span>
<span id="cb13-17">    mlr2, LR)</span>
<span id="cb13-18"></span>
<span id="cb13-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(table2) <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Test Hypothesis"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"HR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P-values"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"S-values"</span>,</span>
<span id="cb13-20">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MLR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LR"</span>)</span>
<span id="cb13-21"></span>
<span id="cb13-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kbl</span>(table2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"html"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">padding =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">longtable =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb13-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#777"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-24">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">row_spec</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row =</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;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#777"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bold =</span> T) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">column_spec</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">column =</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;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#777"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bold =</span> F) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-26">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">full_width =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">html_font =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Cambria"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lightable_options =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"basic"</span>,</span>
<span id="cb13-27">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">font_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fixed_thead =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">enabled =</span> F))</span></code></pre></div></div>
<div class="cell-output-display">
<table class="lightable-classic caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: left; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Test Hypothesis</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">HR</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">P-values</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">S-values</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">MLR</th>
<th data-quarto-table-cell-role="th" style="text-align: left; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">LR</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Halving of hazard</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.50</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">19.25</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.00e+05</td>
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">1.02e+05</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">No effect (null)</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.05</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">4.32</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">6.77e+00</td>
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">6.77e+00</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Point estimate</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.61</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.00e+00</td>
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">1.00e+00</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Doubling of hazard</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.37</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.43</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.49e+00</td>
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">1.49e+00</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Tripling of hazard</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">3.00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">6.64</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.62e+01</td>
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">2.62e+01</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Quintupling of hazard</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">18.25</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.00e+04</td>
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">5.03e+04</td>
</tr>
</tbody>
</table>
</div>
</div>
<hr>
</section>
<section id="plot-the-point-estimate-and-95-compatibility-interval" class="level2">
<h2 class="anchored" data-anchor-id="plot-the-point-estimate-and-95-compatibility-interval">Plot the point estimate and 95% compatibility interval</h2>
<hr>
<div class="cell" data-layout-align="center">
<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">label <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Brown et al. (2017)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> JAMA"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Brown et al. (2017)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> J Clin Psychiatry"</span>)</span>
<span id="cb14-2"></span>
<span id="cb14-3">point <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;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.61</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.7</span>)</span>
<span id="cb14-4">lower <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;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.997</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.1</span>)</span>
<span id="cb14-5">upper <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;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.59</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.6</span>)</span>
<span id="cb14-6"></span>
<span id="cb14-7">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;">data.frame</span>(label, point, lower, upper)</span></code></pre></div></div>
</div>
<hr>
<p>Here we plot the 95% compatibility interval estimate reported from the high-dimensional propensity score analysis.</p>
<hr>
<div class="cell" data-layout-align="center">
<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"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> df, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping =</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> label, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> point, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> lower,</span>
<span id="cb15-2">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> upper, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> label)) <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;">geom_pointrange</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#007C7C"</span>,</span>
<span id="cb15-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</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.4</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;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</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;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb15-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d46c5b"</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.5</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;">coord_flip</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;">scale_y_log10</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> scales<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;">pretty_breaks</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>),</span>
<span id="cb15-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">limits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</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;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Association Between Serotonergic Antidepressant Exposure</span></span>
<span id="cb15-6"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">               </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">During Pregnancy and Child Autism Spectrum Disorder"</span>,</span>
<span id="cb15-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Reported 95% Compatibility Intervals From Primary Results"</span>,</span>
<span id="cb15-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Study"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hazard Ratio (JAMA) +</span></span>
<span id="cb15-9"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">            Adjusted Pooled Odds Ratio (J Clin Psychiatry)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</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;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Null parameter value of 1"</span>,</span>
<span id="cb15-11">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d46c5b"</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.75</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;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>,</span>
<span id="cb15-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Point Estimate = 1.61,</span></span>
<span id="cb15-13"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">           Lower Limit = 0.997, Upper Limit = 2.59"</span>,</span>
<span id="cb15-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#000000"</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.75</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;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>,</span>
<span id="cb15-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Point Estimate = 1.7,</span></span>
<span id="cb15-16"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">           Lower Limit = 1.1, Upper Limit = 2.6"</span>,</span>
<span id="cb15-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#000000"</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.75</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;">theme_light</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;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">angle =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span>,</span>
<span id="cb15-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</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;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</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;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-19">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-16-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="768"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>Once again, the authors reported that<span class="citation" data-cites="brownAssociationSerotonergicAntidepressant2017"><sup>15</sup></span></p>
<blockquote class="blockquote">
<p>In the 2837 pregnancies (7.9%) exposed to antidepressants, 2.0% (95% CI, 1.6%-2.6%) of children were diagnosed with autism spectrum disorder. Risk of autism spectrum disorder was significantly higher with serotonergic antidepressant exposure (4.51 exposed vs 2.03 unexposed per 1000 person-years; between-group difference, 2.48 95% CI, 2.33-2.62 per 1000 person-years) in crude (HR, 2.16 95% CI, 1.64-2.86) and multivariable-adjusted analyses (HR, 1.59 95% CI, 1.17-2.17) (Table 2). After inverse probability of treatment weighting based on the HDPS, the association was not significant (HR, 1.61 95% CI, 0.997-2.59) (Table 2).</p>
</blockquote>
<p>and concluded with</p>
<blockquote class="blockquote">
<p>In children born to mothers receiving public drug coverage in Ontario, Canada, in utero serotonergic antidepressant exposure compared with no exposure was not associated with autism spectrum disorder in the child. Although a causal relationship cannot be ruled out, the previously observed association may be explained by other factors.</p>
</blockquote>
<p>We will show using the graphical and tabular summaries below, why a more nuanced summary such as,</p>
<blockquote class="blockquote">
<p>“After HDPS adjustment for confounding, a 61% hazard elevation remained; however, under the same model, every hypothesis from no elevation up to a 160% hazard increase had <img src="https://latex.codecogs.com/png.latex?p"> &gt; 0.05; Thus, while quite imprecise, these results are consistent with previous observations of a positive association between serotonergic antidepressant prescriptions and subsequent ASD. Because the association may be partially or wholly due to uncontrolled biases, further evidence will be needed for evaluating what, if any, proportion of it can be attributed to causal effects of prenatal serotonergic antidepressant use on ASD incidence.”</p>
</blockquote>
<p>would have been far more appropriate, as we discuss in our paper.<span class="citation" data-cites="rafiSemanticCognitiveTools2020"><sup>1</sup></span></p>
<hr>
</section>
<section id="p-value-and-s-value-functions" class="level2">
<h2 class="anchored" data-anchor-id="p-value-and-s-value-functions"><img src="https://latex.codecogs.com/png.latex?P">-value and <img src="https://latex.codecogs.com/png.latex?S">-value Functions</h2>
<hr>
<p>In order to use this information to construct a <img src="https://latex.codecogs.com/png.latex?P">-value function, we can use the <a href="https://data.lesslikely.com/concurve/"><code>concurve</code></a> functions.</p>
<hr>
<div class="cell" data-layout-align="center">
<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"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concurve"</span>)</span></code></pre></div></div>
</div>
<hr>
<p>We enter the reported point estimates and compatibility limits and produce all possible intervals + <img src="https://latex.codecogs.com/png.latex?P">-values + <img src="https://latex.codecogs.com/png.latex?S">-values. This is calculated assuming normal approximations with the <a href="https://data.lesslikely.com/concurve/reference/curve_rev.html"><code>curve_rev()</code></a> function.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">curve1 <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;">curve_rev</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">point =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.61</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">LL =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.997</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">UL =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.59</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ratio"</span>)</span></code></pre></div></div>
</div>
<hr>
<p>It is stored in the object <code>curve1</code>.</p>
<p>We can generate a table of the relevant statistics from this reanalysis, similar to the table from above, but this time using the <a href="https://data.lesslikely.com/concurve/index.html"><code>concurve</code></a> function, <a href="https://data.lesslikely.com/concurve/reference/curve_table.html"><code>curve_table()</code></a>, but this time it will give us interval estimates of various percentiles (<img src="https://latex.codecogs.com/png.latex?25">%, <img src="https://latex.codecogs.com/png.latex?50">%, <img src="https://latex.codecogs.com/png.latex?75">%, <img src="https://latex.codecogs.com/png.latex?95">%, etc.). These are in turn used to construct the entire confidence (compatibility) distribution or <img src="https://latex.codecogs.com/png.latex?P">-value function.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kbl</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">curve_table</span>(curve1[[<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;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"html"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">padding =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span>,</span>
<span id="cb18-2">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">longtable =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#777"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> F, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">curve_table</span>(curve1[[<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;">%&gt;%</span></span>
<span id="cb18-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">row_spec</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row =</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;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#777"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bold =</span> T) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb18-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">column_spec</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">column =</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;">7</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#777"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bold =</span> F) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb18-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">full_width =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">html_font =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Cambria"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lightable_options =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"basic"</span>,</span>
<span id="cb18-6">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">font_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fixed_thead =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">enabled =</span> F)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb18-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">footnote</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">general_title =</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;">"Table of Statistics for Various Interval Estimate Percentiles"</span>),</span>
<span id="cb18-8">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">general =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<table class="lightable-classic caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Lower Limit</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Upper Limit</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Interval Width</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Interval Level (%)</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">CDF</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">P-value</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">S-value (bits)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.490</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.74</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.250</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">25.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.625</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.750</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.415</td>
</tr>
<tr class="even">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.366</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.90</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.531</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">50.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.750</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.500</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.000</td>
</tr>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.217</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.13</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.914</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">75.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.875</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.250</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.000</td>
</tr>
<tr class="even">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.178</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.20</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.021</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">80.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.900</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.200</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.322</td>
</tr>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.134</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.29</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.152</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">85.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.925</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.150</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.737</td>
</tr>
<tr class="even">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.079</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.40</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.325</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">90.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.950</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.100</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">3.322</td>
</tr>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.999</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.60</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.596</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">95.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.975</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.050</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">4.322</td>
</tr>
<tr class="even">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.933</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.78</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.846</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">97.5</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.988</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.025</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.322</td>
</tr>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.860</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">3.02</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.155</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">99.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.995</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.010</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">6.644</td>
</tr>
</tbody><tfoot>
<tr class="odd">
<td style="text-align: right; padding: 0;"><span style="font-style: italic;">Table of Statistics for Various Interval Estimate Percentiles</span></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
</tr>
<tr class="even">
<td style="text-align: right; padding: 0;"><sup></sup></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
</tr>
</tfoot>

</table>
</div>
</div>
<hr>
</section>
<section id="figure-3-p-value-compatibility-function" class="level2">
<h2 class="anchored" data-anchor-id="figure-3-p-value-compatibility-function">Figure 3: <img src="https://latex.codecogs.com/png.latex?P">-value (Compatibility) Function</h2>
<hr>
<p>Plot the <img src="https://latex.codecogs.com/png.latex?P">-value (Compatibility) function of the <a href="https://doi.org/10.1001/jama.2017.3415">Brown et al.</a> data</p>
<p>Now we plot the <img src="https://latex.codecogs.com/png.latex?P">-value function from the data stored in <code>curve1</code> using the <a href="https://data.lesslikely.com/concurve/reference/ggcurve.html"><code>ggcurve()</code></a> function from <a href="https://data.lesslikely.com/concurve/"><code>concurve</code></a>.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggcurve</span>(curve1[[<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;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ratio"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nullvalue =</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>
<span id="cb19-2">    <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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</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;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expression</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">italic</span>(P),</span>
<span id="cb19-3">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-value (Compatibility) Function"</span>)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expression</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">italic</span>(P),</span>
<span id="cb19-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-values for a range of hazard ratios (HR)"</span>)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hazard Ratio (HR)"</span>,</span>
<span id="cb19-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expression</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">italic</span>(P), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-value"</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;">geom_vline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.61</span>,</span>
<span id="cb19-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</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;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gray"</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.2</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;">geom_vline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.59</span>,</span>
<span id="cb19-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</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;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gray"</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.2</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;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>),</span>
<span id="cb19-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>),</span>
<span id="cb19-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-20-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>It is practically the same as the published version from <a href="https://doi.org/10.1186/s12874-020-01105-9">Rafi &amp; Greenland, 2020</a><span class="citation" data-cites="rafiSemanticCognitiveTools2020"><sup>1</sup></span>.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1602038429/Site/confidencecurve.svg" width="750"></p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1">curve1 <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;">curve_rev</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">point =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.61</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">LL =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.997</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">UL =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.59</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ratio"</span>)</span>
<span id="cb20-2"></span>
<span id="cb20-3">curve2 <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;">curve_rev</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">point =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.7</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">LL =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">UL =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ratio"</span>)</span></code></pre></div></div>
</div>
<hr>
</section>
<section id="cumulative-confidence-compatibility-distribution" class="level2">
<h2 class="anchored" data-anchor-id="cumulative-confidence-compatibility-distribution">Cumulative Confidence (Compatibility Distribution)</h2>
<hr>
<p>Although we do not cover this figure in our paper, it is easy to construct using <a href="https://data.lesslikely.com/concurve/index.html"><code>concurve's</code></a> <a href="https://data.lesslikely.com/concurve/reference/ggcurve.html"><code>ggcurve()</code></a> function by specifying <code>type</code> as “<code>cdf</code>” to see the median estimate within the confidence distribution. The horizontal line that meets at the curve, is approximately the same as the maximum at the <img src="https://latex.codecogs.com/png.latex?P">-value function/confidence (compatibility) curve.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggcurve</span>(curve1[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]], <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;">"cdf"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ratio"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nullvalue =</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="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb21-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P-values for a range of hazard ratios (HR)"</span>,</span>
<span id="cb21-3">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Association Between Serotonergic Antidepressant Exposure</span></span>
<span id="cb21-4"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">       </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">During Pregnancy and Child Autism Spectrum Disorder"</span>,</span>
<span id="cb21-5">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hazard Ratio (HR)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Cumulative Compatibility"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb21-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>),</span>
<span id="cb21-7">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>),</span>
<span id="cb21-8">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-22-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>We will also calculate the likelihoods so that we can generate the corresponding likelihood functions.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1">lik2 <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;">curve_rev</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">point =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.7</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">LL =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">UL =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.6</span>, <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;">"l"</span>,</span>
<span id="cb22-2">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ratio"</span>)</span>
<span id="cb22-3"></span>
<span id="cb22-4">lik1 <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;">curve_rev</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">point =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.61</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">LL =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.997</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">UL =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.59</span>, <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;">"l"</span>,</span>
<span id="cb22-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ratio"</span>)</span></code></pre></div></div>
</div>
<hr>
<p>We can also see how consistent these results are with previous studies conducted by the same research group, given the overlap of the functions, which can be compared using the <a href="https://data.lesslikely.com/concurve/reference/plot_compare.html"><code>plot_compare()</code></a> function. Let’s compare the relative likelihood functions from both studies from this research group to see how consistent the results are.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot_compare</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data1 =</span> lik1[[<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;">data2 =</span> lik2[[<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;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"l1"</span>,</span>
<span id="cb23-2">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ratio"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nullvalue =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Brown et al. 2017. J Clin Psychiatry. vs.</span></span>
<span id="cb23-3"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">              </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Brown et al. 2017. JAMA."</span>,</span>
<span id="cb23-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"J Clin Psychiatry: OR = 1.7, 1/6.83 LI: LL = 1.1, UL = 2.6</span></span>
<span id="cb23-5"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">                         </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">JAMA: HR = 1.61, 1/6.83 LI: LL = 0.997, UL = 2.59"</span>,</span>
<span id="cb23-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xaxis =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hazard Ratio / Odds Ratio"</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;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>),</span>
<span id="cb23-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>),</span>
<span id="cb23-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-24-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>and the <img src="https://latex.codecogs.com/png.latex?P">-value functions.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot_compare</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data1 =</span> curve1[[<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;">data2 =</span> curve2[[<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;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"c"</span>,</span>
<span id="cb24-2">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ratio"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nullvalue =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Brown et al. 2017. J Clin Psychiatry. vs.</span></span>
<span id="cb24-3"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">              </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Brown et al. 2017. JAMA."</span>,</span>
<span id="cb24-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"J Clin Psychiatry: OR = 1.7, 1/6.83 LI: LL = 1.1, UL = 2.6</span></span>
<span id="cb24-5"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">              </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">JAMA: HR = 1.61, 1/6.83 LI: LL = 0.997, UL = 2.59"</span>,</span>
<span id="cb24-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xaxis =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hazard Ratio / Odds Ratio"</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;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>),</span>
<span id="cb24-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>),</span>
<span id="cb24-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-25-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
</section>
<section id="figure-4-s-value-suprisal-function" class="level2">
<h2 class="anchored" data-anchor-id="figure-4-s-value-suprisal-function">Figure 4: <img src="https://latex.codecogs.com/png.latex?S">-value (Suprisal) Function</h2>
<hr>
<p>Plot the <img src="https://latex.codecogs.com/png.latex?S">-value (Surprisal) function of the <a href="https://doi.org/10.1001/jama.2017.3415">Brown et al.</a> data with <a href="https://data.lesslikely.com/concurve/reference/ggcurve.html"><code>ggcurve()</code></a></p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggcurve</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> curve1[[<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;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"s"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ratio"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nullvalue =</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>
<span id="cb25-2">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"S-value (Surprisal) Function"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"S-Values (surprisals) for a range of hazard ratios (HR)"</span>,</span>
<span id="cb25-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xaxis =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hazard Ratio"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yaxis1 =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"S-value (bits of information)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb25-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>),</span>
<span id="cb25-5">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>),</span>
<span id="cb25-6">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-26-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="576"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>which is quite close to the figure from our paper.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1602200052/Site/surprisalcurve.png" width="750"></p>
<hr>
</section>
<section id="likelihood-support-functions" class="level2">
<h2 class="anchored" data-anchor-id="likelihood-support-functions">Likelihood (Support) Functions</h2>
<hr>
<p>Here we provide the code to show how we constructed the likelihood functions from our paper, which are the supplementary figures found <a href="https://static-content.springer.com/esm/art%3A10.1186%2Fs12874-020-01105-9/MediaObjects/12874_2020_1105_MOESM3_ESM.pdf">here (S1)</a> and <a href="https://static-content.springer.com/esm/art%3A10.1186%2Fs12874-020-01105-9/MediaObjects/12874_2020_1105_MOESM4_ESM.pdf">here (S2)</a>.</p>
<hr>
<p>Calculate and Plot Likelihood (Support) Intervals.</p>
<p>Here we use the reported estimates to construct the <img src="https://latex.codecogs.com/png.latex?Z">-scores and standard errors, which are in turn used to compute the likelihoods.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb26-1">hrvalues <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;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.65</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.98</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>)</span>
<span id="cb26-2"></span>
<span id="cb26-3">se <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;">log</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.59</span><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.997</span>)<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;">3.92</span></span>
<span id="cb26-4"></span>
<span id="cb26-5">zscore <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;">sapply</span>(hrvalues, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i) (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(i<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;">1.61</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>se))</span></code></pre></div></div>
</div>
<hr>
</section>
<section id="figure-s1-relative-likelihood-function" class="level2">
<h2 class="anchored" data-anchor-id="figure-s1-relative-likelihood-function">Figure S1: Relative Likelihood Function</h2>
<hr>
<p>We then standardize all the likelihoods by their maximum at the likelihood function,<span class="citation" data-cites="jewellStatisticsEpidemiology2003"><sup>17</sup></span> to produce relative likelihoods, likelihood intervals, and their corresponding relative likelihood function.<span class="citation" data-cites="royallStatisticalEvidenceLikelihood1997"><sup>18</sup></span></p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">support <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;">exp</span>((<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>zscore<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;">2</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;">2</span>)</span>
<span id="cb27-2"></span>
<span id="cb27-3">likfunction <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>(hrvalues, zscore, support)</span>
<span id="cb27-4"></span>
<span id="cb27-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> likfunction, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping =</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> hrvalues, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> support)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</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;">geom_vline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</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;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d46c5b"</span>,</span>
<span id="cb27-7">    <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.75</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;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">6.83</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb27-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#333333"</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.05</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;">geom_ribbon</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> hrvalues,</span>
<span id="cb27-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(support), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> support), <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;">"#d46c5b"</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.1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Relative Likelihood Function"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Relative likelihoods for a range of hazard ratios"</span>,</span>
<span id="cb27-11">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hazard Ratio (HR)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Relative Likelihood </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1/MLR"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.65</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1/6.83 LI = 0.997, 2.59"</span>,</span>
<span id="cb27-13">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#000000"</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;">theme_bw</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;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>),</span>
<span id="cb27-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>),</span>
<span id="cb27-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_log10</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> scales<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;">pretty_breaks</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</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;">scale_y_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mult =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>,</span>
<span id="cb27-17">    <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.0125</span>)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-28-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>The <img src="https://latex.codecogs.com/png.latex?%5Cfrac%7B1%7D%7B6.83%7D"> likelihood interval corresponds to the 95% compatibility interval, as shown by the figure from our paper.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1602200052/Site/relativelikelihood.png" width="750"></p>
<hr>
<p>Below we use the calculated <img src="https://latex.codecogs.com/png.latex?Z">-scores to construct the log-likelihood function which is the upward-concave parabola <img src="https://latex.codecogs.com/png.latex?%5Cfrac%7BZ%5E%7B2%7D%7D%7B2%7D"> = <img src="https://latex.codecogs.com/png.latex?-ln(MLR)"></p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1">support <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (zscore<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;">2</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;">2</span></span>
<span id="cb28-2"></span>
<span id="cb28-3">likfunction <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>(hrvalues, zscore, support)</span>
<span id="cb28-4"></span>
<span id="cb28-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> likfunction, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping =</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> hrvalues, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> support)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb28-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</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;">geom_vline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</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;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d46c5b"</span>,</span>
<span id="cb28-7">    <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.75</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;">geom_ribbon</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> hrvalues, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> support,</span>
<span id="cb28-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(support)), <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;">"#d46c5b"</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.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;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Log-Likelihood Function"</span>,</span>
<span id="cb28-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Log-likelihoods for a range of hazard ratios"</span>,</span>
<span id="cb28-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hazard Ratio (HR)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ln(MLR)"</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;">theme_bw</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;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>),</span>
<span id="cb28-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</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;">scale_x_log10</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> scales<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;">pretty_breaks</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb28-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mult =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.0125</span>)),</span>
<span id="cb28-13">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</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;">7</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;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb28-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-29-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
</section>
<section id="figure-s2-deviance-function-2lnmlr" class="level2">
<h2 class="anchored" data-anchor-id="figure-s2-deviance-function-2lnmlr">Figure S2: Deviance Function <img src="https://latex.codecogs.com/png.latex?2ln(MLR)"></h2>
<hr>
<p>Known as the deviance function, it is twice the log-likelihood, which maps to the <img src="https://latex.codecogs.com/png.latex?S">-value function.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1">support <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (zscore<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;">2</span>)</span>
<span id="cb29-2"></span>
<span id="cb29-3">likfunction <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>(hrvalues, zscore, support)</span>
<span id="cb29-4"></span>
<span id="cb29-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> likfunction, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping =</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> hrvalues, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> support)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</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;">geom_vline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</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;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d46c5b"</span>,</span>
<span id="cb29-7">    <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.75</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;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.84</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</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;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#333333"</span>,</span>
<span id="cb29-8">    <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.05</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;">geom_ribbon</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> hrvalues, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> support,</span>
<span id="cb29-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(support)), <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;">"#d46c5b"</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.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;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>,</span>
<span id="cb29-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.65</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1/6.83 LI = 0.997, 2.59"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb29-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#000000"</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;">theme_bw</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;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>),</span>
<span id="cb29-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>),</span>
<span id="cb29-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_log10</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> scales<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;">pretty_breaks</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</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;">scale_y_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mult =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>,</span>
<span id="cb29-15">    <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.0125</span>)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</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;">14</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</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;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Deviance Function"</span>,</span>
<span id="cb29-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Deviance statistics for a range of hazard ratios"</span>,</span>
<span id="cb29-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hazard Ratio (HR)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" Deviance Statistic </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">2ln(MLR)"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/RG2020BMC_files/figure-html/unnamed-chunk-30-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>And the version from our paper can be found <a href="https://static-content.springer.com/esm/art%3A10.1186%2Fs12874-020-01105-9/MediaObjects/12874_2020_1105_MOESM4_ESM.pdf">here</a>.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1602200052/Site/deviancefunction.png" width="750"></p>
<hr>
<p>It is important to note that although we have calculated these likelihood functions manually here, they can also be generated easily using the <a href="https://data.lesslikely.com/concurve/reference/curve_lik.html"><code>curve_lik()</code></a> function which takes inputs from the <a href="https://cran.r-project.org/package=ProfileLikelihood"><code>ProfileLikelihood</code></a> <code>R</code> package. To see a further discussion, please see the <a href="https://data.lesslikely.com/concurve/articles/likelihood.html">following article</a>, which gives several examples for a wide variety of models.</p>
<p>Further, we urge some caution. Although we endorse the construction and presentation of likelihood functions along with <img src="https://latex.codecogs.com/png.latex?P">-value and <img src="https://latex.codecogs.com/png.latex?S">-value functions, along with the tabulations, the use of pure likelihood methods has been highly controversial among some statisticians, with some going as far as to say that <em>likelihood is blind</em> although not all statisticians believe this, and have responded to such criticisms in kind, see discussants.<span class="citation" data-cites="daviesApproximatingDataDiscussion2008"><sup>19</sup></span> Thus, we support providing both <img src="https://latex.codecogs.com/png.latex?P">-value/<img src="https://latex.codecogs.com/png.latex?S">-value and likelihood-based functions for a complete picture.</p>
<p>Indeed, we can see how they all easily map to one another when plotted side by side, with the following script.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cowplot"</span>)</span>
<span id="cb30-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot_grid</span>(confcurve, surprisalcurve, relsupportfunction, deviancefunction,</span>
<span id="cb30-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span></code></pre></div></div>
</div>
<hr>
<p>A clearer plot comparing the four functions is seen below (click on the image to view in full).</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1581988661/Site/Comparisons.png" width="1000" style="cursor: zoom-in"></p>
<hr>
<p>Additional adjustments that were made to the figures from <a href="https://doi.org/10.1186/s12874-020-01105-9">Rafi &amp; Greenland, 2020</a><span class="citation" data-cites="rafiSemanticCognitiveTools2020"><sup>1</sup></span> were done using Adobe Illustrator and Photoshop.</p>
<p>All errors are ours, and we welcome critical feedback and reporting of errors. To report possible errors in our analyses, please post it as a comment below or as a bug <a href="https://github.com/zadrafi/concurve/issues">here</a>. We will compile them onto a public errata, if any errors or flaws are reported to us.</p>
<hr>
</section>
</section>
<section id="statistical-package-citations" class="level1">
<h1>Statistical Package Citations</h1>
<hr>
<p>Please remember to cite the <code>R</code> packages if you use any of the <code>R</code> scripts from above. The citation for our<span class="citation" data-cites="rafiSemanticCognitiveTools2020"><sup>1</sup></span> can be found below in the References section or it can be <a href="https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-020-01105-9.ris">downloaded here</a> for a reference manager.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb31" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb31-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">citation</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concurve"</span>)</span>
<span id="cb31-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">citation</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TeachingDemos"</span>)</span>
<span id="cb31-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">citation</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ProfileLikelihood"</span>)</span>
<span id="cb31-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">citation</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rstan"</span>)</span>
<span id="cb31-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">citation</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rstanarm"</span>)</span>
<span id="cb31-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">citation</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bayesplot"</span>)</span>
<span id="cb31-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">citation</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"knitr"</span>)</span>
<span id="cb31-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">citation</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kableExtra"</span>)</span>
<span id="cb31-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">citation</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ggplot2"</span>)</span>
<span id="cb31-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">citation</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cowplot"</span>)</span>
<span id="cb31-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">citation</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Statamarkdown"</span>)</span></code></pre></div></div>
</div>
<hr>
</section>
<section id="environment" class="level1">
<h1>Environment</h1>
<hr>
<p>The analyses were run on:</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1">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;">sessionInfo</span>()</span>
<span id="cb32-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(si, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">RNG =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">locale =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb32-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; R version 4.5.2 (2025-10-31)</span></span>
<span id="cb32-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Platform: aarch64-apple-darwin20</span></span>
<span id="cb32-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Running under: macOS Tahoe 26.3</span></span>
<span id="cb32-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb32-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Matrix products: default</span></span>
<span id="cb32-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib </span></span>
<span id="cb32-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1</span></span>
<span id="cb32-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb32-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Random number generation:</span></span>
<span id="cb32-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  RNG:     L'Ecuyer-CMRG </span></span>
<span id="cb32-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Normal:  Inversion </span></span>
<span id="cb32-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Sample:  Rejection </span></span>
<span id="cb32-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  </span></span>
<span id="cb32-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; locale:</span></span>
<span id="cb32-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] C.UTF-8/C.UTF-8/C.UTF-8/C/C.UTF-8/C.UTF-8</span></span>
<span id="cb32-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb32-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; time zone: America/New_York</span></span>
<span id="cb32-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; tzcode source: internal</span></span>
<span id="cb32-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb32-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; attached base packages:</span></span>
<span id="cb32-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1] splines   grid      stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     </span></span>
<span id="cb32-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb32-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; other attached packages:</span></span>
<span id="cb32-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   [1] plotly_4.12.0         TSstudio_0.1.7        tfautograph_0.3.2     tfdatasets_2.18.0     keras_2.16.0         </span></span>
<span id="cb32-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   [6] tensorflow_2.20.0     timetk_2.9.1          modeltime_1.3.5       workflowsets_1.1.1    workflows_1.3.0      </span></span>
<span id="cb32-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [11] tune_2.0.1            tailor_0.1.0          rsample_1.3.2         recipes_1.3.1         parsnip_1.4.1        </span></span>
<span id="cb32-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [16] modeldata_1.5.1       infer_1.1.0           dials_1.4.2           scales_1.4.0          tidymodels_1.4.1     </span></span>
<span id="cb32-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [21] xgboost_3.1.3.1       prophet_1.1.7         rlang_1.1.7           astsa_2.4             bayesforecast_1.0.5  </span></span>
<span id="cb32-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [26] smooth_4.3.1          greybox_2.0.7         glmnet_4.1-10         forecast_9.0.0        fable_0.5.0          </span></span>
<span id="cb32-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [31] fabletools_0.5.1      tsibbledata_0.4.1     tsibble_1.1.6         rstanarm_2.32.2       texPreview_2.1.0     </span></span>
<span id="cb32-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [36] tinytex_0.58          rmarkdown_2.30        brms_2.23.0           bootImpute_1.3.0      knitr_1.51           </span></span>
<span id="cb32-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [41] boot_1.3-32           JuliaCall_0.17.6      reshape2_1.4.5        ProfileLikelihood_1.3 ImputeRobust_1.3-1   </span></span>
<span id="cb32-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [46] gamlss_5.5-0          gamlss.dist_6.1-1     gamlss.data_6.0-7     mvtnorm_1.3-3         performance_0.15.3   </span></span>
<span id="cb32-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [51] summarytools_1.1.5    tidybayes_3.0.7       htmltools_0.5.9       Statamarkdown_0.9.6   car_3.1-3            </span></span>
<span id="cb32-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [56] carData_3.0-6         qqplotr_0.0.7         ggcorrplot_0.1.4.1    mitml_0.4-5           pbmcapply_1.5.1      </span></span>
<span id="cb32-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [61] Amelia_1.8.3          Rcpp_1.1.1            blogdown_1.23         doParallel_1.0.17     iterators_1.0.14     </span></span>
<span id="cb32-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [66] foreach_1.5.2         lattice_0.22-7        bayesplot_1.15.0      wesanderson_0.3.7     VIM_7.0.0            </span></span>
<span id="cb32-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [71] colorspace_2.1-2      here_1.0.2            progress_1.2.3        loo_2.9.0             mi_1.2               </span></span>
<span id="cb32-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [76] Matrix_1.7-4          broom_1.0.12          yardstick_1.3.2       svglite_2.2.2         Cairo_1.7-0          </span></span>
<span id="cb32-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [81] cowplot_1.2.0         mgcv_1.9-4            nlme_3.1-168          xfun_0.56             broom.mixed_0.2.9.6  </span></span>
<span id="cb32-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [86] reticulate_1.44.1     kableExtra_1.4.0      posterior_1.6.1       checkmate_2.3.3       parallelly_1.46.1    </span></span>
<span id="cb32-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [91] miceFast_0.8.5        randomForest_4.7-1.2  missForest_1.6.1      miceadds_3.18-36      quantreg_6.1         </span></span>
<span id="cb32-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [96] SparseM_1.84-2        MCMCpack_1.7-1        MASS_7.3-65           coda_0.19-4.1         latex2exp_0.9.8      </span></span>
<span id="cb32-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [ reached 'max' / getOption("max.print") -- omitted 23 entries ]</span></span>
<span id="cb32-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb32-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; loaded via a namespace (and not attached):</span></span>
<span id="cb32-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   [1] igraph_2.2.1         Formula_1.2-5        rematch2_2.1.2       GPfit_1.0-9          tidyselect_1.2.1    </span></span>
<span id="cb32-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   [6] bridgesampling_1.2-1 lgr_0.5.2            rngtools_1.5.2       mlr3pipelines_0.10.0 dichromat_2.0-0.1   </span></span>
<span id="cb32-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [11] mlr3tuning_1.5.1     png_0.1-8            cli_3.6.5            arrayhelpers_1.1-0   askpass_1.2.1       </span></span>
<span id="cb32-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [16] openssl_2.3.4        textshaping_1.0.4    paradox_1.0.1        officer_0.7.3        lhs_1.2.0           </span></span>
<span id="cb32-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [21] curl_7.0.0           mime_0.13            evaluate_1.0.5       V8_8.0.1             stringi_1.8.7       </span></span>
<span id="cb32-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [26] backports_1.5.0      desc_1.4.3           qqconf_1.3.2         httpuv_1.6.16        rappdirs_0.3.4      </span></span>
<span id="cb32-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [31] details_0.4.0        prodlim_2025.04.28   KMsurv_0.1-6         doRNG_1.8.6.2        survminer_0.5.1     </span></span>
<span id="cb32-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [36] palmerpenguins_0.1.1 DT_0.34.0            DBI_1.2.3            withr_3.0.2          tfruns_1.5.4        </span></span>
<span id="cb32-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [41] tseries_0.10-59      reformulas_0.4.4     class_7.3-23         systemfonts_1.3.1    rprojroot_2.1.1     </span></span>
<span id="cb32-58"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [46] lmtest_0.9-40        formatR_1.14         colourpicker_1.3.0   htmlwidgets_1.6.4    fs_1.6.6            </span></span>
<span id="cb32-59"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [51] labeling_0.4.3       ranger_0.18.0        DEoptimR_1.1-4       zoo_1.8-15           itertools_0.1-3     </span></span>
<span id="cb32-60"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [56] svUnit_1.0.8         timechange_0.4.0     caTools_1.18.3       extremevalues_2.4.1  timeDate_4052.112   </span></span>
<span id="cb32-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [61] data.table_1.18.2.1  pan_1.9              clipr_0.8.0          ellipsis_0.3.2       lazyeval_0.2.2      </span></span>
<span id="cb32-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [66] yaml_2.3.12          survival_3.8-6       crayon_1.5.3         tensorA_0.36.2.1     RColorBrewer_1.1-3  </span></span>
<span id="cb32-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [71] later_1.4.5          codetools_0.2-20     base64enc_0.1-6      shape_1.4.6.1        estimability_1.5.1  </span></span>
<span id="cb32-64"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [76] gdtools_0.4.4        DiceDesign_1.10      foreign_0.8-91       pkgconfig_2.0.3      xml2_1.5.2          </span></span>
<span id="cb32-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [81] mathjaxr_2.0-0       ggpubr_0.6.2         viridisLite_0.4.2    xtable_1.8-4         plyr_1.8.9          </span></span>
<span id="cb32-66"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [86] httr_1.4.7           rbibutils_2.4.1      tools_4.5.2          globals_0.19.0       hardhat_1.4.2       </span></span>
<span id="cb32-67"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [91] pkgbuild_1.4.8       htmlTable_2.4.3      survMisc_0.5.6       shinyjs_2.1.1        crosstalk_1.2.2     </span></span>
<span id="cb32-68"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [96] twosamples_2.0.1     MatrixModels_0.5-4   lme4_1.1-38          digest_0.6.39        numDeriv_2016.8-1.1 </span></span>
<span id="cb32-69"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [ reached 'max' / getOption("max.print") -- omitted 100 entries ]</span></span></code></pre></div></div>
</div>
<hr>
</section>
<section id="stata" class="level1">
<h1>Stata</h1>
<hr>
<div class="cell" data-layout-align="center" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb33" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb33-1">about</span>
<span id="cb33-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">version</span></span></code></pre></div></div>
</div>
<hr>
</section>
<section id="references" class="level1">
<h1>References</h1>
<hr>



</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" data-entry-spacing="2" data-line-spacing="2">
<div id="ref-rafiSemanticCognitiveTools2020" class="csl-entry">
1. Rafi Z, Greenland S. (2020). <span>“Semantic and cognitive tools to aid statistical science: Replace confidence and significance by compatibility and surprise.”</span> <em>BMC Medical Research Methodology</em>. <strong>20</strong>:244. doi: <a href="https://doi.org/10.1186/s12874-020-01105-9">10.1186/s12874-020-01105-9</a>.
</div>
<div id="ref-greenlandTechnicalIssuesInterpretation2020" class="csl-entry">
2. Greenland S, Rafi Z. (2020). <span>“Technical <span>Issues</span> in the <span>Interpretation</span> of <span>S</span>-values and <span>Their Relation</span> to <span>Other Information Measures</span>.”</span> <em>arXiv:200812991 [statME]</em>. <a href="https://arxiv.org/abs/2008.12991">https://arxiv.org/abs/2008.12991</a>.
</div>
<div id="ref-greenlandValidPvaluesBehave2019" class="csl-entry">
3. Greenland S. (2019). <span>“Valid <span>P</span>-values behave exactly as they should: <span>Some</span> misleading criticisms of <span>P</span>-values and their resolution with <span>S</span>-values.”</span> <em>The American Statistician</em>. <strong>73</strong>:106–114. doi: <a href="https://doi.org/10.1080/00031305.2018.1529625">10.1080/00031305.2018.1529625</a>.
</div>
<div id="ref-bayarriValuesCompositeNull2000" class="csl-entry">
4. Bayarri MJ, Berger JO. (2000). <span>“P <span>Values</span> for <span>Composite Null Models</span>.”</span> <em>Journal of the American Statistical Association</em>. <strong>95</strong>:1127–1142. doi: <a href="https://doi.org/10/dpvq8c">10/dpvq8c</a>.
</div>
<div id="ref-robinsAsymptoticDistributionValues2000" class="csl-entry">
5. Robins JM, van der Vaart A, Ventura V. (2000). <span>“Asymptotic <span>Distribution</span> of <span>P Values</span> in <span>Composite Null Models</span>.”</span> <em>Journal of the American Statistical Association</em>. <strong>95</strong>:1143–1156. doi: <a href="https://doi.org/10/gg7krv">10/gg7krv</a>.
</div>
<div id="ref-kuffnerWhyArePvalues2019" class="csl-entry">
6. Kuffner TA, Walker SG. (2019). <span>“Why are <span>P</span>-values controversial?”</span> <em>The American Statistician</em>. <strong>73</strong>:1–3. doi: <a href="https://doi.org/10.1080/00031305.2016.1277161">10.1080/00031305.2016.1277161</a>.
</div>
<div id="ref-cousinsJeffreysLindleyParadox2017" class="csl-entry">
7. Cousins RD. (2017). <span>“The <span>Jeffreys</span> paradox and discovery criteria in high energy physics.”</span> <em>Synthese</em>. <strong>194</strong>:395–432. doi: <a href="https://doi.org/10.1007/s11229-014-0525-z">10.1007/s11229-014-0525-z</a>.
</div>
<div id="ref-coxChapterIntervalEstimation1974" class="csl-entry">
8. Cox DR, Hinkley DV. (1974). <span>“Chapter 7, <span>Interval</span> estimation.”</span> In: Theoretical <span>Statistics</span>. <span>Chapman and Hall/CRC</span>. p. 207–249. doi: <a href="https://doi.org/10.1201/b14832">10.1201/b14832</a>.
</div>
<div id="ref-bowleyDiscussionDrNeyman1934" class="csl-entry">
9. Bowley AL. (1934). <span>“Discussion on <span>Dr</span>. <span>Neyman</span>’s <span>Paper</span>. <span>P</span>. 607 in: <span>Neyman J</span>. <span>On</span> the two different aspects of the representative method: <span>The</span> method of stratified sampling and the method of purposive selection (with discussion).”</span> <em>Journal of the Royal Statistical Society</em>. <strong>4</strong>:558–625. doi: <a href="https://doi.org/10.2307/2342192">10.2307/2342192</a>.
</div>
<div id="ref-coxPrinciplesStatisticalInference2006" class="csl-entry">
10. Cox DR. (2006). <span>“Principles of <span>Statistical Inference</span>.”</span> <span>Cambridge University Press</span>.
</div>
<div id="ref-amrheinInferentialStatisticsDescriptive2019" class="csl-entry">
11. Amrhein V, Trafimow D, Greenland S. (2019). <span>“Inferential statistics as descriptive statistics: <span>There</span> is no replication crisis if we don’t expect replication.”</span> <em>The American Statistician</em>. <strong>73</strong>:262–270. doi: <a href="https://doi.org/10.1080/00031305.2018.1543137">10.1080/00031305.2018.1543137</a>.
</div>
<div id="ref-greenlandStatisticalTestsValues2016" class="csl-entry">
12. Greenland S, Senn SJ, Rothman KJ, Carlin JB, Poole C, Goodman SN, et al. (2016). <span>“Statistical tests, <span>P</span> values, confidence intervals, and power: <span>A</span> guide to misinterpretations.”</span> <em>European Journal of Epidemiology</em>. <strong>31</strong>:337–350. doi: <a href="https://doi.org/10.1007/s10654-016-0149-3">10.1007/s10654-016-0149-3</a>.
</div>
<div id="ref-greenlandAreConfidenceIntervals2019" class="csl-entry">
13. Greenland S. (2019). <span>“Are confidence intervals better termed <span>‘uncertainty intervals’</span>? <span>No</span>: <span>Call</span> them compatibility intervals.”</span> <em>BMJ</em>. <strong>366</strong>. doi: <a href="https://doi.org/10.1136/bmj.l5381">10.1136/bmj.l5381</a>.
</div>
<div id="ref-greenlandAidScientificInference2020" class="csl-entry">
14. Greenland S, Rafi Z. (2020). <span>“To <span>Aid Scientific Inference</span>, <span>Emphasize Unconditional Descriptions</span> of <span>Statistics</span>.”</span> <em>arXiv:190908583 [statME]</em>. <a href="https://arxiv.org/abs/1909.08583">https://arxiv.org/abs/1909.08583</a>.
</div>
<div id="ref-brownAssociationSerotonergicAntidepressant2017" class="csl-entry">
15. Brown HK, Ray JG, Wilton AS, Lunsky Y, Gomes T, Vigod SN. (2017). <span>“Association between serotonergic antidepressant use during pregnancy and autism spectrum disorder in children.”</span> <em>Journal of the American Medical Association</em>. <strong>317</strong>:1544–1552. doi: <a href="https://doi.org/10.1001/jama.2017.3415">10.1001/jama.2017.3415</a>.
</div>
<div id="ref-brownAssociationAntenatalExposure2017" class="csl-entry">
16. Brown HK, Hussain-Shamsy N, Lunsky Y, Dennis C-LE, Vigod SN. (2017). <span>“The association between antenatal exposure to selective serotonin reuptake inhibitors and autism: <span>A</span> systematic review and meta-analysis.”</span> <em>The Journal of Clinical Psychiatry</em>. <strong>78</strong>:e48–e58. doi: <a href="https://doi.org/10.4088/JCP.15r10194">10.4088/JCP.15r10194</a>.
</div>
<div id="ref-jewellStatisticsEpidemiology2003" class="csl-entry">
17. Jewell NP. (2003). <span>“Statistics for <span>Epidemiology</span>.”</span> <span>CRC Press</span>.
</div>
<div id="ref-royallStatisticalEvidenceLikelihood1997" class="csl-entry">
18. Royall R. (1997). <span>“Statistical <span>Evidence</span>: <span>A Likelihood Paradigm</span>.”</span> <span>CRC Press</span>.
</div>
<div id="ref-daviesApproximatingDataDiscussion2008" class="csl-entry">
19. Davies PL. (2008). <span>“Approximating data [with discussion and a rejoinder].”</span> <em>Journal of the Korean Statistical Society</em>. <strong>37</strong>:191–211. doi: <a href="https://doi.org/10/bn8cgk">10/bn8cgk</a>.
</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2020,
  author = {Panda, Sir and Rafi, Zad},
  title = {Tables, {Graphs,} and {Computations} from {Rafi} \&amp;
    {Greenland} (2020)},
  date = {2020-12-12},
  url = {https://lesslikely.com/posts/statistics/RG2020BMC.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2020" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2020). <span>‘Tables, Graphs, and Computations from
Rafi &amp; Greenland (2020)’</span>. <a href="https://lesslikely.com/posts/statistics/RG2020BMC.html">https://lesslikely.com/posts/statistics/RG2020BMC.html</a>.
</div></div></section></div> ]]></description>
  <guid>https://lesslikely.com/posts/statistics/RG2020BMC.html</guid>
  <pubDate>Sat, 12 Dec 2020 05:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/v1602038429/Site/confidencecurve.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>What Makes a Sensitivity Analysis?</title>
  <dc:creator>Sir Panda</dc:creator>
  <link>https://lesslikely.com/posts/statistics/sensitivity.html</link>
  <description><![CDATA[ 





<hr>
<section id="cargo-cult-uncertainty" class="level1">
<h1>Cargo-Cult Uncertainty</h1>
<hr>
<p>Sensitivity analyses are an important part of statistical science and many other disciplines when conducted in a principle and systematic manner. However, in the published sensitivity analyses literature, there are many inconsistencies, misconceptions, and highly misleading findings from these analyses. A giant obstacle that prevents these issues from recurring is that they (sensitivity analysis techniques) are quite difficult to learn and often advanced statistical methods that even many statisticians have difficulty with.</p>
<p>Yet, the appearance of difficulty does not dissuade certain researchers away from adopting them for their own work, (so that they may give their colleagues and their stakeholders that they report to, the impression of rigor and methodological expertise), and when this is done mindlessly, researchers will often skip over learning the details and theory, and like many statistical procedures, they will rely on default settings built in the statistical software.</p>
<p>While there are many suites/commands/functions/libraries available to conduct such analyses, much of these procedures masquerade as meticulous sensitivity analyses and to the users, are often a formality to appease stakeholders and give researchers a false sense of confidence about what they are doing. And yet, their users have little to no idea what they’re actually doing. Thus, like many statistical procedures new and old, they too will inevitably be abused as they become more popular and as they are required in research reports.</p>
<hr>
<p>As Stark &amp; Saltelli<span class="citation" data-cites="Stark2018-eo"><sup>1</sup></span>, along with many others such as Gigerenzer<span class="citation" data-cites="gigerenzerStatisticalRitualsReplication2018"><sup>2</sup></span> and Greenland<span class="citation" data-cites="Greenland2017-es"><sup>3</sup></span> have written in the past. Below is an excerpt where Stark describes that much of statistics is simply people masquerading as data analysts and being rewarded as experts despite not having a single clue what they’re doing.</p>
<hr>
<blockquote class="blockquote">
<p>In our experience, many applications of statistics are cargo-cult statistics: practitioners go through the motions of fitting models, computing p-values or confidence intervals, or simulating posterior distributions. They invoke statistical terms and procedures as incantations, with scant understanding of the assumptions or relevance of the calculations, or even the meaning of the terminology. This demotes statistics from a way of thinking about evidence and avoiding self-deception to a formal “blessing” of claims. The effectiveness of cargo-cult statistics is predictably uneven. But it is effective at getting weak work published - and is even required by some journals…</p>
</blockquote>
<hr>
<p>Here, Stark takes on the issue of widely accessible statistical software for academics, students, and analysts.</p>
<hr>
<blockquote class="blockquote">
<p>Statistical software does not help you know what to compute, nor how to interpret the result. It does not offer to explain the assumptions behind methods, nor does it flag delicate or dubious assumptions. It does not warn you about multiplicity or p-hacking. It does not check whether you picked the hypothesis or analysis after looking at the data, nor track the number of analyses you tried before arriving at the one you sought to publish - another form of multiplicity. The more “powerful” and “user-friendly” the software is, the more it invites cargo-cult statistics.<span class="citation" data-cites="Stark2018-eo"><sup>1</sup></span></p>
</blockquote>
<hr>
<p>Greenland<span class="citation" data-cites="Greenland2017-es"><sup>3</sup></span> focuses on how traditional statistical education is inadequate to deal with the messy and chaotic nature of the world and the missing data that is produced by it. Greenland writes that traditional statistical practice opens the room for several cognitive biases, making many reports and conclusions highly misleading. He provides some hope however, by pointing to the utility of sensitivity analyses for modeling bias and uncertainty.</p>
<hr>
<blockquote class="blockquote">
<p>I argue that current training in statistics and analytical methods is inadequate for addressing major sources of inference distortion, and that it should be expanded to cover the biased perceptual and thinking processes (cognitive biases) that plague research reports. As commonly misused, null-hypothesis significance testing (NHST) combines several cognitive problems to create highly distorted interpretations of study results. Interval estimation has proven highly vulnerable to the same problems. Sensitivity and bias analyses address model uncertainties by varying and relaxing assumptions, but (like Bayesian analyses) they are difficult to perform with proper accounting for prior information and are easily manipulated because they depend on specification of many models and parameters.</p>
</blockquote>
<hr>
<p>However, he then follows up to discuss how difficult sensitivity and bias analyses can be due to the plethora of decisions that the analyst must make when specifying parameters in the analysis. These judgements will differ from researcher to researcher, even in the same group, and such analyses have not been studied as widely as conventional statistical practice.</p>
<hr>
<blockquote class="blockquote">
<p>Even with realistic choices, the sensitivity of sensitivity and bias analyses must be evaluated (51). The plausibility of an estimated bias function is determined by intuitions, prejudices, and understanding of the applied context; those can vary dramatically across researchers, in turn leading to very different specifications and inferences even if they are anchored to the same conventional analysis. Adding to this problem, sensitivity and bias analyses are more difficult to perform correctly and more easily massaged toward preferred conclusions, because they require specification of many more equations and their parameters.</p>
<p>And unlike NHST, abuse of sensitivity and bias analysis is as yet barely studied because the pool of such analyses remains small and highly selective. It thus seems implausible that these analyses will increase replicability of inferences, although they can reveal how assumptions affect those inferences. (Here “replicability” is used according to recommendations of the American Statistical Association (52) to denote independent checks of reported results with new data; “reproducibility” then denotes checks of reported results using the original data and computer code.)</p>
</blockquote>
<hr>
<p>Indeed, this is one drawback of (relatively) newly adopted methods/procedures, they have not been studied long enough as say somethng such as a P-value, which has been studied for centuries. Even something as useful as exploring assumptions and uncertainty such as a principled sensitivity analysis is not free from this.</p>
<p>it seems Greenland’s predictions were accurate; in a large systematic review of published sensitivity analyses led by the mathematician Andrea Saltelli and his group, they found that highly cited papers in top impact factor journals rarely contained sensitivity analyses, and that many of these were poorly done and one-dimensional, in the sense of only varying one parameter at a time, which is hardly informative as a multi-dimensional analysis in which multiple parameters are varied at the same time.</p>
<hr>
<p>Here, we will explore one example of how mindless sensitivity analyses are conducted within the context of clinical trials, although we will not explore multi-dimensional sensitivity analyses here. I make this distinction because the environment to conduct sensitivity/bias analyses differs substantially in trials where regulators are involved versus the environment in which many observational studies are analyzed and presented.</p>
<hr>
<p>In medicine, sensitivity analyses (<strong>SA</strong>) are often conducted in trials and observational studies, but again, little thought is given to what they <em>should</em> entail.<span class="citation" data-cites="Stark2018-eo"><sup>1</sup></span> None of this is surprising given that they are not usually taught in traditional settings, although they have been discussed extensively within the statistical and epidemiological literature<span class="citation" data-cites="greenlandMultipleBiasModelling2005 greenlandBiasAnalysis2008 lashApplyingQuantitativeBias2009 lashGoodPracticesQuantitative2014 lashBiasAnalysisGone2021 gustafsonInvitedCommentaryBetter2021 greenlandDealingInevitableDeficiencies2021"><sup>4–10</sup></span> Yet, the other barrier that remains is that they are incredibly technical and will require the assistance of an analyst familiar with both the theory and the applications. It also does not help that the topic is vast and there are multiple new statistical methods being published every day.</p>
<p>Indeed, the <a href="https://www.taylorfrancis.com/books/mono/10.1201/b17622/handbook-missing-data-methodology-geert-molenberghs-garrett-fitzmaurice-michael-kenward-anastasios-tsiatis"><strong>Handbook of Missing Data Methodology</strong></a>,<span class="citation" data-cites="molenberghsHandbookMissingData2014"><sup>11</sup></span> one of the most authoritative and comprehensive books to date on statistical methods to handle missing data in clinical trials, has nearly <em>six chapters</em> devoted to the topic of sensitivity analyses and different approaches to use. Unfortunately, at the rate that this field is advancing, this book may already be outdated, despite only coming out six years ago.</p>
<p>This article will focus on what a sensitivity analysis is often assumed to be based on practices in the literature, some differing points of view regarding sensitivity analyses (with an example of a highly promoted measure for conducting sensitivity analyses that has been very controversial, and a practical example of conducting <em>principled</em>(by principled, I mean non ad-hoc techniques, as James Carpenter would say) sensitivity analyses in the context of missing data in a randomized clinical trial.</p>
<hr>
<section id="everything-is-sensitive" class="level2">
<h2 class="anchored" data-anchor-id="everything-is-sensitive">Everything is Sensitive</h2>
<hr>
<p>Before we move forward, we must consider what a sensitivity analysis actually entails. The first word of the phrase is an obvious tell, it suggests an analysis that examines how sensitive or robust a result is. But a natural question is, sensitive specifically to what? What sort of perturbations and how relevant are they? Can I vary anything in the analysis to test the sensitivity of the result or assumption? For example, if I obtained an odds ratio of <strong>1.7</strong> from the primary analysis in my experiment and I conducted an extra analysis to see whether the odds ratio would change by a resampling method, is that a sensitivity analysis?</p>
<p>What if I did a completely different type of analysis, for example, suppose the primary analysis was a classical statistical test with an adjustment for multiple comparisons and I decided to run a hierarchical Bayesian regression with a spiked prior on the null, would that be a sensitivity analysis, given they are different frameworks and procedures (although being used for similar goals)? The possibilities of what can be varied are endless when a loose definition of sensitivity analysis is assumed. This is unique to every discipline and their culture. In epidemiology, sensitivity analyses and bias analyses which attempt to extensively explore assumptions and the robustness of the result are used synonymously, yet in the clinical trial world, this is not the case.</p>
<hr>
</section>
<section id="frequent-misconceptions" class="level2">
<h2 class="anchored" data-anchor-id="frequent-misconceptions">Frequent Misconceptions</h2>
<hr>
<p>Take for example in clinical trials and observational studies, in particular, it is common to see primary analyses often being intent-to-treat (<strong>ITT</strong>) analyses and sensitivity analyses being per-protocol analyses (<strong>PP</strong>).</p>
<hr>
<blockquote class="blockquote">
<p>I will not define these terms here and would encourage readers to consult other sources.</p>
</blockquote>
<hr>
<p>The following is a similar example from a high-profile trial published in the <em>The Lancet</em> in 2002,<span class="citation" data-cites="scottMulticentreAneurysmScreening2002"><sup>12</sup></span></p>
<hr>
<blockquote class="blockquote">
<p>The Multicentre Aneurysm Screening Study group randomised 67,800 men to receive an invitation to an abdominal ultrasound scan or not [6]. Of those invited to receive an abdominal scan, 20% did not accept. The primary analysis was by intention to treat, thus estimating the effect of being randomised to abdominal ultrasound. Another analysis investigated the complier average causal effect, which considers what the (average) effect of treatment was in patients who would have adhered to protocol however they were randomised [7].</p>
</blockquote>
<hr>
<p>To many, this may seem perfectly fine, even great. The authors used the question they were primarily interested in as the main analysis, and then conducted an additional analysis to see if these results are consistent. Unfortunately, this is highly problematic as <a href="https://doi.org/10.1186/1471-2288-14-11">Morris et al. (2014)</a><span class="citation" data-cites="morrisChoosingSensitivityAnalyses2014"><sup>13</sup></span> describes</p>
<hr>
<blockquote class="blockquote">
<p>These questions are different, and observing different results should not shake our confidence in either. The CACE analysis was a secondary analysis, not a sensitivity analysis.</p>
<p>It is common for authors to compare the results of intention-to-treat with per-protocol analysis; see for example [8, 9]. While it is hard to pin down the precise question of per-protocol analysis [10], this is clearly different to the question intention-to-treat addresses. Per-protocol analysis should not therefore be considered as a sensitivity analysis for intention-to-treat but as a secondary analysis, if at all.</p>
</blockquote>
<hr>
</section>
<section id="randomness-uncertainty" class="level2">
<h2 class="anchored" data-anchor-id="randomness-uncertainty">Randomness &amp; Uncertainty</h2>
<hr>
</section>
<section id="portable-sensitivity-analyses" class="level2">
<h2 class="anchored" data-anchor-id="portable-sensitivity-analyses">Portable Sensitivity Analyses</h2>
<hr>
<p>These sorts of misunderstandings are so common and so prevalent throughout the literature, so it should come as no surprise that sensitivity analyses are rarely done, or they are done incorrectly. Although not in clinical trials, one particular controversial example has been the promotion and use of the <img src="https://latex.codecogs.com/png.latex?E">-value (the ‘E’ apparently stands for ‘evidence’, but I am not sure.) within epidemiology to assess the amount of confounding necessary within an observational study result to practically reduce the effect estimate to something that is practically null.</p>
<p>The method and value has been adopted with open arms by many epidemiologists and health researchers given that it has simplified a task that is often arduous and requires extensive and careful thought in comparison to the traditional classical analysis. Yet, others have also been highly critical of it for a number of reasons, and although they see the value in promoting sensitivity analyses to more researchers around the world, many are concerned that this measure will also eventually go down the road of P-values, but for observational research.</p>
<hr>
</section>
<section id="regulators-sensitivity-analyses" class="level2">
<h2 class="anchored" data-anchor-id="regulators-sensitivity-analyses">Regulators &amp; Sensitivity Analyses</h2>
<hr>
<p>As mentioned above, there are many possible ways to conduct a sensitivity analysis, especially if the phrase is used in a loose/vague way. Whether or not these are valid and principled approaches to conducting sensitivity analyses is another question. Luckily, many of us do not have to ponder day and night about the semantics about this because both The Handbook of Missing Data Methodology and the <strong>International Council for Harmonisation of Technical Requirements for Pharmaceuticals for Human Use</strong> (<strong>ICH</strong>) have given this topic much thought, and for the latter it is reflected by the fact that they recently created an entire new addition to their E9 guidance document (<a href="https://www.fda.gov/regulatory-information/search-fda-guidance-documents/e9-statistical-principles-clinical-trials"><em>Statistical Principles for Clinical Trials</em></a>) which has served as a reference for clinical trial statisticians for decades. In the addendum, titled <a href="https://database.ich.org/sites/default/files/E9-R1_Step4_Guideline_2019_1203.pdf"><em>Addendum on Estimands and Sensitivity Analysis In Clinical Trials</em></a>, which has now been legally adopted by regulatory agencies around the world including the FDA and EMA, they elaborate on the concept of estimands and the role sensitivity analyses play.</p>
<p>To be clear, estimands are not new and have been discussed in the statistical literature since Tukey<span class="citation" data-cites="mostellerDataAnalysisIncluding1987"><sup>14</sup></span> but the ICH working group’s addendum formalized its adoption in the clinical trial world and the importance of sensitivity analyses.<span class="citation" data-cites="akachaEstimandsTheirRole2017 permuttCovariatesChangeEstimand2020 mitroiuNarrativeReviewEstimands2020"><sup>15–17</sup></span></p>
<hr>
</section>
<section id="estimands-sensitivity" class="level2">
<h2 class="anchored" data-anchor-id="estimands-sensitivity">Estimands &amp; Sensitivity</h2>
<hr>
<blockquote class="blockquote">
<p><strong>A.5.2.1. Role of Sensitivity Analysis</strong></p>
<p>Inferences based on a particular estimand should be robust to limitations in the data and deviations from the assumptions used in the statisticral model for the main estimator. This robustness is evaluated through a sensitivity analysis. Sensitivity analysis should be planned for the main estimators of all estimands that will be important for regulatory decision making and labelling in the product information. This can be a topic for discussion and agreement between sponsor and regulator.</p>
<p>The statistical assumptions that underpin the main estimator should be documented. One or more analyses, focused on the same estimand, should then be pre-specified to investigate these assumptions with the objective of verifying whether or not the estimate derived from the main estimator is robust to departures from its assumptions. This might be characterised as the extent of departures from assumptions that change the interpretation of the results in terms of their statistical or clinical significance (e.g.&nbsp;tipping point analysis).</p>
<p>Distinct from sensitivity analysis, where investigations are conducted with the intent of exploring robustness of departures from assumptions, other analyses that are conducted in order to more fully investigate and understand the trial data can be termed “supplementary analysis” (see Glossary; A.5.3.). Where the primary estimand(s) of interest is agreed between sponsor and regulator, the main estimator is pre-specified unambiguously, and the sensitivity analysis verifies that the estimate derived is reliable for interpretation, supplementary analyses should generally be given lower priority in assessment.</p>
<p><strong>A.5.2.2. Choice of Sensitivity Analysis</strong></p>
<p>When planning and conducting a sensitivity analysis, altering multiple aspects of the main analysis simultaneously can make it challenging to identify which assumptions, if any, are responsible for any potential differences seen. It is therefore desirable to adopt a structured approach, specifying the changes in assumptions that underlie the alternative analyses, rather than simply comparing the results of different analyses based on different sets of assumptions. The need for analyses varying multiple assumptions simultaneously should then be considered on a case by case basis. A distinction between testable and untestable assumptions may be useful when assessing the interpretation and relevance of different analyses.</p>
<p><strong>ICH E9 (R1) Guideline</strong></p>
<p>The need for sensitivity analysis in respect of missing data is established and retains its importance in this framework. Missing data should be defined and considered in respect of a particular estimand (see A.4.). The distinction between data that are missing in respect of a specific estimand and data that are not directly relevant to a specific estimand gives rise to separate sets of assumptions to be examined in sensitivity analysis.</p>
</blockquote>
<hr>
<p>they explicitly define a sensitivity analysis as being an analysis which:</p>
<hr>
<ul>
<li>realistically varies the assumptions from the primary analysis</li>
</ul>
<hr>
<ul>
<li>still targets the same estimand</li>
</ul>
<hr>
<ul>
<li>examines the robustness of the results to</li>
</ul>
<hr>
<ul>
<li>assumption violations or departures</li>
</ul>
<hr>
<ul>
<li>can possibly change the results/conclusions drawn</li>
</ul>
<hr>
<p>They contrast this with more extensive analyses that investigate these violations/departures of assumptions, and characterize those analyse as being supplementary rather than sensitivity. The latter is typically what is seen in rigorous epidemiological studies that employ quantitative bias analyses (a more specialized form of sensitivity analysis).</p>
<p>The ICH E9 addendum contains similar views that are echoed by the National Research Council’s advice on clinical trials (National Research Council 2010)<span class="citation" data-cites="littlePreventionTreatmentMissing2012"><sup>18</sup></span> regarding estimands and sensitivity</p>
<hr>
<blockquote class="blockquote">
<p><strong>Recommendation 15</strong>: Sensitivity analysis should be part of the primary reporting of findings from clinical trials. <strong>Examining sensitivity to the assumptions about the missing data mechanism should be a mandatory component of reporting.</strong></p>
</blockquote>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="grViz html-widget html-fill-item" id="htmlwidget-dae34fd7e70a878822e1" style="width:100%;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-dae34fd7e70a878822e1">{"x":{"diagram":"digraph {\n  graph [layout = dot, rankdir = TB,\n         compound = true, bgcolor = \"transparent\",\n         nodesep = .5, ranksep = .25]\n  node [shape = circle,\n      fixedsize = true,\n      fontsize = 9,\n      fontname = Helvetica,\n      fontcolor = \"#000000\",\n      width = .99,\n      height = .99,\n      style = filled,\n      color = \"#91A3B0\",\n      label = \"\"]\n  edge [color = \"#888888\", arrowhead = normal, arrowtail = inv]\n  rec1 [label = \"Study \nObjective\", fillcolor = \"#D0EAEE\"]\n  rec2 [label = \"Estimand\", fillcolor = \"#abd9ca\"]\n  rec3 [label =  \"Primary \nEstimator\", fillcolor = \"#7aa864\"]\n  rec4 [label = \"Primary \nEstimate\", fillcolor = \"#7aa864\"]\n  rec5 [label = \"Sensitivity \nEstimator \n1\", fillcolor = \"#E69F00\"]\n  rec6 [label = \"Sensitivity \nEstimate \n1\", fillcolor = \"#E69F00\"]\n  rec7 [label = \"Sensitivity \nEstimator \n2\", fillcolor = \"#e7998c\"]\n  rec8 [label = \"Sensitivity \nEstimate \n2\", fillcolor = \"#e7998c\"]\n  # edge definitions with the node IDs\n  rec1 -> rec2\n  rec2 -> rec3 ->rec4\n  rec2 -> rec5 ->rec6\n  rec2 -> rec7 ->rec8}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script>
</div>
</div>
<hr>
<p>Now, back to the <em>NEJM</em> paper. The reason why an <strong>ITT</strong> analysis and a <strong>PP</strong> analysis cannot serve as primary and sensitivity analyses, respectively, is because they are targeting entirely <em>different estimands</em>.<span class="citation" data-cites="morrisChoosingSensitivityAnalyses2014"><sup>13</sup></span> Thus, because they are answering completely different questions, they’re just two different analyses. And the additional <strong>PP</strong> analysis, although important to certain stakeholders, can be classified as a supplementary analysis or a non-sensitivity analysis.</p>
<p>Indeed, the following flowchart from <a href="https://doi.org/10.1186/1471-2288-14-11">Morris et al. (2014)</a><span class="citation" data-cites="morrisChoosingSensitivityAnalyses2014"><sup>13</sup></span> is particularly useful as a guide to differentiate sensitivity analyses from non-sensitivity analyses.</p>
<hr>
<figure class="figure">
<p><img src="https://res.cloudinary.com/less-likely/image/upload/q_auto:best/v1618886541/Site/sensitivitytree.png" style="cursor: zoom-in" class="figure-img"></p>
<figcaption>
Adapted flowchart from <a href="https://doi.org/10.1186/1471-2288-14-11">Morris et al. (2014)</a>
</figcaption>
</figure>
<hr>
</section>
<section id="utility-of-subject-matter-experts" class="level2">
<h2 class="anchored" data-anchor-id="utility-of-subject-matter-experts">Utility of Subject-Matter Experts</h2>
<hr>
<p>So what does a sensitivity analysis actually look like within the context of a clinical trial or experiment? Below, I walk through the analysis of a trial to give some examples.</p>
<hr>
</section>
</section>
<section id="sensitivity-in-clinical-trials" class="level1">
<h1>Sensitivity in Clinical Trials</h1>
<hr>
<p>I’ll use a sample clinical trial dataset, which is described here:<span class="citation" data-cites="chenClinicalTrialData2017"><sup>19</sup></span></p>
<hr>
<blockquote class="blockquote">
<p>“This dataset is typical of diastolic blood pressure data measured in small clinical trials in hypertension from the mid-to-late 1960s and for approximately a decade thereafter.</p>
<p><strong>During this time, hypertension was more severe, the number of effective treatments was relatively small, and the definition (DBP &gt; 95 mmHg) of essential hypertension was not as stringent as it is now (DBP &gt; 80 mmHg)</strong> - as seen in the 1967 report from the Veterans Administration Cooperative Study Group on Antihypertensive Agents VA Study Group (1967).</p>
<p>In Table 3.1, diastolic blood pressure (DBP) was measured (mmHg) in the supine position at baseline (i.e., DBP) before randomization… Patients’ age and sex were recorded at baseline and represent potential covariates. <strong>The primary objective in this chapter in the analysis of this dataset is to test whether treatment A (new drug) may be effective in lowering DBP as compared to B (placebo) and to describe changes in DBP across the times at which it was measured.</strong>”</p>
</blockquote>
<hr>
<p>So to recap, the primary investigators of this trial were interested to see whether treatment A was more effective in lowering DBP when compared to placebo.</p>
<hr>
<blockquote class="blockquote">
<p>Although we will not be using some of the scripts and project setup that I discussed in my <a href="https://lesslikely.com/statistics/statistics-quality-control/#setting-up-the-error-catching-script">statistical workflow post</a> for the sake of efficiency and ease, I would urge and recommend others do so that it remains easy to catch errors. In particular, I would especially recommend using the following packages:</p>
</blockquote>
<hr>
<ul>
<li><a href="https://cran.r-project.org/web/packages/here/index.html"><code>here</code></a></li>
</ul>
<hr>
<ul>
<li><a href="https://cran.r-project.org/web/packages/futile.logger/index.html"><code>futile.logger</code></a></li>
</ul>
<hr>
<ul>
<li><a href="https://cran.r-project.org/web/packages/tryCatchLog/index.html"><code>tryCatchLog</code></a></li>
</ul>
<hr>
<p>For the analyses in this post, see the R packages in the session info section at the <a href="../../statistics/sensitivity/#statistical-software">end of this post</a>, these will need to be loaded in order for the scripts below to work.</p>
<hr>
<div class="cell" data-layout-align="center">
<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">req_packs <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rms"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mice"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"magrittr"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tidyr"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"future"</span>,</span>
<span id="cb1-2">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"showtext"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concurve"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ggtext"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tidyverse"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ggplot2"</span>,</span>
<span id="cb1-3">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"parallel"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kableExtra"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cowplot"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Cairo"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"svglite"</span>,</span>
<span id="cb1-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yardstick"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"broom"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mi"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hmisc"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"here"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"VIM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wesanderson"</span>,</span>
<span id="cb1-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bayesplot"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lattice"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"doParallel"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blogdown"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Amelia"</span>,</span>
<span id="cb1-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bootImpute"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"brms"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rmarkdown"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tinytex"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"texPreview"</span>,</span>
<span id="cb1-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ggcorrplot"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"qqplotr"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"car"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Statamarkdown"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rstan"</span>,</span>
<span id="cb1-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"missForest"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"htmltools"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tidybayes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"performance"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mvtnorm"</span>,</span>
<span id="cb1-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ImputeRobust"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gamlss"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ProfileLikelihood"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"reshape2"</span>,</span>
<span id="cb1-10">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"boot"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"knitr"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MASS"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"miceMNAR"</span>)</span>
<span id="cb1-11"></span>
<span id="cb1-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Load all packages at once</span></span>
<span id="cb1-13"></span>
<span id="cb1-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(req_packs, library, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">character.only =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div></div>
</div>
<hr>
<p>I will now simulate some of the data from this clinical trial.</p>
<hr>
<div class="cell" data-layout-align="center">
<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="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Simulate Trial Data</span></span>
<span id="cb2-2"></span>
<span id="cb2-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</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;">1031</span>,</span>
<span id="cb2-4">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"L'Ecuyer-CMRG"</span>,</span>
<span id="cb2-5">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">normal.kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Inversion"</span>,</span>
<span id="cb2-6">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample.kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rejection"</span>)</span>
<span id="cb2-7"></span>
<span id="cb2-8">BaselineDBP <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>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">117</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb2-9">Group <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;">rbinom</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb2-10">Age <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>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>)</span>
<span id="cb2-11">R1 <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>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</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>
<span id="cb2-12">R2 <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>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb2-13"></span>
<span id="cb2-14">errors <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> mvtnorm<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;">rmvnorm</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>,</span>
<span id="cb2-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">0</span>),</span>
<span id="cb2-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sigma =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">matrix</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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb2-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">byrow =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb2-18">  )</span>
<span id="cb2-19">)</span>
<span id="cb2-20"></span>
<span id="cb2-21">PostDBP <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (Age <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.33</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-22">  (Group <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;">9.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> errors[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span></code></pre></div></div>
</div>
<hr>
<p>I have made some minor adjustments to this dataset and also generated a new variable (<code>Z</code>) based on the existing ones in the dataset that is strongly correlated with the outcome of interest (<code>PostDBP</code>).</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/sensitivity_files/figure-html/unnamed-chunk-8-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<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;"># Explore Data</span></span>
<span id="cb3-2"></span>
<span id="cb3-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(BP_full)</span>
<span id="cb3-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 'data.frame':    500 obs. of  7 variables:</span></span>
<span id="cb3-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ PostDBP    : num  142 140 129 148 135 ...</span></span>
<span id="cb3-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ BaselineDBP: num  119 116 115 119 119 ...</span></span>
<span id="cb3-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ Group      : Factor w/ 2 levels "Drug X","Drug Y": 1 1 2 1 2 2 1 2 1 1 ...</span></span>
<span id="cb3-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ Age        : num  41.8 44.4 41.1 56.6 50.2 ...</span></span>
<span id="cb3-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ Z          : num  0.0141 -0.0629 -0.1101 0.0313 0.0495 ...</span></span>
<span id="cb3-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ R1         : num  0.523 1.021 -0.839 0.413 -0.175 ...</span></span>
<span id="cb3-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ R2         : num  0.451 0.35 0.897 1.227 1.166 ...</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div id="lviazvgdqd" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#lviazvgdqd 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;
}

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

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

#lviazvgdqd .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;
}

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

#lviazvgdqd .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;
}

#lviazvgdqd .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;
}

#lviazvgdqd .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;
}

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

#lviazvgdqd .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;
}

#lviazvgdqd .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;
}

#lviazvgdqd .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;
}

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

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

#lviazvgdqd .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%;
}

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

#lviazvgdqd .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;
}

#lviazvgdqd .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;
}

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

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

#lviazvgdqd .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;
}

#lviazvgdqd .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;
}

#lviazvgdqd .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;
}

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

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

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

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

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

#lviazvgdqd .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;
}

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

#lviazvgdqd .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;
}

#lviazvgdqd .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;
}

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

#lviazvgdqd .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;
}

#lviazvgdqd .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;
}

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

#lviazvgdqd .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;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#lviazvgdqd 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">
<caption><strong>Patient Characteristics</strong></caption>
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</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>Variable</strong></th>
<th id="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="stat_0" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>Overall</strong><br>
N = 500<span class="gt_footnote_marks" style="white-space:nowrap;font-style:italic;font-weight:normal;line-height:0;"><sup>1</sup></span></th>
<th id="stat_1" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>Drug X</strong><br>
N = 258<span class="gt_footnote_marks" style="white-space:nowrap;font-style:italic;font-weight:normal;line-height:0;"><sup>1</sup></span></th>
<th id="stat_2" class="gt_col_heading gt_columns_bottom_border gt_center" data-quarto-table-cell-role="th" scope="col"><strong>Drug Y</strong><br>
N = 242<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" style="font-weight: bold">PostDBP</td>
<td class="gt_row gt_center" headers="n">500</td>
<td class="gt_row gt_center" headers="stat_0">138.5 (133.4, 142.8)</td>
<td class="gt_row gt_center" headers="stat_1">142.5 (140.5, 144.6)</td>
<td class="gt_row gt_center" headers="stat_2">133.4 (131.3, 135.3)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label" style="font-weight: bold">BaselineDBP</td>
<td class="gt_row gt_center" headers="n">500</td>
<td class="gt_row gt_center" headers="stat_0">116.88 (115.56, 118.22)</td>
<td class="gt_row gt_center" headers="stat_1">116.90 (115.53, 118.21)</td>
<td class="gt_row gt_center" headers="stat_2">116.81 (115.59, 118.23)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label" style="font-weight: bold">Age</td>
<td class="gt_row gt_center" headers="n">500</td>
<td class="gt_row gt_center" headers="stat_0">49 (45, 55)</td>
<td class="gt_row gt_center" headers="stat_1">49 (45, 55)</td>
<td class="gt_row gt_center" headers="stat_2">50 (46, 55)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label" style="font-weight: bold">Z</td>
<td class="gt_row gt_center" headers="n">500</td>
<td class="gt_row gt_center" headers="stat_0">0.00 (-0.04, 0.05)</td>
<td class="gt_row gt_center" headers="stat_1">0.00 (-0.04, 0.04)</td>
<td class="gt_row gt_center" headers="stat_2">0.00 (-0.05, 0.05)</td>
</tr>
<tr class="odd">
<td class="gt_row gt_left" headers="label" style="font-weight: bold">R1</td>
<td class="gt_row gt_center" headers="n">500</td>
<td class="gt_row gt_center" headers="stat_0">0.00 (-0.73, 0.56)</td>
<td class="gt_row gt_center" headers="stat_1">0.05 (-0.73, 0.60)</td>
<td class="gt_row gt_center" headers="stat_2">-0.10 (-0.74, 0.52)</td>
</tr>
<tr class="even">
<td class="gt_row gt_left" headers="label" style="font-weight: bold">R2</td>
<td class="gt_row gt_center" headers="n">500</td>
<td class="gt_row gt_center" headers="stat_0">0.96 (0.64, 1.28)</td>
<td class="gt_row gt_center" headers="stat_1">0.96 (0.59, 1.30)</td>
<td class="gt_row gt_center" headers="stat_2">0.97 (0.67, 1.28)</td>
</tr>
</tbody><tfoot>
<tr class="gt_footnotes odd">
<td colspan="5" 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>
<hr>
<div class="cell" data-layout-align="center">
<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>(BP_full)</span>
<span id="cb4-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     PostDBP     BaselineDBP     Group          Age             Z                   R1                  R2        </span></span>
<span id="cb4-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Min.   :124   Min.   :110   Drug X:258   Min.   :27.7   Min.   :-1.85e-01   Min.   :-3.205036   Min.   :-0.646  </span></span>
<span id="cb4-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  1st Qu.:133   1st Qu.:116   Drug Y:242   1st Qu.:45.3   1st Qu.:-4.44e-02   1st Qu.:-0.732386   1st Qu.: 0.645  </span></span>
<span id="cb4-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Median :138   Median :117                Median :49.4   Median : 9.45e-05   Median :-0.000058   Median : 0.960  </span></span>
<span id="cb4-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Mean   :138   Mean   :117                Mean   :49.7   Mean   : 0.00e+00   Mean   :-0.042800   Mean   : 0.962  </span></span>
<span id="cb4-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  3rd Qu.:143   3rd Qu.:118                3rd Qu.:54.7   3rd Qu.: 4.56e-02   3rd Qu.: 0.552206   3rd Qu.: 1.283  </span></span>
<span id="cb4-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Max.   :151   Max.   :123                Max.   :68.4   Max.   : 2.02e-01   Max.   : 3.377526   Max.   : 2.480</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">PostDBP</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">BaselineDBP</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Group</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Age</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Z</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">R1</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">R2</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">142</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">119</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Drug X</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">41.8</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.52</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.45</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">140</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">116</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Drug X</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">44.4</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.06</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.35</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">129</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">115</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Drug Y</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">41.1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.11</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.84</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.90</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">148</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">119</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Drug X</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">56.6</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.03</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.41</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.23</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">135</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">119</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Drug Y</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">50.2</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.05</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.17</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.17</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">135</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">118</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Drug Y</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">55.3</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.89</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.77</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">143</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">117</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Drug X</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">54.3</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.07</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.34</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">133</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">116</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Drug Y</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">55.8</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.05</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-1.91</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.96</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">144</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">118</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Drug X</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">46.9</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.03</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.75</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">150</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">119</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Drug X</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">62.0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.94</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.48</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/sensitivity_files/figure-html/unnamed-chunk-13-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>Now, we can quickly explore the other characteristics of the dataset, and first we look at the rank correlations between the predictors and the response variable.</p>
<hr>
<div class="cell" data-layout-align="center">
<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;"># Data Attributes</span></span>
<span id="cb5-2"></span>
<span id="cb5-3">study_formula <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.formula</span>(PostDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> .)</span>
<span id="cb5-4"></span>
<span id="cb5-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">spearman2</span>(study_formula, BP_full),</span>
<span id="cb5-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb5-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">18</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">alpha</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"darkred"</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>)</span>
<span id="cb5-8">)</span>
<span id="cb5-9"></span>
<span id="cb5-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">v =</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;">col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">alpha</span>(zred, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/sensitivity_files/figure-html/unnamed-chunk-14-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>Along with a correlation matrix between the variables of interest.</p>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error:
#&gt; ! object 'zblue' not found</code></pre>
</div>
<hr>
<p>We will not be looking at the estimates from a fitted model yet. We are mainly looking at a few characteristics of this dataset before we move on to the next step.</p>
<hr>
<section id="the-threat-of-missing-data" class="level2">
<h2 class="anchored" data-anchor-id="the-threat-of-missing-data">The Threat of Missing Data</h2>
<hr>
<p>Now that we have familiarized ourselves with this dataset, we suddenly “notice” that there are missing data (which I actually generated below using a custom function) and suppose we didn’t actually know how the missing data were generated, we might suspect or start with the assumption that the data are missing at random (<strong>MAR</strong>).</p>
<p>We will explore a number of different methods used to handle missing data, including multiple imputation, selection models, and a number of ad-hoc methods commonly used by researchers handle missing data. However, before we move on to discussing some of these methods, we will quickly review concepts and terms regarding missing data mechanisms.</p>
<hr>
<blockquote class="blockquote">
<p>In the figure below, the three missing data mechanisms (MCAR, MAR, and MNAR) and ignorability (whether we need to model the mechanism of missing data) in relation to observed data (Y obs), missing data (Y mis), the missingness matrix (R), and their relationships (q; parameters that explain missingness, i.e., mechanism). The solid arrows, dotted arrows, and arrows with crosses represent “connection,” “possible connection,” and “no connection,” respectively.</p>
<p>The lines connecting ignorability and missingness group the three mechanisms into the two ignorability categories. Also no pure forms of MCAR, MAR, and MNAR exist, and all missingness can be considered as a form of MAR missingness; this is represented by the shaded continuum bar on the left. - Modified from Nakagawa and Freckleton (2011)</p>
</blockquote>
<hr>
<figure class="figure">
<p><img src="https://lesslikely.com/images/missing-mech.png" width="800" style="cursor: zoom-in" class="figure-img"></p>
<figcaption>
Flowchart from <a href="http://www.i-deel.org/uploads/5/2/4/1/52416001/chapter_4.pdf">Ecological Statistics: Contemporary Theory and Applications</a>
</figcaption>
</figure>
<hr>
<p>Of course, here, we do have an idea of what the missing data mechanism is, but we shall assume the role of a data analyst who has just been given a dataset with missing values in the outcome from their clinical colleague.</p>
<hr>
<div class="cell" data-layout-align="center">
<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;"># Generate Missing Data</span></span>
<span id="cb7-2"></span>
<span id="cb7-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;">1031</span>,</span>
<span id="cb7-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"L'Ecuyer-CMRG"</span>,</span>
<span id="cb7-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">normal.kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Inversion"</span>,</span>
<span id="cb7-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample.kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rejection"</span></span>
<span id="cb7-7">)</span>
<span id="cb7-8">Ry <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 class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lesslikely</span>() <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 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;">0</span>)</span>
<span id="cb7-9">PostDBP[Ry <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="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span></span>
<span id="cb7-10">BP_miss <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-11">  PostDBP, BaselineDBP,</span>
<span id="cb7-12">  Group, Age, Z, R1, R2</span>
<span id="cb7-13">)</span>
<span id="cb7-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(BP_miss)</span>
<span id="cb7-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 'data.frame':    500 obs. of  7 variables:</span></span>
<span id="cb7-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ PostDBP    : num  142 140 129 148 135 ...</span></span>
<span id="cb7-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ BaselineDBP: num  119 116 115 119 119 ...</span></span>
<span id="cb7-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ Group      : Factor w/ 2 levels "Drug X","Drug Y": 1 1 2 1 2 2 1 2 1 1 ...</span></span>
<span id="cb7-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ Age        : num  41.8 44.4 41.1 56.6 50.2 ...</span></span>
<span id="cb7-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ Z          : num  0.0141 -0.0629 -0.1101 0.0313 0.0495 ...</span></span>
<span id="cb7-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ R1         : num  0.523 1.021 -0.839 0.413 -0.175 ...</span></span>
<span id="cb7-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  $ R2         : num  0.451 0.35 0.897 1.227 1.166 ...</span></span>
<span id="cb7-23"></span>
<span id="cb7-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(BP_miss))</span>
<span id="cb7-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 245</span></span>
<span id="cb7-26"></span>
<span id="cb7-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Export data for Stata chunks</span></span>
<span id="cb7-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"static/datasets"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb7-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(BP_miss, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"static/datasets/temp.csv"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div></div>
</div>
<hr>
<p>We will now attempt to visualize our dataset and examine what proportion of these data are missing.</p>
<hr>
<div class="cell" data-layout-align="center">
<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">missing_col <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;">c</span>(zblue, zred)</span>
<span id="cb8-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb8-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'zblue' not found</span></span>
<span id="cb8-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aggr</span>(BP_miss,</span>
<span id="cb8-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">alpha</span>(missing_col, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.60</span>),</span>
<span id="cb8-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prop =</span> F, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numbers =</span> T</span>
<span id="cb8-7">)</span>
<span id="cb8-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb8-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'missing_col' not found</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/sensitivity_files/figure-html/unnamed-chunk-19-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="864"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>So now, we must examine this missing dataset and its characteristics and look for any systematic differences. We also examine the proportion of missingness and the influx and outflux patterns. This is important to assess how well connectected the missing data are to the observed data, explained by <a href="https://stefvanbuuren.name/fimd/missing-data-pattern.html">van Buuren here</a></p>
<hr>
<blockquote class="blockquote">
<p>The influx of a variable quantifies how well its missing data connect to the observed data on other variables. The outflux of a variable quantifies how well its observed data connect to the missing data on other variables. In general, higher influx and outflux values are preferred…</p>
<p>Influx and outflux are summaries of the missing data pattern intended to aid in the construction of imputation models. Keeping everything else constant, variables with high influx and outflux are preferred. Realize that outflux indicates the potential (and not actual) contribution to impute other variables. A variable with high <img src="https://latex.codecogs.com/png.latex?O_%7Bj%7D"> may turn out to be useless for imputation if it is unrelated to the incomplete variables. On the other hand, the usefulness of a highly predictive variable is severely limited by a low <img src="https://latex.codecogs.com/png.latex?O_%7Bj%7D">.</p>
<p>More refined measures of usefulness are conceivable, e.g., multiplying <img src="https://latex.codecogs.com/png.latex?O_%7Bj%7D"> by the average proportion of explained variance. Also, we could specialize to one or a few key variables to impute. Alternatively, analogous measures for <img src="https://latex.codecogs.com/png.latex?I_%7Bj%7D"> could be useful. The further development of diagnostic summaries for the missing data pattern is a promising area for further investigation.</p>
</blockquote>
<hr>
<div class="cell" data-layout-align="center">
<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;"># Examine Flux Patterns</span></span>
<span id="cb9-2"></span>
<span id="cb9-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fico</span>(BP_miss), <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;">2</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;">6</span>]</span>
<span id="cb9-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; BaselineDBP       Group         Age           Z          R1 </span></span>
<span id="cb9-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;         0.5         0.5         0.5         0.5         0.5</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: left; color: rgba(119, 119, 119, 255) !important;"></th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">POBS</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Influx</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Outflux</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">AINB</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">AOUT</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">FICO</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">PostDBP</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.51</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.45</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">BaselineDBP</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.49</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Group</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.49</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Age</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.49</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Z</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.49</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">R1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.49</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">R2</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.49</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<p>Next, We start off doing some preliminary analyses to eyeball differences between the observed data and the missing data.</p>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error:
#&gt; ! object 'zblue' not found
#&gt; Error in `title()`:
#&gt; ! plot.new has not been called yet
#&gt; Error:
#&gt; ! object 'zblue' not found
#&gt; Error in `title()`:
#&gt; ! plot.new has not been called yet
#&gt; Error:
#&gt; ! object 'zblue' not found
#&gt; Error in `title()`:
#&gt; ! plot.new has not been called yet
#&gt; Error:
#&gt; ! object 'zblue' not found
#&gt; Error in `title()`:
#&gt; ! plot.new has not been called yet
#&gt; [1] 245</code></pre>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: left; color: rgba(119, 119, 119, 255) !important;"></th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">pobs</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">influx</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">outflux</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">ainb</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">aout</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">fico</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">PostDBP</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.51</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.45</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">BaselineDBP</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.49</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Group</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.49</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Age</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.49</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Z</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.49</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">R1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.49</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">R2</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.49</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<p>Having explored these data, we fit a preliminary model quickly to these missing data using the <a href="https://rdrr.io/pkg/MASS/man/rlm.html"><code>rlm()</code></a> function from the <a href="https://rdrr.io/pkg/MASS/"><code>MASS</code></a> package and glance at what our estimates look like.</p>
<hr>
<div class="cell" data-layout-align="center">
<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="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Exploratory Model Estimates</span></span>
<span id="cb11-2"></span>
<span id="cb11-3">eda_1 <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;">rlm</span>(</span>
<span id="cb11-4">  PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb11-5">    Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2,</span>
<span id="cb11-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> BP_miss,</span>
<span id="cb11-7">  <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;">"MM"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">psi =</span> psi.huber</span>
<span id="cb11-8">)</span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: left; color: rgba(119, 119, 119, 255) !important;"></th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Value</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Std. Error</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">t value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">(Intercept)</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">11.68</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">5.77</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.02</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">factor(Group)Drug Y</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.58</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.13</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-71.57</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">BaselineDBP</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.98</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.05</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">19.86</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Age</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.34</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">34.33</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Z</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.93</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.48</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.62</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">R1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.03</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.07</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.43</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">R2</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.13</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.13</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.94</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">AIC</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">AICc</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">BIC</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">RMSE</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Sigma</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">749</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">750</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">778</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.03</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error:
#&gt; ! object 'zblue' not found
#&gt; Error:
#&gt; ! object 'zblue' not found
#&gt; Error:
#&gt; ! object 'eda_1_resid' not found</code></pre>
</div>
<hr>
<p>Because the <a href="https://rdrr.io/pkg/MASS/man/rlm.html"><code>MASS::rlm()</code></a> function will automatically delete missing observations and do a complete-case analysis, we can gauge what our estimates would look like if we assume that the data are missing completely at random (<strong>MCAR</strong>), which is almost always unrealistic.</p>
<p>It is almost always more realistic to assume that the data are missing at random (<strong>MAR</strong>), <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BPr%7D%5Cleft(R=0%20%5Cmid%20Y_%7B%5Cmathrm%7Bobs%7D%7D,%20Y_%7B%5Cmathrm%7Bmis%7D%7D,%20%5Cpsi%5Cright)=%5Coperatorname%7BPr%7D%5Cleft(R=0%20%5Cmid%20Y_%7B%5Cmathrm%7Bobs%7D%7D,%20%5Cpsi%5Cright)">. This can often be a reasonable assumption to start off with for the primary analysis.<span class="citation" data-cites="buurenFlexibleImputationMissing2018"><sup>20</sup></span></p>
<hr>
</section>
<section id="multiple-imputation-workflow" class="level2">
<h2 class="anchored" data-anchor-id="multiple-imputation-workflow">Multiple Imputation Workflow</h2>
<hr>
<p>For our main analysis, we will build an imputation model to essentially ‘predict’ the missing values in our dataset. This is because multiple imputation is a well-studied set of algorithms that are efficient and robust to deviances from normality.</p>
<hr>
<blockquote class="blockquote">
<p>Modern missing data methodologies include maximum-likelihood estimation (MLE) methods such as expectation–maximisation (EM) and multiple imputation (MI), both recommended for data which is MAR [3]. MI has been shown to be robust under departures from normality, in cases of low sample size, and when the proportion of missing data is high [2]. With complete outcome variables, MI is typically less computationally expensive than MLE, and MLE tends to be problem-specific with a different model being required for each analysis [8].</p>
<ul>
<li>Plumpton CO, Morris T, Hughes DA, White IR. Multiple imputation of multiple multi-item scales when a full imputation model is infeasible. BMC Res Notes. 2016 Jan 26;9:45. doi: 10.1186/s13104-016-1853-5.</li>
</ul>
</blockquote>
<hr>
<p>How exactly does multiple imputation work?</p>
<hr>
<blockquote class="blockquote">
<p>The standard multiple imputation procedure (Rubin, 1987; Schafer, 1997) replaces missing covariate data with values drawn from a set of specified imputation models based on the observed relationships between the covariates and outcome, typically under a missing at random (MAR) assumption (Little and Rubin, 1987). A key feature of the procedure is that it outputs a number, say M, of imputed datasets. A prediction model is then fitted to each imputed dataset to produce imputation-specific regression coefficients, which can be averaged using “Rubin’s rules” (Rubin, 1987) to provide pooled regression coefficients.</p>
<p>To extract predictions from such a prediction model and multiply imputed data, either the sets of imputation-specific regression coefficients or the pooled regression coefficients could be used, and we must decide how to handle individuals with multiply imputed covariates. Thus there are numerous combinations for constructing a set of predictions, including imputation-specific predictions (M predictions for each individual) and pooled predictions (an averaged prediction over imputed datasets for each individual). The differences between them and their advantages and drawbacks are unclear.</p>
</blockquote>
<hr>
<blockquote class="blockquote">
<p>Wood, A.M., Royston, P. and White, I.R. (2015), The estimation and use of predictions for the assessment of model performance using large samples with multiply imputed data. Biom. J., 57: 614-632. <a href="https://doi.org/10.1002/bimj.201400004" class="uri">https://doi.org/10.1002/bimj.201400004</a></p>
</blockquote>
<hr>
<p>We include all possible information in our imputation model, for example, that might mean entail specifying all the variables in our dataset as covariates, and impute the missing data using a set of reliable and well-studied imputation algorithms, and then analyze each dataset and pool the results. Our basic workflow will look like this:</p>
<hr>
<figure class="figure">
<p><img src="https://lesslikely.com/images/missingness.png" width="800" style="cursor: zoom-in" class="figure-img"></p>
<figcaption>
Flowchart from <a href="http://www.i-deel.org/uploads/5/2/4/1/52416001/chapter_4.pdf">Ecological Statistics: Contemporary Theory and Applications</a>
</figcaption>
</figure>
<hr>
</section>
<section id="concepts-in-multiple-imputation" class="level2">
<h2 class="anchored" data-anchor-id="concepts-in-multiple-imputation">Concepts in Multiple Imputation</h2>
<hr>
<p>It can also be written using the following notation, which will be explained below.</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A%5Cbar%7Bb%7D%20&amp;=%5Cfrac%7B1%7D%7Bm%7D%20%5Csum_%7Bi=1%7D%5Em%20b_i%20%5C%5C%0Av_W%20&amp;=%5Cfrac%7B1%7D%7Bm%7D%20%5Csum_%7Bi=1%7D%5Em%20s_%7B.%7D%20e_%7B%5Ccdot%7D%5E2%20%5C%5C%0Av_B%20&amp;=%5Cfrac%7B1%7D%7Bm-1%7D%20%5Csum_%7Bi=1%7D%5Em%5Cleft(b_i-%5Cbar%7Bb%7D%5Cright)%5E2%20%5C%5C%0Av_T%20&amp;=v_W+v_B+%5Cfrac%7Bv_B%7D%7Bm%7D%0A%5Cend%7Baligned%7D%0A"></p>
<hr>
<p><a href="http://www.i-deel.org/uploads/5/2/4/1/52416001/chapter_4.pdf">Nagakawa writes</a>:</p>
<hr>
<blockquote class="blockquote">
<p>There are three main steps in MI: imputation, analysis, and pooling (figure 4.5C). In the imputation step, you create <img src="https://latex.codecogs.com/png.latex?m"> copies of completed data set by using data imputation methods such as the EM/EMB algorithms or the MCMC procedure. In the analysis step, you run separate statistical analyses on each of <img src="https://latex.codecogs.com/png.latex?m"> data sets. Finally, in the pooling step, you aggregate <img src="https://latex.codecogs.com/png.latex?m"> sets of results to produce unbiased parameter and uncertainty estimates.</p>
<p>This aggregation process is done by the following equations (which are automatically calculated in <em>R</em>): where ̄<img src="https://latex.codecogs.com/png.latex?b"> is the mean of <img src="https://latex.codecogs.com/png.latex?b_%7Bi%7D"> (e.g., regression coefficients), which is a parameter estimated from the ith data set (<img src="https://latex.codecogs.com/png.latex?m">), <img src="https://latex.codecogs.com/png.latex?v_W"> is the within-imputation variance calculated from the standard error associated with <img src="https://latex.codecogs.com/png.latex?b_%7Bi%7D">, <img src="https://latex.codecogs.com/png.latex?v_B"> is the between-imputation variance estimates, and <img src="https://latex.codecogs.com/png.latex?v_T"> is the total variance (<img src="https://latex.codecogs.com/png.latex?%E2%88%9Av_T"> is the overall standard error for <img src="https://latex.codecogs.com/png.latex?%5Cbar%7Bb%7D">).</p>
<p>This set of equations for combining estimates from <img src="https://latex.codecogs.com/png.latex?m"> sets of results is often referred to as Rubin’s rules, as it was developed by Rubin (1987). Statistical significance and confidence intervals (CIs) of pooled parameters are obtained by, where <img src="https://latex.codecogs.com/png.latex?df"> is the number of degrees of freedom used for t-tests or to obtain <img src="https://latex.codecogs.com/png.latex?t"> values and CI calculations, and <img src="https://latex.codecogs.com/png.latex?%CE%B1"> is the significance level (e.g., 95% CI, <img src="https://latex.codecogs.com/png.latex?%CE%B1"> = 0.05).:</p>
</blockquote>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0Ad%20f%20&amp;=(m-1)%5Cleft(1+%5Cfrac%7Bm%20v_W%7D%7B(m+1)%20v_B%7D%5Cright)%5E2,%20%5C%5C%0At_%7Bd%20f%7D%20&amp;=%5Cfrac%7B%5Cbar%7Bb%7D%7D%7B%5Csqrt%7Bv_T%7D%7D,%20%5C%5C%0A100(1-%5Calpha)%20%5C%25%20%5Cmathrm%7BCI%7D%20&amp;=%5Cbar%7Bb%7D%20%5Cpm%20t_%7Bd%20f,(1-%5Calpha%20/%202)%20%5Csqrt%7Bv_T%7D%7D%0A%5Cend%7Baligned%7D%0A"></p>
<hr>
<p><a href="http://www.i-deel.org/uploads/5/2/4/1/52416001/chapter_4.pdf">Nagakawa then</a> discusses the similarities between imputation algorithms and MCMC methods,</p>
<hr>
<blockquote class="blockquote">
<p>MCMC procedures (and also Gibbs sampling) are often called Bayesian methods (chapter 1) because their goal is to create the posterior distributions of parameters, but methods using MCMC have much wider applications than Bayesian statistics). The MCMC procedure, is akin to the EM algorithm (Schafer 1997) in that it uses a two-step iterative algorithm to find <img src="https://latex.codecogs.com/png.latex?%5Cbf%7B%5Chat%7Bm%7D%7D"> and <img src="https://latex.codecogs.com/png.latex?%5Cbf%7B%5Chat%7BV%7D%7D">.</p>
<p>The imputation step (I-step) uses stochastic regression with observed data. Next, the posterior step (P-step) uses this filled-in data set to construct the posterior distributions of <img src="https://latex.codecogs.com/png.latex?%5Cbf%7B%5Chat%7Bm%7D%7D"> and <img src="https://latex.codecogs.com/png.latex?%5Cbf%7B%5Chat%7BV%7D%7D">. Then, it uses a Monte Carlo method to sample a new set of <img src="https://latex.codecogs.com/png.latex?%5Cbf%7B%5Chat%7Bm%7D%7D"> and <img src="https://latex.codecogs.com/png.latex?%5Cbf%7B%5Chat%7BV%7D%7D"> from these distributions. These new parameter estimates are used for the subsequent I-step. Iterations of the two steps create the Markov chain, which even actually converges into fully fledged posterior distributions of <img src="https://latex.codecogs.com/png.latex?%5Cbf%7B%5Chat%7Bm%7D%7D"> and <img src="https://latex.codecogs.com/png.latex?%5Cbf%7B%5Chat%7BV%7D%7D"> (figure 4.6B). These distributions are, in turn, used for multiple imputation.</p>
</blockquote>
<hr>
<p>Now that we’ve quickly reviewed some of the concepts of multipe imputation and missing data, we can now begin to build our imputation model. This is generally done by building a model with all relevant covariates, however, this should be compared a reduced model with just the treatment group. This is because we want both the adjusted and unadjusted estimates. We will then compare these models using the <a href="https://github.com/amices/mice/blob/master/R/D3.R">likelihood-ratio test</a><span class="citation" data-cites="mengPerformingLikelihoodRatio1992"><sup>21</sup></span> to see whether there are any substantial differences between the fully-adjusted and reduced model.</p>
<p>The imputation model for a particular parameter will generally resemble the estimation model being used.</p>
<hr>
<blockquote class="blockquote">
<p>When developing your imputation model, it is important to assess if your imputation model is “congenial” or consistent with your analytic model. Consistency means that your imputation model includes (at the very least) the same variables that are in your analytic or estimation model. This includes any transformations to variables that will be needed to assess your hypothesis of interest. This can include log transformations, interaction terms, or recodes of a continuous variable into a categorical form, if that is how it will be used in later analysis. The reason for this relates back to the earlier comments about the purpose of multiple imputation.</p>
<p>Since we are trying to reproduce the proper variance/covariance matrix for estimation, all relationships between our analytic variables should be represented and estimated simultaneously. Otherwise, you are imputing values assuming they have a correlation of zero with the variables you did not include in your imputation model. This would result in underestimating the association between parameters of interest in your analysis and a loss of power to detect properties of your data that may be of interest such as non-linearities and statistical interactions. - <a href="https://stats.oarc.ucla.edu/stata/seminars/mi_in_stata_pt1_new/">From the UCLA Statistical Consulting Website</a></p>
</blockquote>
<hr>
</section>
<section id="monte-carlo-error-analysis" class="level2">
<h2 class="anchored" data-anchor-id="monte-carlo-error-analysis">Monte Carlo Error Analysis</h2>
<hr>
<p>However, before we begin to build the model, we must also have an idea of how many imputations we need to compute. To many, this may seem like a trivial and even nonsensical task when any individual can impute a large number of datasets. Indeed, it may seem that more imputations would give a more reliable and precise estimate, however, nothing in life is free, and running a imputation algorithm that is computationally demanding (and which can potentially take hours or days) is not feasible for everyone, hence the reason for “sample-size” calculations for imputation algorithms.</p>
<hr>
<blockquote class="blockquote">
<p>Multiple imputation is a stochastic procedure. Each time we reimpute our data, we get different sets of imputations because of the randomness of the imputation step, and therefore we get different multiple-imputation estimates. However, we want to be able to reproduce MI results. Of course, we can always set the random-number seed to ensure reproducibility by obtaining the same imputed values. However, what if we use a different seed? Would we not want our results to be similar regardless of what seed we use? This leads us to a notion we call statistical reproducibility—we want results to be similar across repeated uses of the same imputation procedure; that is, we want to minimize the simulation error associated with our results.</p>
<p>To assess the level of simulation error, White, Royston, and Wood (2011) propose to use a Monte Carlo error of the MI results, defined as the standard deviation of the results across repeated runs of the same imputation procedure using the same data. The authors suggest evaluating Monte Carlo error estimates not only for parameter estimates but also for other statistics, including p-values and confidence intervals, as well as MI statistics including RVI and FMI.</p>
</blockquote>
<hr>
<p>The issue with this is that without giving careful thought to how many imputations may be needed for a particular study, one may run the risk of imputing too few datasets and losing information, or they may waste resources imputing a nonsensical amount that may not be necessary. Indeed, the latter seems especially trivial, however, it may often yield no advantages whatsoever, and only incur costs as many authors have argued.</p>
<hr>
<blockquote class="blockquote">
<p>The argument is that “the additional resources that would be required to create and store more than a few imputations would not be well spent” (Schafer 1997, 107), and “in most situations there is simply little advantage to producing and analyzing more than a few imputed datasets” (Schafer and Olsen 1998, 549).</p>
</blockquote>
<hr>
<p>Therefore, we will examine certain characteristics of our dataset with missing values and use them in an analysis to determine how many datasets we should impute to efficiently achieve our goals. We will base this off a number of characteristics such as the fraction of missing information, the proportion of missing observations, and the losses that we are willing to incur.</p>
<p>We first start by running a “dry” or naive imputation of our data to quickly examine some of these characteristics. This imputed dataset will not be used for our primary analysis, it is simply serving to guide us in our main imputation model. This is also why we have set the number of iterations to 0.</p>
<p>Once again, we will include all the variables in our dataset, and use the predictive mean matching method with approximately 5 donors.</p>
<hr>
<div class="cell" data-layout-align="center">
<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="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Dry Imputation</span></span>
<span id="cb13-2"></span>
<span id="cb13-3">form <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>(PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2)</span>
<span id="cb13-4">pred <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;">make.predictorMatrix</span>(BP_miss)</span>
<span id="cb13-5"></span>
<span id="cb13-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parlmice</span>(BP_miss, <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;">"pmm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">m =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>,</span>
<span id="cb13-7">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxit =</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;">cores =</span> cores, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">donors =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,</span>
<span id="cb13-8">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cluster.seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1031</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formulas =</span> form, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ridge =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb13-9">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predictorMatrix =</span> pred, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.collinear =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb13-10">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.constant =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">allow.na =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb13-11">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">printFlag =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">visitSequence =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"monotone"</span>) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-&gt;</span> init_imp</span>
<span id="cb13-12"></span>
<span id="cb13-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span>(init_imp<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>loggedEvents, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>)</span>
<span id="cb13-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; NULL</span></span></code></pre></div></div>
</div>
<hr>
<p>Now that we have imputed our dataset, we may examine it for any issues before moving onto the next step of analyzing it.</p>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error in `xyplot.mids()`:
#&gt; ! Missing formula</code></pre>
</div>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error in `lattice::latticeParseFormula()`:
#&gt; ! model must be a formula object</code></pre>
</div>
<hr>
<p>Although it is only a dry run, there seems to be no issues with it. We now pool our estimates using Rubin’s rules.</p>
<hr>
<div class="cell" data-layout-align="center">
<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">init_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> mice<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;">pool</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">with</span>(</span>
<span id="cb16-2">  init_imp,</span>
<span id="cb16-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rlm</span>(</span>
<span id="cb16-4">    PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-5">      BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-6">      Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2,</span>
<span id="cb16-7">    <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;">"MM"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">psi =</span> psi.huber</span>
<span id="cb16-8">  )</span>
<span id="cb16-9">))</span>
<span id="cb16-10"></span>
<span id="cb16-11">init_res_sum <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;">summary</span>(init_res)</span>
<span id="cb16-12"></span>
<span id="cb16-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(init_res_sum) <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;">c</span>(</span>
<span id="cb16-14">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Term"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Estimate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SE"</span>,</span>
<span id="cb16-15">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Statistic"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"df"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P-val"</span></span>
<span id="cb16-16">)</span>
<span id="cb16-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ztable</span>(init_res_sum)</span></code></pre></div></div>
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Term</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Estimate</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">SE</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Statistic</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">df</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">P-val</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">(Intercept)</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">33.48</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">16.21</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.07</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">factor(Group)Drug Y</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-8.25</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.39</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-21.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">BaselineDBP</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.81</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.14</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">5.90</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Age</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.28</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.03</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">8.57</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Z</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.69</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">4.11</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.17</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">R1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.18</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">R2</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.38</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<p>Now that we have our vector, we can quickly examine certain characteristics such as the fraction of missing information (FIMO), the between-imputation variance and the within-imputation variance. The reason that we focus on these particular attributes is because they are crucial for several tasks in any statistical analysis plan, such as having enough power/precision, minimum long-run coverage, etc.</p>
<p>We use the FIMO from the dry imputation and a number of other criteria to determine how many imputations we need:</p>
<hr>
<ul>
<li>Some have suggested taking the FIMO and multiplying by 100 to obtain the number of imputed datasets needed</li>
</ul>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?m%20%5Capprox%20100%20%5Clambda"></p>
<hr>
<ul>
<li>For our goals, we wish to ensure that the monte-carlo standard error from the imputations are less than 10% of the between-imputation standard error</li>
</ul>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?mcse%20%3C%20B%5E%7B%5Chat%7B-%7D%7D_%7BSE%7D%20*%200.10"></p>
<hr>
<ul>
<li>We wish to minimize the monte-carlo error that is derived from dividing the chosen number of datasets to impute from the fraction of missing information so that the monte-carlo standard error is less than 0.01</li>
</ul>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?%5Cfrac%7BFMI%7D%7Bm%7D%20%E2%89%88%200.01"></p>
<hr>
<ul>
<li>We also wish to minimize the total variance so that the square-root of it is no greater than the ideal variance and the corresponding confidence interval width.</li>
</ul>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?T_%7Bm%7D=%5Cleft(1+%5Cfrac%7B%5Cgamma_%7B0%7D%7D%7Bm%7D%5Cright)%20T_%7B%5Cinfty%7D"></p>
<hr>
<ul>
<li>Furthermore, it is commonly advocated by missing data experts to impute the same or similar number of datasets as fractions of missing observations <img src="https://latex.codecogs.com/png.latex?%5Cgamma_%7B0%7D*100"></li>
</ul>
<hr>
<p>We start by extracting the FMIs from our dry imputation and calculating all these numbers.</p>
<hr>
<div class="cell" data-layout-align="center" data-errors="true">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Calculate Fraction of Missing Information</span></span>
<span id="cb17-2">fmi <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;">max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(init_res,</span>
<span id="cb17-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</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;">"all"</span>),</span>
<span id="cb17-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf.int =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf.level =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span></span>
<span id="cb17-5">)[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fmi"</span>])</span>
<span id="cb17-6"></span>
<span id="cb17-7">m <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> fmi <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.01</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># FMI Imputations</span></span>
<span id="cb17-8"></span>
<span id="cb17-9">mcse <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;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(init_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pooled<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>b) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> m) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># MCSE</span></span>
<span id="cb17-10"></span>
<span id="cb17-11">se <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;">max</span>((init_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pooled<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>ubar) <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;">sqrt</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>)) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># SE</span></span></code></pre></div></div>
</div>
<hr>
<p>What we find is that the fraction of missing information is nearly 50% which is very high and that in order to get a monte-carlo error of less than 0.01, we would need a minimum of at least 50 imputed datasets. We also calculate both the monte-carlo standard error and the standard error from the dry run and find that they are practically equivalent.</p>
<p>However, we must also explore other possibilities in terms of number of imputed datasets to reduce the monte-carlo errors so we run a quick function to do that, checking the effects of a number of imputed datasets on the width of the confidence interval, which is directly tied to the monte-carlo error.</p>
<p>Indeed, Von Hippel (2018) proposed a relationship between the fraction of missing information and the number of imputations needed to achieve a targeted CI length or monte-carlo error using a quadratic formula,</p>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?m=1+%5Cfrac%7B1%7D%7B2%7D%5Cleft(%5Cfrac%7B%5Cgamma_%7B0%7D%7D%7B%5Coperatorname%7BSD%7D%5Cleft(%5Csqrt%7BU_%7B%5Cell%7D%7D%5Cright)%20%5Cmathrm%7BE%7D%5Cleft(%5Csqrt%7BU_%7B%5Cell%7D%7D%5Cright)%7D%5Cright)%5E%7B2%7D"></p>
<hr>
<p>where <img src="https://latex.codecogs.com/png.latex?%5Cmathrm%7BE%7D%5Cleft(%5Csqrt%7BU_%7B%5Cell%7D%7D%5Cright)"> and <img src="https://latex.codecogs.com/png.latex?%5Cmathrm%7BSD%7D%5Cleft(%5Csqrt%7BU_%7B%5Cell%7D%7D%5Cright)"> are the coefficient of variation (CV), summarizing the imputation variation in the SE estimates. We can graphically construct a function to depict this relationship and calculate how many imputations we will need based on some desired error and further display the distribution of this relationship by varying these parameters.</p>
<p>In the function below, adopted from von Hippel, and van Buuren,<span class="citation" data-cites="buurenFlexibleImputationMissing2018"><sup>20</sup></span> I vary both the coefficient of variation and the <img src="https://latex.codecogs.com/png.latex?%5Calpha">-level.</p>
<hr>
<p>With this function, we can now graphically examine the effects of different parameter values on the monte-carlo errors from the imputations.</p>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error in `ci_width()`:
#&gt; ! could not find function "ci_width"
#&gt; Error in `ggplot()`:
#&gt; ! `data` cannot be a function.
#&gt; ℹ Have you misspelled the `data` argument in `ggplot()`?</code></pre>
</div>
<hr>
<p>We can see above that as we aim for smaller monte-carlo errors, we need many more imputations to achieve our desired target.</p>
<p>Now that I have constructed and graphed three differing relationships between monte-carlo errors and number of imputations needed to achieve those errors, and varied the <img src="https://latex.codecogs.com/png.latex?%5Calpha">-levels, we can now move onto choosing a specific number of imputations to construct.</p>
<p>If I choose an <img src="https://latex.codecogs.com/png.latex?%5Calpha"> level of 5%, which the maximum tolerable type-I error rate, and a coefficient of variation of 5%</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Estimate Number of Imputations</span></span>
<span id="cb19-2"></span>
<span id="cb19-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">powerimp</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> init_res, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.10</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.05</span>)</span>
<span id="cb19-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `powerimp()`:</span></span>
<span id="cb19-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! could not find function "powerimp"</span></span>
<span id="cb19-6"></span>
<span id="cb19-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">powerimp</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> init_res, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv =</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;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>)</span>
<span id="cb19-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `powerimp()`:</span></span>
<span id="cb19-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! could not find function "powerimp"</span></span>
<span id="cb19-10"></span>
<span id="cb19-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">powerimp</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> init_res, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</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.05</span>)</span>
<span id="cb19-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `powerimp()`:</span></span>
<span id="cb19-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! could not find function "powerimp"</span></span></code></pre></div></div>
</div>
<hr>
<p>I need to construct approximately 124 imputations to achieve this coefficient of variation, which is what I will use for all the analyses from here on, and it is clear that it is far more reasonable than trying to impute 3000 datasets to achieve a tiny standard error.</p>
<hr>
<p>However, I want to verify my calculations by running a similar estimation command that Stata provides. The documentation says the following regarding RVI and FMI:</p>
<hr>
<blockquote class="blockquote">
<p>Returning to the output, average RVI reports the average relative increase (averaged over all coefficients) in variance of the estimates because of the missing bmi values. A relative variance increase is an increase in the variance of the estimate because of the loss of information about the parameter due to nonresponse relative to the variance of the estimate with no information lost. The closer this number is to zero, the less effect missing data have on the variance of the estimate. Note that the reported RVI will be zero if you use mi estimate with the complete data or with missing data that have not been imputed. In our case, average RVI is small: 0.0312.</p>
<p>Largest FMI reports the largest of all the FMI about coefficient estimates due to nonresponse. This number can be used to get an idea of whether the specified number of imputations is sufficient for the analysis. A rule of thumb is that M ≥ 100 × FMI provides an adequate level of reproducibility of MI analysis. In our example, the largest FMI is 0.14 and the number of imputations, 20, exceeds the required number of imputations: 14</p>
</blockquote>
<hr>
<p>Although I cannot get the number of imputations directly from a command, I can run the <a href="https://www.stata.com/manuals/mimiestimate.pdf"><code>mi estimate</code></a> command, and look at the overall fraction of missing information as the number of imputations increases. If my previous calculations are consistent, I should look to increase the number of imputations until I achieve an FMI of 1.24 or less: 124/100</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb20-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">clear</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">all</span></span>
<span id="cb20-2"></span>
<span id="cb20-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">seed</span> 1031</span>
<span id="cb20-4"></span>
<span id="cb20-5">parallel setclusters 8, statapath(/Applications/Stata)</span>
<span id="cb20-6"></span>
<span id="cb20-7">parallel initialize 8, statapath(/Applications/Stata)</span>
<span id="cb20-8"></span>
<span id="cb20-9"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">quietly</span> import delimited <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"~/Dropbox/LessLikely/static/datasets/temp.csv"</span>, numericcols(2 3 5 6 7 8)</span>
<span id="cb20-10"></span>
<span id="cb20-11"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">quietly</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mi</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> mlong</span>
<span id="cb20-12"></span>
<span id="cb20-13"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">quietly</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mi</span> register imputed baselinedbp postdbp age z <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group</span> r1 r2</span>
<span id="cb20-14"></span>
<span id="cb20-15"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">quietly</span> parallel: <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mi</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">impute</span> chained (pmm, knn(5)) postdbp = baselinedbp age z r1 r2 <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group</span>, burnin(5) add(120) rseed (1031) nomonotone</span>
<span id="cb20-16"></span>
<span id="cb20-17"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">quietly</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mi</span> estimate, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">saving</span>(miest, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span>): <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">rreg</span> postdbp i.<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group</span> baselinedbp age z r1 r2</span>
<span id="cb20-18"></span>
<span id="cb20-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mi</span> estimate <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> miest, mcerror <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">level</span>(95)</span>
<span id="cb20-20"></span>
<span id="cb20-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mi</span> estimate, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">saving</span>(miest, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span>) vartable mcerror <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">level</span>(95) nocitable: <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">rreg</span> postdbp i.<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group</span> baselinedbp age z r1 r2</span>
<span id="cb20-22"></span>
<span id="cb20-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mi</span> estimate <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> miest, mcerror <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">level</span>(95)</span>
<span id="cb20-24">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb20-25">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb20-26">#&gt; </span>
<span id="cb20-27">#&gt; </span>
<span id="cb20-28">#&gt; </span>
<span id="cb20-29">#&gt; </span>
<span id="cb20-30">#&gt; <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">N</span> Clusters: 8</span>
<span id="cb20-31">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb20-32">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb20-33">#&gt; </span>
<span id="cb20-34">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span></code></pre></div></div>
</div>
<hr>
</section>
<section id="the-primary-analysis" class="level2">
<h2 class="anchored" data-anchor-id="the-primary-analysis">The Primary Analysis</h2>
<hr>
<p>For the primary analysis, I will use the predictive-mean matching method and specify 5 donors (based on a number of simulation studies that have examined the effect of various donors specified)<span class="citation" data-cites="schenkerPartiallyParametricTechniques1996"><sup>22</sup></span>, and fit a robust regression that includes all the variables within the dataset. Our imputation model will be</p>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?Y%5E%7B%5Coperatorname%7BPost%7D%7D%20=%20%5Cbeta_%7B0%7D%20+%20%5Cbeta_%7B1%7D%5E%7B%5Coperatorname%7BGroup%7D%7D%20+%20%5Cbeta_%7B2%7D%5E%7B%5Coperatorname%7BBase%7D%7D%20+%20%5Cbeta_%7B3%7D%5E%7B%5Coperatorname%7BAge%7D%7D%20+%20%5Cbeta_%7B4%7D%5E%7B%5Coperatorname%7BZ%7D%7D%20+%20%5Cbeta_%7B5%7D%5E%7B%5Coperatorname%7BR1%7D%7D%20+%20%5Cbeta_%7B6%7D%5E%7B%5Coperatorname%7BR2%7D%7D%20+%20%5Cepsilon"></p>
<hr>
<p>So we will now impute our datasets.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Impute Missing Data</span></span>
<span id="cb21-2"></span>
<span id="cb21-3">form <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>(PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2)</span>
<span id="cb21-4">pred <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;">make.predictorMatrix</span>(BP_miss)</span>
<span id="cb21-5"></span>
<span id="cb21-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parlmice</span>(BP_miss,</span>
<span id="cb21-7">  <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;">"pmm"</span>,</span>
<span id="cb21-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predictorMatrix =</span> pred,</span>
<span id="cb21-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">m =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">120</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cluster.seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1031</span>,</span>
<span id="cb21-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n.core =</span> cores, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n.imp.core =</span> (m <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> cores),</span>
<span id="cb21-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formulas =</span> form, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ridge =</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;">cl.type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FORK"</span>,</span>
<span id="cb21-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">donors =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.collinear =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb21-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.constant =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">allow.na =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb21-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">printFlag =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">visitSequence =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"monotone"</span></span>
<span id="cb21-15">) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-&gt;</span> imp1</span>
<span id="cb21-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `checkForRemoteErrors()`:</span></span>
<span id="cb21-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! 14 nodes produced errors; first error: missing value where TRUE/FALSE needed</span></span>
<span id="cb21-18"></span>
<span id="cb21-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span>(imp1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>loggedEvents, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>)</span>
<span id="cb21-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `h()`:</span></span>
<span id="cb21-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! error in evaluating the argument 'x' in selecting a method for function 'head': object 'imp1' not found</span></span></code></pre></div></div>
</div>
<hr>
<p>Now that we have imputed our datasets, we may examine them for any issues before moving onto the next step of analyzing it.</p>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error in `h()`:
#&gt; ! error in evaluating the argument 'x' in selecting a method for function 'plot': object 'imp1' not found
#&gt; Error in `h()`:
#&gt; ! error in evaluating the argument 'object' in selecting a method for function 'update': object 't1' not found
#&gt; Error:
#&gt; ! object 'imp1' not found</code></pre>
</div>
<hr>
<p>Our imputed datasets seem to look fine so far. We now fit our models to each of these datasets and combine them using Rubin’s rules.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Primary Analysis</span></span>
<span id="cb23-2"></span>
<span id="cb23-3">analysis1 <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;">with</span>(imp1, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rlm</span>(</span>
<span id="cb23-4">  PostDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> (Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-5">    BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2,</span>
<span id="cb23-6">  <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;">"MM"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">psi =</span> psi.huber</span>
<span id="cb23-7">))</span>
<span id="cb23-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb23-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'imp1' not found</span></span>
<span id="cb23-10">analysis2 <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;">with</span>(imp1, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rlm</span>(PostDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> (Group),</span>
<span id="cb23-11">  <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;">"MM"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">psi =</span> psi.huber</span>
<span id="cb23-12">))</span>
<span id="cb23-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb23-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'imp1' not found</span></span>
<span id="cb23-15"></span>
<span id="cb23-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">anova</span>(analysis1, analysis2,</span>
<span id="cb23-17">  <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;">"D3"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">use =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LR"</span></span>
<span id="cb23-18">)</span>
<span id="cb23-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb23-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'analysis1' not found</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1">result1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> mice<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;">pool</span>(analysis1)</span>
<span id="cb24-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb24-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'analysis1' not found</span></span>
<span id="cb24-4"></span>
<span id="cb24-5">results1_sum <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;">summary</span>(result1)</span>
<span id="cb24-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `h()`:</span></span>
<span id="cb24-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! error in evaluating the argument 'object' in selecting a method for function 'summary': object 'result1' not found</span></span>
<span id="cb24-8"></span>
<span id="cb24-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(results1_sum) <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;">c</span>(</span>
<span id="cb24-10">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Term"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Estimate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SE"</span>,</span>
<span id="cb24-11">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Statistic"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"df"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P-val"</span></span>
<span id="cb24-12">)</span>
<span id="cb24-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb24-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'results1_sum' not found</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error:
#&gt; ! object 'results1_sum' not found</code></pre>
</div>
<hr>
<p>While we have our primary analysis estimates, we also continue to examine our imputations for any anomalies.</p>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error in `h()`:
#&gt; ! error in evaluating the argument 'x' in selecting a method for function 'rowMeans': object 'analysis1' not found
#&gt; Error:
#&gt; ! object 'imp1' not found</code></pre>
</div>
<hr>
<p>We’ve done our primary analysis, in which we imputed the missing data under the assumption of <strong>MAR</strong>, which is often a reasonable assumption to start with. Unfortunately, we cannot verify whether or not this assumption is true, but we can vary this missing data assumption and assume that the data are missing not at random (<strong>MNAR</strong>) <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BPr%7D%5Cleft(R=0%20%5Cmid%20Y_%7B%5Cmathrm%7Bobs%7D%7D,%20Y_%7B%5Cmathrm%7Bmis%7D%7D,%20%5Cpsi%5Cright)">, and that in the individuals with missing data, we can assume different numbers than those with complete data. Our likelihood-ratio test also suggests that there’s very little difference between the full model and the reduced model, so we generally will go with the full model.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="grViz html-widget html-fill-item" id="htmlwidget-972e12537c75ce56a9fb" style="width:100%;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-972e12537c75ce56a9fb">{"x":{"diagram":"digraph {\n  graph [layout = dot, rankdir = TB,\n         compound = true, bgcolor = \"transparent\",\n         nodesep = .5, ranksep = .25]\n  node [shape = circle,\n      fixedsize = true,\n      fontsize = 9,\n      fontname = Helvetica,\n      fontcolor = \"#000000\",\n      width = .99,\n      height = .99,\n      style = filled,\n      color = \"#91A3B0\",\n      label = \"\"]\n  edge [color = \"#999\", arrowhead = normal, arrowtail = inv]\n  rec1 [label = \"Study \nObjective\", fillcolor = \"#D0EAEE\"]\n  rec2 [label = \"Estimand\", fillcolor = \"#abd9ca\"]\n  rec3 [label =  \"Primary \nEstimator\", fillcolor = \"#7aa864\"]\n  rec4 [label = \"Primary \nEstimate\", fillcolor = \"#7aa864\"]\n\n  # edge definitions with the node IDs\n  rec1 -> rec2\n  rec2 -> rec3 ->rec4}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script>
</div>
</div>
<hr>
</section>
<section id="sa-i-controlled-imputations" class="level2">
<h2 class="anchored" data-anchor-id="sa-i-controlled-imputations">SA I: Controlled Imputations</h2>
<hr>
<p>Now suppose we wish to handle these missing data under the assumption of <strong>MNAR</strong>, we would now be conducting a sensitivity analysis because we are still targeting the same estimand, but only varying the assumptions. The question / target remain the same. To handle missing data that we assume are <strong>MNAR</strong>, there are a number of different and complex approaches.</p>
<p>We start off with the <img src="https://latex.codecogs.com/png.latex?%5Cdelta">-adjustment, controlled multiple imputation method,<span class="citation" data-cites="permuttSensitivityAnalysisMissing2016"><sup>23</sup></span> in which we assume that the group with missing observations differs systematically from the group with complete observations by a certain quantity. We produce a range of these quantities and add or subtract them from the imputed values and then conduct our analysis on this adjusted, imputed dataset. Here I will make the assumption that the average <code>PostDBP</code> estimate from the missing value group differs from at least 0 mmHg to at most 20 mmHg from the group with no missing observations.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Controlled MI</span></span>
<span id="cb27-2"></span>
<span id="cb27-3">ini <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;">mice</span>(BP_miss,</span>
<span id="cb27-4">  <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;">"pmm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb27-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predictorMatrix =</span> pred</span>
<span id="cb27-6">)</span>
<span id="cb27-7"></span>
<span id="cb27-8">ini<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BaselineDBP"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb27-9">ini<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PostDBP"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pmm"</span></span>
<span id="cb27-10">ini<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Age"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb27-11">ini<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R1"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb27-12">ini<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb27-13">ini<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R2"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb27-14">ini<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Z"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb27-15">meth <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ini<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method</span>
<span id="cb27-16"></span>
<span id="cb27-17">delta <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;">seq</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;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb27-18"></span>
<span id="cb27-19">imp.all <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;">vector</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"list"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(delta))</span>
<span id="cb27-20">post <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ini<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>post</span>
<span id="cb27-21"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <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="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(delta)) {</span>
<span id="cb27-22">  d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> delta[i]</span>
<span id="cb27-23">  cmd <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;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"imp[[j]][, i] &lt;- imp[[j]][, i] +"</span>, d)</span>
<span id="cb27-24">  post[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PostDBP"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cmd</span>
<span id="cb27-25">  imp <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;">mice</span>(BP_miss,</span>
<span id="cb27-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> meth,</span>
<span id="cb27-27">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predictorMatrix =</span> pred,</span>
<span id="cb27-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">m =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxit =</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;">donors =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,</span>
<span id="cb27-29">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cores =</span> cores, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ridge =</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;">formulas =</span> form,</span>
<span id="cb27-30">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.collinear =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb27-31">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.constant =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb27-32">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">allow.na =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">post =</span> post,</span>
<span id="cb27-33">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">printFlag =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb27-34">  )</span>
<span id="cb27-35">  imp.all[[i]] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> imp</span>
<span id="cb27-36">}</span></code></pre></div></div>
</div>
<hr>
<p>Now that we have our imputed datasets that are modified by <img src="https://latex.codecogs.com/png.latex?%5Cdelta">-adjustments, we can fit our models to each imputed dataset and combine the estimates using Rubin’s rules.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Sensitivity Analysis 1</span></span>
<span id="cb28-2"></span>
<span id="cb28-3">output <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;">sapply</span>(imp.all,</span>
<span id="cb28-4">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb28-5">    mice<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;">pool</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">with</span>(</span>
<span id="cb28-6">      x,</span>
<span id="cb28-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rlm</span>(</span>
<span id="cb28-8">        PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb28-9">          BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2,</span>
<span id="cb28-10">        <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;">"MM"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">psi =</span> psi.huber</span>
<span id="cb28-11">      )</span>
<span id="cb28-12">    ))</span>
<span id="cb28-13">  },</span>
<span id="cb28-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">simplify =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"array"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">USE.NAMES =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb28-15">)</span>
<span id="cb28-16"></span>
<span id="cb28-17">a <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.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">t</span>(output)))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pooled</span>
<span id="cb28-18">r <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;">array</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(delta) <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;">7</span>),</span>
<span id="cb28-19">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dim =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(delta), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>),</span>
<span id="cb28-20">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dimnames =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb28-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(delta),</span>
<span id="cb28-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb28-23">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Intercept"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group"</span>,</span>
<span id="cb28-24">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BaselineDBP"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Age"</span>,</span>
<span id="cb28-25">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Z"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R2"</span></span>
<span id="cb28-26">    )</span>
<span id="cb28-27">  )</span>
<span id="cb28-28">)</span>
<span id="cb28-29"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <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="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(delta)) {</span>
<span id="cb28-30">  r[i, ] <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;">cbind</span>(a[[i]][[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"estimate"</span>]])</span>
<span id="cb28-31">}</span>
<span id="cb28-32"></span>
<span id="cb28-33">r <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.data.frame</span>(r)</span>
<span id="cb28-34">r <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;">Delta =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">row.names</span>(r), r, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Delta</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Intercept</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Group</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">BaselineDBP</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Age</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Z</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">R1</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">R2</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-20</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-108.42</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-11.79</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.96</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.30</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-3.49</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.13</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-1.10</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-15</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-50.97</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-10.66</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.47</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.31</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-2.35</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.07</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.62</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-10</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-27.79</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-10.22</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.29</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.31</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-1.82</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.04</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.44</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-5</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-6.65</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.83</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.12</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.33</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-1.35</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.03</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.33</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">12.68</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.54</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.97</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.33</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.92</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.04</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.17</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">5</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">31.46</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.16</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.83</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.33</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.83</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.09</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">10</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">50.77</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-8.84</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.68</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.34</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.11</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.05</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.06</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">15</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">77.47</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-8.33</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.47</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.34</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.10</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.21</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">20</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">141.67</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-7.13</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.08</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.35</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.46</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.15</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.76</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<p>The table above gives the various <img src="https://latex.codecogs.com/png.latex?%5Cdelta">’s (the first column with values ranging from -30 - 30 in increments of 5) that were added to the multiply imputed datasets, and the corresponding estimates from the models fit to those datasets. So now we’ve conducted our first sensitivity analysis using the <img src="https://latex.codecogs.com/png.latex?%5Cdelta">-adjustment, controlled multiple imputation method. This form of sensitivity analysis is also typically what is used and preferred by regulators.<span class="citation" data-cites="permuttSensitivityAnalysisMissing2016"><sup>23</sup></span></p>
<hr>
<blockquote class="blockquote">
<p>Regulators prefer simple methods that impute the missing outcomes under MAR, and then add an adjustment δ to the imputes, while varying δ over a plausible range and independently for each treatment group (Permutt 2016).</p>
<p>The most interesting scenarios will be those where the difference between the δ’s correspond to the size of the treatment effect in the completers. Contours of the p-values may be plotted on a graph as a function of the δ’s to assist in a tipping-point analysis (Liublinska and Rubin 2014).</p>
</blockquote>
<hr>
<p>And as expected, lower <img src="https://latex.codecogs.com/png.latex?%5Cdelta"> values gave us results that were consistent with the primary analysis, while the upper end of the extreme <img src="https://latex.codecogs.com/png.latex?%5Cdelta"> values gave us estimates that were substantially off the mark.</p>
<hr>
<p>Next, we quickly examine the state of a random sample of these imputations to make sure they’re reliable.</p>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error:
#&gt; ! object 'aesthetics' not found</code></pre>
</div>
<hr>
<p>Now we move onto our next and final sensitivity analysis.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="grViz html-widget html-fill-item" id="htmlwidget-b2fcb8117df4050f82a2" style="width:100%;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-b2fcb8117df4050f82a2">{"x":{"diagram":"digraph {\n  graph [layout = dot, rankdir = TB,\n         compound = true,bgcolor = \"transparent\",\n         nodesep = .5, ranksep = .25]\n  node [shape = circle,\n      fixedsize = true,\n      fontsize = 9,\n      fontname = Helvetica,\n      fontcolor = \"#000000\",\n      width = .99,\n      height = .99,\n      style = filled,\n      color = \"#91A3B0\",\n      label = \"\"]\n  edge [color = black, arrowhead = normal, arrowtail = inv]\n  rec1 [label = \"Study \nObjective\", fillcolor = \"#D0EAEE\"]\n  rec2 [label = \"Estimand\", fillcolor = \"#abd9ca\"]\n  rec3 [label =  \"Sensitivity \nEstimator \n1\", fillcolor = \"#E69F00\"]\n  rec4 [label = \"Sensitivity \nEstimate \n1\", fillcolor = \"#E69F00\"]\n\n  # edge definitions with the node IDs\n  rec1 -> rec2\n  rec2 -> rec3 ->rec4}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script>
</div>
</div>
<hr>
</section>
<section id="sa-ii-selection-models" class="level2">
<h2 class="anchored" data-anchor-id="sa-ii-selection-models">SA II: Selection Models</h2>
<hr>
<p>To further explore the <strong>MNAR</strong> assumption, we could also use a Heckman selection model <img src="https://latex.codecogs.com/png.latex?P(Y,R)=P(Y)P(R%7CY)">, as described by van Buuren here<span class="citation" data-cites="buurenFlexibleImputationMissing2018"><sup>20</sup></span></p>
<hr>
<blockquote class="blockquote">
<p>The selection model multiplies the marginal distribution <img src="https://latex.codecogs.com/png.latex?P(Y)"> in the population with the response weights <img src="https://latex.codecogs.com/png.latex?P(R%7CY)">. Both <img src="https://latex.codecogs.com/png.latex?P(Y)"> and <img src="https://latex.codecogs.com/png.latex?P(R%7CY)"> are unknown, and must be specified by the user. The model where <img src="https://latex.codecogs.com/png.latex?P(Y)"> is normal and where <img src="https://latex.codecogs.com/png.latex?P(R%7CY)"> is a probit model is known as the Heckman model. This model is widely used in economics to correct for selection bias.</p>
</blockquote>
<hr>
<p>We can implement this in <code>R</code> using the <a href="https://cran.r-project.org/package=miceMNAR"><code>miceMNAR</code></a> package, which is an extension to the <a href="https://cran.r-project.org/package=mice"><code>mice</code></a> <code>R</code> package.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Selection Models</span></span>
<span id="cb30-2"></span>
<span id="cb30-3">JointModelEq <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;">generate_JointModelEq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> BP_miss,</span>
<span id="cb30-4">                                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">varMNAR =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PostDBP"</span>)</span>
<span id="cb30-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `generate_JointModelEq()`:</span></span>
<span id="cb30-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! could not find function "generate_JointModelEq"</span></span>
<span id="cb30-7"></span>
<span id="cb30-8">JointModelEq[, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PostDBP_var_sel"</span>] <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;">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="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;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb30-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb30-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'JointModelEq' not found</span></span>
<span id="cb30-11">JointModelEq[, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PostDBP_var_out"</span>] <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;">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="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;">0</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>
<span id="cb30-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb30-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'JointModelEq' not found</span></span>
<span id="cb30-14"></span>
<span id="cb30-15">arg <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;">MNARargument</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> BP_miss, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">varMNAR =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PostDBP"</span>,</span>
<span id="cb30-16">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">JointModelEq =</span> JointModelEq)</span>
<span id="cb30-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `MNARargument()`:</span></span>
<span id="cb30-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! could not find function "MNARargument"</span></span>
<span id="cb30-19"></span>
<span id="cb30-20">imp2 <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;">mice</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>data_mod,</span>
<span id="cb30-21">             <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;">"pmm"</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;">1031</span>,</span>
<span id="cb30-22">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predictorMatrix =</span> arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>predictorMatrix,</span>
<span id="cb30-23">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">JointModelEq =</span> arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>JointModelEq,</span>
<span id="cb30-24">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">control =</span> arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>control,</span>
<span id="cb30-25">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.collinear =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb30-26">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.constant =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">allow.na =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb30-27">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">printFlag =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">visitSequence =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"monotone"</span>)</span>
<span id="cb30-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb30-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'arg' not found</span></span>
<span id="cb30-30"></span>
<span id="cb30-31">imp2<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Group <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.factor</span>(imp2<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Group)</span>
<span id="cb30-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb30-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'imp2' not found</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error:
#&gt; ! object 'imp2' not found
#&gt; Error:
#&gt; ! object 'imp2' not found</code></pre>
</div>
<hr>
<p>Now we fit our models to these new datasets and pool them using Rubin’s rules.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Sensitivity Analysis 2</span></span>
<span id="cb32-2"></span>
<span id="cb32-3">analysis3 <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;">with</span>(imp2, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rlm</span>(</span>
<span id="cb32-4">  PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb32-5">    BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2,</span>
<span id="cb32-6">  <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;">"MM"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">psi =</span> psi.huber</span>
<span id="cb32-7">))</span>
<span id="cb32-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb32-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'imp2' not found</span></span>
<span id="cb32-10">result3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> mice<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;">pool</span>(analysis3)</span>
<span id="cb32-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb32-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'analysis3' not found</span></span>
<span id="cb32-13"></span>
<span id="cb32-14">results3_sum <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;">summary</span>(result3)</span>
<span id="cb32-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `h()`:</span></span>
<span id="cb32-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! error in evaluating the argument 'object' in selecting a method for function 'summary': object 'result3' not found</span></span>
<span id="cb32-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(results3_sum) <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;">c</span>(</span>
<span id="cb32-18">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Term"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Estimate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SE"</span>,</span>
<span id="cb32-19">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Statistic"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"df"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P-val"</span></span>
<span id="cb32-20">)</span>
<span id="cb32-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb32-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'results3_sum' not found</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error:
#&gt; ! object 'results3_sum' not found</code></pre>
</div>
<hr>
<p>Now we examine our imputed values.</p>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error in `h()`:
#&gt; ! error in evaluating the argument 'x' in selecting a method for function 'rowMeans': object 'analysis3' not found
#&gt; Error:
#&gt; ! object 'imp2' not found</code></pre>
</div>
<hr>
<p>so now we have completed our second sensitivity analysis.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="grViz html-widget html-fill-item" id="htmlwidget-c734e1f40d76b75963df" style="width:100%;height:480px;"></div>
<script type="application/json" data-for="htmlwidget-c734e1f40d76b75963df">{"x":{"diagram":"digraph {\n  graph [layout = dot, rankdir = TB,\n         compound = true, bgcolor = \"transparent\",\n         nodesep = .5, ranksep = .25]\n  node [shape = circle,\n      fixedsize = true,\n      fontsize = 9,\n      fontname = Helvetica,\n      fontcolor = \"#000000\",\n      width = .99,\n      height = .99,\n      style = filled,\n      color = \"#91A3B0\",\n      label = \"\"]\n  edge [color = \"#999\", arrowhead = normal, arrowtail = inv]\n  rec1 [label = \"Study \nObjective\", fillcolor = \"#D0EAEE\"]\n  rec2 [label = \"Estimand\", fillcolor = \"#abd9ca\"]\n  rec3 [label =  \"Sensitivity \nEstimator \n2\", fillcolor = \"#e7998c\"]\n  rec4 [label = \"Sensitivity \nEstimate \n2\", fillcolor = \"#e7998c\"]\n\n  # edge definitions with the node IDs\n  rec1 -> rec2\n  rec2 -> rec3 ->rec4}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script>
</div>
</div>
<hr>
<p>The results from both the primary analysis, the first sensitivity analysis, and the second seem somewhat consistent. However, with the first sensitivity analysis where we applied <img src="https://latex.codecogs.com/png.latex?%5Cdelta">-adjustments, as the adjustments became larger, the coefficients changed drastically. However, such large <img src="https://latex.codecogs.com/png.latex?%5Cdelta">-adjustments are not realistic and those that were smaller led to coefficients that were closer to the other two analyses.</p>
<hr>
</section>
<section id="supplementary-analyses" class="level2">
<h2 class="anchored" data-anchor-id="supplementary-analyses">Supplementary Analyses</h2>
<hr>
<p>The following analyses are what I mostly consider to be supplementary analyses that may further investigate some violations of assumptions but often go far beyond what would be necessary for a principled sensitivity analysis that would typically accompany a primary analysis.</p>
<hr>
<p>First, I like to check that the results from my analyses are consistent across different statistical software So I may check to see that the results from my primary analysis from <code>R</code> are also similar to the results from another statistical software suite like <code>Stata</code>.</p>
<p>So in <code>Stata</code>, I would likely run something similar to the following in order to mimic the primary analysis in <code>R</code>.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb35" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb35-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">clear</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">all</span></span>
<span id="cb35-2"></span>
<span id="cb35-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">seed</span> 1031</span>
<span id="cb35-4"></span>
<span id="cb35-5">parallel setclusters 8, statapath(/Applications/Stata)</span>
<span id="cb35-6"></span>
<span id="cb35-7">parallel initialize 8, statapath(/Applications/Stata)</span>
<span id="cb35-8"></span>
<span id="cb35-9">import delimited <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"static/datasets/temp.csv"</span>, numericcols(2 3 5 6 7 8)</span>
<span id="cb35-10"></span>
<span id="cb35-11"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">summarize</span></span>
<span id="cb35-12"></span>
<span id="cb35-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mi</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> mlong</span>
<span id="cb35-14"></span>
<span id="cb35-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mi</span> register imputed baselinedbp postdbp age z <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group</span> r1 r2</span>
<span id="cb35-16"></span>
<span id="cb35-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mi</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">impute</span> chained (pmm, knn(5)) postdbp = baselinedbp age z r1 r2 <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group</span>, burnin(20) add(100) rseed (1031) savetrace(trace1, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span>) nomonotone</span>
<span id="cb35-18"></span>
<span id="cb35-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mi</span> estimate, mcerror: <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">rreg</span> postdbp i.<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group</span> baselinedbp age z r1 r2</span>
<span id="cb35-20"></span>
<span id="cb35-21"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">quietly</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mi</span> passive: <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">generate</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">byte</span> imputed = _mi_miss</span>
<span id="cb35-22">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb35-23">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb35-24">#&gt; </span>
<span id="cb35-25">#&gt; </span>
<span id="cb35-26">#&gt; </span>
<span id="cb35-27">#&gt; </span>
<span id="cb35-28">#&gt; <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">N</span> Clusters: 8</span>
<span id="cb35-29">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb35-30">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb35-31">#&gt; </span>
<span id="cb35-32">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span></code></pre></div></div>
</div>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<pre><code>#&gt; Can not set Stata directory, try using -statapath()- option
#&gt; r(601);
#&gt; 
#&gt; 
#&gt; (Summaries of imputed values from -mi impute chained-)
#&gt; 
#&gt; 
#&gt; Contains data from trace1.dta
#&gt;  Observations:         2,100                  Summaries of imputed values from
#&gt;                                                 -mi impute chained-
#&gt;     Variables:             4                  6 Sep 2025 17:50
#&gt; ----------------------------------------------------------------------------------
#&gt; Variable      Storage   Display    Value
#&gt;     name         type    format    label      Variable label
#&gt; ----------------------------------------------------------------------------------
#&gt; iter            byte    %12.0g                Iteration numbers
#&gt; m               byte    %12.0g                Imputation numbers
#&gt; postdbp_mean    float   %9.0g                 Mean of postdbp
#&gt; postdbp_sd      float   %9.0g                 Std. dev. of postdbp
#&gt; ----------------------------------------------------------------------------------
#&gt; Sorted by: 
#&gt; 
#&gt; 
#&gt; 
#&gt; reshaping m=0 data ...
#&gt; (j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#&gt; &gt;  30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 5
#&gt; &gt; 6 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 
#&gt; &gt; 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100)
#&gt; 
#&gt; Data                               Long   -&gt;   Wide
#&gt; -----------------------------------------------------------------------------
#&gt; Number of observations            2,100   -&gt;   21          
#&gt; Number of variables                   4   -&gt;   201         
#&gt; j variable (100 values)               m   -&gt;   (dropped)
#&gt; xij variables:
#&gt;                            postdbp_mean   -&gt;   postdbp_mean1 postdbp_mean2 ... pos
#&gt; &gt; tdbp_mean100
#&gt;                              postdbp_sd   -&gt;   postdbp_sd1 postdbp_sd2 ... postdbp
#&gt; &gt; _sd100
#&gt; -----------------------------------------------------------------------------
#&gt; 
#&gt; assembling results ...
#&gt; 
#&gt; 
#&gt; Time variable: iter, 0 to 20
#&gt;         Delta: 1 unit
#&gt; 
#&gt; 
#&gt; 
#&gt; 
#&gt; file traceplot.svg saved as SVG format</code></pre>
<p><img src="https://lesslikely.com/posts/statistics/traceplot.svg" class="img-fluid"></p>
</div>
<hr>
<p>As you can see from above, I imported the missing data I generated in <code>R</code> into <code>Stata</code>, and then used it to multiply impute the datasets using the predictive mean matching method with 5 donors. I chose the exact same number of variables to include in the imputation model as I did with the primary and sensitivity analyses. Just like the primary analysis, I also used robust regression, <a href="https://www.stata.com/manuals/rrreg.pdf"><code>rreg</code></a> in <code>Stata</code>, to analyze the datasets. The numbers seem to be fairly consistent with those from the primary analysis and the some of the results from the sensitivity analyses.</p>
<p>I will now conduct another supplementary analysis, in which I fit a Bayesian regression model using a <em>t</em>-distribution so that it is analogous to the other robust regression models I have utilized so far, and I will specify a weakly informative prior. I will fit one model using the <code>brm_multiple()</code> function which will fit the model to each of the imputed datasets from before, while I fit another Bayesian model which will impute values during the model fitting process and compare the results.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb37" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb37-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Quantile Regression  --------------------------</span></span>
<span id="cb37-2"></span>
<span id="cb37-3">implist <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> mitml<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;">mids2mitml.list</span>(imp1)</span>
<span id="cb37-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb37-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'imp1' not found</span></span>
<span id="cb37-6"></span>
<span id="cb37-7">vcov.rq <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>(object, ...) {</span>
<span id="cb37-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(object,</span>
<span id="cb37-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nid"</span>,</span>
<span id="cb37-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">covariance =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb37-11">  )<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cov</span>
<span id="cb37-12">}</span>
<span id="cb37-13"></span>
<span id="cb37-14">fit1 <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;">with</span>(implist, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rq</span>(PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb37-15">  Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tau =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>))</span>
<span id="cb37-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb37-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'implist' not found</span></span>
<span id="cb37-18">mitml<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;">testEstimates</span>(fit1)</span>
<span id="cb37-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error:</span></span>
<span id="cb37-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! object 'fit1' not found</span></span>
<span id="cb37-21"></span>
<span id="cb37-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">confint</span>(mitml<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;">testEstimates</span>(fit1))</span>
<span id="cb37-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `h()`:</span></span>
<span id="cb37-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! error in evaluating the argument 'object' in selecting a method for function 'confint': object 'fit1' not found</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb38" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb38-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Bayesian Regression  --------------------------</span></span>
<span id="cb38-2"></span>
<span id="cb38-3">BP_miss<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Group <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.factor</span>(BP_miss<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Group)</span>
<span id="cb38-4"></span>
<span id="cb38-5">brm_form2 <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;">bf</span>(</span>
<span id="cb38-6">  PostDBP <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;">mi</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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-7">    Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">quantile =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.50</span></span>
<span id="cb38-8">)</span>
<span id="cb38-9"></span>
<span id="cb38-10">prior1 <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;">get_prior</span>(brm_form2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> BP_miss, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">knots =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb38-11">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">asym_laplace</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">link =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'identity'</span>))</span>
<span id="cb38-12"></span>
<span id="cb38-13">b_2 <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;">brm</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> brm_form2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> BP_miss, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prior =</span> prior1,</span>
<span id="cb38-14">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">asym_laplace</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">link =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'identity'</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_prior =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'yes'</span>,</span>
<span id="cb38-15">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">control =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_treedepth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adapt_delta =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.80</span>),</span>
<span id="cb38-16">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">iter =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">refresh =</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;">backend =</span>     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">chains =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb38-17">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">algorithm =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sampling"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">knots =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">future =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cores =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>L,</span>
<span id="cb38-18">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warmup =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</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;">1031</span>)</span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb39" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb39-1">post <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;">summary</span>(b_2)[]</span>
<span id="cb39-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `h()`:</span></span>
<span id="cb39-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! error in evaluating the argument 'object' in selecting a method for function 'summary': object 'b_2' not found</span></span>
<span id="cb39-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(b_2)</span>
<span id="cb39-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `h()`:</span></span>
<span id="cb39-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! error in evaluating the argument 'object' in selecting a method for function 'summary': object 'b_2' not found</span></span></code></pre></div></div>
</div>
<hr>
<p>We can also compare the results we get from <code>brms</code>/<code>Stan</code> with <code>MCMCpack.</code></p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb40" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1">posterior_95 <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;">MCMCquantreg</span>(</span>
<span id="cb40-2">  PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-3">    Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2,</span>
<span id="cb40-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> BP_miss,</span>
<span id="cb40-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tau =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcmc =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">chains =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb40-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">thin =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</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;">1031</span></span>
<span id="cb40-7">)</span>
<span id="cb40-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(posterior_95)</span>
<span id="cb40-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb40-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Iterations = 1001:5991</span></span>
<span id="cb40-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Thinning interval = 10 </span></span>
<span id="cb40-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of chains = 1 </span></span>
<span id="cb40-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Sample size per chain = 500 </span></span>
<span id="cb40-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb40-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1. Empirical mean and standard deviation for each variable,</span></span>
<span id="cb40-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    plus standard error of the mean:</span></span>
<span id="cb40-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb40-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                        Mean      SD Naive SE Time-series SE</span></span>
<span id="cb40-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; (Intercept)         10.4270 19.5873  0.87597        0.93578</span></span>
<span id="cb40-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; factor(Group)Drug Y -9.6511  0.4290  0.01919        0.02534</span></span>
<span id="cb40-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; BaselineDBP          1.0180  0.1673  0.00748        0.00798</span></span>
<span id="cb40-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Age                  0.3112  0.0331  0.00148        0.00148</span></span>
<span id="cb40-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Z                   -3.2132  5.5436  0.24792        0.25347</span></span>
<span id="cb40-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; R1                  -0.0298  0.2692  0.01204        0.01355</span></span>
<span id="cb40-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; R2                  -0.4069  0.4056  0.01814        0.02041</span></span>
<span id="cb40-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb40-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 2. Quantiles for each variable:</span></span>
<span id="cb40-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb40-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                        2.5%    25%     50%    75%  97.5%</span></span>
<span id="cb40-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; (Intercept)         -26.255 -3.092  9.7505 22.533 52.079</span></span>
<span id="cb40-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; factor(Group)Drug Y -10.526 -9.940 -9.6349 -9.386 -8.838</span></span>
<span id="cb40-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; BaselineDBP           0.653  0.913  1.0230  1.128  1.329</span></span>
<span id="cb40-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Age                   0.250  0.288  0.3108  0.333  0.372</span></span>
<span id="cb40-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Z                   -14.091 -7.002 -3.5467  0.587  7.370</span></span>
<span id="cb40-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; R1                   -0.514 -0.211 -0.0327  0.149  0.534</span></span>
<span id="cb40-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; R2                   -1.258 -0.672 -0.3626 -0.123  0.307</span></span></code></pre></div></div>
</div>
<hr>
<hr>
<p>Next, we examine the results from the Bayesian model in which values were imputed during model fitting.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb41" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb41-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">posterior_summary</span>(b_2)[<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;">8</span>]</span>
<span id="cb41-2">(post <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;">posterior_samples</span>(b_2))</span></code></pre></div></div>
</div>
<hr>
<p>They seem to be similar to the results we’ve been seeing so far.</p>
<hr>
<p>Indeed, it is no surprise that the Bayesian model with a weakly dispersed prior would give similar results to the base <a href="https://rdrr.io/pkg/MASS/man/rlm.html"><code>rlm()</code></a> function. We now look at robust methods and resampling and the results they give.</p>
<hr>
<p>Although this is currently under the supplementary analysis section, I would very much consider these next two analyses to be sensitivity analyses. The first method utilized here is known as the <em>random indicator method</em>, and it is an experimental method that essentially combines a selection model and a pattern-mixture model and is designed to handle data that are missing not at random. As van Buuren writes<span class="citation" data-cites="buurenFlexibleImputationMissing2018"><sup>20</sup></span></p>
<hr>
<blockquote class="blockquote">
<p>The random indicator method (Jolani 2012)<span class="citation" data-cites="jolaniDualImputationStrategies2012"><sup>24</sup></span> is an experimental iterative method that redraws the missing data indicator under a selection model, and imputes the missing data under a pattern-mixture model, with the objective of estimating δ from the data under relaxed assumptions. Initial simulation results look promising. The algorithm is available as the <code>ri</code> method in <a href="https://cran.r-project.org/web/packages/mice/index.html"><code>mice</code></a>.</p>
</blockquote>
<hr>
<p>The script below utilizes this method (random indicator), but bootstraps the missing dataset before the imputation procedure, and then after multiply imputing the datasets, obtains estimates using maximum likelihood multiple (<strong>MLMI</strong>) imputation, an alternative and more efficient method to the more popular posterior draw multiple imputation (<strong>PDMI</strong>). More about <strong>MLMI</strong> can be found here.<span class="citation" data-cites="vonhippelMaximumLikelihoodMultiple2019"><sup>25</sup></span></p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb42" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Bootstrap Inference</span></span>
<span id="cb42-2"></span>
<span id="cb42-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bootMice</span>(BP_miss, <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;">"ri"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,</span>
<span id="cb42-4">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predictorMatrix =</span> pred, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nBoot =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">96</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nImp =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb42-5">         <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;">1031</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formulas =</span> form, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nCores =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>L,</span>
<span id="cb42-6">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ridge =</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;">remove.collinear =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb42-7">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.constant =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">allow.na =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb42-8">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">printFlag =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">visitSequence =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"monotone"</span>) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-&gt;</span> imps</span>
<span id="cb42-9"></span>
<span id="cb42-10">analyseImp <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>(inputData) {</span>
<span id="cb42-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rlm</span>(PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2,</span>
<span id="cb42-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> inputData, <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;">"MM"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">psi =</span> psi.huber</span>
<span id="cb42-13">  )))</span>
<span id="cb42-14">}</span>
<span id="cb42-15"></span>
<span id="cb42-16">analyseImp1 <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>(inputData) {</span>
<span id="cb42-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">glm</span>(PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2,</span>
<span id="cb42-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> inputData, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gaussian</span>()</span>
<span id="cb42-19">  )))</span>
<span id="cb42-20">}</span>
<span id="cb42-21"></span>
<span id="cb42-22">ests <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;">bootImputeAnalyse</span>(imps, analyseImp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">quiet =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb42-23">ests1 <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;">bootImputeAnalyse</span>(imps, analyseImp1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">quiet =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb42-24"></span>
<span id="cb42-25">ests <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.data.frame</span>(ests)</span>
<span id="cb42-26"></span>
<span id="cb42-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(ests) <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Estimate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Var"</span>,</span>
<span id="cb42-28">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CI.ll"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CI.ul"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"df"</span>)</span>
<span id="cb42-29"></span>
<span id="cb42-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rownames</span>(ests) <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Intercept"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BaselineDBP"</span>,</span>
<span id="cb42-31">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Age"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Z"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R2"</span>)</span>
<span id="cb42-32">ests1 <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.data.frame</span>(ests1)</span>
<span id="cb42-33"></span>
<span id="cb42-34"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(ests1) <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Estimate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Var"</span>,</span>
<span id="cb42-35">                     <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CI.ll"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CI.ul"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"df"</span>)</span>
<span id="cb42-36"></span>
<span id="cb42-37"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rownames</span>(ests1) <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Intercept"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BaselineDBP"</span>,</span>
<span id="cb42-38">                     <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Age"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Z"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R2"</span>)</span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: left; color: rgba(119, 119, 119, 255) !important;"></th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Estimate</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Var</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">CI.ll</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">CI.ul</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">df</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Intercept</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">10.72</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">16.51</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.19</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">19.25</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">18.3</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Group</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.62</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.89</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.34</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">48.0</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">BaselineDBP</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.99</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.91</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.06</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">19.6</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Age</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.34</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.32</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.36</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">55.4</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Z</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.32</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-4.06</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.05</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">51.2</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">R1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.19</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.15</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">64.3</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">R2</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.14</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.39</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.11</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">44.8</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: left; color: rgba(119, 119, 119, 255) !important;"></th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Estimate</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Var</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">CI.ll</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">CI.ul</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">df</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Intercept</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">10.37</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">16.67</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.84</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">18.89</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">19.7</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Group</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.63</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.89</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.36</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">47.5</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">BaselineDBP</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.99</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.92</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.06</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">20.7</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Age</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.33</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.31</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.35</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">57.3</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Z</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-1.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.21</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-4.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.96</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">50.1</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">R1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.18</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.15</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">62.6</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">R2</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.15</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.39</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.09</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">43.3</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<p>For our second supplementary analysis, We will utilize the <code>GAMLSS</code> method, which is an extension of the generalized linear model and the generalized additive model. For the vast majority of the imputations we have conducted, we have drawn values from an assumed normal distribution. Thus, <code>GAMLSS</code> allows us to be far more flexible with our assumptions. However, it is also worth noting that general normal imputations are robust against violations of the assumption of normality</p>
<hr>
<blockquote class="blockquote">
<p>In general, normal imputations appear to be robust against violations of normality. Demirtas, Freels, and Yucel (2008) found that flatness of the density, heavy tails, non-zero peakedness, skewness and multimodality do not appear to hamper the good performance of multiple imputation for the mean structure in samples n &gt; 400, even for high percentages (75%) of missing data in one variable. The variance parameter is more critical though, and could be off-target in smaller samples.</p>
</blockquote>
<hr>
<p>Regardless, we will be using the <code>GAMLSS</code> method and also imputing from a <em>t</em>-distribution, which is much more robust to outliers.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb43" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb43-1">gamt <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;">mice</span>(BP_miss, <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;">"gamlssTF"</span>,</span>
<span id="cb43-2">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predictorMatrix =</span> pred,</span>
<span id="cb43-3">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">m =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxit =</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;">1031</span>,</span>
<span id="cb43-4">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cores =</span> cores, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formulas =</span> form, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ridge =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb43-5">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.collinear =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.constant =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb43-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">allow.na =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">printFlag =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb43-7"></span>
<span id="cb43-8">gt1 <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;">with</span>(gamt, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rlm</span>(PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb43-9">  BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb43-10">  Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2))</span>
<span id="cb43-11"></span>
<span id="cb43-12">resultsgt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> mice<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;">pool</span>(gt1)</span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb44" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb44-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ztable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(resultsgt))</span></code></pre></div></div>
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">term</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">estimate</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">std.error</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">statistic</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">df</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">p.value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">(Intercept)</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">13.23</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">4.95</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.67</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">factor(Group)Drug Y</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.52</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.13</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-76.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">BaselineDBP</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.97</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.04</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">23.48</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Age</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.32</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">35.44</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Z</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.62</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.39</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.44</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">R1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.07</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.34</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">R2</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.14</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.10</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-1.35</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<p>Having done that, I shall try one more supplementary analysis which piqued my curiosity. I recently came across a few papers that concluded that random forests outperformed other imputation algorithms in recovering the true parameter values.</p>
<p>Generally, imputation algorithms are evaluated based on a general simulation design which often resembles the following:</p>
<hr>
<hr>
<ol type="1">
<li>Sampling mechanism only. The basic simulation steps are: choose <img src="https://latex.codecogs.com/png.latex?Q">, take samples <img src="https://latex.codecogs.com/png.latex?Y%5E%7B(s)%7D">, fit the complete-data model, estimate <img src="https://latex.codecogs.com/png.latex?%5Chat%7BQ%7D%5E%7B(s)%7D"> and <img src="https://latex.codecogs.com/png.latex?U%5E%7B(s)%7D"> and calculate the outcomes aggregated over <img src="https://latex.codecogs.com/png.latex?s">.</li>
</ol>
<hr>
<ol start="2" type="1">
<li>Sampling and missing data mechanisms combined. The basic simulation steps are: choose <img src="https://latex.codecogs.com/png.latex?Q">, take samples <img src="https://latex.codecogs.com/png.latex?Y%5E%7B(s)%7D">, generate incomplete data <img src="https://latex.codecogs.com/png.latex?Y_%7B%5Cmathrm%7Bobs%7D%7D%5E%7B(s,%20t)%7D">, impute, estimate <img src="https://latex.codecogs.com/png.latex?%5Chat%7BQ%7D%5E%7B(s,%20t)%7D"> and <img src="https://latex.codecogs.com/png.latex?T%5E%7B(s,%20t)%7D"> and calculate outcomes aggregated over <img src="https://latex.codecogs.com/png.latex?s"> and <img src="https://latex.codecogs.com/png.latex?t">.</li>
</ol>
<hr>
<ol start="3" type="1">
<li>Missing data mechanism only. The basic simulation steps are: choose <img src="https://latex.codecogs.com/png.latex?(%5Chat%7BQ%7D,%20U)">, generate incomplete data <img src="https://latex.codecogs.com/png.latex?Y_%7Bo%20b%20s%7D%5E%7B(t)%7D">, impute, estimate <img src="https://latex.codecogs.com/png.latex?(Q,%20U)%5E%7B(t)%7D"> and <img src="https://latex.codecogs.com/png.latex?B%5E%7B(t)%7D"> and calculate outcomes aggregated over <img src="https://latex.codecogs.com/png.latex?t">.</li>
</ol>
<hr>
<p>These designs generally lead to evaluating a number of metrics which include the following:</p>
<hr>
<ul>
<li>Raw Bias: where <img src="https://latex.codecogs.com/png.latex?RB"> is bias and <img src="https://latex.codecogs.com/png.latex?Q"> is the difference between the estimate and the truth <img src="https://latex.codecogs.com/png.latex?RB=E(Q)-Q">, which may also be expressed as a percent <img src="https://latex.codecogs.com/png.latex?100*%5Cfrac%7BRB=E(Q)-Q%7D%7BQ%7D"></li>
</ul>
<hr>
<ul>
<li>Coverage Rate: which is simply the proportion of times the intervals actually contain the true parameter value</li>
</ul>
<hr>
<ul>
<li>Average Width: the width of the interval estimates, with longer widths indicating less information</li>
</ul>
<hr>
<ul>
<li>Root mean squared error (RMSE) <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BRMSE%7D=%5Csqrt%7B%5Cfrac%7B1%7D%7Bn_%7B%5Ctext%20%7Bmis%20%7D%7D%7D%20%5Csum_%7Bi=1%7D%5E%7Bn_%7B%5Ctext%20%7Bmits%20%7D%7D%7D%5Cleft(y_%7Bi%7D%5E%7B%5Ctext%20%7Bmis%20%7D%7D-%5Cdot%7By%7D_%7Bi%7D%5Cright)%5E%7B2%7D%7D"></li>
</ul>
<hr>
<p>The authors primarily based their conclusions on the root mean squared error (RMSE). However, this is problematic for a number of reasons; imputation is not the same as prediction, and so the same loss functions are not as useful; indeed, the RMSE is highly misleading as a measure of performance.</p>
<p>van Buuren explains here:</p>
<hr>
<blockquote class="blockquote">
<p>It is well known that the minimum RMSE is attained by predicting the missing <img src="https://latex.codecogs.com/png.latex?%5Cdot%7B%7By%7D%7D_%7Bi%7D"> by the linear model with the regression weights set to their least squares estimates. According to this reasoning the “best” method replaces each missing value by its most likely value under the model. However, this will find the same values over and over, and is single imputation.</p>
<p>This method ignores the inherent uncertainty of the missing values (and acts as if they were known after all), resulting in biased estimates and invalid statistical inferences. Hence, the method yielding the lowest RMSE is bad for imputation. More generally, measures based on similarity between the true and imputed values do not separate valid from invalid imputation methods.</p>
</blockquote>
<hr>
<p>Having set up our simulation design, we can now test the performances between regression imputation <em>norm.predict</em> and and regular regression imputation <em>norm</em> and we will be examining the metrics above to evaluate performance. Regression imputation generally gives very biased results given that it uses its predictions to impute the missing values. Thus, I will show here how RMSE is highly misleading as a metric to evaluate the performance of imputation algorithms.</p>
<hr>
<p>Our simulation above will generate a dataset, delete values from the dataset and then impute the missing values for that dataset using regression imputation and stochastic regression imputation. We will use two metrics to evaluate the performance of these two algorithms, RMSE and MAE. Once again, it is worth keeping in mind that regression imputation generally performs very poorly when it comes to imputation and that stochastic regression imputation performs better.</p>
<hr>
<p>What this simulation clearly shows is that despite regression imputation norm.predict giving highly biased results as usual relative to the truth, it still has a much lower RMSE than stochastic regression imputation, which both had a higher RMSE and a closer distance to the correct parameter values. Once again, this is not surprising given that imputation is not the same thing as prediction and therefore the loss functions cannot be used synonymously. However, when it came to raw bias and mean absolute error, stochastic regression imputation outperformed regression imputation which had a much larger mean absolute error and raw bias.</p>
<p>This is why the most informative metrics to focus on when evaluating an imputation algorithm include information/width, sufficient long-run coverage, and less misleading metrics such as mean absolute error and mean absolute percentage error.</p>
<hr>
<p>The authors specifically used the <code>missForest</code> package. I tried using the package, but encountered too many difficulties so I simply specified the <code>rf</code> method in <code>mice</code>, and worked from there.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb45" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb45-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># MI Using Random Forest</span></span>
<span id="cb45-2"></span>
<span id="cb45-3">form <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>(PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2)</span>
<span id="cb45-4"></span>
<span id="cb45-5">rf <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;">parlmice</span>(BP_miss,</span>
<span id="cb45-6">  <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;">"rf"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ntree =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>,</span>
<span id="cb45-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predictorMatrix =</span> pred,</span>
<span id="cb45-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">m =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cluster.seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1031</span>,</span>
<span id="cb45-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cores =</span> cores, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formulas =</span> form, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ridge =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb45-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.collinear =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.constant =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb45-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">allow.na =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">printFlag =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb45-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">visitSequence =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"monotone"</span></span>
<span id="cb45-13">)</span>
<span id="cb45-14"></span>
<span id="cb45-15">rf1 <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;">with</span>(rf, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rlm</span>(PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-16">  BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-17">  Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2))</span>
<span id="cb45-18"></span>
<span id="cb45-19">results5 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> mice<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;">pool</span>(rf1)</span>
<span id="cb45-20"></span>
<span id="cb45-21">results5_sum <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;">summary</span>(results5)</span>
<span id="cb45-22"></span>
<span id="cb45-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(results5_sum) <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;">c</span>(</span>
<span id="cb45-24">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Term"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Estimate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SE"</span>,</span>
<span id="cb45-25">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Statistic"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"df"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P-val"</span></span>
<span id="cb45-26">)</span>
<span id="cb45-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ztable</span>(results5_sum)</span></code></pre></div></div>
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Term</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Estimate</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">SE</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Statistic</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">df</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">P-val</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">(Intercept)</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">37.67</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">7.30</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">5.16</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">factor(Group)Drug Y</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.30</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.18</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-50.41</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">BaselineDBP</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.78</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.06</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">12.40</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Age</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.28</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">20.44</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Z</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.17</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.14</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.55</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">R1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.09</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.15</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">R2</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.19</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.12</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">NA</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
</section>
<section id="full-analysis-set" class="level2">
<h2 class="anchored" data-anchor-id="full-analysis-set">Full Analysis Set</h2>
<hr>
<p>After we run all those analyses, we can finally check our numbers from the full dataset with no missing observations to see how our approaches to handle the missing data have performed. We first look at the fully adjusted model fit with <a href="https://rdrr.io/pkg/MASS/man/rlm.html"><code>rlm()</code></a>.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb46" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb46-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Full Analysis Set</span></span>
<span id="cb46-2"></span>
<span id="cb46-3">final_full_mod <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;">rlm</span>(</span>
<span id="cb46-4">  PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb46-5">    Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2,</span>
<span id="cb46-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> BP_full,</span>
<span id="cb46-7">  <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;">"MM"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">psi =</span> psi.huber</span>
<span id="cb46-8">)</span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: left; color: rgba(119, 119, 119, 255) !important;"></th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Value</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Std. Error</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">t value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">(Intercept)</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">9.19</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">3.72</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.47</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">factor(Group)Drug Y</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.66</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.09</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-106.85</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">BaselineDBP</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.03</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">31.68</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Age</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.33</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">50.17</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">Z</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-2.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-2.00</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">R1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.05</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.21</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">R2</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.09</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-0.09</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Term</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">VIF</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">VIF_CI_low</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">VIF_CI_high</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">SE_factor</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Tolerance</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Tolerance_CI_low</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Tolerance_CI_high</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">factor(Group)</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">489.74</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.99</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">BaselineDBP</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.97</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.75</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.26</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.40</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.51</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.44</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.57</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Age</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.02</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">4.09</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.98</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.24</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Z</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.98</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.75</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2.27</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.41</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.51</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.44</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.57</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">R1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">33.65</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.99</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.03</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">R2</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.01</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1603.17</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.99</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.00</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1.00</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<p>We can also graphically inspect our assumptions.</p>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error:
#&gt; ! object 'zblue' not found
#&gt; Error:
#&gt; ! object 'zblue' not found
#&gt; Error:
#&gt; ! object 'final_full_resid' not found</code></pre>
</div>
<hr>
<p>Then we look at the unadjusted model, where the difference is the group that the participants were randomized to.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb48" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb48-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Unadjusted Model</span></span>
<span id="cb48-2"></span>
<span id="cb48-3">final_reduced_mod <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;">rlm</span>(PostDBP <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;">factor</span>(Group),</span>
<span id="cb48-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> BP_full,</span>
<span id="cb48-5">  <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;">"MM"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">psi =</span> psi.huber</span>
<span id="cb48-6">)</span>
<span id="cb48-7"></span>
<span id="cb48-8">final_reduced_mod_sum <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;">summary</span>(final_reduced_mod)[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"coefficients"</span>]]</span>
<span id="cb48-9"></span>
<span id="cb48-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(final_reduced_mod_sum) <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;">c</span>(</span>
<span id="cb48-11">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Value"</span>,</span>
<span id="cb48-12">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Std. Error"</span>,</span>
<span id="cb48-13">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"t-value"</span></span>
<span id="cb48-14">)</span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: left; color: rgba(119, 119, 119, 255) !important;"></th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Value</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Std. Error</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">t-value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">(Intercept)</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">142.6</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.20</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">728.8</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">factor(Group)Drug Y</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-9.2</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.28</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">-32.7</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<p>We can also compare the two to see if there are any substantial differences.</p>
<hr>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div style="border: 1px solid #ddd; padding: 5px; overflow-x: scroll; width:100%; ">
<table class="table-striped lightable-classic caption-top table table-sm small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Name</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Model</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">AIC</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">AIC_wt</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">AICc</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">AICc_wt</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">BIC</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">BIC_wt</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">RMSE</th>
<th data-quarto-table-cell-role="th" style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Sigma</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">final_full_mod</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">rlm</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1420</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1420</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1453</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.98</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0.99</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">final_reduced_mod</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">rlm</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2556</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2557</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">2569</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">0</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">3.10</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">3.11</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr>
<p>While the results have mostly been consistent, I also wanted to run a few additional analyses of my own to see whether these effect estimates were consistent I first started by constructing the confidence distribution using the <a href=""><code>concurve</code></a> package to see the range of parameter values consistent with the data given the background model assumptions.<span class="citation" data-cites="rafiSemanticCognitiveTools2020 greenlandAidScientificInference2020"><sup>26, 27</sup></span></p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb49" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb49-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Compatibility of Values</span></span>
<span id="cb49-2"></span>
<span id="cb49-3">fit1 <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;">glm</span>(</span>
<span id="cb49-4">  PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb49-5">    Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2,</span>
<span id="cb49-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> BP_full, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gaussian</span>()</span>
<span id="cb49-7">)</span>
<span id="cb49-8"></span>
<span id="cb49-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit1)</span>
<span id="cb49-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb49-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Call:</span></span>
<span id="cb49-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; glm(formula = PostDBP ~ factor(Group) + BaselineDBP + Age + Z + </span></span>
<span id="cb49-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     R1 + R2, family = gaussian(), data = BP_full)</span></span>
<span id="cb49-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb49-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Coefficients:</span></span>
<span id="cb49-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                     Estimate Std. Error t value Pr(&gt;|t|)    </span></span>
<span id="cb49-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; (Intercept)          9.02736    3.65879    2.47    0.014 *  </span></span>
<span id="cb49-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; factor(Group)Drug Y -9.64556    0.08906 -108.30   &lt;2e-16 ***</span></span>
<span id="cb49-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; BaselineDBP          1.00567    0.03120   32.23   &lt;2e-16 ***</span></span>
<span id="cb49-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Age                  0.32696    0.00645   50.69   &lt;2e-16 ***</span></span>
<span id="cb49-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Z                   -1.97391    0.99551   -1.98    0.048 *  </span></span>
<span id="cb49-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; R1                   0.01071    0.04711    0.23    0.820    </span></span>
<span id="cb49-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; R2                  -0.02493    0.08799   -0.28    0.777    </span></span>
<span id="cb49-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ---</span></span>
<span id="cb49-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</span></span>
<span id="cb49-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb49-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; (Dispersion parameter for gaussian family taken to be 0.983)</span></span>
<span id="cb49-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb49-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Null deviance: 15519.32  on 499  degrees of freedom</span></span>
<span id="cb49-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Residual deviance:   484.49  on 493  degrees of freedom</span></span>
<span id="cb49-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; AIC: 1419</span></span>
<span id="cb49-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb49-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of Fisher Scoring iterations: 2</span></span>
<span id="cb49-34"></span>
<span id="cb49-35">fit2 <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;">glm</span>(PostDBP <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;">factor</span>(Group),</span>
<span id="cb49-36">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> BP_full, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gaussian</span>()</span>
<span id="cb49-37">)</span>
<span id="cb49-38"></span>
<span id="cb49-39"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit2)</span>
<span id="cb49-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb49-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Call:</span></span>
<span id="cb49-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; glm(formula = PostDBP ~ factor(Group), family = gaussian(), data = BP_full)</span></span>
<span id="cb49-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb49-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Coefficients:</span></span>
<span id="cb49-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                     Estimate Std. Error t value Pr(&gt;|t|)    </span></span>
<span id="cb49-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; (Intercept)          142.596      0.193   737.3   &lt;2e-16 ***</span></span>
<span id="cb49-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; factor(Group)Drug Y   -9.263      0.278   -33.3   &lt;2e-16 ***</span></span>
<span id="cb49-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ---</span></span>
<span id="cb49-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</span></span>
<span id="cb49-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb49-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; (Dispersion parameter for gaussian family taken to be 9.65)</span></span>
<span id="cb49-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb49-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Null deviance: 15519.3  on 499  degrees of freedom</span></span>
<span id="cb49-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Residual deviance:  4805.8  on 498  degrees of freedom</span></span>
<span id="cb49-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; AIC: 2556</span></span>
<span id="cb49-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb49-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of Fisher Scoring iterations: 2</span></span>
<span id="cb49-58"></span>
<span id="cb49-59">curve1 <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;">curve_gen</span>(fit1,</span>
<span id="cb49-60">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">var =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"factor(Group)Drug Y"</span>, <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>
<span id="cb49-61">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">log =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">steps =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">table =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb49-62">)</span></code></pre></div></div>
</div>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/sensitivity_files/figure-html/unnamed-chunk-82-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
<div class="cell-output-display">
<table class="lightable-classic caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Lower Limit</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Upper Limit</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Interval Width</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Interval Level (%)</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">CDF</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">P-value</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">S-value (bits)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.67</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.62</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.057</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">25.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.625</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.750</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.415</td>
</tr>
<tr class="even">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.71</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.59</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.120</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">50.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.750</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.500</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.000</td>
</tr>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.75</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.54</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.205</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">75.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.875</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.250</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.000</td>
</tr>
<tr class="even">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.76</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.53</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.228</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">80.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.900</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.200</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.322</td>
</tr>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.77</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.52</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.256</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">85.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.925</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.150</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.737</td>
</tr>
<tr class="even">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.79</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.50</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.293</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">90.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.950</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.100</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">3.322</td>
</tr>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.82</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.47</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.349</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">95.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.975</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.050</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">4.322</td>
</tr>
<tr class="even">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.85</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.45</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.399</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">97.5</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.988</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.025</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.322</td>
</tr>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.88</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.42</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.459</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">99.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.995</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.010</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">6.644</td>
</tr>
</tbody><tfoot>
<tr class="odd">
<td style="text-align: right; padding: 0;"><span style="font-style: italic;">Table of Statistics for Various Interval Estimate Percentiles</span></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
</tr>
<tr class="even">
<td style="text-align: right; padding: 0;"><sup></sup></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
</tr>
</tfoot>

</table>
</div>
</div>
<hr>
<p>Indeed, our confidence distribution ends up being very similar to our Bayesian posterior distribution for the treatment effect. Under certain situations, the maximum likelihood estimate ends up also being equivalent to the median unbiased estimate. In this case, it happens to be very similar to the maximum a posteriori estimate.</p>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?C%20V_%7Bn%7D(%5Ctheta)=1-2%5Cleft%7CH_%7Bn%7D(%5Ctheta)-0.5%5Cright%7C=2%20%5Cmin%20%5Cleft%5C%7BH_%7Bn%7D(%5Ctheta),%201-H_%7Bn%7D(%5Ctheta)%5Cright%5C%7D"></p>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error:
#&gt; ! object 'b_2' not found
#&gt; Error in `post$fixed`:
#&gt; ! $ operator is invalid for atomic vectors</code></pre>
</div>
<hr>
<p>We can also check to see that our confidence distribution and posterior distribution are consistent with the profile-likelihood function, which is free of nuisance parameters. The advantage of profiling is allowing us to recover more accurate parameter estimates when there are several nuisance parameters or messy data. Below are implementations in both <code>R</code> and <code>Stata</code>, except this time we do not specify errors from the <em>t</em>-distribution.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb51" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb51-1">analyseImp3 <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>(inputData, i) {</span>
<span id="cb51-2">  dt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> inputData[i, ]</span>
<span id="cb51-3">  (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">glm</span>(PostDBP <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;">factor</span>(Group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BaselineDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Z <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> R2,</span>
<span id="cb51-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dt, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gaussian</span>()</span>
<span id="cb51-5">  ))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb51-6">}</span>
<span id="cb51-7"></span>
<span id="cb51-8">bootdist <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> boot<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;">boot</span>(</span>
<span id="cb51-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> BP_full, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">statistic =</span> analyseImp3,</span>
<span id="cb51-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">R =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sim =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ordinary"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"i"</span>,</span>
<span id="cb51-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">parallel =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"multicore"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncpus =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span></span>
<span id="cb51-12">)</span>
<span id="cb51-13"></span>
<span id="cb51-14">sd <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> boot<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;">boot.ci</span>(bootdist, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf =</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="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">99</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;">100</span>), <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;">"bca"</span>)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>]</span>
<span id="cb51-15"></span>
<span id="cb51-16">A <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sd<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bca</span>
<span id="cb51-17"></span>
<span id="cb51-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">qplot</span>((<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(A[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>], A[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>])), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"density"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">I</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#3f8f9b44"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb51-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_less</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb51-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb51-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bCA Bootstrap Density Plot"</span>,</span>
<span id="cb51-22">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"'Group' Parameter Value (Treatment Effect mmHg)"</span>,</span>
<span id="cb51-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Density"</span></span>
<span id="cb51-24">  )</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/sensitivity_files/figure-html/unnamed-chunk-84-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?L_%7Bt_%7Bn%7D%7D(%5Ctheta)=f_%7Bn%7D%5Cleft(F_%7Bn%7D%5E%7B-1%7D%5Cleft(H_%7Bp%20i%20v%7D(%5Ctheta)%5Cright)%5Cright)%5Cleft%7C%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20t%7D%20%5Cpsi%5Cleft(t_%7Bn%7D,%20%5Ctheta%5Cright)%5Cright%7C=h_%7Bp%20i%20v%7D(%5Ctheta)%5Cleft%7C%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20t%7D%20%5Cpsi(t,%20%5Ctheta)%5Cright%7C%20/%5Cleft.%5Cleft%7C%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20%5Ctheta%7D%20%5Cpsi(t,%20%5Ctheta)%5Cright%7C%5Cright%7C_%7Bt=t_%7Bn%7D%7D"></p>
<hr>
<hr>
<p>We now focus on profiling on the treatment effect and calculating the profile deviance function. We then multiply our deviance by -0.5 to obtain the profile log-likelihood function.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb52" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb52-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Profile Likelihood</span></span>
<span id="cb52-2"></span>
<span id="cb52-3">prof <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;">profile</span>(fit1)</span>
<span id="cb52-4">disp <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;">attr</span>(prof, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"summary"</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dispersion</span>
<span id="cb52-5">mindev <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;">attr</span>(prof, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"original.fit"</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>deviance</span>
<span id="cb52-6"></span>
<span id="cb52-7">dev1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> prof[[<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>tau<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;">2</span></span>
<span id="cb52-8">dev2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dev1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> disp <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> mindev</span>
<span id="cb52-9"></span>
<span id="cb52-10">tmpf <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>(x, n) {</span>
<span id="cb52-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb52-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">par =</span> n, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tau =</span> x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>tau,</span>
<span id="cb52-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">deviance =</span> x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>tau<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;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> disp <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> mindev,</span>
<span id="cb52-14">    x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>par.vals, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb52-15">  )</span>
<span id="cb52-16">}</span>
<span id="cb52-17"></span>
<span id="cb52-18">pp <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;">do.call</span>(rbind, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(tmpf, prof, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(prof),</span>
<span id="cb52-19">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">SIMPLIFY =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb52-20">))</span>
<span id="cb52-21"></span>
<span id="cb52-22">pp2 <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;">melt</span>(pp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">id.var =</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;">3</span>)</span>
<span id="cb52-23">pp3 <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;">subset</span>(pp2, par <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> variable, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">select =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>variable)</span>
<span id="cb52-24">pp4 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pp3[<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;">c</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;">13</span>), ]</span>
<span id="cb52-25"></span>
<span id="cb52-26">pp4<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>loglik <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pp4<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>deviance <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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/sensitivity_files/figure-html/unnamed-chunk-87-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb53" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb53-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">clear</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">all</span></span>
<span id="cb53-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">seed</span> 1031</span>
<span id="cb53-3">import delimited <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"static/datasets/temp.csv"</span>, numericcols(2 3 5 6 7 8)</span>
<span id="cb53-4"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">foreach</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">of</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">varlist</span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group</span> baselinedbp age z r1 r2 {</span>
<span id="cb53-5">grstyle init</span>
<span id="cb53-6">grstyle <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">color</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">background</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">white</span>, opacity(.1)</span>
<span id="cb53-7"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">quietly</span> pllf <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">glm</span> postdbp <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group</span> baselinedbp age z r1 r2, profile(<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`var'</span>)</span>
<span id="cb53-8"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">graph</span> copy Graph <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">`var'</span></span>
<span id="cb53-9">}</span>
<span id="cb53-10"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">graph</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">combine</span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group</span> baselinedbp age z r1 r2</span>
<span id="cb53-11"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">graph</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">export</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"loglikfunction.svg"</span>, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">replace</span></span>
<span id="cb53-12">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb53-13">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb53-14">#&gt; </span>
<span id="cb53-15">#&gt; </span>
<span id="cb53-16">#&gt; </span>
<span id="cb53-17">#&gt; </span>
<span id="cb53-18">#&gt; (encoding automatically selected: ISO-8859-2)</span>
<span id="cb53-19">#&gt; (7 vars, 500 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">obs</span>)</span>
<span id="cb53-20">#&gt; </span>
<span id="cb53-21">#&gt; command grstyle is unrecognized</span>
<span id="cb53-22">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(199);</span>
<span id="cb53-23">#&gt; </span>
<span id="cb53-24">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(199);</span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<table class="lightable-classic caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Lower Limit</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Upper Limit</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">CI Width</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Level (%)</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">CDF</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">P-value</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">S-value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.67</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.62</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.057</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">25.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.625</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.750</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.415</td>
</tr>
<tr class="even">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.71</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.59</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.120</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">50.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.750</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.500</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.000</td>
</tr>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.75</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.54</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.205</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">75.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.875</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.250</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.000</td>
</tr>
<tr class="even">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.76</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.53</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.228</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">80.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.900</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.200</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.322</td>
</tr>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.77</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.52</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.256</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">85.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.925</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.150</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.737</td>
</tr>
<tr class="even">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.79</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.50</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.293</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">90.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.950</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.100</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">3.322</td>
</tr>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.82</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.47</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.349</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">95.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.975</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.050</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">4.322</td>
</tr>
<tr class="even">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.85</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.45</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.399</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">97.5</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.988</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.025</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.322</td>
</tr>
<tr class="odd">
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.88</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">-9.42</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.459</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">99.0</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.995</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.010</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">6.644</td>
</tr>
</tbody><tfoot>
<tr class="odd">
<td style="text-align: right; padding: 0;"><span style="font-style: italic;">Table of Statistics for Various Interval Estimate Percentiles</span></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
</tr>
<tr class="even">
<td style="text-align: right; padding: 0;"><sup></sup></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
</tr>
</tfoot>

</table>
</div>
</div>
<hr>
<p>I then compared the results of the full analysis set to the results from the primary analysis and sensitivity analyses.</p>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<pre><code>#&gt; Can not set Stata directory, try using -statapath()- option
#&gt; r(601);
#&gt; 
#&gt; 
#&gt; 
#&gt; 
#&gt; -initialize- invalid parallel subcommand (help parallel)
#&gt; r(198);
#&gt; 
#&gt; r(198);</code></pre>
</div>
<hr>
</section>
<section id="examining-the-analyses" class="level2">
<h2 class="anchored" data-anchor-id="examining-the-analyses">Examining the Analyses</h2>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error:
#&gt; ! object 'result1' not found
#&gt; Error:
#&gt; ! object 'result3' not found
#&gt; Error in `post[["fixed"]]`:
#&gt; ! subscript out of bounds
#&gt; Error:
#&gt; ! object 'pmm' not found
#&gt; Error:
#&gt; ! object 'pmm' not found
#&gt; Error:
#&gt; ! object 'heckman' not found
#&gt; Error:
#&gt; ! object 'bayes' not found
#&gt; Error:
#&gt; ! object 'pmm_mpe' not found
#&gt; Error:
#&gt; ! object 'pmm' not found
#&gt; Error:
#&gt; ! object 'heckman' not found
#&gt; Error:
#&gt; ! object 'bayes' not found
#&gt; Error:
#&gt; ! object 'pmm_mae' not found
#&gt; Error:
#&gt; ! object 'pmm' not found
#&gt; Error:
#&gt; ! object 'heckman' not found
#&gt; Error:
#&gt; ! object 'bayes' not found
#&gt; Error:
#&gt; ! object 'pmm_huber' not found
#&gt; Error:
#&gt; ! object 'pmm' not found
#&gt; Error:
#&gt; ! object 'heckman' not found
#&gt; Error:
#&gt; ! object 'bayes' not found
#&gt; Error:
#&gt; ! object 'pmm_msd' not found
#&gt; Error:
#&gt; ! object 'mi_eval' not found
#&gt; Error:
#&gt; ! object 'mi_eval' not found
#&gt; Error:
#&gt; ! object 'mi_eval' not found
#&gt; Error:
#&gt; ! object 'mi_eval' not found</code></pre>
</div>
<hr>
<p>We can see that that the overall treatment effect is approximately 9.7-9.9, and for most of the principled methods we used to handle the missing data, we did not obtain similar estimates. For example, both the primary analysis and the controlled multiple imputation methods did not yield the correct treatment effect estimate in the adjusted model.</p>
<p>In fact, nearly all of the methods used except for the Heckman selection model, yielded overestimates of the treatment effect. Even though such analyses can be substantially improved with more specification and more information, the reality is that data that are assumed to be <strong>MNAR</strong> are difficult to handle and that no method can guarantee the correct answer. Indeed, we knew the missing data model / mechanism, via our custom function</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb56" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb56-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Missing Data Mechanism</span></span>
<span id="cb56-2"></span>
<span id="cb56-3">lesslikely <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>() {</span>
<span id="cb56-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</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;">1031</span>,</span>
<span id="cb56-5">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"L'Ecuyer-CMRG"</span>,</span>
<span id="cb56-6">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">normal.kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Inversion"</span>,</span>
<span id="cb56-7">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample.kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rejection"</span></span>
<span id="cb56-8">  )</span>
<span id="cb56-9">  logistic <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>(x) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(x) <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="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(x))</span>
<span id="cb56-10">  <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;">rbinom</span>(n, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">logistic</span>(errors[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]))</span>
<span id="cb56-11">}</span>
<span id="cb56-12"></span>
<span id="cb56-13">Ry <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 class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lesslikely</span>() <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 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;">0</span>)</span>
<span id="cb56-14">PostDBP[Ry <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="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span></span></code></pre></div></div>
</div>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5CPr(R_1=0)=%5Cpsi_0+%5Cfrac%7Be%5E%7BY_1%7D%7D%7B1+e%5E%7BY_1%7D%7D%5Cpsi_1%0A%5Cend%7Bequation%7D"></p>
<hr>
<p>for <strong>MNAR</strong> we set <img src="https://latex.codecogs.com/png.latex?%5Cpsi_%5Cmathrm%7BMNAR%7D=(0,1)"></p>
<hr>
<p>Thus, we obtain the following model:</p>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Balign%7D%0A%20%20%5Cmathrm%7BMNAR%7D&amp;:%5Cmathrm%7Blogit%7D(%5CPr(R_1=0))%20=%20Y_1%20%5C%0A%5Cend%7Balign%7D"></p>
<hr>
<p>Even the random indicator method, which has shown much promise in simulation studies<span class="citation" data-cites="jolaniDualImputationStrategies2012"><sup>24</sup></span> and offers the advantage of not having to specify a pattern-mixture or selection model could not recover the correct treatment effect estimate either, showing the difficulty of handling missing data and the limitations of automated approaches.</p>
<hr>
<p>I hope it is clear from the examples above that it is quite easy to do any analyses with missing data and use a variety of ad-hoc approaches or even principled approaches to explore whether or not the results you’ve obtained are trustworthy or at least even give that impression, but doing a careful and principled one is quite difficult and requires much thought that will take into account real departures from assumptions and whether or not those will lead to substantial changes in results and conclusions/decisions.</p>
<hr>
</section>
</section>
<section id="acknowledgements" class="level1">
<h1>Acknowledgements</h1>
<hr>
<blockquote class="blockquote">
<p>I’d like to thank <a href="https://twitter.com/tmorris_mrc"><strong>Dr.&nbsp;Tim Morris</strong></a> and <a href="https://twitter.com/ADAlthousePhD"><strong>Dr.&nbsp;Andrew Althouse</strong></a> for helpful comments on an earlier version of this piece. My <strong>acknowledgment</strong> of their help does <strong>not</strong> imply endorsement of my views by these colleagues or vice versa, and I remain <strong>solely</strong> responsible for the views expressed herein. All errors are my own. To point out such errors, please leave a comment below or use the <a href="../../contact">contact form</a> to get in touch.</p>
</blockquote>
<hr>
</section>
<section id="statistical-environments" class="level1">
<h1>Statistical Environments</h1>
<hr>
<section id="r-environment" class="level4">
<h4 class="anchored" data-anchor-id="r-environment">R Environment</h4>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#&gt;  setting  value
#&gt;  version  R version 4.5.2 (2025-10-31)
#&gt;  os       macOS Tahoe 26.3
#&gt;  system   aarch64, darwin20
#&gt;  ui       X11
#&gt;  language (EN)
#&gt;  collate  C.UTF-8
#&gt;  ctype    C.UTF-8
#&gt;  tz       America/New_York
#&gt;  date     2026-02-02
#&gt;  pandoc   3.8.3 @ /opt/homebrew/bin/ (via rmarkdown)
#&gt;  quarto   1.8.27 @ /Applications/quarto/bin/quarto
#&gt; 
#&gt; ─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#&gt;  ! package           * version    date (UTC) lib source
#&gt;    abind               1.4-8      2024-09-12 [1] CRAN (R 4.5.0)
#&gt;    Amelia            * 1.8.3      2024-11-08 [1] CRAN (R 4.5.0)
#&gt;    arm                 1.14-4     2024-04-01 [1] CRAN (R 4.5.0)
#&gt;    arrayhelpers        1.1-0      2020-02-04 [1] CRAN (R 4.5.0)
#&gt;    askpass             1.2.1      2024-10-04 [1] CRAN (R 4.5.0)
#&gt;    backports           1.5.0      2024-05-23 [1] CRAN (R 4.5.0)
#&gt;    base              * 4.5.2      2025-11-01 [?] local
#&gt;    base64enc           0.1-6      2026-02-02 [1] CRAN (R 4.5.2)
#&gt;    bayesplot         * 1.15.0     2025-12-12 [1] CRAN (R 4.5.2)
#&gt;    bbotk               1.8.1      2025-11-26 [1] CRAN (R 4.5.2)
#&gt;    bcaboot             0.2-3      2021-05-09 [1] CRAN (R 4.5.0)
#&gt;    bitops              1.0-9      2024-10-03 [1] CRAN (R 4.5.0)
#&gt;    blogdown          * 1.23       2026-01-18 [1] CRAN (R 4.5.2)
#&gt;    boot              * 1.3-32     2025-08-29 [1] CRAN (R 4.5.0)
#&gt;    bootImpute        * 1.3.0      2025-12-15 [1] CRAN (R 4.5.2)
#&gt;    bridgesampling      1.2-1      2025-11-19 [1] CRAN (R 4.5.2)
#&gt;    brms              * 2.23.0     2025-09-09 [1] CRAN (R 4.5.0)
#&gt;    Brobdingnag         1.2-9      2022-10-19 [1] CRAN (R 4.5.0)
#&gt;    broom             * 1.0.12     2026-01-27 [1] CRAN (R 4.5.2)
#&gt;    broom.mixed       * 0.2.9.6    2024-10-15 [1] CRAN (R 4.5.0)
#&gt;    Cairo             * 1.7-0      2025-10-29 [1] CRAN (R 4.5.0)
#&gt;    car               * 3.1-3      2024-09-27 [1] CRAN (R 4.5.0)
#&gt;    carData           * 3.0-6      2026-01-30 [1] CRAN (R 4.5.2)
#&gt;    cards               0.7.1      2025-12-02 [1] CRAN (R 4.5.2)
#&gt;    caTools             1.18.3     2024-09-04 [1] CRAN (R 4.5.0)
#&gt;    checkmate         * 2.3.3      2025-08-18 [1] CRAN (R 4.5.0)
#&gt;    class               7.3-23     2025-01-01 [1] CRAN (R 4.5.0)
#&gt;    cli               * 3.6.5      2025-04-23 [1] CRAN (R 4.5.0)
#&gt;    clipr               0.8.0      2022-02-22 [1] CRAN (R 4.5.0)
#&gt;    cluster             2.1.8.1    2025-03-12 [1] CRAN (R 4.5.0)
#&gt;    coda              * 0.19-4.1   2024-01-31 [1] CRAN (R 4.5.0)
#&gt;    codetools           0.2-20     2024-03-31 [1] CRAN (R 4.5.0)
#&gt;    colorspace        * 2.1-2      2025-09-22 [1] CRAN (R 4.5.0)
#&gt;    commonmark          2.0.0      2025-07-07 [1] CRAN (R 4.5.0)
#&gt;  P compiler            4.5.2      2025-11-01 [1] local
#&gt;    concurve          * 3.0.0      2026-02-02 [1] local
#&gt;    cowplot           * 1.2.0      2025-07-07 [1] CRAN (R 4.5.0)
#&gt;    crayon              1.5.3      2024-06-20 [1] CRAN (R 4.5.0)
#&gt;    curl                7.0.0      2025-08-19 [1] CRAN (R 4.5.0)
#&gt;    data.table          1.18.2.1   2026-01-27 [1] CRAN (R 4.5.2)
#&gt;  P datasets          * 4.5.2      2025-11-01 [1] local
#&gt;    DBI                 1.2.3      2024-06-02 [1] CRAN (R 4.5.0)
#&gt;    DEoptimR            1.1-4      2025-07-27 [1] CRAN (R 4.5.0)
#&gt;    desc                1.4.3      2023-12-10 [1] CRAN (R 4.5.0)
#&gt;    details             0.4.0      2025-02-09 [1] CRAN (R 4.5.0)
#&gt;    DiagrammeR          1.0.11     2024-02-02 [1] CRAN (R 4.5.0)
#&gt;    dichromat           2.0-0.1    2022-05-02 [1] CRAN (R 4.5.0)
#&gt;    digest              0.6.39     2025-11-19 [1] CRAN (R 4.5.2)
#&gt;    distributional      0.6.0      2026-01-14 [1] CRAN (R 4.5.2)
#&gt;    doParallel        * 1.0.17     2022-02-07 [1] CRAN (R 4.5.0)
#&gt;    doRNG               1.8.6.2    2025-04-02 [1] CRAN (R 4.5.0)
#&gt;    dplyr             * 1.1.4      2023-11-17 [1] CRAN (R 4.5.0)
#&gt;    e1071               1.7-17     2025-12-18 [1] CRAN (R 4.5.2)
#&gt;    emmeans             2.0.1      2025-12-16 [1] CRAN (R 4.5.2)
#&gt;    estimability        1.5.1      2024-05-12 [1] CRAN (R 4.5.0)
#&gt;    evaluate            1.0.5      2025-08-27 [1] CRAN (R 4.5.0)
#&gt;    extremevalues       2.4.1      2024-12-17 [1] CRAN (R 4.5.0)
#&gt;    farver              2.1.2      2024-05-13 [1] CRAN (R 4.5.0)
#&gt;    fastmap             1.2.0      2024-05-15 [1] CRAN (R 4.5.0)
#&gt;    flextable           0.9.10     2025-08-24 [1] CRAN (R 4.5.0)
#&gt;    fontBitstreamVera   0.1.1      2017-02-01 [1] CRAN (R 4.5.0)
#&gt;    fontLiberation      0.1.0      2016-10-15 [1] CRAN (R 4.5.0)
#&gt;    fontquiver          0.2.1      2017-02-01 [1] CRAN (R 4.5.0)
#&gt;    forcats           * 1.0.1      2025-09-25 [1] CRAN (R 4.5.0)
#&gt;    foreach           * 1.5.2      2022-02-02 [1] CRAN (R 4.5.0)
#&gt;    foreign             0.8-91     2026-01-29 [1] CRAN (R 4.5.2)
#&gt;    formatR             1.14       2023-01-17 [1] CRAN (R 4.5.0)
#&gt;    Formula             1.2-5      2023-02-24 [1] CRAN (R 4.5.0)
#&gt;    fs                  1.6.6      2025-04-12 [1] CRAN (R 4.5.0)
#&gt;    furrr               0.3.1      2022-08-15 [1] CRAN (R 4.5.0)
#&gt;    future            * 1.69.0     2026-01-16 [1] CRAN (R 4.5.2)
#&gt;    future.apply      * 1.20.1     2025-12-09 [1] CRAN (R 4.5.2)
#&gt;    gamlss            * 5.5-0      2025-08-19 [1] CRAN (R 4.5.0)
#&gt;    gamlss.data       * 6.0-7      2025-09-04 [1] CRAN (R 4.5.0)
#&gt;    gamlss.dist       * 6.1-1      2023-08-23 [1] CRAN (R 4.5.0)
#&gt;    gdtools             0.4.4      2025-10-06 [1] CRAN (R 4.5.0)
#&gt;    generics            0.1.4      2025-05-09 [1] CRAN (R 4.5.0)
#&gt;    ggcorrplot        * 0.1.4.1    2023-09-05 [1] CRAN (R 4.5.0)
#&gt;    ggdist              3.3.3      2025-04-23 [1] CRAN (R 4.5.0)
#&gt;    ggplot2           * 4.0.1      2025-11-14 [1] CRAN (R 4.5.2)
#&gt;    ggpubr              0.6.2      2025-10-17 [1] CRAN (R 4.5.0)
#&gt;    ggsignif            0.6.4      2022-10-13 [1] CRAN (R 4.5.0)
#&gt;    ggtext            * 0.1.2      2022-09-16 [1] CRAN (R 4.5.0)
#&gt;    glmnet              4.1-10     2025-07-17 [1] CRAN (R 4.5.0)
#&gt;    globals             0.19.0     2026-02-02 [1] CRAN (R 4.5.2)
#&gt;    glue                1.8.0      2024-09-30 [1] CRAN (R 4.5.0)
#&gt;  P graphics          * 4.5.2      2025-11-01 [1] local
#&gt;  P grDevices         * 4.5.2      2025-11-01 [1] local
#&gt;  P grid              * 4.5.2      2025-11-01 [1] local
#&gt;    gridExtra           2.3        2017-09-09 [1] CRAN (R 4.5.0)
#&gt;    gridtext            0.1.5      2022-09-16 [1] CRAN (R 4.5.0)
#&gt;    gt                  1.3.0      2026-01-22 [1] CRAN (R 4.5.2)
#&gt;    gtable              0.3.6      2024-10-25 [1] CRAN (R 4.5.0)
#&gt;    gtsummary         * 2.5.0      2025-12-05 [1] CRAN (R 4.5.2)
#&gt;    here              * 1.0.2      2025-09-15 [1] CRAN (R 4.5.0)
#&gt;    Hmisc             * 5.2-5      2026-01-09 [1] CRAN (R 4.5.2)
#&gt;    hms                 1.1.4      2025-10-17 [1] CRAN (R 4.5.0)
#&gt;    htmlTable           2.4.3      2024-07-21 [1] CRAN (R 4.5.0)
#&gt;    htmltools         * 0.5.9      2025-12-04 [1] CRAN (R 4.5.2)
#&gt;    htmlwidgets         1.6.4      2023-12-06 [1] CRAN (R 4.5.0)
#&gt;    httr                1.4.7      2023-08-15 [1] CRAN (R 4.5.0)
#&gt;    ImputeRobust      * 1.3-1      2018-11-30 [1] CRAN (R 4.5.0)
#&gt;    inline              0.3.21     2025-01-09 [1] CRAN (R 4.5.0)
#&gt;    insight             1.4.5      2026-01-26 [1] CRAN (R 4.5.2)
#&gt;    iterators         * 1.0.14     2022-02-05 [1] CRAN (R 4.5.0)
#&gt;    itertools           0.1-3      2014-03-12 [1] CRAN (R 4.5.0)
#&gt;    jomo                2.7-6      2023-04-15 [1] CRAN (R 4.5.0)
#&gt;    jsonlite            2.0.0      2025-03-27 [1] CRAN (R 4.5.0)
#&gt;    kableExtra        * 1.4.0      2024-01-24 [1] CRAN (R 4.5.0)
#&gt;    km.ci               0.5-6      2022-04-06 [1] CRAN (R 4.5.0)
#&gt;    KMsurv              0.1-6      2025-05-20 [1] CRAN (R 4.5.0)
#&gt;    knitr             * 1.51       2025-12-20 [1] CRAN (R 4.5.2)
#&gt;    labeling            0.4.3      2023-08-29 [1] CRAN (R 4.5.0)
#&gt;    laeken              0.5.3      2024-01-25 [1] CRAN (R 4.5.0)
#&gt;    latex2exp         * 0.9.8      2026-01-09 [1] CRAN (R 4.5.2)
#&gt;    lattice           * 0.22-7     2025-04-02 [1] CRAN (R 4.5.0)
#&gt;    lgr                 0.5.2      2026-01-30 [1] CRAN (R 4.5.2)
#&gt;    lifecycle           1.0.5      2026-01-08 [1] CRAN (R 4.5.2)
#&gt;    listenv             0.10.0     2025-11-02 [1] CRAN (R 4.5.0)
#&gt;    litedown            0.9        2025-12-18 [1] CRAN (R 4.5.2)
#&gt;    lme4                1.1-38     2025-12-02 [1] CRAN (R 4.5.2)
#&gt;    lmtest              0.9-40     2022-03-21 [1] CRAN (R 4.5.0)
#&gt;    loo               * 2.9.0      2025-12-23 [1] CRAN (R 4.5.2)
#&gt;    lubridate         * 1.9.4      2024-12-08 [1] CRAN (R 4.5.0)
#&gt;    magick              2.9.0      2025-09-08 [1] CRAN (R 4.5.0)
#&gt;    magrittr          * 2.0.4      2025-09-12 [1] CRAN (R 4.5.0)
#&gt;    markdown            2.0        2025-03-23 [1] CRAN (R 4.5.0)
#&gt;    MASS              * 7.3-65     2025-02-28 [1] CRAN (R 4.5.0)
#&gt;    mathjaxr            2.0-0      2025-12-01 [1] CRAN (R 4.5.2)
#&gt;    Matrix            * 1.7-4      2025-08-28 [1] CRAN (R 4.5.0)
#&gt;    MatrixModels        0.5-4      2025-03-26 [1] CRAN (R 4.5.0)
#&gt;    matrixStats         1.5.0      2025-01-07 [1] CRAN (R 4.5.0)
#&gt;    mcmc                0.9-8      2023-11-16 [1] CRAN (R 4.5.0)
#&gt;    MCMCpack          * 1.7-1      2024-08-27 [1] CRAN (R 4.5.0)
#&gt;    metadat             1.4-0      2025-02-04 [1] CRAN (R 4.5.0)
#&gt;    metafor             4.8-0      2025-01-28 [1] CRAN (R 4.5.0)
#&gt;  P methods           * 4.5.2      2025-11-01 [1] local
#&gt;    mgcv              * 1.9-4      2025-11-07 [1] CRAN (R 4.5.0)
#&gt;    mi                * 1.2        2025-09-02 [1] CRAN (R 4.5.0)
#&gt;    mice              * 3.19.0     2025-12-10 [1] CRAN (R 4.5.2)
#&gt;    miceadds          * 3.18-36    2025-09-12 [1] CRAN (R 4.5.0)
#&gt;    miceFast          * 0.8.5      2025-02-03 [1] CRAN (R 4.5.0)
#&gt;    minqa               1.2.8      2024-08-17 [1] CRAN (R 4.5.0)
#&gt;    missForest        * 1.6.1      2025-10-26 [1] CRAN (R 4.5.0)
#&gt;    mitml             * 0.4-5      2023-03-08 [1] CRAN (R 4.5.0)
#&gt;    mitools             2.4        2019-04-26 [1] CRAN (R 4.5.0)
#&gt;    mlr3                1.3.0      2025-12-03 [1] CRAN (R 4.5.2)
#&gt;    mlr3learners        0.14.0     2025-12-13 [1] CRAN (R 4.5.2)
#&gt;    mlr3misc            0.19.0     2025-09-12 [1] CRAN (R 4.5.0)
#&gt;    mlr3pipelines       0.10.0     2025-11-07 [1] CRAN (R 4.5.0)
#&gt;    mlr3tuning          1.5.1      2025-12-14 [1] CRAN (R 4.5.2)
#&gt;    multcomp            1.4-29     2025-10-20 [1] CRAN (R 4.5.0)
#&gt;    mvtnorm           * 1.3-3      2025-01-10 [1] CRAN (R 4.5.0)
#&gt;    nlme              * 3.1-168    2025-03-31 [1] CRAN (R 4.5.0)
#&gt;    nloptr              2.2.1      2025-03-17 [1] CRAN (R 4.5.0)
#&gt;    nnet                7.3-20     2025-01-01 [1] CRAN (R 4.5.0)
#&gt;    numDeriv            2016.8-1.1 2019-06-06 [1] CRAN (R 4.5.0)
#&gt;    officer             0.7.3      2026-01-16 [1] CRAN (R 4.5.2)
#&gt;    opdisDownsampling   1.0.1      2024-04-15 [1] CRAN (R 4.5.0)
#&gt;    openssl             2.3.4      2025-09-30 [1] CRAN (R 4.5.0)
#&gt;    otel                0.2.0      2025-08-29 [1] CRAN (R 4.5.0)
#&gt;    palmerpenguins      0.1.1      2022-08-15 [1] CRAN (R 4.5.0)
#&gt;    pan                 1.9        2023-12-07 [1] CRAN (R 4.5.0)
#&gt;    paradox             1.0.1      2024-07-09 [1] CRAN (R 4.5.0)
#&gt;  P parallel          * 4.5.2      2025-11-01 [1] local
#&gt;    parallelly        * 1.46.1     2026-01-08 [1] CRAN (R 4.5.2)
#&gt;    pbmcapply         * 1.5.1      2022-04-28 [1] CRAN (R 4.5.0)
#&gt;    performance       * 0.15.3     2025-12-01 [1] CRAN (R 4.5.2)
#&gt;    pillar              1.11.1     2025-09-17 [1] CRAN (R 4.5.0)
#&gt;    pkgbuild            1.4.8      2025-05-26 [1] CRAN (R 4.5.0)
#&gt;    pkgconfig           2.0.3      2019-09-22 [1] CRAN (R 4.5.0)
#&gt;    plyr                1.8.9      2023-10-02 [1] CRAN (R 4.5.0)
#&gt;    png                 0.1-8      2022-11-29 [1] CRAN (R 4.5.0)
#&gt;    polspline           1.1.25     2024-05-10 [1] CRAN (R 4.5.0)
#&gt;    posterior         * 1.6.1      2025-02-27 [1] CRAN (R 4.5.0)
#&gt;    pracma              2.4.6      2025-10-22 [1] CRAN (R 4.5.0)
#&gt;    prettyunits         1.2.0      2023-09-24 [1] CRAN (R 4.5.0)
#&gt;    ProfileLikelihood * 1.3        2023-08-25 [1] CRAN (R 4.5.0)
#&gt;    progress          * 1.2.3      2023-12-06 [1] CRAN (R 4.5.0)
#&gt;    proxy               0.4-29     2025-12-29 [1] CRAN (R 4.5.2)
#&gt;    purrr             * 1.2.1      2026-01-09 [1] CRAN (R 4.5.2)
#&gt;    qqconf              1.3.2      2023-04-14 [1] CRAN (R 4.5.0)
#&gt;    qqplotr           * 0.0.7      2025-09-05 [1] CRAN (R 4.5.0)
#&gt;    quantreg          * 6.1        2025-03-10 [1] CRAN (R 4.5.0)
#&gt;    QuickJSR            1.9.0      2026-01-25 [1] CRAN (R 4.5.2)
#&gt;    R6                  2.6.1      2025-02-15 [1] CRAN (R 4.5.0)
#&gt;    ragg                1.5.0      2025-09-02 [1] CRAN (R 4.5.0)
#&gt;    randomForest      * 4.7-1.2    2024-09-22 [1] CRAN (R 4.5.0)
#&gt;    ranger              0.18.0     2026-01-16 [1] CRAN (R 4.5.2)
#&gt;    rbibutils           2.4.1      2026-01-21 [1] CRAN (R 4.5.2)
#&gt;    rcartocolor         2.1.2      2025-07-23 [1] CRAN (R 4.5.0)
#&gt;    RColorBrewer        1.1-3      2022-04-03 [1] CRAN (R 4.5.0)
#&gt;    Rcpp              * 1.1.1      2026-01-10 [1] CRAN (R 4.5.2)
#&gt;    RcppParallel        5.1.11-1   2025-08-27 [1] CRAN (R 4.5.0)
#&gt;    Rdpack              2.6.5      2026-01-23 [1] CRAN (R 4.5.2)
#&gt;    readr             * 2.1.6      2025-11-14 [1] CRAN (R 4.5.2)
#&gt;    reformulas          0.4.4      2026-02-02 [1] CRAN (R 4.5.2)
#&gt;    rematch2            2.1.2      2020-05-01 [1] CRAN (R 4.5.0)
#&gt;    reshape2          * 1.4.5      2025-11-12 [1] CRAN (R 4.5.0)
#&gt;    reticulate        * 1.44.1     2025-11-14 [1] CRAN (R 4.5.2)
#&gt;    rlang               1.1.7      2026-01-09 [1] CRAN (R 4.5.2)
#&gt;    rmarkdown         * 2.30       2025-09-28 [1] CRAN (R 4.5.0)
#&gt;    rms               * 8.1-0      2025-10-14 [1] CRAN (R 4.5.0)
#&gt;    rngtools            1.5.2      2021-09-20 [1] CRAN (R 4.5.0)
#&gt;    robustbase          0.99-6     2025-09-04 [1] CRAN (R 4.5.0)
#&gt;    rpart               4.1.24     2025-01-07 [1] CRAN (R 4.5.0)
#&gt;    rprojroot           2.1.1      2025-08-26 [1] CRAN (R 4.5.0)
#&gt;    rstan             * 2.32.7     2025-03-10 [1] CRAN (R 4.5.0)
#&gt;    rstantools          2.6.0      2026-01-10 [1] CRAN (R 4.5.2)
#&gt;    rstatix             0.7.3      2025-10-18 [1] CRAN (R 4.5.0)
#&gt;    rstudioapi          0.18.0     2026-01-16 [1] CRAN (R 4.5.2)
#&gt;    S7                  0.2.1      2025-11-14 [1] CRAN (R 4.5.2)
#&gt;    sandwich            3.1-1      2024-09-15 [1] CRAN (R 4.5.0)
#&gt;    sass                0.4.10     2025-04-11 [1] CRAN (R 4.5.0)
#&gt;    scales              1.4.0      2025-04-24 [1] CRAN (R 4.5.0)
#&gt;    sessioninfo         1.2.3      2025-02-05 [1] CRAN (R 4.5.0)
#&gt;    shape               1.4.6.1    2024-02-23 [1] CRAN (R 4.5.0)
#&gt;    showtext          * 0.9-7      2024-03-02 [1] CRAN (R 4.5.0)
#&gt;    showtextdb        * 3.0        2020-06-04 [1] CRAN (R 4.5.0)
#&gt;    sp                  2.2-0      2025-02-01 [1] CRAN (R 4.5.0)
#&gt;    SparseM           * 1.84-2     2024-07-17 [1] CRAN (R 4.5.0)
#&gt;  P splines           * 4.5.2      2025-11-01 [1] local
#&gt;    StanHeaders       * 2.32.10    2024-07-15 [1] CRAN (R 4.5.0)
#&gt;    Statamarkdown     * 0.9.6      2025-10-07 [1] CRAN (R 4.5.0)
#&gt;  P stats             * 4.5.2      2025-11-01 [1] local
#&gt;  P stats4            * 4.5.2      2025-11-01 [1] local
#&gt;    stringi             1.8.7      2025-03-27 [1] CRAN (R 4.5.0)
#&gt;    stringr           * 1.6.0      2025-11-04 [1] CRAN (R 4.5.0)
#&gt;    survival            3.8-6      2026-01-16 [1] CRAN (R 4.5.2)
#&gt;    survminer           0.5.1      2025-09-02 [1] CRAN (R 4.5.0)
#&gt;    survMisc            0.5.6      2022-04-07 [1] CRAN (R 4.5.0)
#&gt;    svglite           * 2.2.2      2025-10-21 [1] CRAN (R 4.5.0)
#&gt;    svgPanZoom          0.3.4      2020-02-15 [1] CRAN (R 4.5.0)
#&gt;    svUnit              1.0.8      2025-08-26 [1] CRAN (R 4.5.0)
#&gt;    sysfonts          * 0.8.9      2024-03-02 [1] CRAN (R 4.5.0)
#&gt;    systemfonts         1.3.1      2025-10-01 [1] CRAN (R 4.5.0)
#&gt;    tensorA             0.36.2.1   2023-12-13 [1] CRAN (R 4.5.0)
#&gt;    texPreview        * 2.1.0      2024-01-24 [1] CRAN (R 4.5.0)
#&gt;    textshaping         1.0.4      2025-10-10 [1] CRAN (R 4.5.0)
#&gt;    TH.data             1.1-5      2025-11-17 [1] CRAN (R 4.5.2)
#&gt;    tibble            * 3.3.1      2026-01-11 [1] CRAN (R 4.5.2)
#&gt;    tidybayes         * 3.0.7      2024-09-15 [1] CRAN (R 4.5.0)
#&gt;    tidyr             * 1.3.2      2025-12-19 [1] CRAN (R 4.5.2)
#&gt;    tidyselect          1.2.1      2024-03-11 [1] CRAN (R 4.5.0)
#&gt;    tidyverse         * 2.0.0      2023-02-22 [1] CRAN (R 4.5.0)
#&gt;    timechange          0.4.0      2026-01-29 [1] CRAN (R 4.5.2)
#&gt;    tinytex           * 0.58       2025-11-19 [1] CRAN (R 4.5.2)
#&gt;  P tools               4.5.2      2025-11-01 [1] local
#&gt;    twosamples          2.0.1      2023-06-23 [1] CRAN (R 4.5.0)
#&gt;    tzdb                0.5.0      2025-03-15 [1] CRAN (R 4.5.0)
#&gt;  P utils             * 4.5.2      2025-11-01 [1] local
#&gt;    uuid                1.2-2      2026-01-23 [1] CRAN (R 4.5.2)
#&gt;    V8                  8.0.1      2025-10-10 [1] CRAN (R 4.5.0)
#&gt;    vcd                 1.4-13     2024-09-16 [1] CRAN (R 4.5.0)
#&gt;    vctrs               0.7.1      2026-01-23 [1] CRAN (R 4.5.2)
#&gt;    VIM               * 7.0.0      2026-01-10 [1] CRAN (R 4.5.2)
#&gt;    viridisLite         0.4.2      2023-05-02 [1] CRAN (R 4.5.0)
#&gt;    visNetwork          2.1.4      2025-09-04 [1] CRAN (R 4.5.0)
#&gt;    wesanderson       * 0.3.7      2023-10-31 [1] CRAN (R 4.5.0)
#&gt;    whisker             0.4.1      2022-12-05 [1] CRAN (R 4.5.0)
#&gt;    withr               3.0.2      2024-10-28 [1] CRAN (R 4.5.0)
#&gt;    xfun              * 0.56       2026-01-18 [1] CRAN (R 4.5.2)
#&gt;    xml2                1.5.2      2026-01-17 [1] CRAN (R 4.5.2)
#&gt;    xtable            * 1.8-4      2019-04-21 [1] CRAN (R 4.5.0)
#&gt;    yaml                2.3.12     2025-12-10 [1] CRAN (R 4.5.2)
#&gt;    yardstick         * 1.3.2      2025-01-22 [1] CRAN (R 4.5.0)
#&gt;    zip                 2.3.3      2025-05-13 [1] CRAN (R 4.5.0)
#&gt;    zoo                 1.8-15     2025-12-15 [1] CRAN (R 4.5.2)
#&gt; 
#&gt;  [1] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
#&gt; 
#&gt;  * ── Packages attached to the search path.
#&gt;  P ── Loaded and on-disk path mismatch.
#&gt; 
#&gt; ─ External software ────────────────────────────────────────────────────────────────────────────────────────────────────────────
#&gt;  setting        value
#&gt;  cairo          1.17.6
#&gt;  cairoFT
#&gt;  pango          1.50.14
#&gt;  png            1.6.44
#&gt;  jpeg           9.5
#&gt;  tiff           LIBTIFF, Version 4.5.0
#&gt;  tcl            8.6.13
#&gt;  curl           8.7.1
#&gt;  zlib           1.2.12
#&gt;  bzlib          1.0.8, 13-Jul-2019
#&gt;  xz             5.6.3
#&gt;  deflate        1.23
#&gt;  PCRE           10.44 2024-06-07
#&gt;  ICU            76.1
#&gt;  TRE            TRE 0.8.0 R_fixes (BSD)
#&gt;  iconv          Apple or GNU libiconv 1.11 /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libR.dylib
#&gt;  readline       5.2
#&gt;  BLAS           /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
#&gt;  lapack         /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib
#&gt;  lapack_version 3.12.1
#&gt; 
#&gt; ─ Python configuration ─────────────────────────────────────────────────────────────────────────────────────────────────────────
#&gt;  Python is not available
#&gt; 
#&gt; ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#&gt; $RNGkind
#&gt; [1] "L'Ecuyer-CMRG" "Inversion"     "Rejection"</code></pre>
</div>
<hr>
</section>
<section id="stata" class="level4">
<h4 class="anchored" data-anchor-id="stata">Stata Environment</h4>
<hr>
<div class="cell" data-layout-align="center" data-collectcode="true" data-statapath="/Applications/StataNow/StataMP.app/Contents/MacOS/StataMP">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb58" style="background: #f1f3f5;"><pre class="sourceCode stata code-with-copy"><code class="sourceCode stata"><span id="cb58-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">display</span> %tcMonth_dd,CCYY_hh:MM_am now()</span>
<span id="cb58-2">about</span>
<span id="cb58-3">#&gt; Can <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">set</span> Stata directory, <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">try</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">using</span> -statapath()- option</span>
<span id="cb58-4">#&gt; <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">r</span>(601);</span>
<span id="cb58-5">#&gt; </span>
<span id="cb58-6">#&gt; </span>
<span id="cb58-7">#&gt;    February 2,2026 9:26 pm</span>
<span id="cb58-8">#&gt; </span>
<span id="cb58-9">#&gt; </span>
<span id="cb58-10">#&gt; StataNow/MP 19.5 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> Mac (Apple Silicon)</span>
<span id="cb58-11">#&gt; Revision 28 Jan 2026</span>
<span id="cb58-12">#&gt; Copyright 1985-2025 StataCorp LLC</span>
<span id="cb58-13">#&gt; </span>
<span id="cb58-14">#&gt; Total physical <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">memory</span>: 48.01 GB</span>
<span id="cb58-15">#&gt; </span>
<span id="cb58-16">#&gt; Stata license: Single-user 2-core , expiring  6 Feb 2027</span>
<span id="cb58-17">#&gt; Serial number: 501909358563</span>
<span id="cb58-18">#&gt;   Licensed to: Zad Rafi</span>
<span id="cb58-19">#&gt;                Hunter</span></code></pre></div></div>
</div>
<hr>
</section>
</section>
<section id="references" class="level1">
<h1>References</h1>
<hr>


<!-- -->


</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" data-entry-spacing="2" data-line-spacing="2">
<div id="ref-Stark2018-eo" class="csl-entry">
1. Stark PB, Saltelli A. (2018). <span>“Cargo-cult statistics and scientific crisis.”</span> <em>Significance</em>. <strong>15</strong>:40–43. doi: <a href="https://doi.org/10.1111/j.1740-9713.2018.01174.x">10.1111/j.1740-9713.2018.01174.x</a>.
</div>
<div id="ref-gigerenzerStatisticalRitualsReplication2018" class="csl-entry">
2. Gigerenzer G. (2018). <span>“Statistical <span>Rituals</span>: <span>The Replication Delusion</span> and <span>How We Got There</span>.”</span> <em>Advances in Methods and Practices in Psychological Science</em>. <strong>1</strong>:198–218. doi: <a href="https://doi.org/10.1177/2515245918771329">10.1177/2515245918771329</a>.
</div>
<div id="ref-Greenland2017-es" class="csl-entry">
3. Greenland S. (2017). <span>“Invited commentary: <span>The</span> need for cognitive science in methodology.”</span> <em>American Journal of Epidemiology</em>. <strong>186</strong>:639–645. doi: <a href="https://doi.org/10.1093/aje/kwx259">10.1093/aje/kwx259</a>.
</div>
<div id="ref-greenlandMultipleBiasModelling2005" class="csl-entry">
4. Greenland S. (2005). <span>“Multiple-bias modelling for analysis of observational data.”</span> <em>Journal of the Royal Statistical Society Series A (Statistics in Society)</em>. <strong>168</strong>:267–306. doi: <a href="https://doi.org/10.1111/j.1467-985X.2004.00349.x">10.1111/j.1467-985X.2004.00349.x</a>.
</div>
<div id="ref-greenlandBiasAnalysis2008" class="csl-entry">
5. Greenland S, Lash TL. (2008). <span>“Bias analysis.”</span> In: Rothman KJ, Greenland S, Lash TL, editors. Modern <span>Epidemiology</span>. 3rd edition. <span>Lippincott Williams &amp; Wilkins</span>. p. 345–380.
</div>
<div id="ref-lashApplyingQuantitativeBias2009" class="csl-entry">
6. Lash TL, Fox MP, Fink AK. (2009). <span>“Applying <span>Quantitative Bias Analysis</span> to <span>Epidemiologic Data</span>.”</span> <span>Springer New York</span>.
</div>
<div id="ref-lashGoodPracticesQuantitative2014" class="csl-entry">
7. Lash TL, Fox MP, MacLehose RF, Maldonado G, McCandless LC, Greenland S. (2014). <span>“Good practices for quantitative bias analysis.”</span> <em>International Journal of Epidemiology</em>. <strong>43</strong>:1969–1985. doi: <a href="https://doi.org/10.1093/ije/dyu149">10.1093/ije/dyu149</a>.
</div>
<div id="ref-lashBiasAnalysisGone2021" class="csl-entry">
8. Lash TL, Ahern TP, Collin LJ, Fox MP, MacLehose RF. (2021). <span>“Bias <span>Analysis Gone Bad</span>.”</span> <em>American Journal of Epidemiology</em>. doi: <a href="https://doi.org/10.1093/aje/kwab072">10.1093/aje/kwab072</a>.
</div>
<div id="ref-gustafsonInvitedCommentaryBetter2021" class="csl-entry">
9. Gustafson P. (2021). <span>“Invited <span>Commentary</span>: <span>Toward Better Bias Analysis</span>.”</span> <em>American Journal of Epidemiology</em>. doi: <a href="https://doi.org/10.1093/aje/kwab068">10.1093/aje/kwab068</a>.
</div>
<div id="ref-greenlandDealingInevitableDeficiencies2021" class="csl-entry">
10. Greenland S. (2021). <span>“Dealing with the <span>Inevitable Deficiencies</span> of <span>Bias Analysis</span> and <span>All Analyses</span>.”</span> <em>American Journal of Epidemiology</em>. doi: <a href="https://doi.org/10.1093/aje/kwab069">10.1093/aje/kwab069</a>.
</div>
<div id="ref-molenberghsHandbookMissingData2014" class="csl-entry">
11. Molenberghs G, Fitzmaurice G, Kenward MG, Tsiatis A, Verbeke G. (2014). <span>“Handbook of <span>Missing Data Methodology</span>.”</span> <span>CRC Press</span>.
</div>
<div id="ref-scottMulticentreAneurysmScreening2002" class="csl-entry">
12. Scott RaP. (2002). <span>“The <span>Multicentre Aneurysm Screening Study</span> (<span>MASS</span>) into the effect of abdominal aortic aneurysm screening on mortality in men: A randomised controlled trial.”</span> <em>The Lancet</em>. <strong>360</strong>:1531–1539. doi: <a href="https://doi.org/10.1016/S0140-6736(02)11522-4">10.1016/S0140-6736(02)11522-4</a>.
</div>
<div id="ref-morrisChoosingSensitivityAnalyses2014" class="csl-entry">
13. Morris TP, Kahan BC, White IR. (2014). <span>“Choosing sensitivity analyses for randomised trials: principles.”</span> <em>BMC Medical Research Methodology</em>. <strong>14</strong>:11. doi: <a href="https://doi.org/10.1186/1471-2288-14-11">10.1186/1471-2288-14-11</a>.
</div>
<div id="ref-mostellerDataAnalysisIncluding1987" class="csl-entry">
14. Mosteller F, Tukey JW. (1987). <span>“Data analysis including statistics.”</span> In: The <span>Collected Works</span> of <span>John W</span>. <span>Tukey</span>: <span>Philosophy</span> and <span>Principles</span> of <span>Data Analysis</span> 1965-1986. <span>CRC Press</span>.
</div>
<div id="ref-akachaEstimandsTheirRole2017" class="csl-entry">
15. Akacha M, Bretz F, Ohlssen D, Rosenkranz G, Schmidli H. (2017). <span>“Estimands and <span>Their Role</span> in <span>Clinical Trials</span>.”</span> <em>Statistics in Biopharmaceutical Research</em>. <strong>9</strong>:268–271. doi: <a href="https://doi.org/10.1080/19466315.2017.1302358">10.1080/19466315.2017.1302358</a>.
</div>
<div id="ref-permuttCovariatesChangeEstimand2020" class="csl-entry">
16. Permutt T. (2020). <span>“Do <span>Covariates Change</span> the <span>Estimand</span>?”</span> <em>Statistics in Biopharmaceutical Research</em>. <strong>12</strong>:45–53. doi: <a href="https://doi.org/10.1080/19466315.2019.1647874">10.1080/19466315.2019.1647874</a>.
</div>
<div id="ref-mitroiuNarrativeReviewEstimands2020" class="csl-entry">
17. Mitroiu M, Oude Rengerink K, Teerenstra S, Pétavy F, Roes KCB. (2020). <span>“A narrative review of estimands in drug development and regulatory evaluation: Old wine in new barrels?”</span> <em>Trials</em>. <strong>21</strong>:671. doi: <a href="https://doi.org/10.1186/s13063-020-04546-1">10.1186/s13063-020-04546-1</a>.
</div>
<div id="ref-littlePreventionTreatmentMissing2012" class="csl-entry">
18. Little RJ, D’Agostino R, Cohen ML, Dickersin K, Emerson SS, Farrar JT, et al. (2012). <span>“The <span>Prevention</span> and <span>Treatment</span> of <span>Missing Data</span> in <span>Clinical Trials</span>.”</span> <em>New England Journal of Medicine</em>. <strong>367</strong>:1355–1360. doi: <a href="https://doi.org/10.1056/NEJMsr1203730">10.1056/NEJMsr1203730</a>.
</div>
<div id="ref-chenClinicalTrialData2017" class="csl-entry">
19. Chen D-G(Din), Peace KE, Zhang P. (2017). <span>“Clinical trial data analysis using r and SAS.”</span> 2nd edition. Chapman; Hall/CRC. doi: <a href="https://doi.org/10.1201/9781315155104">10.1201/9781315155104</a>.
</div>
<div id="ref-buurenFlexibleImputationMissing2018" class="csl-entry">
20. Buuren S van. (2018). <span>“Flexible <span>Imputation</span> of <span>Missing Data</span>, <span>Second Edition</span>.”</span> <span>CRC Press</span>.
</div>
<div id="ref-mengPerformingLikelihoodRatio1992" class="csl-entry">
21. Meng X-L, Rubin DB. (1992). <span>“Performing <span>Likelihood Ratio Tests</span> with <span>Multiply</span>-<span>Imputed Data Sets</span>.”</span> <em>Biometrika</em>. <strong>79</strong>:103–111. doi: <a href="https://doi.org/10.2307/2337151">10.2307/2337151</a>.
</div>
<div id="ref-schenkerPartiallyParametricTechniques1996" class="csl-entry">
22. Schenker N, Taylor J. (1996). <span>“Partially parametric techniques for multiple imputation.”</span> <em>Computational Statistics &amp; Data Analysis</em>. <strong>22</strong>:425–446. doi: <a href="https://doi.org/10.1016/0167-9473(95)00057-7">10.1016/0167-9473(95)00057-7</a>.
</div>
<div id="ref-permuttSensitivityAnalysisMissing2016" class="csl-entry">
23. Permutt T. (2016). <span>“Sensitivity analysis for missing data in regulatory submissions.”</span> <em>Statistics in Medicine</em>. <strong>35</strong>:2876–2879. doi: <a href="https://doi.org/10.1002/sim.6753">10.1002/sim.6753</a>.
</div>
<div id="ref-jolaniDualImputationStrategies2012" class="csl-entry">
24. Jolani S. (2012). <span>“Dual <span>Imputation Strategies</span> for <span>Analyzing Incomplete Data</span>.”</span>
</div>
<div id="ref-vonhippelMaximumLikelihoodMultiple2019" class="csl-entry">
25. von Hippel PT, Bartlett J. (2019). <span>“Maximum likelihood multiple imputation: <span>Faster</span> imputations and consistent standard errors without posterior draws.”</span> <em>arXiv:12100870 [stat]</em>. <a href="https://arxiv.org/abs/1210.0870">https://arxiv.org/abs/1210.0870</a>.
</div>
<div id="ref-rafiSemanticCognitiveTools2020" class="csl-entry">
26. Rafi Z, Greenland S. (2020). <span>“Semantic and cognitive tools to aid statistical science: Replace confidence and significance by compatibility and surprise.”</span> <em>BMC Medical Research Methodology</em>. <strong>20</strong>:244. doi: <a href="https://doi.org/10.1186/s12874-020-01105-9">10.1186/s12874-020-01105-9</a>.
</div>
<div id="ref-greenlandAidScientificInference2020" class="csl-entry">
27. Greenland S, Rafi Z. (2020). <span>“To <span>Aid Scientific Inference</span>, <span>Emphasize Unconditional Descriptions</span> of <span>Statistics</span>.”</span> <em>arXiv:190908583 [statME]</em>. <a href="https://arxiv.org/abs/1909.08583">https://arxiv.org/abs/1909.08583</a>.
</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2020,
  author = {Panda, Sir and Panda, Sir},
  title = {What {Makes} a {Sensitivity} {Analysis?}},
  date = {2020-12-12},
  url = {https://lesslikely.com/posts/statistics/sensitivity.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2020" class="csl-entry quarto-appendix-citeas">
1. Panda S, Panda S. (2020). <span>‘What Makes a Sensitivity
Analysis?’</span> <a href="https://lesslikely.com/posts/statistics/sensitivity.html">https://lesslikely.com/posts/statistics/sensitivity.html</a>.
</div></div></section></div> ]]></description>
  <category>statistics</category>
  <guid>https://lesslikely.com/posts/statistics/sensitivity.html</guid>
  <pubDate>Sat, 12 Dec 2020 05:00:00 GMT</pubDate>
  <media:content url="https://lesslikely.com/images/sensitivity.png" medium="image" type="image/png" height="122" width="144"/>
</item>
<item>
  <title>Quality Control in Statistical Analyses</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/statistics/statistical-quality-control.html</link>
  <description><![CDATA[ 





<hr>
<p>Experienced statisticians and data analysts are familiar with stories where a coding error has led to an entire conclusion changing, <a href="https://jamanetwork.com/journals/jama/fullarticle/2752474">or even a retraction</a>.[@aboumatarNoticeRetractionAboumatar2019] It’s the sort of stuff that keeps people up at night. Unfortunately, not many of us think about these sorts of scenarios until we realize it’s very possible that it could happen to any of us.</p>
<p>To me, it seems that many of these issues could be avoided by having a principled data management and statistical workflow, and making it as transparent, open, and reproducible as possible. I’d like to quickly go over a few things that I’ve found helpful over the years, and I’ll first start with data management and data entry and then move onto analysis workflows. I largely consider this to be a living document, and I’m sure many people who will read this will have far better suggestions, so please leave them down below in the comments!</p>
<p>Before I go on, I want to emphasize that backing up your data, scripts, and <a href="https://happygitwithr.com/">using version control</a> is extremely important. There is no debate about this. It’s necessary so that other collaborators/colleagues can inspect your work and catch potential mistakes or see overall progress, but more importantly, it will prevent you from losing your data in a disaster, and it’ll help you catch your own mistakes, since you’ll be the most familiar with the data and scripts.</p>
<hr>
<section id="data-entry-management" class="level1">
<h1>Data Entry &amp; Management</h1>
<hr>
<p>A nice paper that I’d like to review is the one by <a href="https://doi.org/10.1080/00031305.2017.1375989">Broman &amp; Woo, 2018</a> on how to manage your data when working with spreadsheets.[@bromanDataOrganizationSpreadsheets2018] The sad reality is that even though spreadsheets like Microsoft Excel or Google Sheets are available everywhere, and easy to use, there are many risks when working with spreadsheets, just ask any <a href="https://genomebiology.biomedcentral.com/articles/10.1186/s13059-016-1044-7?fbclid=IwAR06eQ5LTg2LX5byJBWfC6rJdAbAGXKvy3PUOhzPsVjUGqb7KqB1V_x36M0">statistician who works in genetics</a> or any bioinformatician.[@ziemannGeneNameErrors2016]</p>
<p>One of the most fatal errors <a href="https://theconversation.com/why-you-should-never-use-microsoft-excel-to-count-coronavirus-cases-147681">occurred recently</a> when a group of researchers lost thousands of documented COVID cases because they entered data for each case as a column instead of a row, and Excel has a limit on how many columns and rows it can handle (<strong>1,048,576 rows</strong> and <strong>16,384 columns</strong>, <a href="https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3">according to Microsoft</a>), as a result, most of these cases were lost, resulting in an enormous waste of resources due to a careless and ignorant mistake, highlighting the dangers of recklessly inputting data and conducting statistical analyses. There is no doubt that reviewing principles of good data management and workflow are essential to any data analyst. I’d like to touch on some of the most important points of <a href="https://doi.org/10.1080/00031305.2017.1375989">Broman &amp; Woo, 2018</a> paper before moving onto some other “principles” I’d like to share:</p>
<hr>
<section id="general-principle-be-consistent-with-everything" class="level2">
<h2 class="anchored" data-anchor-id="general-principle-be-consistent-with-everything">General Principle: Be Consistent With Everything</h2>
<hr>

<ul>
<li>When labeling missing values (<code>NA</code>, <code>N/A</code>, etc.):
<ul>
<li><p>
<span style="color:#7aa864; font-weight: 700;">Good</span>: Choose one method (<code>NA</code>, <code>N/A</code>, etc.) and stick with it.
</p></li>
<li><p>
<span style="color:#CD5C5C; font-weight: 700;">Bad</span>: Leaving cells empty to indicate missingness.
</p></li>
</ul></li>
</ul>
<hr>
<ul>
<li>When labeling response variables:
<ul>
<li><p>
<span style="color:#7aa864; font-weight: 700;">Good</span>: If you label a response variable consistently, for example, <code>fat-free-mass</code> in every instance to refer to the same variable.
</p></li>
<li><p>
<span style="color:#CD5C5C; font-weight: 700;">Bad</span>: If you label a response variable <code>fat-free-mass</code> in one script/sheet, and <code>ffm</code>/<code>fat_free_mass</code> in another.
</p></li>
</ul></li>
</ul>
<hr>
<ul>
<li>When formatting variable predictor names:
<ul>
<li><p>
<span style="color:#7aa864; font-weight: 700;">Good</span>: <code>predictor_1_week12</code>, <code>predictor_2_week12</code>, <code>response_variable_week12</code>. This is consistent, with the order of the names, and dates/weeks, so it is easier to organize, inspect, and clean. Same thing applies to labeling response variables and pretty much all variables.
</p></li>
<li><p>
<span style="color:#CD5C5C; font-weight: 700;">Bad</span>: When you label one variable <code>week12_predictor_1</code>, the next <code>predictor_2_week12</code>, and the last, <code>12_week_response</code>. Just <em>no</em>.
</p></li>
</ul></li>
</ul>
<hr>
<ul>
<li>When formatting dates:
<ul>
<li><p>
<span style="color:#7aa864; font-weight: 700;">Good</span>: Use one format, <code>YYYY-MM-DD</code>, consistently.
</p></li>
<li><p>
<span style="color:#CD5C5C; font-weight: 700;">Bad</span>: Everything else.
</p></li>
</ul></li>
</ul>
<hr>
<ul>
<li>When filling out cells:
<ul>
<li><p>
<span style="color:#7aa864; font-weight: 700;">Good</span>: One cell = one thing. No more, no less.
</p></li>
<li><p>
<span style="color:#CD5C5C; font-weight: 700;">Bad</span>: One cell = multiple entries or no entries at all.
</p></li>
</ul></li>
</ul>
<hr>
<ul>
<li>When keeping track of the data:
<ul>
<li><p>
<span style="color:#7aa864; font-weight: 700;">Good</span>: Create a comprehensive data dictionary so anyone can look at it and understand the spreadsheets/dataframes/variables.
</p></li>
<li><p>
<span style="color:#CD5C5C; font-weight: 700;">Bad</span>: Expecting yourself and others to figure it out based on the variable names that you thought were brilliant.
</p></li>
</ul></li>
</ul>
<hr>
<ul>
<li>When using Excel or Google Sheet’s shiny features:
<ul>
<li><p>
<span style="color:#7aa864; font-weight: 700;">Good</span>: Avoid using any of them, any formulas, highlighting, <em>italicizing</em>, <span style="font-weight:700;">bolding</span>, etc.
</p></li>
<li><p>
<span style="color:#CD5C5C; font-weight: 700;">Bad</span>: If you’re the type of person to create charts in Excel.
</p></li>
</ul></li>
</ul>
<hr>
<ul>
<li>Planning for disasters:
<ul>
<li><p>
<span style="color:#7aa864; font-weight: 700;">Good</span>: Always, always, backup your files, save them in .txt files. Keep backups of those. And most importantly, <a href="https://happygitwithr.com/"><strong>use version control!</strong></a>
</p></li>
<li><p>
<span style="color:#CD5C5C; font-weight: 700;">Bad</span>: You don’t really plan for disasters and go with the flow.
</p></li>
</ul></li>
</ul>

<hr>
<ul>
<li>Last but not least, when entering cases:
<ul>
<li><p>
</p><p><span style="color:#7aa864; font-weight: 700;">Good</span>: Rows are for cases and observations, and columns are for variables and characteristics. Please do not switch these up!</p></li>
<li><p>
</p><p><span style="color:#CD5C5C; font-weight: 700;">Bad</span>: Using them interchangeably.</p></li>
</ul></li>
</ul>
<hr>
</section>
</section>
<section id="setting-up-a-principled-statistical-workflow" class="level1">
<h1>Setting Up a Principled Statistical Workflow</h1>
<hr>
<p>Here’s what I’ve been doing for many years and what seems to work for me (none of these ideas are originally mine, and I actually picked them up over the years from others’ advice, which will be linked below).</p>
<hr>
<section id="setting-up-the-project-folder" class="level2">
<h2 class="anchored" data-anchor-id="setting-up-the-project-folder">Setting up the Project Folder</h2>
<hr>
<p>When setting up a folder specific for a project (if you’re not doing this, you absolutely need to), first, I will create a folder with the title of my project, and usually have an <a href="https://rstudio.com/"><code>RStudio</code></a> project set up in there.</p>
<hr>
<blockquote class="blockquote">
<p>Disclaimer: while much of this advice will be familiar and easy to understand for those who use <code>R</code>, I think the general principles are widely applicable, especially for those who use scripts in their statistical software).</p>
</blockquote>
<hr>
<p>This folder will contain many other folders (more on that below), so the structure will end up being a bit complex.</p>
<hr>
<p><img data-enlargeable="" style="cursor: zoom-in" src="https://res.cloudinary.com/less-likely/image/upload/v1613136545/Site/diagram.png" alt="workflow"></p>
<hr>
<blockquote class="blockquote">
<p>It may be a bit difficult to read the words within the circles, but clicking on the diagram should enlargen it and allow you to zoom in, giving you a sense of how I organize all these scripts and files.</p>
</blockquote>
<hr>
<p>If this ends up confusing you, you can just scroll all the way down to see an image of what the folder structure looks like.</p>
<p>Instead of constantly changing the working directory to each subfolder when I need to do something inside that subfolder for a particular project or analysis, I set the project folder as the working directory only once, and then run the following:</p>
<hr>
<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="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Very seriously consider installing the `here` package</span></span>
<span id="cb1-2"></span>
<span id="cb1-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># https://cran.r-project.org/package=here</span></span>
<span id="cb1-4"></span>
<span id="cb1-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"here"</span>)</span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># This and the scripts below take</span></span>
<span id="cb1-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># the directory used and set it as the top</span></span>
<span id="cb1-9"></span>
<span id="cb1-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set_here</span>()</span>
<span id="cb1-11"></span>
<span id="cb1-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">here</span>()</span></code></pre></div></div>
</div>
<hr>
<p>This not only sets the working directory, but gives you far more control over how you can save your files from any place within the hierarchical folder structure. It will create a file called <code>.here</code> inside the <code>Main Project</code> folder, which will indicate that this is the top level of the hierarchy.</p>
<p>Then, I will usually have created a <code>README.Rmd</code> file in the <code>Main Project</code> folder with updates on what I’ve done and what I still need to work on, so I will remember and so my collaborators can see it too (when it has been pushed to GitHub or other <a href="https://happygitwithr.com/">version control</a> repos).</p>
<p>Next, I’ll set up a <code>Data</code> folder inside the <code>Main Project</code> folder. This is where all my data/spreadsheets/.txt files and data dictionaries will go. The original data files will stay inside this folder, while I create two other subsubfolders inside this <code>Data</code> folder called <code>Transformed</code> and <code>Models</code>. In <code>Transformed</code>, I will typically save <code>.rds</code> files that were a result of cleaning and transforming the data, including imputing missing data. I will touch more on exactly how I do that later below. A <code>Models</code> subfolder will obviously store fitted models and any validation/sensitivity analyses of those models.[@morrisChoosingSensitivityAnalyses2014]</p>
<p>Now, back to the <code>Main Project</code> folder, I’ll set up another folder within it called <code>R</code>. This will be where all of my <code>.R</code> scripts/files live. I will number them sequentially along with a title for a specific purpose, like so</p>
<hr>
<ul>
<li><p><code>main.R</code></p></li>
<li><p><code>01-functions.R</code></p></li>
<li><p><code>02-cleaning.R</code></p></li>
<li><p><code>03-inspection.R</code></p></li>
<li><p><code>04-analysis.R</code></p></li>
<li><p><code>04.5-validation.R</code></p></li>
<li><p><code>05-sensitivity.R</code></p></li>
<li><p><code>06-tables.R</code></p></li>
</ul>
<hr>
</section>
<section id="setting-up-the-functions-script" class="level2">
<h2 class="anchored" data-anchor-id="setting-up-the-functions-script">Setting up the Functions Script</h2>
<hr>
<p>All potential <code>R</code> packages and custom functions that I need will belong in <code>01-functions.R</code>. This <code>.R</code> file will only serve this purpose and nothing else. As you’ve guessed by now, the other <code>.R</code> files will be doing the same, they have very specific purposes and are organized to reflect this.</p>
<p>An example of the first script can be found below.</p>
<hr>
<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="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Necessary Packages ------------------------------------</span></span>
<span id="cb2-2"></span>
<span id="cb2-3">req_packs <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rms"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concurve"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mice"</span>,</span>
<span id="cb2-4">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tidyverse"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"parallel"</span>,</span>
<span id="cb2-5">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bayesplot"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"projpred"</span>,</span>
<span id="cb2-6">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hmisc"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"loo"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rstan"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"here"</span>,</span>
<span id="cb2-7">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tryCatchLog"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"futile.logger"</span>,</span>
<span id="cb2-8">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"patchwork"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"corrplot"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"beepr"</span>,</span>
<span id="cb2-9">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"summarytools"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"broom"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wakefield"</span>,</span>
<span id="cb2-10">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"boot"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mfp"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"knitr"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flextable"</span>,</span>
<span id="cb2-11">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MASS"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lme4"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"brms"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"miceMNAR"</span>)</span>
<span id="cb2-12"></span>
<span id="cb2-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Load all packages at once</span></span>
<span id="cb2-14"></span>
<span id="cb2-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(req_packs, library,</span>
<span id="cb2-16">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">character.only =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb2-17"></span>
<span id="cb2-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Loggings messages</span></span>
<span id="cb2-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">options</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">keep.source =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb2-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">options</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tryCatchLog.write.error.dump.file"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb2-21"></span>
<span id="cb2-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Set seed for random number generator</span></span>
<span id="cb2-23"></span>
<span id="cb2-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">RNGkind</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"L'Ecuyer-CMRG"</span>)</span>
<span id="cb2-25"><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;">1031</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># My birthday</span></span>
<span id="cb2-26"></span>
<span id="cb2-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># RStan Settings  -------------------------------------</span></span>
<span id="cb2-28"></span>
<span id="cb2-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_set</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>())</span>
<span id="cb2-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">color_scheme_set</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>)</span>
<span id="cb2-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rstan_options</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">auto_write =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb2-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">options</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mc.cores =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb2-33"></span>
<span id="cb2-34"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">has_build_tools</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">debug =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb2-35"></span>
<span id="cb2-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Stan Settings  ---------------------------------------</span></span>
<span id="cb2-37"></span>
<span id="cb2-38">dotR <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;">file.path</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Sys.getenv</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"HOME"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".R"</span>)</span>
<span id="cb2-39"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</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;">file.exists</span>(dotR)) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(dotR)</span>
<span id="cb2-40">M <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;">file.path</span>(dotR, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Makevars"</span>)</span>
<span id="cb2-41"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</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;">file.exists</span>(M)) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.create</span>(M)</span>
<span id="cb2-42"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">CXX14FLAGS=-O3 -march=native -mtune=native -fPIC"</span>,</span>
<span id="cb2-43">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CXX14=g++"</span>,</span>
<span id="cb2-44">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">file =</span> M, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><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;">append =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div></div>
</div>
<hr>
<p>The script above loads all the necessary <code>R</code> packages each time it is called, along with the specified functions, so most of the other <code>.R</code> files will depend upon this one.</p>
<p>However, I will not be running each of these <code>.R</code> files/scripts individually, line by line, or by selecting all the lines in an <code>.R</code> file and running the script.</p>
<p>Instead, after I’ve created all these files (figuring out what I need to do carefully and writing it down and annotating it), every single <code>.R</code> file except for <code>main.R</code> will have the following script, which I will explain later below (or some iteration of this script to match the name of the file) at the beginning:</p>
<hr>
</section>
<section id="setting-up-the-error-catching-script" class="level2">
<h2 class="anchored" data-anchor-id="setting-up-the-error-catching-script">Setting up the Error Catching Script</h2>
<hr>
<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>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"here"</span>)</span>
<span id="cb3-2"></span>
<span id="cb3-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set_here</span>()</span>
<span id="cb3-4"></span>
<span id="cb3-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"01-functions.R"</span>))</span>
<span id="cb3-6"></span>
<span id="cb3-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(futile.logger)</span>
<span id="cb3-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tryCatchLog)</span>
<span id="cb3-9"></span>
<span id="cb3-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Keeps source code file name and line number tracking</span></span>
<span id="cb3-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">options</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">keep.source =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb3-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">options</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tryCatchLog.write.error.dump.file"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb3-13"></span>
<span id="cb3-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Logs messages into a file</span></span>
<span id="cb3-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">flog.appender</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">appender.file</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"my_app.log"</span>))</span>
<span id="cb3-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">flog.threshold</span>(INFO)</span>
<span id="cb3-17"></span>
<span id="cb3-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Function that catches any messages</span></span>
<span id="cb3-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatchLog</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"script.R"</span>))</span></code></pre></div></div>
</div>
<hr>
<p>You’ll notice several things. First, I’m once again calling the <a href="https://cran.r-project.org/package=here"><code>here</code></a> package and telling it that I’m working within this folder (<code>R</code>), and then I’m calling the <code>01-functions.R</code> file by using the <code>source()</code> function, but also notice how the <code>source()</code> function is followed by a <code>here()</code> function/argument. This <code>here()</code> function allows you to fully control files in a specific folder from anywhere else, without having to actually be in that folder. So, suppose I was in the <code>Main Project</code> -&gt; <code>Data</code> -&gt; <code>Models</code> folder and I was saving my work there (in the <code>Models</code> folder), which is pretty far from the <code>R</code> folder, I can still, using functions like <code>source()</code>, <code>save()</code>, etc., call or manipulate files from a totally different folder by specifying the hierarchy using <code>here()</code>. This can also be done in other ways, but those are far more cumbersome, and not flexible.</p>
<p>This is how I always call the necessary packages and functions I need from every <code>.R</code> script, simply by using the <code>source()</code> function and using <code>here()</code> to direct it to the <code>01-functions.R</code> file in the <code>R</code> folder. Now let’s look at the next few lines.</p>
<hr>
<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;">flog.appender</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">appender.file</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"script.log"</span>))</span>
<span id="cb4-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">flog.threshold</span>(INFO)</span>
<span id="cb4-3"></span>
<span id="cb4-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatchLog</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"script.R"</span>))</span></code></pre></div></div>
</div>
<hr>
<p>This script is designed to catch any warnings that occur inside the <code>.R</code> script and save them to a .log file in another subfolder within the <code>R</code> folder called <code>Errors</code>. So here’s an example of a full script for a mix of data generation and inspection, so that you can see it in action.</p>
<hr>
</section>
<section id="example-of-data-loading-inspection" class="level2">
<h2 class="anchored" data-anchor-id="example-of-data-loading-inspection">Example of Data Loading &amp; Inspection</h2>
<hr>
<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;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"here"</span>)</span>
<span id="cb5-2"></span>
<span id="cb5-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set_here</span>()</span>
<span id="cb5-4"></span>
<span id="cb5-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"01-functions.R"</span>)) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Loads all R functions</span></span>
<span id="cb5-6"></span>
<span id="cb5-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># First we need some data</span></span>
<span id="cb5-8"></span>
<span id="cb5-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">RNGkind</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kind =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"L'Ecuyer-CMRG"</span>)</span>
<span id="cb5-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;">1031</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># My birthday</span></span>
<span id="cb5-11"></span>
<span id="cb5-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Suppose you wanted to simulate a clinical trial</span></span>
<span id="cb5-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"simstudy"</span>)</span>
<span id="cb5-14"></span>
<span id="cb5-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Simulating a Clinical Trial --------------------------</span></span>
<span id="cb5-16"></span>
<span id="cb5-17">def <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;">defData</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">varname =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"male"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dist =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"binary"</span>,</span>
<span id="cb5-18">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span> , <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;">"cid"</span>)</span>
<span id="cb5-19">def <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;">defData</span>(def, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">varname =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"over65"</span>,</span>
<span id="cb5-20">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dist =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"binary"</span>,</span>
<span id="cb5-21">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-1.7 + .8 * male"</span>,</span>
<span id="cb5-22">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">link =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"logit"</span>)</span>
<span id="cb5-23">def <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;">defData</span>(def,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">varname =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"baseDBP"</span>,</span>
<span id="cb5-24">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dist =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"normal"</span>,</span>
<span id="cb5-25">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">70</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">variance =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>)</span>
<span id="cb5-26">def <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;">defData</span>(def, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">varname =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"age"</span>,</span>
<span id="cb5-27">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dist =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"normal"</span>,</span>
<span id="cb5-28">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb5-29">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">variance =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb5-30">def <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;">defData</span>(def, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">varname =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"visits"</span>,</span>
<span id="cb5-31">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dist =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"poisson"</span>,</span>
<span id="cb5-32">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1.5 - 0.2 * age + 0.5 * male"</span>,</span>
<span id="cb5-33">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">link =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"log"</span>)</span>
<span id="cb5-34">def <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;">defData</span>(def, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">varname =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"weight"</span>,</span>
<span id="cb5-35">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dist =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"normal"</span>,</span>
<span id="cb5-36">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">variance =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>)</span>
<span id="cb5-37">dtstudy <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;">genData</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>, def)</span>
<span id="cb5-38">study <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;">trtAssign</span>(dtstudy, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nTrt =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb5-39">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">balanced =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grpName =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rxGrp"</span>)</span>
<span id="cb5-40">study <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.data.frame</span>(study)</span>
<span id="cb5-41">study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>iq <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> iq <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> wakefield<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;">iq</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>)</span>
<span id="cb5-42">study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>height <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> height <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> wakefield<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;">height</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>)</span>
<span id="cb5-43">study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>income <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> income <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> wakefield<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;">income</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>,</span>
<span id="cb5-44">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</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;">"Income"</span>)</span>
<span id="cb5-45">study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>SAT_score <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> wakefield<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;">sat</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1500</span>,</span>
<span id="cb5-46">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">min =</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;">max =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2400</span>,</span>
<span id="cb5-47">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</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;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SAT"</span>)</span>
<span id="cb5-48">study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>visits <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.numeric</span>(study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>visits)</span>
<span id="cb5-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Add noisy predictors</span></span>
<span id="cb5-50">study[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</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;">20</span>] <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;">lapply</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;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FUN =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i)</span>
<span id="cb5-51">                         (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>,</span>
<span id="cb5-52">                                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)))</span>
<span id="cb5-53">varname <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;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x%d"</span>, (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</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;">20</span>))</span>
<span id="cb5-54"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(study)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</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;">20</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> varname</span>
<span id="cb5-55"></span>
<span id="cb5-56">study1 <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;">trtAssign</span>(dtstudy, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">balanced =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb5-57">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strata =</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;">"over65"</span>),</span>
<span id="cb5-58">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">grpName =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rxGrp"</span>)</span>
<span id="cb5-59"></span>
<span id="cb5-60">study1</span>
<span id="cb5-61"></span>
<span id="cb5-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Inspecting Data  -------------------------------------</span></span>
<span id="cb5-63"></span>
<span id="cb5-64">summarytools<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;">view</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dfSummary</span>(study))</span>
<span id="cb5-65"></span>
<span id="cb5-66">study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>over65 <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.factor</span>(study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>over65)</span>
<span id="cb5-67">study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>male <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.factor</span>(study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>male)</span>
<span id="cb5-68">study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rxGrp <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.factor</span>(study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rxGrp)</span>
<span id="cb5-69"></span>
<span id="cb5-70">study_formula <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.formula</span>(baseDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> .)</span>
<span id="cb5-71"></span>
<span id="cb5-72"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">spearman2</span>(study_formula, study))</span>
<span id="cb5-73"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">v =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb5-74"></span>
<span id="cb5-75">x_1 <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>(<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> study)[, <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-76"></span>
<span id="cb5-77"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Initial Data Analysis  ------------------------------</span></span>
<span id="cb5-78"></span>
<span id="cb5-79">(cormatrix <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;">cor</span>(x_1)))</span>
<span id="cb5-80"></span>
<span id="cb5-81">col <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;">colorRampPalette</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;">"#BB4444"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#EE9988"</span>,</span>
<span id="cb5-82">                          <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#FFFFFF"</span>,</span>
<span id="cb5-83">                          <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#77AADD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#4477AA"</span>))</span>
<span id="cb5-84"></span>
<span id="cb5-85"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">corrplot</span>(cormatrix, <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;">"color"</span>,</span>
<span id="cb5-86">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">col</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>),</span>
<span id="cb5-87">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tl.col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tl.cex =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.40</span>,</span>
<span id="cb5-88">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">addCoef.col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">number.cex =</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">35</span>)</span>
<span id="cb5-89"></span>
<span id="cb5-90"></span>
<span id="cb5-91">clus1 <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;">varclus</span>(x_1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">similarity =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"h"</span>)</span>
<span id="cb5-92">clus2 <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;">varclus</span>(x_1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">similarity =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"s"</span>)</span>
<span id="cb5-93">clus3 <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;">varclus</span>(x_1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">similarity =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"p"</span>)</span>
<span id="cb5-94"></span>
<span id="cb5-95"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(clus1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hoeffing's D statistic"</span>,</span>
<span id="cb5-96">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lwd =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</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;">cex =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>)</span>
<span id="cb5-97"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">title</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hierarchical Cluster Analysis"</span>)</span>
<span id="cb5-98"></span>
<span id="cb5-99"></span>
<span id="cb5-100"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(clus2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lwd =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</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;">cex =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>)</span>
<span id="cb5-101"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(clus3, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lwd =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</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;">cex =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>)</span>
<span id="cb5-102"></span>
<span id="cb5-103">Pre <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;">names</span>(study)</span>
<span id="cb5-104">(fmla <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.formula</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"~"</span>,</span>
<span id="cb5-105">                          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(Pre,</span>
<span id="cb5-106">                                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"+"</span>))))</span>
<span id="cb5-107"></span>
<span id="cb5-108"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Redundancy analysis</span></span>
<span id="cb5-109"></span>
<span id="cb5-110">redun <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;">redun</span>(fmla,</span>
<span id="cb5-111">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> study,</span>
<span id="cb5-112">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2 =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.90</span>, <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;">"ordinary"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">allcat =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb5-113">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tlinear =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">iterms =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pr =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div></div>
</div>
<hr>
<p>The above script simulated some fake data for a hypothetical clinical trial (usually we use this first script to load data from a .csv or .txt file) and then we used several functions to inspect the dataframe for the structure and distributions of the variables and missing data, etc. We also attempted to properly code the variables. Now, in order to capture any possible errors, we will have to run this entire script from another <code>R</code> script instead of running it line by line or selecting all the code and running it.</p>
<p>We will do this from a Main source script, which will allow us to use the <code>tryCatchLog()</code> function.</p>
<hr>
</section>
<section id="example-of-the-main-source-script" class="level2">
<h2 class="anchored" data-anchor-id="example-of-the-main-source-script">Example of the Main Source Script</h2>
<hr>
<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;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"here"</span>)</span>
<span id="cb6-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tryCatchLog"</span>)</span>
<span id="cb6-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"futile.logger"</span>)</span>
<span id="cb6-4"></span>
<span id="cb6-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set_here</span>() <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Load and set here</span></span>
<span id="cb6-6"></span>
<span id="cb6-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">here</span>() <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Call here</span></span>
<span id="cb6-8"></span>
<span id="cb6-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">options</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">keep.source =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb6-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">options</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tryCatchLog.write.error.dump.file"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb6-11"></span>
<span id="cb6-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Script loads all necessary functions</span></span>
<span id="cb6-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">flog.appender</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">appender.file</span>(</span>
<span id="cb6-14">  <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;">"Errors"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"01-functions.log"</span>)))</span>
<span id="cb6-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatchLog</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"01-functions.R"</span>)))</span>
<span id="cb6-16"></span>
<span id="cb6-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Line script to clean the data</span></span>
<span id="cb6-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">flog.appender</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">appender.file</span>(</span>
<span id="cb6-19">  <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;">"Errors"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"02-cleaning.log"</span>)))</span>
<span id="cb6-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatchLog</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"02-cleaning.R"</span>)))</span>
<span id="cb6-21"></span>
<span id="cb6-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Line script below to inspect the data</span></span>
<span id="cb6-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">flog.appender</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">appender.file</span>(</span>
<span id="cb6-24">  <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;">"Errors"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"03-inspection.log"</span>)))</span>
<span id="cb6-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatchLog</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"03-inspection.R"</span>)))</span>
<span id="cb6-26"></span>
<span id="cb6-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Load saved objects from cleanings</span></span>
<span id="cb6-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">flog.appender</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">appender.file</span>(</span>
<span id="cb6-29">  <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;">"Errors"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"03.5-load_data.log"</span>)))</span>
<span id="cb6-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatchLog</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"03.5-load_data.R"</span>)))</span>
<span id="cb6-31"></span>
<span id="cb6-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Main analysis script</span></span>
<span id="cb6-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">flog.appender</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">appender.file</span>(</span>
<span id="cb6-34">  <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;">"Errors"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"04-analysis.log"</span>)))</span>
<span id="cb6-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatchLog</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"04-analysis.R"</span>)))</span>
<span id="cb6-36"></span>
<span id="cb6-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Below is the validation of main analysis results</span></span>
<span id="cb6-38"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">flog.appender</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">appender.file</span>(</span>
<span id="cb6-39">  <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;">"Errors"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"04.5-validation.log"</span>)))</span>
<span id="cb6-40"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatchLog</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"04.5-validation.R"</span>)))</span>
<span id="cb6-41"></span>
<span id="cb6-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Test the sensitivity of the results by</span></span>
<span id="cb6-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># varying assumptions/multiple parameters</span></span>
<span id="cb6-44"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">flog.appender</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">appender.file</span>(</span>
<span id="cb6-45">  <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;">"Errors"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"05-sensitivity.log"</span>)))</span>
<span id="cb6-46"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatchLog</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"05-sensitivity.R"</span>)))</span>
<span id="cb6-47"></span>
<span id="cb6-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Generate tables and figures of all your results</span></span>
<span id="cb6-49"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">flog.appender</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">appender.file</span>(</span>
<span id="cb6-50">  <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;">"Errors"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"06-tables.log"</span>)))</span>
<span id="cb6-51"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatchLog</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"06-tables.R"</span>)))</span>
<span id="cb6-52"></span>
<span id="cb6-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Export these into actual files that can be</span></span>
<span id="cb6-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># inserted into papers, reports, etc.</span></span>
<span id="cb6-55"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">flog.appender</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">appender.file</span>(</span>
<span id="cb6-56">  <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;">"Errors"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"07-export.log"</span>)))</span>
<span id="cb6-57"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatchLog</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"07-export.R"</span>)))</span></code></pre></div></div>
</div>
<hr>
<p>If anything went wrong during the simulations and their inspections in the first script from above, it would have been captured by the error-catching scripts that we have set up, which would be placed within a .log file in the <code>Errors</code> folder, which is inside the <code>R</code> folder.</p>
<hr>
</section>
<section id="setting-the-seed" class="level2">
<h2 class="anchored" data-anchor-id="setting-the-seed">Setting the Seed</h2>
<hr>
<blockquote class="blockquote">
<p>Also, note that we have set the seed using a specific random number generator algorithm. This is not that important, however, it is important to correctly set the seed for reproducing any random numbers generated. This requires even more careful thought when running a simulation study, in which the states of the simulation need to be saved for a particular repetition, and so that streams do not overlap.[@morrisUsingSimulationStudies2019]</p>
</blockquote>
<hr>
<p>I will admit that the error script is not <em>perfect</em> at capturing warnings, but for most things, if something wrong occurs when a script is run, the function <code>tryCatchLog()</code> and its .log file usually catches the warning, so I would know that something went wrong and what specifically.</p>
<p>However, some may be skeptical of this approach and ask why I need to catch these errors and save them if I ran the scripts? Why not just scroll up and look at the console to see the errors or warnings?</p>
<p>Many reasons:</p>
<hr>
<ul>
<li>Suppose the analyses take a very long time, and are computationally intensive, and <code>R</code>/<a href="https://rstudio.com/"><code>RStudio</code></a> crashes, you may not be able to figure out what went wrong.</li>
<li>Suppose the analysis completed but because there was so much occurring in the console (for example, sampling from a posterior) that you missed the warnings/errors and got results that you don’t know have issues.</li>
</ul>
<hr>
<p>Thus, having this system set up to catch errors in every script also helps us automate the entire workflow once we’ve carefully set it up. After each <code>.R</code> script has one of these message-catching scripts, we can run our entire analysis from start to finish from <code>main.R</code> with one command. This not only makes your workspace organized, but also makes it easier for others to reproduce your work if you share your files and folders via a repository.</p>
<hr>
<p>So, now the <code>Error</code> folder will contain .txt files with any warning messages or errors.</p>
<p>Typically, when I’m setting up a new project, I will also add a few other folders such as an <code>Outputs</code> folder, where I will save tables and graphs, and a <code>Report</code> folder, where I might be working on a manuscript.</p>
<p>Now that I’ve mentioned my hierarchy and how I catch errors, I can mention some other things that I believe are absolutely heinous practices.</p>
<p>Many people often will run an entire analysis and have several objects/vectors stored in their Global Environment in <code>R</code> and <code>RStudio</code>. Suppose they’re taking a break, finished with the analysis, turning off the computer, or stepping away for whatever reason, what they’ll typically do is click the save button on the top right pane and “Save the workspace image”. Indeed, if they don’t do that themselves, the IDE <code>RStudio</code> will explicitly ask them if they wish to save their workspace image.</p>
<p>This is a horrific practice and you should never do this because it can lead to several problems such as:</p>
<ul>
<li><p>having several saved objects and packages conflict with one another once they’re all loaded together at once</p></li>
<li><p>having giant workspace images, that will probably cause <code>R</code>, and especially <code>RStudio</code> to constantly crash</p></li>
<li><p>not allowing you to load very specific objects that you need at a time while leaving everything else</p></li>
</ul>
<p>I would say that it is a good idea to never save the workspace image, ever. It is also quite easy to turn off. Simply go the <code>RStudio</code> menu and click <em>Preferences</em>, and in the <em>General</em> section, you will see the following options:</p>
<hr>
<p><img data-enlargeable="" width="500" style="cursor: zoom-in" src="https://res.cloudinary.com/less-likely/image/upload/v1604649526/Site/RStudio_Default_Save_Options.png"></p>
<hr>
<p>It is essential to uncheck everything under <em>R Sessions</em>, <em>Workspace</em>, and <em>History</em>, so that you do not set your self up for a future disaster.</p>
<p>Instead of using these convenient but highly problematic options, always use the <code>saveRDS()</code> base <code>R</code> function, where the first argument is the object in your environment that you want to save, and the second argument is the path where you want to save it, which of course should be using the <code>here()</code> function.</p>
<p>Now suppose I decided to use multiple imputation because I had a dataset with many missing values, and suppose I had a grasp of the missing data mechanism, and so I used something like the not-at-random fully conditional specification approach (<strong>NARFCS</strong>)[@tompsettUseNotatrandomFully2018] to attempt to handle data that I believe to be missing not at random (<strong>MNAR</strong>), and I wanted to save the imputed dataset, and only load the imputed dataset next time. This is how I would do it (in the vaguest way possible). First, I’ll start with the dataset that we generated above and generate missing values via different missing data mechanisms using the <code>ampute()</code> function from the <code>mice</code> package.[@buurenMiceMultivariateImputation2011]</p>
<hr>
<blockquote class="blockquote">
<p><strong>Important</strong>: This is all assuming that one has carefully constructed an imputation model, and that multiple imputation is the most appropriate solution. As many others have pointed out, simply running a script like <code>mice(data)</code> in <code>R</code> without careful thought to the imputation model, is a very, very bad idea. Missing data is an extremely complex topic and I recommend everyone carefully read the works[@buurenFlexibleImputationMissing2018] of missing data researchers such as:</p>
</blockquote>
<ul>
<li><p><a href="https://stefvanbuuren.name/fimd/">Stef van Buuren</a></p>
<blockquote class="blockquote">

</blockquote></li>
<li><p><a href="https://twitter.com/tmorris_mrc">Tim Morris</a></p>
<blockquote class="blockquote">

</blockquote></li>
<li><p><a href="https://www.ctu.mrc.ac.uk/about-us/senior-staff/ian-white/">Ian White</a></p>
<blockquote class="blockquote">

</blockquote></li>
<li><p><a href="https://scholar.google.com/citations?user=5q4fhUoAAAAJ&amp;hl=en">Donald Rubin</a></p>
<blockquote class="blockquote">

</blockquote></li>
<li><p><a href="https://thestatsgeek.com/">Jonathan Bartlett</a></p>
<blockquote class="blockquote">

</blockquote></li>
<li><p><a href="https://www.paulgstf.com/">Paul Gustafson</a></p>
<blockquote class="blockquote">

</blockquote></li>
</ul>
<hr>
</section>
<section id="example-of-a-multiple-imputation-script" class="level2">
<h2 class="anchored" data-anchor-id="example-of-a-multiple-imputation-script">Example of a Multiple Imputation Script</h2>
<hr>
<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"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"01-functions.R"</span>))</span>
<span id="cb7-2"></span>
<span id="cb7-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"beepr"</span>)</span>
<span id="cb7-4"></span>
<span id="cb7-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Package that uses multiple imputation</span></span>
<span id="cb7-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># by chained equations</span></span>
<span id="cb7-7"></span>
<span id="cb7-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mice"</span>)</span>
<span id="cb7-9"></span>
<span id="cb7-10"></span>
<span id="cb7-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Generate Missing Data  --------------------------------</span></span>
<span id="cb7-12"></span>
<span id="cb7-13">study_mnar <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;">ampute</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> study[, <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;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>],</span>
<span id="cb7-14">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prop =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.65</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mech =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MNAR"</span>)</span>
<span id="cb7-15">mnar_patterns <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> study_mnar<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>patterns</span>
<span id="cb7-16">mnar_weight <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> study_mnar<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>weight</span>
<span id="cb7-17">study_mnar_rerun <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;">ampute</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> study[, <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;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>],</span>
<span id="cb7-18">                           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prop =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb7-19">                           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mech =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MNAR"</span>,</span>
<span id="cb7-20">                           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">patterns =</span> mnar_patterns,</span>
<span id="cb7-21">                           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weights =</span> mnar_weight)</span>
<span id="cb7-22">study_mar <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;">ampute</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> study[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</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;">4</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prop =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb7-23">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mech =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MAR"</span>)</span>
<span id="cb7-24">mar_patterns <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> study_mar<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>patterns</span>
<span id="cb7-25">mar_weight <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> study_mar<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>weight</span>
<span id="cb7-26">study_mar_rerun <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;">ampute</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> study[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</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;">4</span>],</span>
<span id="cb7-27">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prop =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb7-28">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mech =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MAR"</span>,</span>
<span id="cb7-29">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">patterns =</span> mar_patterns,</span>
<span id="cb7-30">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weights =</span> mar_weight)</span>
<span id="cb7-31"></span>
<span id="cb7-32">study_mar_rerun[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>over65 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.factor</span>()</span>
<span id="cb7-34">study_mar_rerun[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>male <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-35">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.factor</span>()</span>
<span id="cb7-36">study_mar_rerun[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rxGrp <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-37">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.factor</span>()</span>
<span id="cb7-38"></span>
<span id="cb7-39">df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> study_mnar_rerun<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>amp</span>
<span id="cb7-40">df2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> study_mar_rerun<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>amp</span>
<span id="cb7-41"></span>
<span id="cb7-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Inspect Data</span></span>
<span id="cb7-43"></span>
<span id="cb7-44"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(df) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Inspect data frame</span></span>
<span id="cb7-45"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(df) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># High level summary of dataframe</span></span>
<span id="cb7-46"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(df)) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Look at missing values etc.</span></span>
<span id="cb7-47"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colSums</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(df))</span>
<span id="cb7-48">summarytools<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;">view</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dfSummary</span>(df))</span>
<span id="cb7-49"></span>
<span id="cb7-50"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(df2) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Inspect data frame</span></span>
<span id="cb7-51"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(df2) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># High level summary of dataframe</span></span>
<span id="cb7-52"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(df2)) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Look at missing values etc.</span></span>
<span id="cb7-53"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colSums</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(df2))</span>
<span id="cb7-54">summarytools<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;">view</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dfSummary</span>(df2))</span>
<span id="cb7-55"></span>
<span id="cb7-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prepare Data for Imputation -------------------------</span></span>
<span id="cb7-57"></span>
<span id="cb7-58">temp <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df</span>
<span id="cb7-59">temp2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df2</span>
<span id="cb7-60"></span>
<span id="cb7-61"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">missing_plot</span>(temp)</span>
<span id="cb7-62"></span>
<span id="cb7-63"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">missing_plot</span>(temp2)</span>
<span id="cb7-64"></span>
<span id="cb7-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Set-up predictor matrix</span></span>
<span id="cb7-66"></span>
<span id="cb7-67">predMatrix <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;">make.predictorMatrix</span>(temp)</span>
<span id="cb7-68">predMatrix2 <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;">make.predictorMatrix</span>(temp2)</span>
<span id="cb7-69"></span>
<span id="cb7-70"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Set-up predictor matrix for unidentifiable part:</span></span>
<span id="cb7-71">predSens <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;">matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</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;">6</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>)</span>
<span id="cb7-72"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(predSens) <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;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(temp), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb7-73"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rownames</span>(predSens) <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;">names</span>(temp)</span>
<span id="cb7-74"></span>
<span id="cb7-75"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Set-up list with sensitivity parameter values</span></span>
<span id="cb7-76"></span>
<span id="cb7-77">pSens <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;">rep</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ncol</span>(temp))</span>
<span id="cb7-78"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(pSens) <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;">names</span>(temp)</span>
<span id="cb7-79">pSens[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rxGrp"</span>]] <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="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>.<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb7-80">pSens[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"baseDBP"</span>]] <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="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>.<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb7-81">pSens[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"male"</span>]] <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="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>.<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb7-82">pSens[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"over65"</span>]] <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="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>.<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb7-83"></span>
<span id="cb7-84"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># MICE RI Imputation  ----------------------------------</span></span>
<span id="cb7-85"></span>
<span id="cb7-86">z1 <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;">parlmice</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> temp, <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;">"ri"</span>,</span>
<span id="cb7-87">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predictorMatrix =</span> predMatrix,</span>
<span id="cb7-88">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">m =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb7-89">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cluster.seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1031</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n.core =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb7-90">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n.imp.core =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cl.type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FORK"</span>,</span>
<span id="cb7-91">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ridge =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-04</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.collinear =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb7-92">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.constant =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">allow.na =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb7-93"></span>
<span id="cb7-94">z2 <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;">parlmice</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> temp2, <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;">"pmm"</span>,</span>
<span id="cb7-95">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predictorMatrix =</span> predMatrix2,</span>
<span id="cb7-96">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">m =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb7-97">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cluster.seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1031</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n.core =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb7-98">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ridge =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-04</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">remove.collinear =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb7-99">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n.imp.core =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cl.type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FORK"</span>)</span>
<span id="cb7-100"></span>
<span id="cb7-101">zfinal <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;">cbind</span>(z1, z2)</span>
<span id="cb7-102"></span>
<span id="cb7-103"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Heckman Imputation  ----------------------------------</span></span>
<span id="cb7-104"></span>
<span id="cb7-105">study<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseDBP <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> temp<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseDBP</span>
<span id="cb7-106">JointModelEq<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;">generate_JointModelEq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data=</span>temp,</span>
<span id="cb7-107">                                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">varMNAR=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"baseDBP"</span>)</span>
<span id="cb7-108">JointModelEq[,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"baseDBP_var_sel"</span>] <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;">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="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;">1</span>)</span>
<span id="cb7-109">JointModelEq[,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"baseDBP_var_out"</span>] <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;">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="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;">1</span>)</span>
<span id="cb7-110"></span>
<span id="cb7-111">arg <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;">MNARargument</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> temp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">varMNAR =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"baseDBP"</span>,</span>
<span id="cb7-112">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">JointModelEq =</span> JointModelEq)</span>
<span id="cb7-113"></span>
<span id="cb7-114">arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"age"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ri"</span></span>
<span id="cb7-115">arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"visits"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ri"</span></span>
<span id="cb7-116">arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"weight"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ri"</span></span>
<span id="cb7-117">arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"iq"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ri"</span></span>
<span id="cb7-118">arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"height"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ri"</span></span>
<span id="cb7-119"></span>
<span id="cb7-120">imp1 <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;">parlmice</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>data_mod,</span>
<span id="cb7-121">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>method,</span>
<span id="cb7-122">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predictorMatrix =</span> arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>predictorMatrix,</span>
<span id="cb7-123">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">JointModelEq =</span> arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>JointModelEq,</span>
<span id="cb7-124">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">control =</span> arg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>control,</span>
<span id="cb7-125">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxit =</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;">m =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>,</span>
<span id="cb7-126">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cluster.seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1031</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n.core =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb7-127">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n.imp.core =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cl.type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FORK"</span>)</span>
<span id="cb7-128"></span>
<span id="cb7-129">analysis1 <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;">with</span>(zfinal, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">glm</span>(baseDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> visits <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> weight <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> iq <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> height <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> rxGrp <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> male <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> over65))</span>
<span id="cb7-130">result1 <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;">pool</span>(analysis1)</span>
<span id="cb7-131"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(result1)</span>
<span id="cb7-132"></span>
<span id="cb7-133">z2 <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;">parlmice</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> temp2, <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;">"pmm"</span>,</span>
<span id="cb7-134">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">predictorMatrix =</span> predMatrix2,</span>
<span id="cb7-135">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">m =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">maxit =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb7-136">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cluster.seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1031</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n.core =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb7-137">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n.imp.core =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cl.type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FORK"</span>)</span>
<span id="cb7-138"></span>
<span id="cb7-139">heckman <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;">cbind</span>(imp1, z2)</span>
<span id="cb7-140"></span>
<span id="cb7-141"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">beep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># I will touch on this function below.</span></span>
<span id="cb7-142"></span>
<span id="cb7-143"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">saveRDS</span>(zfinal, <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;">"Main Project"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Data"</span>,</span>
<span id="cb7-144">                     <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"zfinal.rds"</span>))</span></code></pre></div></div>
</div>
<hr>
<p>Here is the workflow truly showing its advantages, <code>saveRDS()</code> is saving a very specific object (<code>zfinal</code>, the imputed dataset) into the <code>Data</code> folder by using the hierarchical structure of the folder which can easily be navigated using <code>here()</code>. Notice how to save something and use <code>here()</code> to specify the location, the first argument is <code>Main Project</code>, followed by <code>Data</code>, and then comes the object name (<code>zfinal.rds</code>).</p>
<p>Now I have saved my imputed dataset as an object called <code>zfinal.rds</code> and it is saved in the <code>Data</code> folder even though I am hypothetically working from the <code>R</code> folder.</p>
<p>Also notice that I use the <code>beep()</code> function from the <a href="https://cran.r-project.org/package=beepr">beepr</a> <code>R</code> package, which can be quite handy in letting you know if a particular script or analysis is done.</p>
<p>Next time, if I cleared my entire global environment and wanted to only load the imputed dataset, I would simply have to just click on the <code>zfinal.rds</code> file in the <code>Data</code> folder and it would load into the environment or I could use the following command,</p>
<hr>
</section>
<section id="saving-and-reading-data-carefully" class="level2">
<h2 class="anchored" data-anchor-id="saving-and-reading-data-carefully">Saving and Reading Data Carefully</h2>
<hr>
<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="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># The function readRDS() and saveRDS()</span></span>
<span id="cb8-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># are possibly the most important base R functions</span></span>
<span id="cb8-3"></span>
<span id="cb8-4">zfinal <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;">"zfinal.rds"</span>,</span>
<span id="cb8-5">             <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;">"Main Project"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Data"</span>,</span>
<span id="cb8-6">                  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"zfinal.rds"</span>))</span></code></pre></div></div>
</div>
<hr>
<p>This gives us full control over the environment, and it’s also why I encourage people to turn off the automatic prompt to save the workspace that <a href="https://rstudio.com/"><code>RStudio</code></a> gives you by default (I am certain even Hadley Wickham has said the same on multiple occasions).</p>
<p>So if I now wanted to include the imputed dataset into one of my <code>.R</code> scripts that I am trying to automate with one command, whether for reproducibility, or speed, etc., I could do it with absolute control.</p>
<p>This is also how I save my models and how I validate them, which is especially handy because running those can also take an excruciatingly long time.</p>
<p>Here’s an example of a script that would be in the <code>04-analysis.R</code> script, I’m leaving out the warning-catching script now to avoid making this too long. I don’t need to load the <a href="https://cran.r-project.org/package=brms"><code>brms</code></a> package because I’m already calling it from the first <code>.R</code> script, <code>01-functions.R</code> (but I’m just showing it for now to avoid confusion), and then I am saving it in the <code>Models</code> folder which is found in the <code>Data</code> folder. And again, the <code>beep()</code> function would let me know when the script is over, and scripts like this can often take very long, due to the computational intensity.</p>
<p>The script below is an analysis script whose results we plan on saving once completed. Due to the arguments I have set (iterations, warmups, chains, and using an imputed dataset), it can often take a long time before it is finished, and if I did happen to do other tasks while I was waiting on that, the output would automatically save to the <code>Models</code> folder via <code>saveRDS()</code>, and I would also receive a notification via the <code>beep()</code> function, preventing me from wasting any time.</p>
<hr>
</section>
<section id="example-modeling-script" class="level2">
<h2 class="anchored" data-anchor-id="example-modeling-script">Example Modeling Script</h2>
<hr>
<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;"># Calling all packages, please report for duty</span></span>
<span id="cb9-2"></span>
<span id="cb9-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"01-functions.R"</span>))</span>
<span id="cb9-4"></span>
<span id="cb9-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"brms"</span>)</span>
<span id="cb9-6"></span>
<span id="cb9-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># This is a script I used previously</span></span>
<span id="cb9-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># where I used Bayes for regularization</span></span>
<span id="cb9-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Although these are all generic options</span></span>
<span id="cb9-10"></span>
<span id="cb9-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prior Information  --------------------------------</span></span>
<span id="cb9-12"></span>
<span id="cb9-13">sample_z <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;">complete</span>(zfinal, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb9-14"></span>
<span id="cb9-15">n_1 <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;">nrow</span>(sample_z) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># of observations</span></span>
<span id="cb9-16"></span>
<span id="cb9-17">k_1 <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;">ncol</span>(sample_z) <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;"># of predictors</span></span>
<span id="cb9-18"></span>
<span id="cb9-19">p0_1 <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;">2</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prior for the number of relevant variables</span></span>
<span id="cb9-20"></span>
<span id="cb9-21">tau0_1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> p0_1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (k_1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> p0_1) <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="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(n_1) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># tau scale</span></span>
<span id="cb9-22"></span>
<span id="cb9-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Regularized horseshoe prior</span></span>
<span id="cb9-24">hs_prior <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;">set_prior</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"horseshoe(scale_global = tau0_1,</span></span>
<span id="cb9-25"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">                      scale_slab = 1)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">class =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"b"</span>)</span>
<span id="cb9-26"></span>
<span id="cb9-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"future"</span>)</span>
<span id="cb9-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plan</span>(multiprocess)</span>
<span id="cb9-29"></span>
<span id="cb9-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Regularized Bayesian quantile</span></span>
<span id="cb9-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># regression using regularized horseshoe prior</span></span>
<span id="cb9-32">brms<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;">brm_multiple</span>(</span>
<span id="cb9-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bf</span>(baseDBP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> age <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> visits <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> weight <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> iq <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> height <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> rxGrp <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> male <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> over65,</span>
<span id="cb9-34">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">quantile =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.50</span>),</span>
<span id="cb9-35">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> zfinal, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prior =</span> hs_prior,</span>
<span id="cb9-36">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">asym_laplace</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_prior =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb9-37">     <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;">1031</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">future =</span> F,</span>
<span id="cb9-38">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">iter =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warmup =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">chains =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb9-39">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cores =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">thin =</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;">combine =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb9-40">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">control =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_treedepth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb9-41">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adapt_delta =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.80</span>)) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-&gt;</span> pen_model_1</span>
<span id="cb9-42"></span>
<span id="cb9-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Principled way of saving results</span></span>
<span id="cb9-44"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">saveRDS</span>(pen_model_1,</span>
<span id="cb9-45">        <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;">"Main Project"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Data"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Models"</span>,</span>
<span id="cb9-46">             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pen_model_1.rds"</span>))</span>
<span id="cb9-47"></span>
<span id="cb9-48"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">beep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div></div>
</div>
<hr>
<p>So I’ve saved the full contents of the fitted model (<code>pen_model_1</code>), which are usually several gigabytes large in size, within the <code>Models</code> folder. Once again, notice how the <code>here()</code> function allows you to work from a subfolder like <code>R</code>, which is inside the <code>Main Project</code> folder, and allows you to specify the hierarchy, and where you are within it, and save to whichever folder you wish, in this case <code>Models</code>, which is inside of <code>Data</code>. Now, I will typically conduct model checks and make sure it is performing well, and not misspecified,</p>
<hr>
<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"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"01-functions.R"</span>))</span>
<span id="cb10-2"></span>
<span id="cb10-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Inspect RHat values ---------------------------</span></span>
<span id="cb10-4"></span>
<span id="cb10-5">rhats_1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pen_model_1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rhats</span>
<span id="cb10-6"></span>
<span id="cb10-7">rhats_1_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (rhats_1 <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;">1.1</span>)</span>
<span id="cb10-8">((<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(rhats_1_df)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb10-9">    (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(rhats_1_df) <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;">ncol</span>(rhats_1_df)) <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>
<span id="cb10-10"></span>
<span id="cb10-11">rhats_1_vec <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.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unlist</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb10-12">  rhats_1[, <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;">ncol</span>(rhats_1)])))</span>
<span id="cb10-13"></span>
<span id="cb10-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pdf</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;">"Outputs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Figures"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Diagnostics"</span>,</span>
<span id="cb10-15">         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OUTCOME_COMP_rhat.pdf"</span>))</span>
<span id="cb10-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc_rhat_hist</span>(rhats_1_vec) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggtitle</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Model 1 Chain Convergence"</span>)</span>
<span id="cb10-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dev.off</span>()</span>
<span id="cb10-19"></span>
<span id="cb10-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Inspect Effective Sample Size ----------------------</span></span>
<span id="cb10-21"></span>
<span id="cb10-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc_neff_hist</span>(rhats_1_vec) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggtitle</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Effective Sample Size"</span>)</span>
<span id="cb10-24"></span>
<span id="cb10-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Inspect Divergences ---------------------------</span></span>
<span id="cb10-26"></span>
<span id="cb10-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pdf</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;">"Outputs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Figures"</span>,</span>
<span id="cb10-28">         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Diagnostics"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OUTCOME_1.pdf"</span>))</span>
<span id="cb10-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc_nuts_divergence</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nuts_params</span>(pen_model_1),</span>
<span id="cb10-30">                     <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log_posterior</span>(pen_model_1))</span>
<span id="cb10-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dev.off</span>()</span>
<span id="cb10-32"></span>
<span id="cb10-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Examine Residual Plots ----------------------------</span></span>
<span id="cb10-34"></span>
<span id="cb10-35">df_resid_stan_1 <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="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fitted</span>(pen_model_1)[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb10-36">                              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">residuals</span>(pen_model_1)[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb10-37"></span>
<span id="cb10-38"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pdf</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;">"Outputs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Figures"</span>,</span>
<span id="cb10-39">         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Diagnostics"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OUTCOME_1.pdf"</span>))</span>
<span id="cb10-40"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df_resid_stan_1,</span>
<span id="cb10-41">       <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;">sample =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">residuals</span>(pen_model_1)[, <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="cb10-42">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_qq</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-43">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_qq_line</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-44">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggtitle</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Model 1 Residuals"</span>)</span>
<span id="cb10-45"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dev.off</span>()</span>
<span id="cb10-46"></span>
<span id="cb10-47">(sum1 <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;">posterior_summary</span>(pen_model_1))[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</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;">8</span>, ])</span>
<span id="cb10-48"></span>
<span id="cb10-49"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc_intervals</span>(pen_model_1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">point_est =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"median"</span>,</span>
<span id="cb10-50">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">prob_outer =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb10-51">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pars =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parnames</span>(pen_model_1)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-52">  ggplot2<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;">scale_y_discrete</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-53">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>),</span>
<span id="cb10-54">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>),</span>
<span id="cb10-55">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>,</span>
<span id="cb10-56">                                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-57">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rect"</span>,</span>
<span id="cb10-58">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xmin =</span> <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.05</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xmax =</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;">ymin =</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;">ymax =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>,</span>
<span id="cb10-59">    <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;">"darkred"</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.075</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-60">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"segment"</span>,</span>
<span id="cb10-61">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <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.05</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> <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.05</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</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;">yend =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>,</span>
<span id="cb10-62">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#990000"</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.4</span>,</span>
<span id="cb10-63">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">75</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <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;">+</span></span>
<span id="cb10-64">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"segment"</span>,</span>
<span id="cb10-65">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</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;">xend =</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;">y =</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;">yend =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>,</span>
<span id="cb10-66">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#990000"</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.4</span>,</span>
<span id="cb10-67">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">75</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <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;">+</span></span>
<span id="cb10-68">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggtitle</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Change in Outcome 1"</span>)</span>
<span id="cb10-69"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dev.off</span>()</span>
<span id="cb10-70"></span>
<span id="cb10-71"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pdf</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;">"Outputs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Figures"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OUTCOME_1.pdf"</span>))</span>
<span id="cb10-72"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mcmc_hist</span>(pen_model_1)</span>
<span id="cb10-73"></span>
<span id="cb10-74"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Posterior Predictive Checks</span></span>
<span id="cb10-75"></span>
<span id="cb10-76"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pdf</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;">"Outputs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Figures"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Diagnostics"</span>,</span>
<span id="cb10-77">         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OUTCOME_1check.pdf"</span>))</span>
<span id="cb10-78"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pp_check</span>(pen_model_1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nsamples =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">250</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-79">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggtitle</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Posterior Predictive Check: Model 1"</span>)</span>
<span id="cb10-80"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dev.off</span>()</span>
<span id="cb10-81"></span>
<span id="cb10-82"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Shows dens_overlay plot by default</span></span>
<span id="cb10-83"></span>
<span id="cb10-84">bayes_rsq1 <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;">bayes_R2</span>(pen_model_1)</span>
<span id="cb10-85"></span>
<span id="cb10-86">bayes_rsq1 <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;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(bayes_rsq1))</span>
<span id="cb10-87"></span>
<span id="cb10-88"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(sum1, <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;">"Outputs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Tables"</span>,</span>
<span id="cb10-89">                     <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OUTCOME_1.csv"</span>))</span></code></pre></div></div>
</div>
<hr>
<p>Once I have fit my model and done some initial checks, I usually conduct some more thorough checks using k-fold cross-validation or nested cross-validation, or bootstrap optimism.</p>
<p>A script of this can be found below.</p>
<hr>
<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;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"01-functions.R"</span>))</span>
<span id="cb11-2"></span>
<span id="cb11-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 10-Fold Cross-Validations -------------------------</span></span>
<span id="cb11-4"></span>
<span id="cb11-5">kfold_1 <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;">kfold</span>(pen_model_1, <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;">10</span>,</span>
<span id="cb11-6">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">save_fits =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cores =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb11-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">saveRDS</span>(kfold_1, <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;">"Data"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Models"</span>,</span>
<span id="cb11-8">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Validation"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kfold_1.rds"</span>))</span>
<span id="cb11-9">kfp_1 <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;">kfold_predict</span>(kfold_1)</span>
<span id="cb11-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">saveRDS</span>(kfp_1, <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;">"Data"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Models"</span>,</span>
<span id="cb11-11">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Validation"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kfp_1.rds"</span>))</span>
<span id="cb11-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kfold_rmse</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> kfp_1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>y,</span>
<span id="cb11-13">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yrep =</span> kfp_1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>yrep,</span>
<span id="cb11-14">           <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;">"rmse"</span>,</span>
<span id="cb11-15">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">reps =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5000</span>,</span>
<span id="cb11-16"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cores =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]][[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"t"</span>]]<span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">)</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-&gt;</span> kfold_rmse_1</span>
<span id="cb11-17"></span>
<span id="cb11-18">kfold_rmse_1 <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;">median</span>(kfold_rmse_1)</span>
<span id="cb11-19"></span>
<span id="cb11-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">saveRDS</span>(kfold_rmse_1,</span>
<span id="cb11-21">        <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;">"Data"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Models"</span>,</span>
<span id="cb11-22">             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Validation"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kfold_rmse_1.rds"</span>))</span></code></pre></div></div>
</div>
<hr>
<p>Once I’ve written all my analysis and validation scripts, I’ll typically create a subfolder in the <code>Outputs</code> folder called <code>Figures</code> and <code>Tables</code> and save them appropriately with the help <code>here()</code>.</p>
<hr>
</section>
<section id="example-table-script" class="level2">
<h2 class="anchored" data-anchor-id="example-table-script">Example Table Script</h2>
<hr>
<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"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">source</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;">"R"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"01-functions.R"</span>))</span>
<span id="cb12-2"></span>
<span id="cb12-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Read in Validation Objects ------------------------</span></span>
<span id="cb12-4"></span>
<span id="cb12-5">kfold_1 <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;">"kfold_1.rds"</span>,</span>
<span id="cb12-6">                   <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;">"Main Project"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Data"</span>,</span>
<span id="cb12-7">                        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Models"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Validation"</span>,</span>
<span id="cb12-8">                        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kfold_1.rds"</span>))</span>
<span id="cb12-9">kfold_2 <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;">"kfold_1.rds"</span>,</span>
<span id="cb12-10">                   <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;">"Main Project"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Data"</span>,</span>
<span id="cb12-11">                        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Models"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Validation"</span>,</span>
<span id="cb12-12">                        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kfold_2.rds"</span>))</span>
<span id="cb12-13">kfp_1 <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;">"kfp_1.rds"</span>,</span>
<span id="cb12-14">                 <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;">"Main Project"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Data"</span>,</span>
<span id="cb12-15">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Models"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Validation"</span>,</span>
<span id="cb12-16">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kfp_1.rds"</span>))</span>
<span id="cb12-17">kfp_2 <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;">"kfp_1.rds"</span>,</span>
<span id="cb12-18">                 <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;">"Main Project"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Data"</span>,</span>
<span id="cb12-19">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Models"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Validation"</span>,</span>
<span id="cb12-20">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kfp_2.rds"</span>))</span>
<span id="cb12-21"></span>
<span id="cb12-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Extract Estimates from Objects ---------------------</span></span>
<span id="cb12-23"></span>
<span id="cb12-24">KFOLDIC_1 <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;">c</span>(kfold_1[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"estimates"</span>]][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>],</span>
<span id="cb12-25">                     kfold_2[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"estimates"</span>]][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>])</span>
<span id="cb12-26">KFOLDIC_SE_1 <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;">c</span>(kfold_1[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"estimates"</span>]][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],</span>
<span id="cb12-27">                        kfold_2[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"estimates"</span>]][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb12-28">BAYES_R2 <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;">c</span>(bayes_rsq1, bayes_rsq2), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb12-29">KFOLD_ELPD_1 <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;">c</span>(kfold_1[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"estimates"</span>]][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb12-30">                        kfold_2[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"estimates"</span>]][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb12-31">KFOLD_ELPD_SE_1 <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;">c</span>(kfold_1[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"estimates"</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;">2</span>],</span>
<span id="cb12-32">                           kfold_2[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"estimates"</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;">2</span>])</span>
<span id="cb12-33"></span>
<span id="cb12-34">Outcome <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OUTCOME_1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OUTCOME_2"</span>)</span>
<span id="cb12-35"></span>
<span id="cb12-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Construct Data Frames ------------------------------</span></span>
<span id="cb12-37"></span>
<span id="cb12-38">table4 <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>(Outcome, BAYES_R2, KFOLD_ELPD_1,</span>
<span id="cb12-39">                     KFOLD_ELPD_SE_1, KFOLDIC_1,</span>
<span id="cb12-40">                     KFOLDIC_SE_1)</span>
<span id="cb12-41"></span>
<span id="cb12-42"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(table4) <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Outcome"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Bayes R^2"</span>,</span>
<span id="cb12-43">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"10-fold CV ELPD"</span>,</span>
<span id="cb12-44">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"10-fold CV ELPD SE"</span>,</span>
<span id="cb12-45">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"10-fold CV IC"</span>,</span>
<span id="cb12-46">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"10-fold CV IC SE"</span>)</span>
<span id="cb12-47"></span>
<span id="cb12-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Export as Tables ----------------------------------</span></span>
<span id="cb12-49"></span>
<span id="cb12-50"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(table4, <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;">"Main Project"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Outputs"</span>,</span>
<span id="cb12-51">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Tables"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Table4.csv"</span>))</span>
<span id="cb12-52"></span>
<span id="cb12-53">table5 <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>(Outcome, KFOLD_ELPD_1,</span>
<span id="cb12-54">                     KFOLD_ELPD_SE_1,</span>
<span id="cb12-55">                     KFOLDIC_1, KFOLDIC_SE_1)</span>
<span id="cb12-56"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(table5) <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;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Outcome"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"10-fold CV ELPD"</span>,</span>
<span id="cb12-57">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"10-fold CV ELPD SE"</span>,</span>
<span id="cb12-58">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"10-fold CV IC"</span>,</span>
<span id="cb12-59">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"10-fold CV IC SE"</span>)</span>
<span id="cb12-60"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(table5,</span>
<span id="cb12-61">          <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;">"Main Project"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Outputs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Tables"</span>,</span>
<span id="cb12-62">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Table5.csv"</span>))</span>
<span id="cb12-63"></span>
<span id="cb12-64"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Save Tables From Sensitivity Analyses --------------</span></span>
<span id="cb12-65"></span>
<span id="cb12-66"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(sens_table_OUTCOME_1,</span>
<span id="cb12-67">          <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;">"Main Project"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Outputs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Tables"</span>,</span>
<span id="cb12-68">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Table7_OUTCOME_1.csv"</span>))</span>
<span id="cb12-69"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(sens_table_OUTCOME_2,</span>
<span id="cb12-70">          <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;">"Main Project"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Outputs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Tables"</span>,</span>
<span id="cb12-71">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Table7_OUTCOME_2.csv"</span>))</span></code></pre></div></div>
</div>
<hr>
<p>Then, I’ll go back to the <code>README.Rmd</code> file, make notes of the hierarchy of the entire folder and subfolders, and what’s been completed, and what still needs to be done.</p>
<p>Now, suppose I deleted all of my saved models, imputed data, graphs, and tables, (which would be a devastating blow!) and only had the original dataset and organized scripts. Anyone could go into my project and simply highlight the entire <code>main.R</code> file and run it, and they would get all the same outputs and models, assuming a seed was set in advance, which is essential. Although, it might take them a long time to get the same outputs (if computationally intensive)… they would likely be able to get all the exact same results.</p>
<hr>
</section>
</section>
<section id="possible-drawbacks-of-this-approach" class="level1">
<h1>Possible Drawbacks of this Approach</h1>
<hr>
<p>Every proposal tends to have drawbacks or limitations, and those who do not explicitly tell you about them are misleading you. In the approach I have outlined above, one major drawback is that it takes a somewhat long time to set up and therefore could deter many statisticians and data analysts. The other drawback is that by loading all your functions and libraries in the first <code>01_functions.R</code> script, there is potential for conflict between functions, therefore you’ll have to be mindful of what packages you need and when. Indeed, I ran into this issue when loading the <code>brms</code> package, which had several functions that conflicted with the base <code>R</code> functions. So please be mindful of this.</p>
<p>Further, and most importantly, I have no evidence that this approach can truly prevent errors, it is simply a belief I have as a result of my own experiences and suggesting them to others, and hearing positive comments. So please, take that into account, although I would be grateful if you were able to share your positive or even negative experiences using this approach below.</p>
<hr>
<p>Please, please annotate your scripts, as I have done so several times above to explain some of the functions. This is not only helpful for others who are trying to go through your code and understand it, but also for yourself. If you end up forgetting what function does what, and what steps you were taking, you will be in for a really frustrating time, and possibly prone to making serious mistakes.</p>
<p>Here’s what my project folders tend to look like (figure below). And here is a <a href="https://github.com/zadrafi/statworkflow">template GitHub repo</a> to show what the structure typically looks like.</p>
<hr>
<p><img data-enlargeable="" width="400" style="cursor: zoom-in" src="https://res.cloudinary.com/less-likely/image/upload/v1592068111/Site/Screen_Shot_2020-06-13_at_11.38.26_AM.png"></p>
<hr>
<p>It should go without saying that sharing your data (if possible) and code will help you and your collaborators catch errors before it’s too late, but also, sharing them with others/the public after a project is done will <em>also</em> help catch possible errors that you/your collaborators/reviewers didn’t catch, which may mislead other researchers and also result in a much more stressful situation for you.</p>
<p>And last but not least, it is also essential to give extensive details on which version of <code>R</code> you used and which packages you used and their versions. This is because many scripts that once worked on previous versions of the software may no longer give the same results or may not even work at all. In order for someone to reproduce your results, they’ll need to know the environment on which you ran your analyses on. You can provide these details easily simply by running the script <code>sessionInfo()</code>, which should be at the end of every <code>R</code> script you run.</p>
<hr>
</section>
<section id="helpful-resources" class="level1">
<h1>Helpful Resources</h1>
<hr>
<ul>
<li><a href="https://stackoverflow.com/questions/1429907/workflow-for-statistical-analysis-and-report-writing">Workflow for Statistical Analysis and Report Writing</a></li>
</ul>
<hr>
<ul>
<li><a href="https://stackoverflow.com/questions/19967478/how-to-save-data-file-into-rdata">How to Save Data File into .RData?</a></li>
</ul>
<hr>
<ul>
<li><a href="https://www.youtube.com/watch?v=Ry2xjTBtNFE">Basic Data Entry Using Excel</a></li>
</ul>
<hr>
<ul>
<li><a href="https://www.kristianbrock.com/post/send-me-data/">Sending Me Data in Excel</a></li>
</ul>
<hr>
<ul>
<li><a href="https://happygitwithr.com/">Happy Git and GitHub for the useR</a></li>
</ul>
<hr>
</section>
<section id="environment" class="level1">
<h1>Environment</h1>
<hr>
<p>The analyses were run on:</p>
<hr>
<div class="cell">
<pre><code>#&gt; R version 4.5.2 (2025-10-31)
#&gt; Platform: aarch64-apple-darwin20
#&gt; Running under: macOS Tahoe 26.3
#&gt; 
#&gt; Matrix products: default
#&gt; BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
#&gt; LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
#&gt; 
#&gt; Random number generation:
#&gt;  RNG:     Mersenne-Twister 
#&gt;  Normal:  Inversion 
#&gt;  Sample:  Rejection 
#&gt;  
#&gt; locale:
#&gt; [1] C.UTF-8/C.UTF-8/C.UTF-8/C/C.UTF-8/C.UTF-8
#&gt; 
#&gt; time zone: America/New_York
#&gt; tzcode source: internal
#&gt; 
#&gt; attached base packages:
#&gt; [1] stats     graphics  grDevices utils     datasets  methods   base     
#&gt; 
#&gt; loaded via a namespace (and not attached):
#&gt;  [1] jsonlite_2.0.0        gtable_0.3.6          compiler_4.5.2        dplyr_1.1.4           tidyselect_1.2.1     
#&gt;  [6] Rcpp_1.1.0            parallel_4.5.2        dichromat_2.0-0.1     gridExtra_2.3         scales_1.4.0         
#&gt; [11] yaml_2.3.12           fastmap_1.2.0         here_1.0.2            ggplot2_4.0.1         R6_2.6.1             
#&gt; [16] generics_0.1.4        curl_7.0.0            knitr_1.51            htmlwidgets_1.6.4     tibble_3.3.0         
#&gt; [21] rprojroot_2.1.1       pillar_1.11.1         RColorBrewer_1.1-3    rlang_1.1.6           V8_8.0.1             
#&gt; [26] inline_0.3.21         rstan_2.32.7          xfun_0.55             S7_0.2.1              RcppParallel_5.1.11-1
#&gt; [31] otel_0.2.0            cli_3.6.5             magrittr_2.0.4        digest_0.6.39         grid_4.5.2           
#&gt; [36] lifecycle_1.0.4       StanHeaders_2.32.10   vctrs_0.6.5           evaluate_1.0.5        glue_1.8.0           
#&gt; [41] farver_2.1.2          QuickJSR_1.8.1        codetools_0.2-20      stats4_4.5.2          pkgbuild_1.4.8       
#&gt; [46] colorspace_2.1-2      rmarkdown_2.30        matrixStats_1.5.0     tools_4.5.2           loo_2.9.0            
#&gt; [51] pkgconfig_2.0.3       htmltools_0.5.9</code></pre>
</div>
<hr>
</section>
<section id="references" class="level1">
<h1>References</h1>
<hr>


<!-- -->

</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2020,
  author = {Panda, Sir and Rafi, Zad},
  title = {Quality {Control} in {Statistical} {Analyses}},
  date = {2020-06-13},
  url = {https://lesslikely.com/posts/statistics/statistical-quality-control.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2020" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2020). <span>‘Quality Control in Statistical
Analyses’</span>. <a href="https://lesslikely.com/posts/statistics/statistical-quality-control.html">https://lesslikely.com/posts/statistics/statistical-quality-control.html</a>.
</div></div></section></div> ]]></description>
  <category>statistics</category>
  <guid>https://lesslikely.com/posts/statistics/statistical-quality-control.html</guid>
  <pubDate>Sat, 13 Jun 2020 04:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/v1613136545/Site/diagram.png" medium="image" type="image/png"/>
</item>
<item>
  <title>Book Review: Regression and Other Stories by Gelman, Hill, and Vehtari</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/statistics/regression-stories.html</link>
  <description><![CDATA[ 





<hr>
<p>Over a decade ago, <a href="https://statmodeling.stat.columbia.edu/">Andrew Gelman</a> and <a href="https://steinhardt.nyu.edu/faculty/Jennifer_L_Hill">Jennifer Hill</a> gave applied researchers a comprehensive book <em>(<a href="https://www.amazon.com/Analysis-Regression-Multilevel-Hierarchical-Models/dp/052168689X">Data Analysis Using Regression and Multilevel/Hierarchical Models</a>)</em> on fitting simple and complex statistical models in <code>R</code> both from a classical framework and a Bayesian one. Now they’re back with an updated version and a new author (<a href="https://users.aalto.fi/~ave/">Aki Vehtari</a>).</p>
<p>Much has changed in applied statistics since 2006 (when the book was first released). The primary software used at the time and in the book to fit Bayesian models was <code>BUGS</code> (Bayesian inference Using Gibbs Sampling).</p>
<p>However, both <code>BUGS</code> and some of the <code>R</code> code in the first edition are now outdated. The new edition updates the <code>R</code> code and contains intuitive instructions on how to fit simple and complex models using the probabilistic programming language, <a href="https://mc-stan.org/"><code>Stan</code></a> (also developed by Gelman and <a href="https://mc-stan.org/about/team/">colleagues</a>), which is now used in several fields (even for <a href="https://statmodeling.stat.columbia.edu/2019/04/24/postdoctoral-position-in-vancouver-using-stan-working-on-wine-for-reals/">studying wine!</a>).</p>
<p>Indeed, running a Bayesian regression model in <code>R</code> is now as simple as</p>
<hr>
<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="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># I use the sample PlantGrowth dataset in R</span></span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rstanarm"</span>)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bayesplot"</span>)</span>
<span id="cb1-4">pg <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> PlantGrowth</span>
<span id="cb1-5">model1 <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;">stan_glm</span>(weight <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> group, </span>
<span id="cb1-6">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> pg, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">refresh =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb1-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(model1)</span>
<span id="cb1-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb1-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Model Info:</span></span>
<span id="cb1-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  function:     stan_glm</span></span>
<span id="cb1-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  family:       gaussian [identity]</span></span>
<span id="cb1-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  formula:      weight ~ group</span></span>
<span id="cb1-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  algorithm:    sampling</span></span>
<span id="cb1-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  sample:       4000 (posterior sample size)</span></span>
<span id="cb1-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  priors:       see help('prior_summary')</span></span>
<span id="cb1-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  observations: 30</span></span>
<span id="cb1-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  predictors:   3</span></span>
<span id="cb1-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb1-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Estimates:</span></span>
<span id="cb1-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;               mean   sd   10%   50%   90%</span></span>
<span id="cb1-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; (Intercept)  5.0    0.2  4.8   5.0   5.3 </span></span>
<span id="cb1-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; grouptrt1   -0.4    0.3 -0.7  -0.4   0.0 </span></span>
<span id="cb1-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; grouptrt2    0.5    0.3  0.1   0.5   0.9 </span></span>
<span id="cb1-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; sigma        0.6    0.1  0.5   0.6   0.8 </span></span>
<span id="cb1-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb1-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Fit Diagnostics:</span></span>
<span id="cb1-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;            mean   sd   10%   50%   90%</span></span>
<span id="cb1-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; mean_PPD 5.1    0.2  4.9   5.1   5.3  </span></span>
<span id="cb1-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb1-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; The mean_ppd is the sample average posterior predictive distribution of the outcome variable (for details see help('summary.stanreg')).</span></span>
<span id="cb1-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb1-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; MCMC diagnostics</span></span>
<span id="cb1-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;               mcse Rhat n_eff</span></span>
<span id="cb1-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; (Intercept)   0.0  1.0  2534 </span></span>
<span id="cb1-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; grouptrt1     0.0  1.0  2503 </span></span>
<span id="cb1-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; grouptrt2     0.0  1.0  2719 </span></span>
<span id="cb1-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; sigma         0.0  1.0  3035 </span></span>
<span id="cb1-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; mean_PPD      0.0  1.0  3484 </span></span>
<span id="cb1-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; log-posterior 0.0  1.0  1681 </span></span>
<span id="cb1-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb1-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; For each parameter, mcse is Monte Carlo standard error, n_eff is a crude measure of effective sample size, and Rhat is the potential scale reduction factor on split chains (at convergence Rhat=1).</span></span>
<span id="cb1-42"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(model1)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/regression-stories_files/figure-html/unnamed-chunk-2-1.svg" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>Another key difference between the first edition and the new edition is that the 2006 book attempted to cover several topics at once. It contained instructions on how to fit simple models in a classical framework all the way up to multilevel models in a Bayesian framework. The new edition attempts to reduce this information overload by splitting itself into two volumes.</p>
<p>The first volume <em>(Regression and Other Stories)</em> covers fitting simple and complex models using <code>R</code> and <code>Stan</code>, and is oriented towards the applied researcher or statistician, who wants a smooth introduction to fitting Bayesian models using <code>Stan</code> without diving into much theory or math.</p>
<p>A draft copy of the table of contents in the new edition can be <a href="../../uploads/regressiontoc.pdf">found here</a>, though it’s very likely that the published edition will have some changes.</p>
<p>The book does not cover much of multilevel modeling, which is reserved for the second volume, <em>Advanced Regression and Multilevel Models</em> (planned to be released in the next year or two).</p>
<p>Make no mistake, although both of these books are unlikely to touch on a serious amount of theory or math, they are not books that can be read without serious engagement and practice. Every chapter contains enough math for the reader to understand the concepts being discussed with exercises at the end to solidify these concepts.</p>
<p>The chapter exercises are incredibly similar to these exam questions that Gelman created for his Applied Regression class.</p>
<p>Question: <a href="https://statmodeling.stat.columbia.edu/2019/06/01/question-1-of-our-applied-regression-final-exam/">1</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/02/question-2-of-our-applied-regression-final-exam-and-solution-to-question-1/">2</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/03/question-3-of-our-applied-regression-final-exam-and-solution-to-question-2/">3</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/04/question-4-of-our-applied-regression-final-exam-and-solution-to-question-3/">4</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/05/question-5-of-our-applied-regression-final-exam-and-solution-to-question-4/">5</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/06/question-6-of-our-applied-regression-final-exam-and-solution-to-question-5/">6</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/07/question-7-of-our-applied-regression-final-exam-and-solution-to-question-6/">7</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/08/question-8-of-our-applied-regression-final-exam-and-solution-to-question-7/">8</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/09/question-9-of-our-applied-regression-final-exam-and-solution-to-question-8/">9</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/10/question-10-of-our-applied-regression-final-exam-and-solution-to-question-9/">10</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/11/question-11-of-our-applied-regression-final-exam-and-solution-to-question-10/">11</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/12/question-12-of-our-applied-regression-final-exam-and-solution-to-question-11/">12</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/13/question-13-of-our-applied-regression-final-exam-and-solution-to-question-12/">13</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/14/question-14-of-our-applied-regression-final-exam-and-solution-to-question-13/">14</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/15/question-15-of-our-applied-regression-final-exam-and-solution-to-question-14/">15</a>, <a href="https://statmodeling.stat.columbia.edu/2019/06/16/were-done-with-our-applied-regression-final-exam-and-solution-to-question-15/">solution to 15</a>.</p>
<p>I suspect that many of the commenters of the blog who had some difficulty with these questions would have had an easier time had they had the opportunity to read the book.</p>
<p>The new edition also covers several news stories from the past few years (some of which long-time blog readers will be familiar with) and gives readers a set of tools to think critically about these stories and how proper statistical thinking could’ve prevented mishaps. In addition, it incorporates concepts that Gelman and colleagues have developed and solidified over the years, since the first edition was published, such as the concept of <a href="https://doi.org/10.1177%2F1745691614551642">Type-M and Type-S errors</a>.</p>
<p>Overall, the book is quite comprehensive and will leave the reader with a rich set of tools to think critically about statistics and to fit models in the real world. I look forward to grabbing a hard copy once the book is out, which seems to be in the <a href="https://twitter.com/avehtari/status/1251188631487774720">summer to fall of 2020</a>.</p>
<hr>
<blockquote class="blockquote">
<p>Update: Looks like the <a href="https://www.amazon.com/Regression-Stories-Analytical-Methods-Research/dp/110702398X">book is out!</a></p>
</blockquote>



<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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2019,
  author = {Panda, Sir and Rafi, Zad},
  title = {Book {Review:} {Regression} and {Other} {Stories} by
    {Gelman,} {Hill,} and {Vehtari}},
  date = {2019-06-11},
  url = {https://lesslikely.com/posts/statistics/regression-stories.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2019" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2019). <span>‘Book Review: Regression and Other
Stories by Gelman, Hill, and Vehtari’</span>. <a href="https://lesslikely.com/posts/statistics/regression-stories.html">https://lesslikely.com/posts/statistics/regression-stories.html</a>.
</div></div></section></div> ]]></description>
  <guid>https://lesslikely.com/posts/statistics/regression-stories.html</guid>
  <pubDate>Tue, 11 Jun 2019 04:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1587793393/Site/gelman_raos_2020.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Book Review: Fisher, Neyman, and the Creation of Classical Statistics</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/statistics/classical-lehmann.html</link>
  <description><![CDATA[ 





<hr>
<p>Erich Lehmann’s <a href="https://www.springer.com/us/book/9781441994998">last book</a>,<span class="citation" data-cites="Lehmann2011-vs"><sup>1</sup></span> which was published after his death, is on the history of classical statistics and its creators. Specifically, how his mentor Jerzy Neyman and his adversary Ronald Fisher helped lay the foundations for the methods that are used today in several fields.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700110/Site/classicalgiants.png" alt="Picture of the giants who founded frequentist statistics such as Egon Pearson, Ronald Fisher, and Jerzy Neyman" style="width:80%"></p>
<hr>
<section id="a-very-brief-history-of-classical-statistics" class="level1">
<h1>A Very Brief History of Classical Statistics</h1>
<hr>
<p>This post is intended to be a general review/summary of the book, which I recommend to everyone and anyone who is interested in statistics and science. The book clears up several misconceptions people have about how frequentist statistics came to be the dominant school of statistics. Thus, I want to go over four topics from Lehmann’s book that I believe people should know more about:</p>
<hr>
<ul>
<li><p>How the founders of classical statistics viewed Bayesian inference</p></li>
<li><p>What they each developed</p></li>
<li><p>How they came to become so conflicted</p></li>
<li><p>And how their views changed over time</p></li>
</ul>
<hr>
</section>
<section id="where-are-the-bayesians" class="level1">
<h1>Where Are The Bayesians?</h1>
<hr>
<p>As Stephen Senn points out in his <a href="https://www.youtube.com/watch?v=vJIc_9wzh6Y">Fisher Memorial Lecture</a> at the Royal Statistical Society, there is a common myth that everyone who practiced applied statistics before the early 20th century was using Bayesian inference and doing everything correctly, but then Fisher came in and created significance testing, thus giving researchers a powerful tool to easily hack their data and produce publishable results, and now we have several replication crises because of this.</p>
<p>Of course, this is far from the truth and any thorough investigation into the history of statistics will clear up this up amongst many other misconceptions.</p>
<p>As several individuals may know, it was Thomas Bayes who came up with Bayes theorem and it was Richard Price who disseminated most of his writings after Bayes’s death. However, as many self-identified Bayesians will attest, using Bayes’ theorem does not make one a Bayesian. It is actually quite hard to know how Bayes would react to modern Bayesian inference. The Bayesian inference that we are familiar with today can be attributed to Pierre-Simon Laplace, who popularized what is now known as “objective Bayes.”</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700141/Site/Pierre-Simon-Laplace_1749-1827.jpg" alt="Portrait of Pierre Simon Laplace" style="width:40%"></p>
<hr>
<p>Back then, it was not called “Bayesian inference” but was referred to as “inverse probability” and it was a method used by many before the dominance of classical statistics. So this is one part that common myths get right. Inverse probability did indeed have a moment in history before the dominance of frequentist statistics.</p>
<p>Laplace, and several others popularized such methods, but around the end of the 19th century, the tides began to shift. Several mathematicians and statisticians began to discourage the use of inverse probability because they saw it as a nonrigorous method of data analysis.</p>
<p>This can be seen in the following passages about Fisher.</p>
<hr>
<blockquote class="blockquote">
<p>“His first publication on this new approach to inference was a 1930 paper “Inverse probability.” The paper begins with a critique of the inverse (Bayesian) method. This section ends with Fisher’s asking:</p>
<p><strong>If, then, we follow writers like Boole, Venn and Chrystal in rejecting the inverse argument as devoid of foundation and incapable even of consistent application</strong>, how are we to avoid the staggering falsity of saying that however extensive our knowledge of the values of x may be, yet we know nothing and can know nothing about the values of <img src="https://latex.codecogs.com/png.latex?%5Ctheta"> ?” (78)</p>
</blockquote>
<hr>
<p>Thus, Fisher was not the first to reject inverse probability, he was building on arguments from proto frequentists who already began to condemn inverse probability. Neyman was also a serious critic of inverse probability. In fact, he was probably more of a critic of it at a later point in time then Fisher (much on that later)!</p>
<hr>
<blockquote class="blockquote">
<p>“On one subject, Fisher and Neyman agreed. Fisher, after 1922, and Neyman, after 1937, were <strong>united in their strong opposition to the use of prior distributions</strong> (unless they were <strong>based on substantial empirical evidence</strong>).” (90)</p>
</blockquote>
<hr>
<p>Although the two giants of classical statistics both condemned inverse probability, it withstood their influential criticisms.</p>
<hr>
<blockquote class="blockquote">
<p>“It seems ironic that one of the most significant developments after Fisher and Neyman had established their foundations was to rejuvenate an approach they both had strongly opposed and thought to have vanquished: inverse probability…</p>
<p>The nineteenth century approach to inverse probability, championed particularly by Laplace, considered the prior distribution to represent complete ignorance. This concept, now called objective Bayes, was taken up and improved by the Cambridge geophysicist Harold Jeffreys, culminating in his 1939 book, “<em>Theory of Probability</em>.”</p>
<p>A different Bayesian approach, called subjective, was proposed by Ramsey (1926) and Bruno de Finetti in the 1930s. It considered probability as a measure of a person’s subjective degree of uncertainty about a situation. This view came into its own with the publication in 1954 of L. J. Savage’s book, “<em>Foundations of Statistics</em>,” in which he derives the existence of such subjective probabilities from a few, quite plausible, axioms.” (91)</p>
</blockquote>
<hr>
<p>Now that we have looked at how the founders of classical statistics viewed and attempted to discourage the use of inverse probability, we can move onto a brief summary of each of their individual contributions.</p>
<hr>
</section>
<section id="fishers-contributions" class="level1">
<h1>Fisher’s Contributions</h1>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1559517576/Site/fisher_old.jpg" alt="Picture of Ronald Fisher sitting and smoking" style="width:50%"></p>
<hr>
<p>Much of Fisher’s early work was a result of two individuals, Karl Pearson and William Gosset. Pearson’s work on the method of moments to estimate parameters led to Fisher developing his superior estimation method, maximum likelihood, which he presented in his 1922 foundations paper, “<em>On the mathematical foundations of theoretical statistics</em>.”</p>
<hr>
<blockquote class="blockquote">
<p>“Having defined the problem of statistics to be the estimation of parameters, Fisher states the properties that he desires for his estimators. They are consistency, efficiency, and sufficiency…</p>
<p>He then proposes what he had already suggested earlier in the section on <strong>the solution of the estimation problem, the method of maximum likelihood</strong>, which “consists, then, simply of choosing such values of these parameters as have the maximum likelihood.” Fisher believes that this method satisfies his three criteria, in particular that it satisfied the criterion of sufficiency, although he states that he “is not satisfied as to the mathematical rigor of any proof which I can put forward to that effect.” He also claims that sufficiency implies efficiency…</p>
<p>Thus, in this paper Fisher has not only <strong>formulated the general problem of optimal estimation, but he has also provided a solution</strong>. It is a stunning achievement.” (10)</p>
</blockquote>
<hr>
<p>Gosset’s initial work on test statistics, his inability derive proofs for small sample methods, and constant prodding led to Fisher developing several statistical tests which ended up being published in his highly influential book, <em>Statistical Methods For Research Workers</em>,</p>
<hr>
<blockquote class="blockquote">
<p>“For testing the value of a population mean, it had been customary to use a statistic equivalent to what today is called Student’s t, and to refer to the normal distribution. For large samples, this provided a good approximation.</p>
<p>However, Gosset soon realized that for <strong>the small samples with which he had to work, the approximation was inadequate</strong>. He then had the crucial insight that exact results could be obtained by making an additional assumption, namely that the form of the distribution of the observations is known. Gosset undertook to determine it for the case that the underlying distribution is normal, and he obtained the correct result, although he was not able to give a rigorous proof.</p>
<p>The first proof was obtained (although not published) by Fisher in 1912. His proof was finally published in 1915 [4], together with the corresponding proof for the correlation coefficient that Student had conjectured in a second paper of 1908(b). Fisher followed this in 1921 [14] with a derivation of the distribution of the intraclass correlation coefficient. And then, as a result of constant prodding and urging by Gosset, he found a number of additional small-sample distributions, and in 1925 presented the totality of these results in his book, <em>“Statistical Methods for Research Workers.”</em> (6)</p>
</blockquote>
<hr>
<p>In the book, Fisher’s main focus was on statistical testing and not estimation, and he made this clear,</p>
<hr>
<blockquote class="blockquote">
<p>“…the prime object of this book is to put into the hands of research workers… <strong>the means of applying statistical tests accurately to numerical data accumulated in their own laboratories</strong> … and later refers to the exact distributions with the use of which this book is chiefly concerned… Thus, the book does not primarily deal with estimation but with significance testing. In fact, estimation is never again mentioned.” (16)</p>
</blockquote>
<hr>
<p>His section about chi-squared tests and significance testing became highly influential,</p>
<hr>
<blockquote class="blockquote">
<p>“<strong>In preparing this table we have borne in mind that in practice we do not want to know the exact value of P for any observed</strong> <img src="https://latex.codecogs.com/png.latex?%5Cchi%7B2%7D">, but, in the first place, whether or not the observed value is open to suspicion. If P is between .1 and .9 there is certainly no reason to suspect the hypothesis tested. If it is below .02 it is strongly indicated that the hypothesis fails to account for the whole of the facts. <strong>We shall not often be astray if we draw a conventional line at .05 and consider that higher values of</strong> <img src="https://latex.codecogs.com/png.latex?%5Cchi%7B2%7D"> indicate a real discrepancy.” (17)</p>
</blockquote>
<hr>
<p>He also presents examples,</p>
<hr>
<blockquote class="blockquote">
<p>“In the first of these, in particular, he finds a p-value between 0.01 and 0.02 and concludes: “If we take P = 0.05 as the limit of significant deviation, <strong>we shall say that in this case the deviations from expectation are significant</strong>.” (17)</p>
</blockquote>
<hr>
<p>And he expanded on significance testing with analysis of variance, which he had derived while working at Rothamsted analyzing crop data. The book was a large success,</p>
<hr>
<blockquote class="blockquote">
<p>“The first edition of 1,050 copies was sold out after three years, and the second edition of 1,250 copies in another two. Every two to three years necessitated a new edition, which usually contained some improvements and often additions. The size of the editions steadily increased and the eleventh edition of 1950 ran to 7,500 copies. The last edition, the fourteenth, was published posthumously in 1970 from notes Fisher had prepared before his death in 1962.” (25)</p>
</blockquote>
<hr>
<p>And set the groundwork for his next task, discussing experimental methods, which would be published in his second book, <em>The Design of Experiments</em>. In it, he discusses how techniques like randomization were necessary for the validity of statistical tests and how they perform amongst a wide variety of distributions,</p>
<hr>
<blockquote class="blockquote">
<p>“Randomisation properly carried out … ensures that the estimates of error will take proper care of all such causes of different growth rates, and <strong>relieves the experimenter from the anxiety of considering and estimating the magnitude of the innumerable causes by which his data may be disturbed.</strong> The one flaw in Darwin’s procedure was the absence of randomisation…</p>
<p>It seems to have escaped recognition that the physical act of randomisation which, as has been shown, is necessary for the validity of any test of significance, affords the means, in respect of any particular body of data, of examining the wider hypothesis <strong>in which no normality of distribution is implied</strong>.” (66)</p>
</blockquote>
<hr>
<p>Although he had proposed randomization tests as a way of dealing with nonnormal distributions, due to their tedious calculations, they never became popular at the time. The book also touched on several other concepts such as randomized blocks, Latin squares, and factorial designs. He also made his position very clear on significance tests and the null hypothesis,</p>
<hr>
<blockquote class="blockquote">
<p>“By increasing the size of the experiment, we can render it more sensitive, meaning by this that it will allow of the detection of a lower degree of sensory discrimination… . <strong>Since in every case the experiment is capable of disproving, but never of proving this hypothesis</strong>, we may say that the value of the experiment is increased whenever it permits the null hypothesis to be more readily disproved.” (64)</p>
</blockquote>
<hr>
<p>Here we can see Fisher’s concept of statistical power, though “sensitivity” was never a quantified concept. He also clearly states his position on the null hypothesis, that we can never accept it, <a href="../../statistics/evidence-of-absence">a mistake that many researchers continue to make today</a>.</p>
<p>Now that we have discussed some of Fisher’s contributions to classical statistics, we can discuss the contributions of Jerzy Neyman.</p>
<hr>
</section>
<section id="neymans-contributions" class="level1">
<h1>Neyman’s Contributions</h1>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700127/Site/Jerzy_Neyman.jpg" alt="Photo of Jerzy Neyman and his colleagues" style="width:40%"></p>
<hr>
<p>Just like Fisher, Neyman was also impacted by Gosset. However, the influence was indirect. In the 1920s, Egon Pearson, had come across the small-sample tests that both Fisher and Gosset had popularized and had the realization that he must make a name for himself if he ever wished to be free of his father’s influence.</p>
<hr>
<blockquote class="blockquote">
<p>“In 1925-6, I was in a state of puzzlement, and realized that, <strong>if I was to continue an academic career as a mathematical statistician</strong>, <strong>I must construct for myself what might be termed a statistical philosophy</strong>, which would have to combine what I accepted from K. P.’s large- sample tradition with the newer ideas of Fisher.” (7)</p>
</blockquote>
<hr>
<p>Thus, he contacted Gosset about practical usage of the t-test, to which Gosset replied,</p>
<hr>
<blockquote class="blockquote">
<p>“Even if the chance is very small, say .00001, that doesn’t in itself necessarily prove that the sample is not drawn randomly from the population [specified by the hypothesis]; <strong>what it does is to show that if there is any alternative hypothesis</strong> which will explain the occurrence of the sample with a more reasonable probability, say .05 (such as that it belongs to a different population or that the sample wasn’t random or whatever will do the trick), you will be very much more inclined to consider that the original hypothesis is not true.” (E. S. Pearson, 1939.)</p>
<p>“In his obituary of Gosset, Pearson continues, Gosset’s reply had a tremendous influence on the direction of my subsequent work, for the first paragraph contains the germ of that idea which has formed the basis of all the later joint researches of Neyman and myself. It is the simple suggestion that the only valid reason for rejecting a statistical hypothesis is that <strong>some alternative explains the observed events with a greater degree of probability</strong>.” (7)</p>
</blockquote>
<hr>
<p>As a result, Pearson decided to collaborate with someone who was not taught by his father, but who also had the mathematical abilities to create a generalizable theorem that he had in mind. Thus, began the collaboration between Neyman and Pearson.</p>
<p>In 1928, they published a paper in <em>Biometrika</em> titled, <em>“On the use and interpretation of certain test criteria,”</em> where they introduced two kinds of errors,</p>
<hr>
<blockquote class="blockquote">
<ol type="1">
<li><p>Sometimes,when hypothesis A is rejected, <img src="https://latex.codecogs.com/png.latex?%5CSigma"> will in fact have been drawn from <img src="https://latex.codecogs.com/png.latex?%5CPi">.</p></li>
<li><p>More often, in accepting hypothesis A, <img src="https://latex.codecogs.com/png.latex?%5CSigma"> will really have been drawn from [some alternative population] <img src="https://latex.codecogs.com/png.latex?%5CPi">. (31)</p></li>
</ol>
</blockquote>
<hr>
<p>As Lehmann notes, the paper was a great achievement,</p>
<hr>
<blockquote class="blockquote">
<p>“It introduces the consideration of alternatives, the two kinds of error, and the distinction between simple and composite hypotheses. In addition, of course, it proposes the likelihood ratio test. This test is intuitively appealing, and Neyman and Pearson show that in a number of important cases it leads to very satisfactory solutions. It has become the standard approach to new testing problems.” (34)</p>
<p>But the Neyman-Pearson lemma was still incomplete. It was between the years of 1930 and 1933 that Neyman had several insights into how to improve the theory, which Pearson already had felt satisfied with.</p>
<p>“In the next letter, dated March 8, Neyman suggests that he and Egon must “fix a certain plan, as we have lot of problems already started and then left in the wood.” He lists several such problems, among them: to finish what I have started to do with the variation calculus. You will understand it in a moment.</p>
<p>To reduce for a given level the errors of rejecting a true hypothesis, we may use any test. Now we want to find a test which would 1) <strong>reduce the probability of rejecting a true hypothesis to the level</strong> <img src="https://latex.codecogs.com/png.latex?%5Cleq%20%5Cvarepsilon"> and 2) <strong>such that the probability of accepting a false hypothesis should be minimum</strong>. – We find that if such a test exists, then <strong>it is the</strong> <img src="https://latex.codecogs.com/png.latex?%5Clambda">-test. I am now shure [sic] that in a few days I shall be ready. This will show that the “<img src="https://latex.codecogs.com/png.latex?%5Clambda"> principle” is not only a principle but that <strong>there are arguments to prove that it is really “the best test</strong>.”” (35)</p>
</blockquote>
<hr>
<p>These correspondences led to their 1933 paper,</p>
<p><em>“On the Problem of the Most Efficient Tests of Statistical Hypotheses.”</em> in which both authors introduce the novel idea of behavioral guidance,</p>
<hr>
<blockquote class="blockquote">
<p>“Without hoping to know whether each separate hypothesis is true or false, <strong>we may search for rules to govern our behavior</strong> with regard to them, in following which we insure that, in the long run of experience, <strong>we shall not be too often wrong</strong>.” (36)</p>
</blockquote>
<hr>
<p>As Lehmann notes,</p>
<hr>
<blockquote class="blockquote">
<p>“After outlining the general theory, the paper in the next section deals with the case of simple hypotheses and brings the statement and proof of the basic result, now known as the <strong>Neyman-Pearson Fundamental Lemma</strong>. It states that for testing a simple hypothesis against a simple alternative, <strong>the test that at a given level maximizes the probability of rejection is the likelihood ratio test at that level</strong>.” (36)</p>
</blockquote>
<hr>
<p>Lehmann summarizes much of the collaboration with the following,</p>
<hr>
<blockquote class="blockquote">
<p>“The collaboration falls into two quite distinct parts. In the early stages, the important ideas, including in particular that of the likelihood ratio principle, all come from Pearson. In fact, Neyman frequency misunderstands them, and continually tries to interpret them in terms of inverse probability.</p>
<p>On the other hand, Pearson is sold on the likelihood ratio principle, which is intuitively appealing and which seems to give reasonable solutions in the cases on which they try it out. But for Neyman, as he is gradually catching on, intuitive appeal is not enough. If the principle is really as good as it appears to be, there ought to be logical justification.</p>
<p>And then one day in early 1930, he sees the light. Since there are two sources of error, one of which is being controlled, the best test is the one minimizing the other one. And from then on, it is Neyman who has the new ideas and Pearson is the reluctant follower. Neyman formulates, and shortly thereafter proves, the Fundamental Lemma and realizes that in some special cases there exist what they later call uniformly most powerful tests. These turn out to coincide with the likelihood ratio tests.” (39)</p>
</blockquote>
<hr>
</section>
<section id="the-fallout-between-the-creators-of-classical-statistics" class="level1">
<h1>The Fallout Between The Creators Of Classical Statistics</h1>
<hr>
<p>The conflict between Neyman and Fisher is well known, however, very few are able to accurately point out what lead to each individual strongly detesting the other.</p>
<p>In fact, early correspondences between Neyman and Fisher showed that they were incredibly friendly towards one another. In 1932, Neyman asked Fisher to review their 1933 paper before they submitted it, to which Fisher replied,</p>
<hr>
<blockquote class="blockquote">
<p>“I should be very much interested to see your paper on “the best tests,” as the whole question of tests of significance seems to me to be of immense philosophical importance, and the work you showed me was surely of great promise. It is quite probable that if the work is submitted to the Royal Society, I might be asked to act as referee, and in that case I shall certainly not refuse.” (45)</p>
</blockquote>
<hr>
<p>Fisher not only read the paper, but read it so carefully that he was able to catch a mathematical error and point it out to Neyman and Pearson before it was published,</p>
<hr>
<blockquote class="blockquote">
<p>“When the paper appeared in 1933, the omission was corrected, and a footnote acknowledged that, “We are indebted to Dr.&nbsp;R. A. Fisher – for kindly calling our attention to the fact that we had originally omitted to refer to this restriction.” (46)</p>
</blockquote>
<hr>
<p>Neyman thanked Fisher for his help,</p>
<hr>
<blockquote class="blockquote">
<p>Neyman: “Pearson writes that you have recommended our paper for publication. Although it maybe considered ridiculous to thank a judge, I have intense feeling of gratefulness, which I hope you will kindly accept…” (57)</p>
<p>Fisher replies, “It was a great pleasure to hear from you again.” (57)</p>
<p>Neyman: “I am often thinking that it would be very useful for me to work with you. Unfortunately, this requires considerable amount of money – without speaking of your consent – of course…” (57)</p>
<p>Fisher answers, “You may be sure of my consent,” and in the next letter, “I like hearing from Poland. Best wishes for a Merry Christmas.” (58)</p>
</blockquote>
<hr>
<p>Unfortunately, their relationship began to degrade after the retirement of Karl Pearson. The department of applied statistics that he was the head of was split into the department of statistics, which would be led by his son Egon, and the department of genetics, where Fisher was appointed as Galton professor. Thus, Fisher, one of the creators of classical statistics, was not allowed to teach statistics, while in the floor downstairs, Egon Pearson (a man that he was surely not fond of) was leading the new statistics department.</p>
<p>This change in tone could be seen by the correspondence between Neyman and Fisher following Fisher’s appointment as Galton professor,</p>
<hr>
<blockquote class="blockquote">
<p>“Dr.&nbsp;Pearson writes me that soon you will be Galton Professor at the University College, London. Very probably <strong>this means a general reorganization of the Department of Applied Statistics and possibly new people will be needed</strong>. I know that there are many statisticians in England and that many of them would be willing to work under you. But improbable things do happen sometimes and you may have a vacant position in your laboratory. In that case please consider whether I can be of any use.” (58)</p>
</blockquote>
<hr>
<p>Fisher replies,</p>
<hr>
<blockquote class="blockquote">
<p>“Many thanks for your letter of congratulation. You will be interested to hear that the <strong>Dept. of Statistics has now been separated officially from the Galton Laboratory</strong>. I think Egon Pearson is designated as Reader in Statistics. This arrangement will be much laughed at, but it will be rather a poor joke, I fancy, for both Pearson and myself. I think, however, we will make the best of it.</p>
<p><strong>I shall not lecture on statistics, but probably on “the logic of experimentation,</strong>” so that my lectures will not be troubled by students who cannot see through a wire fence. I wish I had a fine place for you, but it will be long before my new department can be given any sort of unity and coherence, and you will be head of a faculty before I shall be able to get much done. <strong>If in England, do not fail to see me at University College</strong>.” (58)</p>
</blockquote>
<hr>
<p>Of course, there is little doubt that both Karl and Egon Pearson contributed to the fallout between Neyman and Fisher. In 1929, Egon Pearson had submitted a critical review of the second edition of <em>Statistical Methods For Research Workers</em> to <em>Nature</em>,</p>
<hr>
<blockquote class="blockquote">
<p>“There is one criticism, however, which must be made from the statistical point of view. A large number of the tests developed are based…on the assumption that the population sampled is of the “normal” form. That this is the case may be gathered from a careful reading of the text, but the point is not sufficiently emphasized.</p>
<p>It does not appear reasonable to lay stress on the “exactness” of the tests when no means whatever are given of appreciating how rapidly they become inexact as the population sampled diverges from normality. That the tests, for example, connected with the analysis of variance are far more dependent on normality than those involving Student’s z (or t) distribution is almost certain, but no clear indication of the need for caution in their application is given.” (22)</p>
</blockquote>
<hr>
<p>As Lehmann points out, Fisher was deeply offended by this review. Nearly six years later (1935), Neyman encountered a similar reaction when he submitted a paper titled, “Statistical problems in agricultural experimentation” pointing out problems with some of the concepts that Fisher had introduced in his book, <em>The Design of Experiments</em>. Fisher was furious,</p>
<hr>
<blockquote class="blockquote">
<p>“I had hoped that Dr.&nbsp;Neyman’s paper would be on a subject with which the author was fully acquainted, and on which he could speak with authority, as in the case of his address to the Society delivered last summer. Since seeing the paper, <strong>I have come to the conclusion that Dr.&nbsp;Neyman had been somewhat unwise in his choice of topics</strong>… (59)</p>
<p>Were it not for the persistent effort which Dr.&nbsp;Neyman and Dr.&nbsp;Pearson had made to treat what they speak of as problems of estimation, by means merely of tests of significance, I have no doubt that Dr.&nbsp;Neyman would not have been in any danger of falling into the series of misunderstandings which his paper revealed.” (59)</p>
</blockquote>
<hr>
<p>Correspondences from there on out had become hostile,</p>
<hr>
<blockquote class="blockquote">
<p>“Neyman later (Reid 1982, p.&nbsp;126) recalls that a week after this meeting, Fisher stopped by his room at University College:</p>
<p>And he said to me that he and I are in the same building… . That, as I know, he had published a book – and that’s Statistical Methods for Research Workers – and he is upstairs from me so he knows something about my lectures – that from time to time I mention his ideas, this and that – and that this would be quite appropriate if I were not here in the College but, say, in California – but if I am going to be at University College, then this is not acceptable to him.</p>
<p><strong>And then I said, “<em>Do you mean that if I am here, I should just lecture using your book</em>?” And then he gave an affirmative answer. And I said, “<em>Sorry, no. I cannot promise that</em>.” And then he said, “<em>Well, if so, then from now on I shall oppose you in all my capacities</em>.”</strong></p>
<p>Reid also reports (p.&nbsp;124) that, After the Royal Statistical Society meeting of March 28, relations between workers on the two floors of K. P.’s old preserve became openly hostile. One evening, late that spring, Neyman and Pearson returned to their department after dinner to do some work.</p>
<p>Entering, they were startled to find <strong>strewn on the floor the wooden models which Neyman had used to illustrate his talk on the relative advantages of randomized blocks and Latin squares</strong>. They were regularly kept in a cupboard in the laboratory. Both Neyman and Pearson always believed that the models were removed by Fisher in a fit of anger.” (59)</p>
</blockquote>
<hr>
</section>
<section id="there-is-no-one-neyman-nor-one-fisher" class="level1">
<h1>There Is No One Neyman Nor One Fisher</h1>
<hr>
<p>When Fisher released his first edition of <em>Statistical Methods For Research Workers</em> (SMRW), he recommended 5% or 1% as good choices for significance levels, with the latter being used when a “more stringent requirement was necessary.” Fisher was also not interested in exact P-values as pointed out in the section discussing his contributions.</p>
<p>Many of these views changed as he released later editions of his SMRW and his new book, <em>Statistical Methods for Scientific Inference</em> (SMSI). For example, he no longer recommended a particular level of significance,</p>
<hr>
<blockquote class="blockquote">
<p>“In his late, 1956, book SMSI, Fisher protested that “<strong>no scientific worker has a fixed level of significance at which from year to year, and in all circumstances, he rejects hypotheses; he rather gives his mind to each particular case, and his ideas</strong>” (52)</p>
</blockquote>
<hr>
<p>In the 13th edition of SMRW he stated,</p>
<hr>
<blockquote class="blockquote">
<p>“<strong>The actual value of P obtainable from the table by interpolation indicates the strength of the evidence against the hypothesis</strong>. A value of <img src="https://latex.codecogs.com/png.latex?%5Cchi%7B2%7D"> exceeding the 5 per cent. point is seldom to be disregarded.” (52)</p>
</blockquote>
<hr>
<p>Thus, Fisher had changed his mind on the topic.</p>
<p>Neyman too had a significant change of mind during the course of his collaboration with Pearson. At first, he constantly defaulted to inverse probability methods, as noted by Pearson’s letter to him in 1978,</p>
<hr>
<blockquote class="blockquote">
<p>“I have eight letters which you wrote to me during February and March 1929, trying to persuade me to put my name as a joint author. But you had introduced an a priori law of probability…, and I was not willing to start from this basis. True we had given the inverse probability as an alternative approach in our 1928 Part I paper, but I must in 1927-28 still have been ready to concede to your line of thought.</p>
<p>However, <strong>by 1929 I had come down firmly to agree with Fisher that prior distributions should not be used</strong>, except in cases where they were based on real knowledge, e.g., in some Mendelian problems. <strong>You were disappointed, but accepted my decision</strong>; after all, the whole mathematical development in the paper was yours.” (42)</p>
</blockquote>
<hr>
<p>Though eventually Neyman abandoned his interest in inverse probability and became a serious critic,</p>
<hr>
<blockquote class="blockquote">
<p>“His conviction of the inapplicability of the inverse method had by then become a fundamental part of his statistical philosophy, <strong>from which he never wavered</strong>.” (42)</p>
</blockquote>
<hr>
<p>Although this post is mainly fixated on the book by Lehmann, I would like to at least paste this one relevant passage from <a href="https://www.jstor.org/stable/23736900">Hulbert &amp; Lombardi, 2009</a>,<span class="citation" data-cites="Hurlbert2009-ks"><sup>2</sup></span></p>
<hr>
<blockquote class="blockquote">
<p>“In a later philosophical essay, Neyman (1977: 112) recounted their cloud-seeding studies, and labeled P values of 0.09, 0.03, and &lt; 0.01 reported in their earlier paper (Lovasich et al.&nbsp;1971), as “approximately significant,” “significant,” and “highly significant,” respectively. The dichotomies of the paleoFisherian and Neyman-Pearsonian frameworks were quietly admitted to be less appropriate than more nebulous interpretations — at least in cloud work!</p>
<p>Indeed, Cox (2006a: 43, 195) has noted that “the differences between Fisher and Neyman … were not nearly as great as the asperity of the arguments between them might suggest … [and in] actual practice … Neyman … often reported p-values whereas some of Fisher’s use of tests … was much more dichotomous”!</p>
</blockquote>
<hr>
<p>As we can see from a summary of Lehmann’s book, the individuals who founded classical statistics were skilled and talented individuals who were also complex and had various reasons for doing what they did. I hope this blog post encourages readers to fully dive into Lehmann’s book where he gives a far more detailed account of Fisher and Neyman’s contributions to classical statistics.</p>
<hr>
</section>
<section id="references" class="level1">
<h1>References</h1>
<hr>



</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" data-entry-spacing="2" data-line-spacing="2">
<div id="ref-Lehmann2011-vs" class="csl-entry">
1. Lehmann EL. (2011). <span>“Fisher, neyman, and the creation of classical statistics.”</span> Springer New York. doi: <a href="https://doi.org/10.1007/978-1-4419-9500-1">10.1007/978-1-4419-9500-1</a>.
</div>
<div id="ref-Hurlbert2009-ks" class="csl-entry">
2. Hurlbert SH, Lombardi CM. (2009). <span>“Final collapse of the neyman-pearson decision theoretic framework and rise of the <span class="nocase">neoFisherian</span>.”</span> <strong>46</strong>:311–349. doi: <a href="https://doi.org/10.5735/086.046.0501">10.5735/086.046.0501</a>.
</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2018,
  author = {Panda, Sir and Rafi, Zad},
  title = {Book {Review:} {Fisher,} {Neyman,} and the {Creation} of
    {Classical} {Statistics}},
  date = {2018-12-30},
  url = {https://lesslikely.com/posts/statistics/classical-lehmann.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2018" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2018). <span>‘Book Review: Fisher, Neyman, and the
Creation of Classical Statistics’</span>. <a href="https://lesslikely.com/posts/statistics/classical-lehmann.html">https://lesslikely.com/posts/statistics/classical-lehmann.html</a>.
</div></div></section></div> ]]></description>
  <guid>https://lesslikely.com/posts/statistics/classical-lehmann.html</guid>
  <pubDate>Sun, 30 Dec 2018 05:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1559517576/Site/fisher_old.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>GAMS</title>
  <dc:creator>Sir Panda</dc:creator>
  <link>https://lesslikely.com/posts/statistics/gams.html</link>
  <description><![CDATA[ 





<div class="cell" data-layout-align="center">
<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>(mgcv) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fit and interrogate GAMs</span></span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Tidy and flexible data manipulation</span></span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(marginaleffects) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Compute conditional and marginal effects</span></span>
<span id="cb1-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Flexible plotting</span></span>
<span id="cb1-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(patchwork) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Combining ggplot objects</span></span>
<span id="cb1-6"></span>
<span id="cb1-7"></span>
<span id="cb1-8">plant <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> CO2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as_tibble</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plant =</span> Plant, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> Type, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> Treatment) <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;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plant =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(plant, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ordered =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>))</span></code></pre></div></div>
</details>
</div>
<hr>
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<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">model_1 <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;">gam</span>(</span>
<span id="cb2-2">  uptake <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">s</span>(plant, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bs =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"re"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">s</span>(conc, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> treatment, <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;">7</span>),</span>
<span id="cb2-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> plant,</span>
<span id="cb2-6">  <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;">"REML"</span>,</span>
<span id="cb2-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Gamma</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">link =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"log"</span>)</span>
<span id="cb2-8">)</span>
<span id="cb2-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(model_1)</span>
<span id="cb2-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb2-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Family: Gamma </span></span>
<span id="cb2-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Link function: log </span></span>
<span id="cb2-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb2-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Formula:</span></span>
<span id="cb2-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; uptake ~ treatment * type + s(plant, bs = "re") + s(conc, by = treatment, </span></span>
<span id="cb2-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     k = 7)</span></span>
<span id="cb2-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb2-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Parametric coefficients:</span></span>
<span id="cb2-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                                  Estimate Std. Error t value Pr(&gt;|t|)    </span></span>
<span id="cb2-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; (Intercept)                        3.5161     0.0638   55.14  &lt; 2e-16 ***</span></span>
<span id="cb2-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; treatmentchilled                  -0.1132     0.0902   -1.26  0.21399    </span></span>
<span id="cb2-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; typeMississippi                   -0.3120     0.0902   -3.46  0.00098 ***</span></span>
<span id="cb2-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; treatmentchilled:typeMississippi  -0.3604     0.1275   -2.83  0.00631 ** </span></span>
<span id="cb2-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ---</span></span>
<span id="cb2-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</span></span>
<span id="cb2-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb2-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Approximate significance of smooth terms:</span></span>
<span id="cb2-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                              edf Ref.df     F p-value    </span></span>
<span id="cb2-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; s(plant)                    7.03   8.00  8.02  &lt;2e-16 ***</span></span>
<span id="cb2-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; s(conc):treatmentnonchilled 5.19   5.68 83.89  &lt;2e-16 ***</span></span>
<span id="cb2-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; s(conc):treatmentchilled    5.01   5.55 58.97  &lt;2e-16 ***</span></span>
<span id="cb2-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ---</span></span>
<span id="cb2-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</span></span>
<span id="cb2-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb2-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; R-sq.(adj) =  0.957   Deviance explained = 95.5%</span></span>
<span id="cb2-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; -REML = 239.08  Scale est. = 0.010327  n = 84</span></span>
<span id="cb2-37"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(model_1)</span>
<span id="cb2-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                      (Intercept)                 treatmentchilled                  typeMississippi </span></span>
<span id="cb2-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                          3.51609                         -0.11321                         -0.31196 </span></span>
<span id="cb2-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; treatmentchilled:typeMississippi                       s(plant).1                       s(plant).2 </span></span>
<span id="cb2-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                         -0.36041                         -0.04123                         -0.01529 </span></span>
<span id="cb2-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                       s(plant).3                       s(plant).4                       s(plant).5 </span></span>
<span id="cb2-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                          0.05652                         -0.04010                          0.02693 </span></span>
<span id="cb2-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                       s(plant).6                       s(plant).7                       s(plant).8 </span></span>
<span id="cb2-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                          0.01317                         -0.05593                          0.04989 </span></span>
<span id="cb2-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                       s(plant).9                      s(plant).10                      s(plant).11 </span></span>
<span id="cb2-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                          0.00604                         -0.21558                          0.09712 </span></span>
<span id="cb2-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                      s(plant).12    s(conc):treatmentnonchilled.1    s(conc):treatmentnonchilled.2 </span></span>
<span id="cb2-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                          0.11846                          5.23232                          1.13324 </span></span>
<span id="cb2-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    s(conc):treatmentnonchilled.3    s(conc):treatmentnonchilled.4    s(conc):treatmentnonchilled.5 </span></span>
<span id="cb2-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                         -1.90483                          0.12919                          0.23606 </span></span>
<span id="cb2-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    s(conc):treatmentnonchilled.6       s(conc):treatmentchilled.1       s(conc):treatmentchilled.2 </span></span>
<span id="cb2-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                          1.20260                          3.69059                          2.11750 </span></span>
<span id="cb2-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;       s(conc):treatmentchilled.3       s(conc):treatmentchilled.4       s(conc):treatmentchilled.5 </span></span>
<span id="cb2-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                         -2.36770                          0.06347                          0.23654 </span></span>
<span id="cb2-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;       s(conc):treatmentchilled.6 </span></span>
<span id="cb2-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                          0.96775</span></span></code></pre></div></div>
</details>
</div>
<hr>
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<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;">plot</span>(model_1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">select =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shade =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">h =</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;">lty =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>)</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/gams_files/figure-html/unnamed-chunk-5-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="2100"></p>
</figure>
</div>
</div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<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;">plot_predictions</span>(model_1,</span>
<span id="cb4-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">condition =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conc"</span>,</span>
<span id="cb4-3">  <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;">"link"</span></span>
<span id="cb4-4">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb4-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Linear predictor (link scale)"</span>,</span>
<span id="cb4-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Average smooth effect of concentration"</span>,</span>
<span id="cb4-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Aggregated across treatments and types"</span></span>
<span id="cb4-9">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/gams_files/figure-html/unnamed-chunk-6-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="2100"></p>
</figure>
</div>
</div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<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"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot_predictions</span>(model_1,</span>
<span id="cb5-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">condition =</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;">"conc"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"type"</span>),</span>
<span id="cb5-3">  <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;">"link"</span></span>
<span id="cb5-4">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb5-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Linear predictor (link scale)"</span>,</span>
<span id="cb5-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Average smooth effect of concentration"</span>,</span>
<span id="cb5-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Per treatment, per type"</span></span>
<span id="cb5-9">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/gams_files/figure-html/unnamed-chunk-7-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="2100"></p>
</figure>
</div>
</div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<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;">plot_slopes</span>(model_1,</span>
<span id="cb6-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">variables =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conc"</span>,</span>
<span id="cb6-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">condition =</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;">"conc"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment"</span>),</span>
<span id="cb6-4">  <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;">"link"</span></span>
<span id="cb6-5">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</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;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb6-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1st derivative of the linear predictor"</span>,</span>
<span id="cb6-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Conditional slopes of the concentration effect"</span>,</span>
<span id="cb6-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Per treatment, per type"</span></span>
<span id="cb6-11">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/gams_files/figure-html/unnamed-chunk-8-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="2100"></p>
</figure>
</div>
</div>
<details class="code-fold">
<summary>Code</summary>
<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;">plot_predictions</span>(model_1,</span>
<span id="cb7-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">condition =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conc"</span>,</span>
<span id="cb7-3">  <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 class="at" style="color: #657422;
background-color: null;
font-style: inherit;">points =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb7-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rug =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb7-5">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb7-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Expected response"</span>,</span>
<span id="cb7-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Average smooth effect of concentration"</span>,</span>
<span id="cb7-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Aggregated across treatments and types"</span></span>
<span id="cb7-10">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/gams_files/figure-html/unnamed-chunk-8-2.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="2100"></p>
</figure>
</div>
</div>
<details class="code-fold">
<summary>Code</summary>
<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;">plot_predictions</span>(model_1,</span>
<span id="cb8-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">condition =</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;">"conc"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"type"</span>),</span>
<span id="cb8-3">  <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 class="at" style="color: #657422;
background-color: null;
font-style: inherit;">points =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb8-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rug =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb8-5">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb8-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb8-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Expected response"</span>,</span>
<span id="cb8-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Average smooth effect of concentration"</span>,</span>
<span id="cb8-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Per treatment, per type"</span></span>
<span id="cb8-10">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/gams_files/figure-html/unnamed-chunk-8-3.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="2100"></p>
</figure>
</div>
</div>
<details class="code-fold">
<summary>Code</summary>
<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;">plot_slopes</span>(model_1,</span>
<span id="cb9-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">variables =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conc"</span>,</span>
<span id="cb9-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">condition =</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;">"conc"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"type"</span>),</span>
<span id="cb9-4">  <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="cb9-5">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</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;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb9-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb9-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1st derivative of the expected response"</span>,</span>
<span id="cb9-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Conditional slopes of the concentration effect"</span>,</span>
<span id="cb9-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Per treatment, per type"</span></span>
<span id="cb9-11">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/gams_files/figure-html/unnamed-chunk-8-4.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="2100"></p>
</figure>
</div>
</div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<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">Xp <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>(model_1, <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;">"lpmatrix"</span>)</span>
<span id="cb10-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dim</span>(Xp)</span>
<span id="cb10-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 84 28</span></span>
<span id="cb10-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(Xp)</span>
<span id="cb10-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1] "(Intercept)"                      "treatmentchilled"                 "typeMississippi"                 </span></span>
<span id="cb10-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [4] "treatmentchilled:typeMississippi" "s(plant).1"                       "s(plant).2"                      </span></span>
<span id="cb10-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [7] "s(plant).3"                       "s(plant).4"                       "s(plant).5"                      </span></span>
<span id="cb10-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [10] "s(plant).6"                       "s(plant).7"                       "s(plant).8"                      </span></span>
<span id="cb10-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [13] "s(plant).9"                       "s(plant).10"                      "s(plant).11"                     </span></span>
<span id="cb10-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [16] "s(plant).12"                      "s(conc):treatmentnonchilled.1"    "s(conc):treatmentnonchilled.2"   </span></span>
<span id="cb10-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [19] "s(conc):treatmentnonchilled.3"    "s(conc):treatmentnonchilled.4"    "s(conc):treatmentnonchilled.5"   </span></span>
<span id="cb10-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [22] "s(conc):treatmentnonchilled.6"    "s(conc):treatmentchilled.1"       "s(conc):treatmentchilled.2"      </span></span>
<span id="cb10-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [25] "s(conc):treatmentchilled.3"       "s(conc):treatmentchilled.4"       "s(conc):treatmentchilled.5"      </span></span>
<span id="cb10-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [28] "s(conc):treatmentchilled.6"</span></span>
<span id="cb10-15">beta <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;">coef</span>(model_1)</span>
<span id="cb10-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all.equal</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(beta), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(Xp))</span>
<span id="cb10-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] TRUE</span></span></code></pre></div></div>
</details>
</div>
<hr>
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<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">preds <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>(Xp <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%*%</span> beta)</span>
<span id="cb11-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all.equal</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fitted</span>(model_1), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(preds))</span>
<span id="cb11-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] TRUE</span></span>
<span id="cb11-4">newXp <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>(model_1,</span>
<span id="cb11-5">  <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;">"lpmatrix"</span>,</span>
<span id="cb11-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">newdata =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb11-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plant =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Qn1"</span>,</span>
<span id="cb11-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nonchilled"</span>,</span>
<span id="cb11-9">    <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;">"Mississippi"</span>,</span>
<span id="cb11-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">278</span></span>
<span id="cb11-11">  )</span>
<span id="cb11-12">)</span>
<span id="cb11-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dim</span>(newXp)</span>
<span id="cb11-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1]  1 28</span></span>
<span id="cb11-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(newXp <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%*%</span> beta)</span>
<span id="cb11-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   [,1]</span></span>
<span id="cb11-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 1 27.6</span></span></code></pre></div></div>
</details>
</div>
<hr>
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<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">conc_seq <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;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(plant<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(plant<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">length.out =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>)</span>
<span id="cb12-2">newdat <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="cb12-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc =</span> conc_seq,</span>
<span id="cb12-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plant =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Qn1"</span>,</span>
<span id="cb12-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nonchilled"</span>,</span>
<span id="cb12-6">  <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;">"Mississippi"</span></span>
<span id="cb12-7">)</span>
<span id="cb12-8">newXp <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>(model_1, <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;">"lpmatrix"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">newdata =</span> newdat)</span>
<span id="cb12-9">conc_coefs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> model_1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>smooth[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>first.para<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>model_1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>smooth[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>last.para</span>
<span id="cb12-10">conc_coefs</span>
<span id="cb12-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 17 18 19 20 21 22</span></span></code></pre></div></div>
</details>
</div>
<hr>
<figure class="figure">
<p><img src="https://lesslikely.com/post/statistics/forecastedsales.png" width="700" style="cursor: zoom-in" class="figure-img"></p>
<figcaption>
Trace plot of imputed datasets.
</figcaption>
</figure>
<hr>
<section id="python" class="level2">
<h2 class="anchored" data-anchor-id="python">Python</h2>
<hr>
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<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">model_2 <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;">glm</span>(</span>
<span id="cb13-2">  uptake <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">poly</span>(conc, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> treatment <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> plant,</span>
<span id="cb13-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> plant,</span>
<span id="cb13-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Gamma</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">link =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"log"</span>)</span>
<span id="cb13-6">)</span>
<span id="cb13-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot_predictions</span>(model_1,</span>
<span id="cb13-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">condition =</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;">"conc"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"type"</span>),</span>
<span id="cb13-9">  <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 class="at" style="color: #657422;
background-color: null;
font-style: inherit;">points =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb13-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rug =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb13-11">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb13-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Expected response"</span>,</span>
<span id="cb13-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Average smooth effect of concentration"</span>,</span>
<span id="cb13-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Per treatment, per type"</span></span>
<span id="cb13-16">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/gams_files/figure-html/unnamed-chunk-12-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="2100"></p>
</figure>
</div>
</div>
<details class="code-fold">
<summary>Code</summary>
<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"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot_predictions</span>(model_2,</span>
<span id="cb14-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">condition =</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;">"conc"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"type"</span>),</span>
<span id="cb14-3">  <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 class="at" style="color: #657422;
background-color: null;
font-style: inherit;">points =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb14-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rug =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb14-5">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb14-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Expected response"</span>,</span>
<span id="cb14-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Average smooth effect of concentration"</span>,</span>
<span id="cb14-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Per treatment, per type"</span></span>
<span id="cb14-10">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/gams_files/figure-html/unnamed-chunk-12-2.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="2100"></p>
</figure>
</div>
</div>
</div>
<hr>
</section>
<section id="r" class="level2">
<h2 class="anchored" data-anchor-id="r">R</h2>
<hr>
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<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"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">avg_comparisons</span>(model_1,</span>
<span id="cb15-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">newdata =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">datagrid</span>(</span>
<span id="cb15-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc =</span> conc_seq,</span>
<span id="cb15-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> unique,</span>
<span id="cb15-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> unique</span>
<span id="cb15-6">  ),</span>
<span id="cb15-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">variables =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment"</span>,</span>
<span id="cb15-8">  <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;">"type"</span></span>
<span id="cb15-9">)</span>
<span id="cb15-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb15-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;         type Estimate Std. Error     z Pr(&gt;|z|)    S 2.5 % 97.5 %</span></span>
<span id="cb15-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Quebec         -4.76       3.04 -1.57    0.117  3.1 -10.7   1.19</span></span>
<span id="cb15-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Mississippi   -10.71       2.20 -4.87   &lt;0.001 19.8 -15.0  -6.40</span></span>
<span id="cb15-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb15-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Term: treatment</span></span>
<span id="cb15-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Type: response</span></span>
<span id="cb15-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Comparison: chilled - nonchilled</span></span>
<span id="cb15-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">avg_comparisons</span>(model_1,</span>
<span id="cb15-19">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">newdata =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">datagrid</span>(</span>
<span id="cb15-20">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc =</span> conc_seq,</span>
<span id="cb15-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> unique,</span>
<span id="cb15-22">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> unique</span>
<span id="cb15-23">  ),</span>
<span id="cb15-24">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">variables =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment"</span>,</span>
<span id="cb15-25">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</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;">"conc"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"type"</span>)</span>
<span id="cb15-26">)</span>
<span id="cb15-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb15-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    conc        type Estimate Std. Error      z Pr(&gt;|z|)    S  2.5 % 97.5 %</span></span>
<span id="cb15-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    95.0 Quebec         0.413       1.60  0.258  0.79644  0.3  -2.73   3.55</span></span>
<span id="cb15-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    95.0 Mississippi   -3.114       1.02 -3.057  0.00224  8.8  -5.11  -1.12</span></span>
<span id="cb15-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    96.8 Quebec         0.373       1.61  0.232  0.81662  0.3  -2.78   3.53</span></span>
<span id="cb15-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    96.8 Mississippi   -3.183       1.03 -3.102  0.00192  9.0  -5.19  -1.17</span></span>
<span id="cb15-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    98.6 Quebec         0.332       1.62  0.205  0.83731  0.3  -2.84   3.51</span></span>
<span id="cb15-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; --- 990 rows omitted. See ?print.marginaleffects ---</span></span>
<span id="cb15-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   996.4 Mississippi  -11.426       2.75 -4.156  &lt; 0.001 14.9 -16.81  -6.04</span></span>
<span id="cb15-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   998.2 Quebec        -4.436       3.97 -1.119  0.26334  1.9 -12.21   3.34</span></span>
<span id="cb15-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   998.2 Mississippi  -11.427       2.76 -4.147  &lt; 0.001 14.9 -16.83  -6.03</span></span>
<span id="cb15-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  1000.0 Quebec        -4.435       3.98 -1.115  0.26467  1.9 -12.23   3.36</span></span>
<span id="cb15-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  1000.0 Mississippi  -11.428       2.76 -4.138  &lt; 0.001 14.8 -16.84  -6.02</span></span>
<span id="cb15-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Term: treatment</span></span>
<span id="cb15-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Type: response</span></span>
<span id="cb15-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Comparison: chilled - nonchilled</span></span>
<span id="cb15-43"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot_comparisons</span>(model_1,</span>
<span id="cb15-44">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">newdata =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">datagrid</span>(</span>
<span id="cb15-45">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc =</span> conc_seq,</span>
<span id="cb15-46">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> unique,</span>
<span id="cb15-47">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> unique</span>
<span id="cb15-48">  ),</span>
<span id="cb15-49">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">variables =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment"</span>,</span>
<span id="cb15-50">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</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;">"conc"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"type"</span>),</span>
<span id="cb15-51">  <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;">"link"</span></span>
<span id="cb15-52">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-53">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</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;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-54">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb15-55">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Estimated difference"</span>,</span>
<span id="cb15-56">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Difference between treatment levels"</span>,</span>
<span id="cb15-57">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Chilled - nonchilled, per type"</span></span>
<span id="cb15-58">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/statistics/gams_files/figure-html/unnamed-chunk-13-1.svg" class="img-fluid quarto-figure quarto-figure-center figure-img" width="2100"></p>
</figure>
</div>
</div>
</div>
<hr>
</section>
<section id="stata" class="level2">
<h2 class="anchored" data-anchor-id="stata">Stata</h2>
<hr>
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<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">max_growth <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>(hi, lo, x) {</span>
<span id="cb16-2">  dydx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (hi <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> lo) <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;">1e-6</span></span>
<span id="cb16-3">  dydx_max <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;">max</span>(dydx)</span>
<span id="cb16-4">  x[dydx <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> dydx_max][<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb16-5">}</span>
<span id="cb16-6"></span>
<span id="cb16-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">comparisons</span>(model_1,</span>
<span id="cb16-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">newdata =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">datagrid</span>(</span>
<span id="cb16-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc =</span> conc_seq,</span>
<span id="cb16-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> unique,</span>
<span id="cb16-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> unique</span>
<span id="cb16-12">  ),</span>
<span id="cb16-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">variables =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conc"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-6</span>),</span>
<span id="cb16-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vcov =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb16-15">  <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;">"treatment"</span>,</span>
<span id="cb16-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison =</span> max_growth</span>
<span id="cb16-17">)</span>
<span id="cb16-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb16-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   treatment Estimate</span></span>
<span id="cb16-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  nonchilled      157</span></span>
<span id="cb16-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  chilled         151</span></span>
<span id="cb16-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb16-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Term: conc</span></span>
<span id="cb16-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Type: response</span></span>
<span id="cb16-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Comparison: +1e-06</span></span>
<span id="cb16-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hypotheses</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">slopes</span>(model_1,</span>
<span id="cb16-27">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">newdata =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">datagrid</span>(</span>
<span id="cb16-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc =</span> conc_seq,</span>
<span id="cb16-29">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> unique,</span>
<span id="cb16-30">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> unique</span>
<span id="cb16-31">  ),</span>
<span id="cb16-32">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">variables =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conc"</span>,</span>
<span id="cb16-33">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</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;">"conc"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment"</span>),</span>
<span id="cb16-34">  <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;">"link"</span></span>
<span id="cb16-35">)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-36">  dplyr<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;">filter</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="cb16-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb16-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Estimate Std. Error    z Pr(&gt;|z|)    S    2.5 %  97.5 %</span></span>
<span id="cb16-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.00809   0.000877 9.23   &lt;0.001 65.0 6.37e-03 0.00981</span></span>
<span id="cb16-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.00647   0.000830 7.80   &lt;0.001 47.2 4.84e-03 0.00810</span></span>
<span id="cb16-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.00809   0.000878 9.21   &lt;0.001 64.7 6.36e-03 0.00981</span></span>
<span id="cb16-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.00647   0.000828 7.81   &lt;0.001 47.3 4.85e-03 0.00809</span></span>
<span id="cb16-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.00808   0.000874 9.25   &lt;0.001 65.2 6.37e-03 0.00980</span></span>
<span id="cb16-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; --- 196 rows omitted. See ?print.marginaleffects ---</span></span>
<span id="cb16-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.00127   0.000504 2.52   0.0116  6.4 2.84e-04 0.00226</span></span>
<span id="cb16-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.00122   0.000515 2.37   0.0178  5.8 2.12e-04 0.00223</span></span>
<span id="cb16-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.00117   0.000521 2.25   0.0243  5.4 1.52e-04 0.00219</span></span>
<span id="cb16-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.00113   0.000529 2.13   0.0334  4.9 8.84e-05 0.00216</span></span>
<span id="cb16-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.00108   0.000545 1.98   0.0476  4.4 1.15e-05 0.00215</span></span>
<span id="cb16-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Term: conc</span></span></code></pre></div></div>
</details>
</div>
<iframe title="m" width="640" height="541.25" src="https://app.powerbi.com/reportEmbed?reportId=c377c2a0-a702-4d33-a8ce-b454a5f69302&amp;autoAuth=true&amp;ctid=85539884-d6cb-44b5-a575-20470b81d1d5" frameborder="0" allowfullscreen="true"></iframe>
</section>
<section id="section" class="level2">
<h2 class="anchored" data-anchor-id="section"><iframe title="nb" width="1140" height="541.25" src="https://app.powerbi.com/reportEmbed?reportId=9f3a36c5-18a8-436e-85cf-145ac593b7fc&amp;autoAuth=true&amp;ctid=85539884-d6cb-44b5-a575-20470b81d1d5&amp;actionBarEnabled=true&amp;reportCopilotInEmbed=true" frameborder="0" allowfullscreen="true"></iframe></h2>
</section>
<section id="computational-environments" class="level1">
<h1>Computational Environments</h1>
<hr>
<section id="overall-platforms" class="level2">
<h2 class="anchored" data-anchor-id="overall-platforms">Overall Platforms</h2>
<hr>
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-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 class="at" style="color: #657422;
background-color: null;
font-style: inherit;">info =</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;">"platform"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"external"</span>))</span>
<span id="cb17-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span></span>
<span id="cb17-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  setting  value</span></span>
<span id="cb17-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  version  R version 4.5.2 (2025-10-31)</span></span>
<span id="cb17-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  os       macOS Tahoe 26.3</span></span>
<span id="cb17-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  system   aarch64, darwin20</span></span>
<span id="cb17-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ui       X11</span></span>
<span id="cb17-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  language (EN)</span></span>
<span id="cb17-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  collate  C.UTF-8</span></span>
<span id="cb17-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ctype    C.UTF-8</span></span>
<span id="cb17-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  tz       America/New_York</span></span>
<span id="cb17-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  date     2026-01-30</span></span>
<span id="cb17-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  pandoc   3.8.3 @ /opt/homebrew/bin/ (via rmarkdown)</span></span>
<span id="cb17-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  quarto   1.8.27 @ /Applications/quarto/bin/quarto</span></span>
<span id="cb17-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb17-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ─ External software ────────────────────────────────────────────────────────────────────────────────────────────────────────────</span></span>
<span id="cb17-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  setting        value</span></span>
<span id="cb17-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  cairo          1.17.6</span></span>
<span id="cb17-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  cairoFT</span></span>
<span id="cb17-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  pango          1.50.14</span></span>
<span id="cb17-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  png            1.6.44</span></span>
<span id="cb17-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  jpeg           9.5</span></span>
<span id="cb17-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  tiff           LIBTIFF, Version 4.5.0</span></span>
<span id="cb17-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  tcl            8.6.13</span></span>
<span id="cb17-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  curl           8.7.1</span></span>
<span id="cb17-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  zlib           1.2.12</span></span>
<span id="cb17-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  bzlib          1.0.8, 13-Jul-2019</span></span>
<span id="cb17-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  xz             5.6.3</span></span>
<span id="cb17-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  deflate        1.23</span></span>
<span id="cb17-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  PCRE           10.44 2024-06-07</span></span>
<span id="cb17-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ICU            76.1</span></span>
<span id="cb17-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  TRE            TRE 0.8.0 R_fixes (BSD)</span></span>
<span id="cb17-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  iconv          Apple or GNU libiconv 1.11 /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libR.dylib</span></span>
<span id="cb17-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  readline       5.2</span></span>
<span id="cb17-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  BLAS           /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib</span></span>
<span id="cb17-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  lapack         /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib</span></span>
<span id="cb17-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  lapack_version 3.12.1</span></span>
<span id="cb17-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb17-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span></span></code></pre></div></div>
</details>
</div>
<hr>
</section>
<section id="r-packages" class="level2">
<h2 class="anchored" data-anchor-id="r-packages"><code>R</code> Packages</h2>
<hr>
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-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 class="at" style="color: #657422;
background-color: null;
font-style: inherit;">info =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"packages"</span>)</span>
<span id="cb18-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ═ Session info ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════</span></span>
<span id="cb18-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span></span>
<span id="cb18-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  package           * version    date (UTC) lib source</span></span>
<span id="cb18-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  abind               1.4-8      2024-09-12 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Amelia            * 1.8.3      2024-11-08 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  arm                 1.14-4     2024-04-01 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  arrayhelpers        1.1-0      2020-02-04 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  askpass             1.2.1      2024-10-04 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  backports           1.5.0      2024-05-23 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  base64enc           0.1-3      2015-07-28 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  bayesplot         * 1.15.0     2025-12-12 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  bbotk               1.8.1      2025-11-26 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  bcaboot             0.2-3      2021-05-09 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  bitops              1.0-9      2024-10-03 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  blogdown          * 1.23       2026-01-18 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  boot              * 1.3-32     2025-08-29 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  bootImpute        * 1.3.0      2025-12-15 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  bridgesampling      1.2-1      2025-11-19 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  brms              * 2.23.0     2025-09-09 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Brobdingnag         1.2-9      2022-10-19 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  broom             * 1.0.12     2026-01-27 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  broom.mixed       * 0.2.9.6    2024-10-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Cairo             * 1.7-0      2025-10-29 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  callr               3.7.6      2024-03-25 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  car               * 3.1-3      2024-09-27 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  carData           * 3.0-5      2022-01-06 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  caTools             1.18.3     2024-09-04 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  checkmate         * 2.3.3      2025-08-18 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  class               7.3-23     2025-01-01 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  cli                 3.6.5      2025-04-23 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  clipr               0.8.0      2022-02-22 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  cluster             2.1.8.1    2025-03-12 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  coda              * 0.19-4.1   2024-01-31 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  codetools           0.2-20     2024-03-31 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  colorspace        * 2.1-2      2025-09-22 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  concurve          * 3.0.0      2026-01-30 [1] local</span></span>
<span id="cb18-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  cowplot           * 1.2.0      2025-07-07 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  crayon              1.5.3      2024-06-20 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  curl                7.0.0      2025-08-19 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  data.table          1.18.2.1   2026-01-27 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  DBI                 1.2.3      2024-06-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  DEoptimR            1.1-4      2025-07-27 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  desc                1.4.3      2023-12-10 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  details             0.4.0      2025-02-09 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  dichromat           2.0-0.1    2022-05-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  digest              0.6.39     2025-11-19 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  distributional      0.6.0      2026-01-14 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  doParallel        * 1.0.17     2022-02-07 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  doRNG               1.8.6.2    2025-04-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  dplyr             * 1.1.4      2023-11-17 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  e1071               1.7-17     2025-12-18 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  emmeans             2.0.1      2025-12-16 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  estimability        1.5.1      2024-05-12 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  evaluate            1.0.5      2025-08-27 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  extremevalues       2.4.1      2024-12-17 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  farver              2.1.2      2024-05-13 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-58"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  fastmap             1.2.0      2024-05-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-59"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  flextable           0.9.10     2025-08-24 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-60"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  fontBitstreamVera   0.1.1      2017-02-01 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  fontLiberation      0.1.0      2016-10-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  fontquiver          0.2.1      2017-02-01 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  forcats           * 1.0.1      2025-09-25 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-64"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  foreach           * 1.5.2      2022-02-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  foreign             0.8-90     2025-03-31 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-66"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Formula             1.2-5      2023-02-24 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-67"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  fs                  1.6.6      2025-04-12 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-68"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  furrr               0.3.1      2022-08-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-69"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  future            * 1.69.0     2026-01-16 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-70"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  future.apply      * 1.20.1     2025-12-09 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-71"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  gamlss            * 5.5-0      2025-08-19 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-72"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  gamlss.data       * 6.0-7      2025-09-04 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-73"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  gamlss.dist       * 6.1-1      2023-08-23 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-74"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  gdtools             0.4.4      2025-10-06 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-75"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  generics            0.1.4      2025-05-09 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-76"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ggcorrplot        * 0.1.4.1    2023-09-05 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-77"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ggdist              3.3.3      2025-04-23 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-78"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ggplot2           * 4.0.1      2025-11-14 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-79"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ggpubr              0.6.2      2025-10-17 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-80"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ggsignif            0.6.4      2022-10-13 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-81"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ggtext            * 0.1.2      2022-09-16 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-82"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  glmnet              4.1-10     2025-07-17 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-83"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  globals             0.18.0     2025-05-08 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-84"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  glue                1.8.0      2024-09-30 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-85"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  gridExtra           2.3        2017-09-09 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-86"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  gridtext            0.1.5      2022-09-16 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-87"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  gtable              0.3.6      2024-10-25 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-88"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  here              * 1.0.2      2025-09-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-89"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Hmisc             * 5.2-5      2026-01-09 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-90"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  hms                 1.1.4      2025-10-17 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-91"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  htmlTable           2.4.3      2024-07-21 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-92"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  htmltools         * 0.5.9      2025-12-04 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-93"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  htmlwidgets         1.6.4      2023-12-06 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-94"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  httr                1.4.7      2023-08-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-95"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ImputeRobust      * 1.3-1      2018-11-30 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-96"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  inline              0.3.21     2025-01-09 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-97"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  insight             1.4.5      2026-01-26 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-98"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  iterators         * 1.0.14     2022-02-05 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-99"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  itertools           0.1-3      2014-03-12 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-100"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  jomo                2.7-6      2023-04-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-101"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  jsonlite            2.0.0      2025-03-27 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-102"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  JuliaCall         * 0.17.6     2024-12-07 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-103"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  kableExtra        * 1.4.0      2024-01-24 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-104"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  km.ci               0.5-6      2022-04-06 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-105"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  KMsurv              0.1-6      2025-05-20 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-106"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  knitr             * 1.51       2025-12-20 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-107"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  labeling            0.4.3      2023-08-29 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-108"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  laeken              0.5.3      2024-01-25 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-109"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  latex2exp         * 0.9.8      2026-01-09 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-110"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  lattice           * 0.22-7     2025-04-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-111"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  lgr                 0.5.0      2025-07-23 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-112"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  lifecycle           1.0.5      2026-01-08 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-113"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  listenv             0.10.0     2025-11-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-114"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  lme4                1.1-38     2025-12-02 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-115"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  lmtest              0.9-40     2022-03-21 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-116"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  loo               * 2.9.0      2025-12-23 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-117"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  lubridate         * 1.9.4      2024-12-08 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-118"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  magick              2.9.0      2025-09-08 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-119"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  magrittr          * 2.0.4      2025-09-12 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-120"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  marginaleffects   * 0.31.0     2025-11-15 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-121"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  MASS              * 7.3-65     2025-02-28 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-122"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mathjaxr            2.0-0      2025-12-01 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-123"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Matrix            * 1.7-4      2025-08-28 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-124"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  MatrixModels        0.5-4      2025-03-26 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-125"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  matrixStats         1.5.0      2025-01-07 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-126"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mcmc                0.9-8      2023-11-16 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-127"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  MCMCpack          * 1.7-1      2024-08-27 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-128"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  metadat             1.4-0      2025-02-04 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-129"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  metafor             4.8-0      2025-01-28 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-130"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mgcv              * 1.9-4      2025-11-07 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-131"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mi                * 1.2        2025-09-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-132"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mice              * 3.19.0     2025-12-10 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-133"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  miceadds          * 3.18-36    2025-09-12 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-134"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  miceFast          * 0.8.5      2025-02-03 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-135"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  minqa               1.2.8      2024-08-17 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-136"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  missForest        * 1.6.1      2025-10-26 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-137"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mitml             * 0.4-5      2023-03-08 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-138"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mitools             2.4        2019-04-26 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-139"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mlr3                1.3.0      2025-12-03 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-140"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mlr3learners        0.14.0     2025-12-13 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-141"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mlr3misc            0.19.0     2025-09-12 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-142"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mlr3pipelines       0.10.0     2025-11-07 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-143"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mlr3tuning          1.5.1      2025-12-14 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-144"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  multcomp            1.4-29     2025-10-20 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-145"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  mvtnorm           * 1.3-3      2025-01-10 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-146"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  nlme              * 3.1-168    2025-03-31 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-147"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  nloptr              2.2.1      2025-03-17 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-148"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  nnet                7.3-20     2025-01-01 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-149"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  numDeriv            2016.8-1.1 2019-06-06 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-150"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  officer             0.7.3      2026-01-16 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-151"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  opdisDownsampling   1.0.1      2024-04-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-152"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  openssl             2.3.4      2025-09-30 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-153"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  otel                0.2.0      2025-08-29 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-154"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  palmerpenguins      0.1.1      2022-08-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-155"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  pan                 1.9        2023-12-07 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-156"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  pander              0.6.6      2025-03-01 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-157"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  paradox             1.0.1      2024-07-09 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-158"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  parallelly        * 1.46.1     2026-01-08 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-159"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  patchwork         * 1.3.2      2025-08-25 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-160"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  pbmcapply         * 1.5.1      2022-04-28 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-161"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  performance       * 0.15.3.6   2026-01-29 [1] https://easystats.r-universe.dev (R 4.5.2)</span></span>
<span id="cb18-162"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  pillar              1.11.1     2025-09-17 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-163"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  pkgbuild            1.4.8.9000 2026-01-26 [1] Github (r-lib/pkgbuild@35af314)</span></span>
<span id="cb18-164"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  pkgconfig           2.0.3      2019-09-22 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-165"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  plyr                1.8.9      2023-10-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-166"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  png                 0.1-8      2022-11-29 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-167"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  polspline           1.1.25     2024-05-10 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-168"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  posterior         * 1.6.1      2025-02-27 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-169"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  pracma              2.4.6      2025-10-22 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-170"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  prettyunits         1.2.0      2023-09-24 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-171"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  processx            3.8.6      2025-02-21 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-172"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ProfileLikelihood * 1.3        2023-08-25 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-173"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  progress          * 1.2.3      2023-12-06 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-174"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  proxy               0.4-29     2025-12-29 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-175"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ps                  1.9.1      2025-04-12 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-176"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  purrr             * 1.2.1      2026-01-09 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-177"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  qqconf              1.3.2      2023-04-14 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-178"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  qqplotr           * 0.0.7      2025-09-05 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-179"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  quantreg          * 6.1        2025-03-10 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-180"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  QuickJSR            1.9.0      2026-01-25 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-181"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  R6                  2.6.1      2025-02-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-182"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ragg                1.5.0      2025-09-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-183"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  randomForest      * 4.7-1.2    2024-09-22 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-184"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  ranger              0.18.0     2026-01-16 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-185"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rapportools         1.2        2025-02-28 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-186"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rbibutils           2.4.1      2026-01-21 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-187"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rcartocolor         2.1.2      2025-07-23 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-188"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  RColorBrewer        1.1-3      2022-04-03 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-189"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Rcpp              * 1.1.1      2026-01-10 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-190"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  RcppParallel        5.1.11-1   2025-08-27 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-191"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Rdpack              2.6.5      2026-01-23 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-192"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  readr             * 2.1.6      2025-11-14 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-193"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  reformulas          0.4.3.1    2026-01-08 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-194"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rematch2            2.1.2      2020-05-01 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-195"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  reshape2          * 1.4.5      2025-11-12 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-196"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  reticulate        * 1.44.1     2025-11-14 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-197"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rlang               1.1.7      2026-01-09 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-198"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rmarkdown         * 2.30       2025-09-28 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-199"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rms               * 8.1-0      2025-10-14 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-200"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rngtools            1.5.2      2021-09-20 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-201"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  robustbase          0.99-6     2025-09-04 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-202"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rpart               4.1.24     2025-01-07 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-203"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rprojroot           2.1.1      2025-08-26 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-204"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rstan             * 2.32.7     2025-03-10 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-205"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rstantools          2.6.0      2026-01-10 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-206"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rstatix             0.7.3      2025-10-18 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-207"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  rstudioapi          0.18.0     2026-01-16 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-208"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  S7                  0.2.1      2025-11-14 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-209"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  sandwich            3.1-1      2024-09-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-210"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  scales              1.4.0      2025-04-24 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-211"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  sessioninfo         1.2.3      2025-02-05 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-212"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  shape               1.4.6.1    2024-02-23 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-213"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  showtext          * 0.9-7      2024-03-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-214"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  showtextdb        * 3.0        2020-06-04 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-215"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  sp                  2.2-0      2025-02-01 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-216"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  SparseM           * 1.84-2     2024-07-17 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-217"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  StanHeaders       * 2.32.10    2024-07-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-218"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Statamarkdown     * 0.9.6      2026-01-06 [1] Github (Hemken/Statamarkdown@dc936d8)</span></span>
<span id="cb18-219"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  stringi             1.8.7      2025-03-27 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-220"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  stringr           * 1.6.0      2025-11-04 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-221"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  summarytools      * 1.1.5      2026-01-27 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-222"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  survival            3.8-6      2026-01-16 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-223"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  survminer           0.5.1      2025-09-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-224"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  survMisc            0.5.6      2022-04-07 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-225"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  svglite           * 2.2.2      2025-10-21 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-226"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  svgPanZoom          0.3.4      2020-02-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-227"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  svUnit              1.0.8      2025-08-26 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-228"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  sysfonts          * 0.8.9      2024-03-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-229"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  systemfonts         1.3.1      2025-10-01 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-230"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  tensorA             0.36.2.1   2023-12-13 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-231"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  texPreview        * 2.1.0      2024-01-24 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-232"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  textshaping         1.0.4      2025-10-10 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-233"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  TH.data             1.1-5      2025-11-17 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-234"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  tibble            * 3.3.1      2026-01-11 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-235"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  tidybayes         * 3.0.7      2024-09-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-236"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  tidyr             * 1.3.2      2025-12-19 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-237"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  tidyselect          1.2.1      2024-03-11 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-238"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  tidyverse         * 2.0.0      2023-02-22 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-239"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  timechange          0.3.0      2024-01-18 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-240"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  tinytex           * 0.58       2025-11-19 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-241"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  twosamples          2.0.1      2023-06-23 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-242"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  tzdb                0.5.0      2025-03-15 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-243"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  uuid                1.2-2      2026-01-23 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-244"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  V8                  8.0.1      2025-10-10 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-245"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  vcd                 1.4-13     2024-09-16 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-246"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  vctrs               0.7.1      2026-01-23 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-247"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  VIM               * 7.0.0      2026-01-10 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-248"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  viridisLite         0.4.2      2023-05-02 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-249"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  wesanderson       * 0.3.7      2023-10-31 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-250"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  whisker             0.4.1      2022-12-05 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-251"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  withr               3.0.2      2024-10-28 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-252"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  xfun              * 0.56       2026-01-18 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-253"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  xml2                1.5.2      2026-01-17 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-254"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  xtable              1.8-4      2019-04-21 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-255"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  yaml                2.3.12     2025-12-10 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-256"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  yardstick         * 1.3.2      2025-01-22 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-257"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  zip                 2.3.3      2025-05-13 [1] CRAN (R 4.5.0)</span></span>
<span id="cb18-258"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  zoo                 1.8-15     2025-12-15 [1] CRAN (R 4.5.2)</span></span>
<span id="cb18-259"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb18-260"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library</span></span>
<span id="cb18-261"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  * ── Packages attached to the search path.</span></span>
<span id="cb18-262"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb18-263"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span></span></code></pre></div></div>
</details>
</div>
<hr>
</section>
</section>
<section id="references" class="level1">
<h1>References</h1>
<hr>


<!-- -->

</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2018,
  author = {Panda, Sir and Panda, Sir},
  title = {GAMS},
  date = {2018-11-11},
  url = {https://lesslikely.com/posts/statistics/gams.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2018" class="csl-entry quarto-appendix-citeas">
1. Panda S, Panda S. (2018). <span>‘GAMS’</span>. <a href="https://lesslikely.com/posts/statistics/gams.html">https://lesslikely.com/posts/statistics/gams.html</a>.
</div></div></section></div> ]]></description>
  <category>statistics</category>
  <guid>https://lesslikely.com/posts/statistics/gams.html</guid>
  <pubDate>Sun, 11 Nov 2018 05:00:00 GMT</pubDate>
  <media:content url="https://raw.githubusercontent.com/stan-dev/logos/master/logo.png" medium="image" type="image/png"/>
</item>
<item>
  <title>P-values Are Tough And S-values Can Help</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/statistics/s-values.html</link>
  <description><![CDATA[ 





<hr>
<p>The <img src="https://latex.codecogs.com/png.latex?P">-value doesn’t have many fans. There are those who don’t understand it, often treating it as a measure it’s not, whether that’s a posterior probability, the probability of getting results due to chance alone, or some other bizarre/incorrect interpretation.<span class="citation" data-cites="gigerenzerStatisticalRitualsReplication2018 goodmanDirtyDozenTwelve2008 greenlandStatisticalTestsValues2016"><sup>1–3</sup></span> Then there are those who dislike it because they think the concept is too difficult to understand or because they see it as a noisy statistic we’re not interested in.</p>
<p>However, the groups of people mentioned above aren’t mutually exclusive. Many who dislike and criticize the <img src="https://latex.codecogs.com/png.latex?P">-value also do not understand its properties and behavior. This is unfortunate, given how important and widely used they are. In this article, which could also have been titled, <img src="https://latex.codecogs.com/png.latex?P">-values: More Than You Ever Wanted to Know, I take on the task of explaining:</p>
<hr>
<ul>
<li>what <img src="https://latex.codecogs.com/png.latex?P">-values are</li>
</ul>
<hr>
<ul>
<li>the assumptions behind them</li>
</ul>
<hr>
<ul>
<li>their properties and behavior</li>
</ul>
<hr>
<ul>
<li>different schools of interpretation</li>
</ul>
<hr>
<ul>
<li>misleading criticisms of <img src="https://latex.codecogs.com/png.latex?P">-values</li>
</ul>
<hr>
<ul>
<li>some valid issues in interpretation</li>
</ul>
<hr>
<ul>
<li>how these issues can be resolved</li>
</ul>
<hr>
<section id="what-is-a-p-value-anyway" class="level1">
<h1>What is a <em>P</em>-value Anyway?</h1>
<hr>
<section id="some-definitions-descriptions" class="level2">
<h2 class="anchored" data-anchor-id="some-definitions-descriptions">Some Definitions &amp; Descriptions</h2>
<hr>
<p>The <img src="https://latex.codecogs.com/png.latex?P">-value is the probability of getting a result (specifically, a test statistic) at least as extreme as what was observed if <strong>every model assumption</strong>, in addition to the targeted test hypothesis (usually a null hypothesis), used to compute it <strong>were correct</strong>.<span class="citation" data-cites="rafiSemanticCognitiveTools2020 greenlandStatisticalTestsValues2016 greenlandValidPvaluesBehave2019"><sup>3–5</sup></span></p>
<p>A simple, mathematically rigorous definition of a <img src="https://latex.codecogs.com/png.latex?P">-value (for those interested) is given by <a href="https://www.stat.berkeley.edu/~stark/Preprints/pValues.pdf">Stark (2015)</a>.</p>
<hr>
<blockquote class="blockquote">
<p>Let <img src="https://latex.codecogs.com/png.latex?P"> be the probability distribution of the data <img src="https://latex.codecogs.com/png.latex?X">, which takes values in the measurable space <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%7BX%7D">. Let <img src="https://latex.codecogs.com/png.latex?%5Cleft%5C%7BR_%7B%5Calpha%7D%5Cright%5C%7D_%7B%5Calpha%20%5Cin%5B0,1%5D%7D"> be a collection of <img src="https://latex.codecogs.com/png.latex?P"> -measurable subsets of <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%7BX%7D"> such that (1) <img src="https://latex.codecogs.com/png.latex?P%5Cleft(R_%7B%5Calpha%7D%5Cright)=%5Calpha"> and (2) If <img src="https://latex.codecogs.com/png.latex?%5Calpha%5E%7B%5Cprime%7D%3C%5Calpha"> then <img src="https://latex.codecogs.com/png.latex?R_%7B%5Calpha%5E%7B%5Cprime%7D%7D%20%5Csubset%20R_%7B%5Calpha%7D">. Then the <img src="https://latex.codecogs.com/png.latex?P">-value of <img src="https://latex.codecogs.com/png.latex?H_%7B0%7D"> for data <img src="https://latex.codecogs.com/png.latex?X=x"> is inf <img src="https://latex.codecogs.com/png.latex?_%7B%5Calpha%20%5Cin%5B0,1%5D%7D%5Cleft%5C%7B%5Calpha:%20x%20%5Cin%20R_%7B%5Calpha%7D%5Cright%5C%7D">.</p>
</blockquote>
<hr>
<p>A descriptive but technical definition is given by Sander Greenland below. The description can seem dense, so feel free to skip over it for now and revisit it after reading the rest of the post.</p>
<hr>
<blockquote class="blockquote">
<p>A single <img src="https://latex.codecogs.com/png.latex?P">-value <img src="https://latex.codecogs.com/png.latex?p"> is the quantile location of a directional measure of divergence <img src="https://latex.codecogs.com/png.latex?t"> = <img src="https://latex.codecogs.com/png.latex?t(y;M)"> of the data point <img src="https://latex.codecogs.com/png.latex?y"> (usually, the vector in <img src="https://latex.codecogs.com/png.latex?n">-space formed by <img src="https://latex.codecogs.com/png.latex?n"> individual observations) from a test model manifold <img src="https://latex.codecogs.com/png.latex?M"> in the <img src="https://latex.codecogs.com/png.latex?n">-dimensional expectation space defined the logical structure of the data generator (“experiment” or causal structure) that produced the data <img src="https://latex.codecogs.com/png.latex?y">. <img src="https://latex.codecogs.com/png.latex?M"> is the subset of the <img src="https://latex.codecogs.com/png.latex?Y">-space into which the conjunction of the model constraints (assumptions) force the data expectation or predict where y would be were there no ‘random’ variability. I also use <img src="https://latex.codecogs.com/png.latex?M"> to denote the set of all the model constraints, as well as their conjunction.</p>
<p>With this logical set-up, the observed <img src="https://latex.codecogs.com/png.latex?P">-value is the quantile <img src="https://latex.codecogs.com/png.latex?p"> for the observed value <img src="https://latex.codecogs.com/png.latex?t"> of <img src="https://latex.codecogs.com/png.latex?T"> = <img src="https://latex.codecogs.com/png.latex?t(Y;M)">. This <img src="https://latex.codecogs.com/png.latex?p"> is read off a reference distribution <img src="https://latex.codecogs.com/png.latex?F%20=%20F(t;M)"> for <img src="https://latex.codecogs.com/png.latex?T"> derived from <img src="https://latex.codecogs.com/png.latex?M">. This formulation is essentially that of the “value of P” appearing in Pearson’s seminal 1900 paper on goodness-of-fit tests. Notably, his famed chi-squared statistic is the squared Euclidean distance from <img src="https://latex.codecogs.com/png.latex?y"> to <img src="https://latex.codecogs.com/png.latex?M">, with coordinates expressed in standard-deviation units derived from <img src="https://latex.codecogs.com/png.latex?M">.</p>
<p>More broadly, the statistic <img src="https://latex.codecogs.com/png.latex?T"> can be taken as a measure of divergence of a more general embedding or background model manifold <img src="https://latex.codecogs.com/png.latex?A"> (which includes all ‘auxiliary’ assumptions) from a more restrictive model <img src="https://latex.codecogs.com/png.latex?M">, with the goodness-of-fit case taking <img src="https://latex.codecogs.com/png.latex?A"> as a saturated model covering the entire observation space, and the more common “hypothesis testing” case taking M as the conjunction of an unsaturated <img src="https://latex.codecogs.com/png.latex?A"> with a targeted ‘test’ constraint (or set of constraints) <img src="https://latex.codecogs.com/png.latex?H">. This <img src="https://latex.codecogs.com/png.latex?H"> is logically independent of <img src="https://latex.codecogs.com/png.latex?A"> and consistent with <img src="https://latex.codecogs.com/png.latex?A">, with <img src="https://latex.codecogs.com/png.latex?M"> = <img src="https://latex.codecogs.com/png.latex?H"> &amp; <img src="https://latex.codecogs.com/png.latex?A"> in logical terms, or <img src="https://latex.codecogs.com/png.latex?M"> = <img src="https://latex.codecogs.com/png.latex?H"> + <img src="https://latex.codecogs.com/png.latex?A"> in set-theoretic terms with + being union (in particular, we assume no element in <img src="https://latex.codecogs.com/png.latex?H"> is entailed or contradicted by <img src="https://latex.codecogs.com/png.latex?A"> and no element in <img src="https://latex.codecogs.com/png.latex?A"> is entailed or contradicted by <img src="https://latex.codecogs.com/png.latex?H">).</p>
</blockquote>
<hr>
</section>
<section id="misleading-definitions" class="level2">
<h2 class="anchored" data-anchor-id="misleading-definitions">Misleading Definitions</h2>
<hr>
<p>It is very common to see the <img src="https://latex.codecogs.com/png.latex?P">-value defined as</p>
<hr>
<blockquote class="blockquote">
<p><strong>The probability of obtaining test results at least as extreme as the results actually observed, under the assumption that the null hypothesis is correct.</strong></p>
</blockquote>
<hr>
<p>Indeed, this is the actual definition currently given on the <a href="https://en.wikipedia.org/wiki/P-value">Wikipedia page for the topic</a>, however, it is inadequate and misleading because it hides and reifies the other assumptions used to compute the <img src="https://latex.codecogs.com/png.latex?P">-value and exclusively focuses on the null hypothesis.</p>
<p>The test hypothesis (often the null hypothesis) is only one component of the entire model that is being tested. This is reflected in the first definition I gave above, which explicitly emphasizes that every model assumption must be true. Thus, the <img src="https://latex.codecogs.com/png.latex?P">-value is sensitive to all these assumptions and their violation(s).</p>
<hr>
</section>
<section id="auxilliary-assumptions" class="level2">
<h2 class="anchored" data-anchor-id="auxilliary-assumptions">Auxilliary Assumptions</h2>
<hr>
<p>Some of these key <strong>assumptions</strong> behind the computation of a <img src="https://latex.codecogs.com/png.latex?P">-value are that some sort of <strong>random process was employed</strong> (random sampling, random assignment, etc.), that there are <strong>no uncontrolled sources of bias</strong> (confounding, programming errors, equipment defects, sparse-data bias)<span class="citation" data-cites="greenlandSparseDataBias2016"><sup>6</sup></span> in the results, and that <strong>the test hypothesis</strong> (often the null hypothesis) <strong>is correct</strong>. Some of these assumptions can be seen in the figure below from<span class="citation" data-cites="greenlandAidScientificInference2020"><sup>7</sup></span>, which will be discussed later on. This entire set of assumptions is generally referred to as the <em>test model</em>, and that is because the entire assumed model is being tested.</p>
<hr>
<figure class="figure">
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1605000180/Site/pvalueassumptions.svg" alt="P-value assumptions" width="500" style="cursor: zoom-in" class="figure-img"></p>
<figcaption>
Conditional versus unconditional interpretations of P-values, S-values, and compatibility intervals (CIs). (A) Conditional interpretation, in which background model assumptions, such as no systematic error, are assumed to be correct; thus,the information provided by the P-value and S-value is targeted towards the test hypothesis. (B)Unconditional interpretation, in which no aspect of the statistical model is assumed to be correct; thus,the information provided by the P-value and S-value is targeted toward the entire test model.
</figcaption>
</figure>
<hr>
<p>We often start from the position that all those assumptions are correct (hence, we “condition” on them, even though they are often not correct)<span class="citation" data-cites="greenlandAidScientificInference2020"><sup>7</sup></span> when calculating the <img src="https://latex.codecogs.com/png.latex?P">-value, so that any deviation of the data from what was expected under those assumptions would be <strong>purely random error</strong>. But in reality such deviations could also be the result of <strong>any</strong> assumptions being false, including <em>but not limited to</em> the test hypothesis.</p>
<hr>
<blockquote class="blockquote">
<p>Note: “Conditioning” here refers to taking the assumptions in the model as given, and should not be confused with conditional probability.</p>
</blockquote>
<hr>
<p>For example, in high-energy physics, neutrinos were found in one study to be faster than light due to the resulting large test statistic and corresponding small <img src="https://latex.codecogs.com/png.latex?P">-value, but this result was later found to be a result of a defect in the fiber-optic timing system for that experiment.<span class="citation" data-cites="moskowitzFasterthanlightNeutrinosAren2012"><sup>8</sup></span> Thus, the low <img src="https://latex.codecogs.com/png.latex?P">-value was not because the assumed null hypothesis was false, but instead due to a bias in the procedure.</p>
<p>So the <img src="https://latex.codecogs.com/png.latex?P">-value <strong>cannot</strong> be the probability of one of these assumptions, such as <em>“the probability of getting results due to chance alone.”</em> A statement like this is <strong>backwards</strong> because it’s quantifying one of the assumptions behind the computation of a <img src="https://latex.codecogs.com/png.latex?P">-value.</p>
<p>This assumption of chance causing the results is assumed to be true (aka 100%) along with several other things, when calculating the <img src="https://latex.codecogs.com/png.latex?P">-value, but this does not mean it is actually correct and the calculation of the <img src="https://latex.codecogs.com/png.latex?P">-value <em>cannot</em> be the <em>probability</em> of one of those <strong>assumptions</strong>.</p>
<hr>
</section>
<section id="probability-of-what" class="level2">
<h2 class="anchored" data-anchor-id="probability-of-what">Probability of What?</h2>
<hr>
<p>It is also important to clarify that <img src="https://latex.codecogs.com/png.latex?P">-values are not <em>probabilities of data</em> or parameter values, which many like to say to differentiate from probabilities of hypotheses. Rather, <img src="https://latex.codecogs.com/png.latex?P">-values are probabilities of “data features”, such as test statistics (i.e.&nbsp;a z-score or <img src="https://latex.codecogs.com/png.latex?%5Cchi%5E%7B2%7D"> statistic) or can be interpreted as the percentile at which the observed test statistic falls within the expected distribution for the test statistic, assuming all the model assumptions are true.<span class="citation" data-cites="perezgonzalezPvaluesPercentilesCommentary2015 fraserPvalueFunctionStatistical2019"><sup>9, 10</sup></span></p>
<hr>
</section>
<section id="properties-uniformity" class="level2">
<h2 class="anchored" data-anchor-id="properties-uniformity">Properties (Uniformity)</h2>
<hr>
<p>A <img src="https://latex.codecogs.com/png.latex?P">-value is considered to be valid if over repeated trials it would be uniform when the tested hypothesis and all other assumptions used to compute the <img src="https://latex.codecogs.com/png.latex?P">-value are correct (see the histogram below to see what this looks like). Typically, this test hypothesis is a null hypothesis where the tested parameter value is usually 0 or 1, but this property applies to any test hypothesis for any parameter value. Thus, there is the random variable <img src="https://latex.codecogs.com/png.latex?P">, which (when valid) follows this uniform distribution, and the realization of this random variable, <img src="https://latex.codecogs.com/png.latex?p">, which is the observed <img src="https://latex.codecogs.com/png.latex?P">-value. The latter is what most researchers are interpreting from studies.</p>
<p>Thus, if we were to simulate two variables that are practically the same (meaning there’s no difference between them) and then compare them, say, using a t-test, and we were to iterate this process 10000 times and plot the distribution of the observed P-values, it would be uniform, indicating that any P-value within the interval from 0-1 is just as likely as any other to be observed.</p>
<hr>
<div class="cell" data-layout-align="center">
<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="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @title Simulation of valid P-values where test hypothesis is true</span></span>
<span id="cb1-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param X The first variable we are simulating</span></span>
<span id="cb1-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param Y The second variable we are simulating</span></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param n.sim # The number of simulations</span></span>
<span id="cb1-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param t The object storing the t-test results</span></span>
<span id="cb1-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param t.sim # Empty numeric vector to contain values</span></span>
<span id="cb1-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @param n.samp # Sample size in each group</span></span>
<span id="cb1-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' @NOTE The null hypothesis does not have to be 0, it can be any value.</span></span>
<span id="cb1-9"></span>
<span id="cb1-10">n.sim <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;">10000</span></span>
<span id="cb1-11">t.sim <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;">numeric</span>(n.sim)</span>
<span id="cb1-12">n.samp <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;">1000</span></span>
<span id="cb1-13"></span>
<span id="cb1-14"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <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>n.sim) {</span>
<span id="cb1-15">  X <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.samp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb1-16">  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.samp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</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;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb1-17">  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;">data.frame</span>(X, Y)</span>
<span id="cb1-18">  t <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;">t.test</span>(X, Y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mu =</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;">paired =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb1-19">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">var.equal =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> df)</span>
<span id="cb1-20">  t.sim[i] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> t[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]]</span>
<span id="cb1-21">}</span></code></pre></div></div>
</div>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; Error in `theme_less()`:
#&gt; ! could not find function "theme_less"</code></pre>
</div>
<hr>
<p>Many frequentist statisticians do not consider <img src="https://latex.codecogs.com/png.latex?P">-values to be valid/useful if they fail to meet this validity criterion of being uniform, hence they do not recognize variants such as the posterior predictive <img src="https://latex.codecogs.com/png.latex?P">-value (which concentrates around values such as 0.5, rather than being uniform) to be valid.</p>
<p>Indeed, there have been great efforts to calibrate the <img src="https://latex.codecogs.com/png.latex?P">-value which ranges from mathematical solutions such as taking the <img src="https://latex.codecogs.com/png.latex?(1%20+%20%5B-e*p*%5Clog(p)%5D%5E%7B-1%7D)%5E%7B-1%7D"> which gives the lower bound on the conditional type I error,<span class="citation" data-cites="sellkeCalibrationValuesTesting2001 greenlandTechnicalIssuesInterpretation2020"><sup>11, 12</sup></span> to taking the <img src="https://latex.codecogs.com/png.latex?C_%7B1%7D(K):=%5Csqrt%7BK%7D-1"> of the <img src="https://latex.codecogs.com/png.latex?P">-value (the square-root calibrator), yielding a test martingale,<span class="citation" data-cites="shaferTestMartingalesBayes2011"><sup>13</sup></span> or even empirically attempting to recalibrate the <img src="https://latex.codecogs.com/png.latex?P">-value by collecting observed <img src="https://latex.codecogs.com/png.latex?P">-values from observational studies with negative controls (“test-hypotheses where the exposure is not believed to cause the outcome”) and using them to calculate the empirical null distribution.<span class="citation" data-cites="schuemieRobustEmpiricalCalibration2016"><sup>14</sup></span></p>
<p>The latter is done since observational studies are prone to several more biases than controlled, randomized experiments, thus the observed <img src="https://latex.codecogs.com/png.latex?P">-values and estimated effect sizes are used to calculate the systematic errors within the sampling distribution and are used for recalibration of the <img src="https://latex.codecogs.com/png.latex?P">-value. Whether or not this approach is effective, however, is a different matter.<span class="citation" data-cites="gruberLimitationsEmpiricalCalibration2016"><sup>15</sup></span> In short, calibration is an often sought-out property of <img src="https://latex.codecogs.com/png.latex?P">-values.</p>
<p>Many frequentist statisticians do not consider <img src="https://latex.codecogs.com/png.latex?P">-values to be valid/useful if they fail to meet this validity criterion of being uniform, hence they do not recognize variants such as the posterior predictive <img src="https://latex.codecogs.com/png.latex?P">-value (which concentrates around values such as 0.5, rather than being uniform) to be valid.</p>
<p>Indeed, there have been great efforts to calibrate the <img src="https://latex.codecogs.com/png.latex?P">-value which ranges from mathematical solutions such as taking the <img src="https://latex.codecogs.com/png.latex?(1%20+%20%5B-e*p*%5Clog(p)%5D%5E%7B-1%7D)%5E%7B-1%7D"> which gives the lower bound on the conditional type I error,<span class="citation" data-cites="sellkeCalibrationValuesTesting2001 greenlandTechnicalIssuesInterpretation2020"><sup>11, 12</sup></span> to taking the <img src="https://latex.codecogs.com/png.latex?C_%7B1%7D(K):=%5Csqrt%7BK%7D-1"> of the <img src="https://latex.codecogs.com/png.latex?P">-value (the square-root calibrator), yielding a test martingale,<span class="citation" data-cites="shaferTestMartingalesBayes2011"><sup>13</sup></span> or even empirically attempting to recalibrate the <img src="https://latex.codecogs.com/png.latex?P">-value by collecting observed <img src="https://latex.codecogs.com/png.latex?P">-values from observational studies with negative controls (“test-hypotheses where the exposure is not believed to cause the outcome”) and using them to calculate the empirical null distribution.<span class="citation" data-cites="schuemieRobustEmpiricalCalibration2016"><sup>14</sup></span></p>
<p>The latter is done since observational studies are prone to several more biases than controlled, randomized experiments, thus the observed <img src="https://latex.codecogs.com/png.latex?P">-values and estimated effect sizes are used to calculate the systematic errors within the sampling distribution and are used for recalibration of the <img src="https://latex.codecogs.com/png.latex?P">-value. Whether or not this approach is effective, however, is a different matter.<span class="citation" data-cites="gruberLimitationsEmpiricalCalibration2016"><sup>15</sup></span> In short, calibration is an often sought-out property of <img src="https://latex.codecogs.com/png.latex?P">-values.</p>
<hr>
</section>
</section>
<section id="the-different-interpretations" class="level1">
<h1>The Different Interpretations</h1>
<hr>
<section id="the-decision-theoretic-approach" class="level2">
<h2 class="anchored" data-anchor-id="the-decision-theoretic-approach">The Decision-Theoretic Approach</h2>
<hr>
<p>Many researchers interpret the <img src="https://latex.codecogs.com/png.latex?P">-value in a behavioral, decision-guiding way such as being statistically significant or not (defined below) depending on whether observed <em>p</em> from a study (the realization of the random variable <img src="https://latex.codecogs.com/png.latex?P">) falls below a fixed cutoff level (<img src="https://latex.codecogs.com/png.latex?%5Calpha">, which is the maximum tolerable type I error rate).<span class="citation" data-cites="neymanProblemMostEfficient1933"><sup>16</sup></span></p>
<hr>
</section>
<section id="statistical-significance" class="level2">
<h2 class="anchored" data-anchor-id="statistical-significance">Statistical Significance</h2>
<hr>
<p>Thus, in this approach, users do not care how small or large the observed <img src="https://latex.codecogs.com/png.latex?P">-value <img src="https://latex.codecogs.com/png.latex?p"> is, but simply, whether or not it fell beneath the pre-specified <img src="https://latex.codecogs.com/png.latex?%5Calpha"> level (often 0.05). If it falls below <img src="https://latex.codecogs.com/png.latex?%5Calpha"> they behave inline with the rejection of this test hypothesis, and if it fails to fall below <img src="https://latex.codecogs.com/png.latex?%5Calpha">, then they must behave in a manner where they accept this test hypothesis. The phrase <em>statistical significance</em>, simply indicates that the observed <img src="https://latex.codecogs.com/png.latex?P">-value <img src="https://latex.codecogs.com/png.latex?p"> fell below this pre-specified <img src="https://latex.codecogs.com/png.latex?%5Calpha"> level, and nothing else. It does not indicate any meaningful significance on its own.</p>
<p>The pioneers of this approach, Jerzy Neyman and Egon Pearson, define this behavioral guidance in their 1933 paper, “On the Problem of the Most Efficient Tests of Statistical Hypotheses”<span class="citation" data-cites="neymanProblemMostEfficient1933"><sup>16</sup></span></p>
<hr>
<blockquote class="blockquote">
<p>Without hoping to know whether each separate hypothesis is true or false, we may search for rules to govern our behavior with regard to them, in following which we insure that, in the long run of experience, we shall not be too often wrong.</p>
</blockquote>
<hr>
<p>This decision-making framework may be useful in certain scenarios,<span class="citation" data-cites="whiteheadCaseFrequentismClinical1993"><sup>17</sup></span> where some sort of randomization is possible, where experiments can be repeated, and where there is large control over the experimental conditions, with one of the most notable historical examples being Egon Pearson (son of Karl Pearson and coauthor of Jerzy Neyman) using it to <a href="https://www.ams.org/journals/bull/1936-42-09/S0002-9904-1936-06365-2/S0002-9904-1936-06365-2.pdf">improve quality control</a> in industrial settings.</p>
<p>Contrary to some claims,<span class="citation" data-cites="rubinWhatTypeType2019"><sup>18</sup></span> this approach does <strong>NOT</strong> require exact replications of the experiments, instead, it requires that a valid <img src="https://latex.codecogs.com/png.latex?%5Calpha"> level is used consistently.<span class="citation" data-cites="neymanProblemMostEfficient1933 Lehmann2011-vs"><sup>16, 19</sup></span> In this approach, the exact, observed <img src="https://latex.codecogs.com/png.latex?P">-value from a study is not as relevant and cannot validly be interpreted without an entire set of studies that are compared to the fixed error rate (<img src="https://latex.codecogs.com/png.latex?%5Calpha">).</p>
<hr>
<figure class="figure">
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700110/Site/classicalgiants.png" alt="Picture of the giants who founded frequentist statistics such as Egon Pearson, Ronald Fisher, and Jerzy Neyman" width="800" style="cursor: zoom-in" class="figure-img"></p>
<figcaption>
From left to right: Ronald A. Fisher, Jerzy Neyman, and Egon Pearson.
</figcaption>
</figure>
<hr>
</section>
<section id="the-inductive-approach" class="level2">
<h2 class="anchored" data-anchor-id="the-inductive-approach">The Inductive Approach</h2>
<hr>
<p>Others interpret the <img src="https://latex.codecogs.com/png.latex?P">-value <img src="https://latex.codecogs.com/png.latex?p"> in an inductive inferential/evidential (<strong>Fisherian</strong>) way,<span class="citation" data-cites="fisherDesignExperiments1935 fisherStatisticalMethodsScientific1955"><sup>20, 21</sup></span> as a <strong>continuous</strong> measure of evidence against the very test hypothesis and entire model (all assumptions) used to compute it (let’s go with this for now, even though there are some problems with this interpretation, more on that below).</p>
<p>This interpretation as a continuous measure of evidence <strong>against</strong> the test hypothesis and the entire model used to compute it can be seen in the figure below from<span class="citation" data-cites="greenlandAidScientificInference2020"><sup>7</sup></span>. In one framework (left panel), we may assume certain assumptions to be true (“conditioning” on them, i.e, use of random assignment), and in the other (right panel), we question all assumptions, hence the “unconditional” interpretation. Unlike the <strong>Neyman-Pearson</strong> approach, this inferential approach allows interpretation of <img src="https://latex.codecogs.com/png.latex?P">-values from single studies, and indeed, lower values of it are taken as more evidence against the tested hypothesis.</p>
<hr>
</section>
<section id="null-hypothesis-significance-testing" class="level2">
<h2 class="anchored" data-anchor-id="null-hypothesis-significance-testing">Null-Hypothesis Significance Testing</h2>
<hr>
<p>However, it is also worth pointing out that most individuals do not interpret <img src="https://latex.codecogs.com/png.latex?P">-values from a <strong>Neyman-Pearson</strong> or <strong>Fisherian</strong> standpoint, rather, they fuse both approaches together, which is what we commonly know today as “null-hypothesis significance testing.” This approach is regarded by most as being a incompatible hybrid given that it often confuses error rates (<img src="https://latex.codecogs.com/png.latex?%5Calpha">, <img src="https://latex.codecogs.com/png.latex?%5Cbeta">), which are fixed before a study, with the <img src="https://latex.codecogs.com/png.latex?P">-value, which is not a fixed error-rate, and the fusion of these approaches often has been blamed for the replication crisis in science by many statisticians. Though some believe these approaches can be reconciled and are useful.<span class="citation" data-cites="bickelNullHypothesisSignificance2019"><sup>22</sup></span></p>
<hr>
<figure class="figure">
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1605000180/Site/pvalueassumptions.svg" alt="P-value assumptions" width="500" style="cursor: zoom-in" class="figure-img"></p>
<figcaption>
Conditional versus unconditional interpretations of P-values, S-values, and compatibility intervals (CIs). (A) Conditional interpretation, in which background model assumptions, such as no systematic error, are assumed to be correct; thus,the information provided by the P-value and S-value is targeted towards the test hypothesis. (B)Unconditional interpretation, in which no aspect of the statistical model is assumed to be correct; thus,the information provided by the P-value and S-value is targeted toward the entire test model.
</figcaption>
</figure>
<hr>
<p>Back to the <strong>Fisherian</strong> approach, the interpretation of the <img src="https://latex.codecogs.com/png.latex?P">-value as a continuous measure of evidence against the test model that produced it shouldn’t be confused with other statistics that serve as support measures. Likelihood ratios and Bayes factors are <strong>absolute</strong> measures of evidence <strong>for</strong> a model compared to another model, whereas the <img src="https://latex.codecogs.com/png.latex?P">-value is a <strong>relative</strong> measure of “evidence” (more on that below) that can be tricky to interpret.<span class="citation" data-cites="jeffreysTestsSignificanceTreated1935 jeffreysTheoryProbability1998 royallStatisticalEvidenceLikelihood1997"><sup>23–25</sup></span> Indeed, this is why the <img src="https://latex.codecogs.com/png.latex?P">-value is converted by some Bayesians to a lower bound of the Bayes factor by taking <img src="https://latex.codecogs.com/png.latex?-e*p*%5Clog(p)">.<span class="citation" data-cites="sellkeCalibrationValuesTesting2001 greenlandTechnicalIssuesInterpretation2020"><sup>11, 12</sup></span></p>
<hr>
</section>
<section id="measure-of-compatibility" class="level2">
<h2 class="anchored" data-anchor-id="measure-of-compatibility">Measure of Compatibility</h2>
<hr>
<p>The <img src="https://latex.codecogs.com/png.latex?P">-value is not an absolute measure of evidence for a model (such as the null/alternative model), it is a continuous <strong>measure of the compatibility</strong> of the <strong>observed data</strong> with the <strong>model</strong> used to compute it.<span class="citation" data-cites="greenlandStatisticalTestsValues2016"><sup>3</sup></span></p>
<p>If it’s high, it means the observed data are <strong>very compatible</strong> with the model used to compute it. If it’s very low, then it indicates that the data are <strong>not as compatible</strong> with the model used to calculate it, and this low compatibility may be due to random variation and/or it may be due to a violation of assumptions (such as the null model not being true, not using randomization, a programming error or equipment defect such as that <a href="https://www.washingtonpost.com/blogs/compost/post/faster-than-light-neutrinos-arent/2012/02/23/gIQA5MmjVR_blog.html">seen with neutrinos</a>, etc.).</p>
<p>Low compatibility of the data with the model can be implied as evidence against the test hypothesis, if we accept the rest of the model used to compute the <img src="https://latex.codecogs.com/png.latex?P">-value. Thus, lower <img src="https://latex.codecogs.com/png.latex?P">-values from a <strong>Fisherian</strong> perspective are seen as stronger evidence against the test hypothesis given the rest of the model.</p>
<hr>
</section>
</section>
<section id="common-misleading-criticisms" class="level1">
<h1>Common, Misleading Criticisms</h1>
<hr>
<section id="estimation-and-intervals" class="level2">
<h2 class="anchored" data-anchor-id="estimation-and-intervals">Estimation and Intervals</h2>
<hr>
<p>A common criticism put forth by many is that <img src="https://latex.codecogs.com/png.latex?P">-values are useless, given that they cannot tell you the size of the effect and because they are confounded by sample size and effect size, and that researchers should instead give compatibility (confidence) intervals. However, this criticism is nonsensical as they can both be given and serve different purposes.</p>
<p>A <img src="https://latex.codecogs.com/png.latex?P">-value for a particular parameter value gives the compatibility between the test model in question, which will vary from one parameter value to the next, and the data. An interval estimate such as a 95% frequentist interval simply gives the region of parameter values with <img src="https://latex.codecogs.com/png.latex?P">-values above the corresponding <img src="https://latex.codecogs.com/png.latex?%5Calpha"> level, and which are more consistent with the data than the parameter values outside the interval limits. An interval estimate by itself does not explicitly tell one how consistent a parameter value is with the data, which the <img src="https://latex.codecogs.com/png.latex?P">-value does.</p>
<hr>
</section>
<section id="overstating-the-evidence" class="level2">
<h2 class="anchored" data-anchor-id="overstating-the-evidence">Overstating the Evidence</h2>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?P">-values are routinely criticized for overstating the amount of evidence from a study. Such statements are also often given using Bayesian arguments, of which many are skeptical. However, the <img src="https://latex.codecogs.com/png.latex?P">-value cannot overstate evidence as it is simply providing the location at which the test statistic fell in the expected distribution, given that every model assumption were true. It is simply indicative of how surprising/extreme the observed result was, given certain assumptions.</p>
<p>Any overstating of evidence, is not an issue of the statistic itself, but rather users. If we treat the <img src="https://latex.codecogs.com/png.latex?P-"> value as nothing more or less than a continuous measure of compatibility of the observed data with the model used to compute it (observed <img src="https://latex.codecogs.com/png.latex?p">) given certain model assumptions, we won’t run into some of the common misinterpretations such as “the <img src="https://latex.codecogs.com/png.latex?P">-value is the probability of a hypothesis”, or the “probability of chance alone”, or “the probability of being incorrect”.<span class="citation" data-cites="greenlandStatisticalTestsValues2016"><sup>3</sup></span></p>
<p>Indeed, many of the “problems” commonly associated with the <img src="https://latex.codecogs.com/png.latex?P">-value are not due to the actual statistic itself, but rather researchers’ misinterpretations of what it is and what it means for a study.</p>
<p>The answer to these misconceptions may be compatibilism, with less compatibility (smaller <img src="https://latex.codecogs.com/png.latex?P">-values) indicating a poor fit between the data and the test model and hence more evidence against the test hypothesis.</p>
<p>A <img src="https://latex.codecogs.com/png.latex?P">-value of 0.04 means that assuming that <strong>all</strong> the assumptions of the model used to compute the <img src="https://latex.codecogs.com/png.latex?P">-value are correct, we won’t get data (a test statistic) at least as extreme as what was observed by random variation more than 4% of the time.</p>
<p>To many, such low compatibility between the data and the model may lead them to reject the test hypothesis (the null hypothesis).</p>
<hr>
</section>
</section>
<section id="some-valid-issues" class="level1">
<h1>Some Valid Issues</h1>
<hr>
<section id="mismatch-with-direction" class="level2">
<h2 class="anchored" data-anchor-id="mismatch-with-direction">Mismatch With Direction</h2>
<hr>
<p>If you recall from above, I wrote that the <img src="https://latex.codecogs.com/png.latex?P">-value is seen by many as being a continuous measure of evidence against the test hypothesis and model. Technically speaking, it would be incorrect to define it this way because as the <img src="https://latex.codecogs.com/png.latex?P">-value goes up (with the highest value being 1 or 100%), there is <strong>less</strong> evidence against the test hypothesis since the data are <strong>more compatible</strong> with the test model. 1 = perfect compatibility of the data with the test model.</p>
<p>As the <img src="https://latex.codecogs.com/png.latex?P">-value gets lower (with the lowest value being 0), there is <strong>less compatibility</strong> between the data and the model, hence <strong>more</strong> evidence against the test hypothesis used to compute <img src="https://latex.codecogs.com/png.latex?p">.</p>
<p>Thus, saying that <img src="https://latex.codecogs.com/png.latex?P">-values are measures of evidence against the hypothesis used to compute them is a backward definition. This definition would be correct if higher <img src="https://latex.codecogs.com/png.latex?P">-values inferred more evidence against the test hypothesis and vice versa.</p>
<hr>
</section>
<section id="difficulties-due-to-scale" class="level2">
<h2 class="anchored" data-anchor-id="difficulties-due-to-scale">Difficulties Due to Scale</h2>
<hr>
<p>Another problem with <img src="https://latex.codecogs.com/png.latex?P">-values and their interpretation is scaling. Since the statistic is meant to be a continuous measure of compatibility (and relative evidence against the test model + hypothesis), we would hope that differences between <img src="https://latex.codecogs.com/png.latex?P">-values would be equal (on an additive scale), as this makes it easier to interpret.</p>
<p>For example, the difference between 0 and 10 dollars is the same as the difference between 90 and 100 dollars, in that both are a difference of 10 dollars. And this property remains consistent across various intervals, 120 and 130, 1,000,000 and 1,000,010.</p>
<p>Unfortunately, this doesn’t apply to the <img src="https://latex.codecogs.com/png.latex?P">-value because it is on the inverse-exponential scale. The difference between a <img src="https://latex.codecogs.com/png.latex?P">-value of 0.01 and 0.10 is not the same as the difference between 0.90 and 0.99.</p>
<hr>
<figure class="figure">
<p><img src="https://lesslikely.com/images/norm.svg" alt="Gaussian distribution" width="680" style="cursor: zoom-in" class="figure-img"></p>
<figcaption>
A gaussian probability densitiy with the standard deviations annotated. Data points further away from the mean, are more extreme and unlikely events. I also must admit that this is one of my favorite figures of a gaussian distribution.
</figcaption>
</figure>
<hr>
<hr>
<p>For example, with a normal distribution (above), a z-score of 0 results in a <img src="https://latex.codecogs.com/png.latex?P">-value of 1 (perfect compatibility). If we now move to a z-score of 1, the <img src="https://latex.codecogs.com/png.latex?P">-value is 0.31. Thus, we saw a dramatic decrease from a <img src="https://latex.codecogs.com/png.latex?P">-value of 1 to 0.31 with one z-score. A 0.69 decrease in the <img src="https://latex.codecogs.com/png.latex?P">-value.</p>
<p>Now let’s move from a z-score of 1 to a z-score of 2. We saw a decrease of 0.69 with the change in <strong>one</strong> z-score before, so the new <img src="https://latex.codecogs.com/png.latex?P">-value must be 0.31 - 0.69 = -0.38 right? <strong>No</strong>. The <img src="https://latex.codecogs.com/png.latex?P">-value for a z-score of 2 is 0.045. The <img src="https://latex.codecogs.com/png.latex?P">-value for a z-score of 3 is 0.003. Even though we’ve only been moving by <strong>one</strong> z-score at a time, the changes in <img src="https://latex.codecogs.com/png.latex?P">-values don’t remain constant; the decreases become larger and larger.</p>
<p>Thus, the difference between the <img src="https://latex.codecogs.com/png.latex?P">-values of 0.01 and 0.10, in terms of z-score, is substantially larger than the difference between 0.90 and 0.99. Again, this makes it difficult to interpret as a statistic across the board, especially as a continuous measure. This can further be seen in the figure from <a href="https://doi.org/10.1186/s12874-020-01105-9">Rafi &amp; Greenland (2020)</a>.</p>
<table class="caption-top table">
<tbody>
<tr class="odd">
<td style="text-align: left;"></td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="resolution-with-surprisals" class="level1">
<h1>Resolution with Surprisals</h1>
<hr>
<p>The issues described above such as the backward definition and the problem of scaling can make it difficult to conceptualize the <img src="https://latex.codecogs.com/png.latex?P">-value as being an evidence measure against the test hypothesis and test model. However, these issues can be addressed by taking the negative log of the <img src="https://latex.codecogs.com/png.latex?P">-value <img src="https://latex.codecogs.com/png.latex?%E2%80%93%5Clog_%7B2%7D(p)"> , which yields something known as the Shannon information value or <em>surprisal (</em><img src="https://latex.codecogs.com/png.latex?s">) value,<span class="citation" data-cites="rafiSemanticCognitiveTools2020 coleSurprise2020 greenlandValidPvaluesBehave2019"><sup>4, 5, 26</sup></span> named after <a href="https://en.wikipedia.org/wiki/Claude_Shannon">Claude Shannon</a>, the father of information theory.<span class="citation" data-cites="Shannon1948-uq"><sup>27</sup></span></p>
<table class="caption-top table">
<tbody>
<tr class="odd">
<td style="text-align: left;"></td>
</tr>
</tbody>
</table>
<p>Unlike the <img src="https://latex.codecogs.com/png.latex?P">-value, this value is not a probability but a continuous measure of <em>information</em> in <strong>bits</strong> of information against the test hypothesis and is taken from the observed test statistic computed by the test model.</p>
<p>It also provides a more intuitive way to think about <img src="https://latex.codecogs.com/png.latex?P">-values. Imagine that the variable <img src="https://latex.codecogs.com/png.latex?k"> is always the nearest integer to the calculated value of <img src="https://latex.codecogs.com/png.latex?s">. Now, take for example a <img src="https://latex.codecogs.com/png.latex?P">-value of 0.05, the <img src="https://latex.codecogs.com/png.latex?S">-value for this would be <img src="https://latex.codecogs.com/png.latex?s"> = <img src="https://latex.codecogs.com/png.latex?%E2%80%93%5Clog_%7B2%7D(0.05)"> which equals 4.3 bits of information embedded in the test statistic, which can be implied as evidence against the test hypothesis.</p>
<p>How much evidence is this? <img src="https://latex.codecogs.com/png.latex?k"> can help us think about this. The nearest integer to 4.3 is 4. Thus, the data which yield a <img src="https://latex.codecogs.com/png.latex?P">-value of 0.05 which results in an <img src="https://latex.codecogs.com/png.latex?s"> value of 4.3 bits of information is <strong>no more surprising</strong> than getting <strong>all heads</strong> on 4 fair coin tosses.</p>
<p>Another example. Let’s say our study gives us a <img src="https://latex.codecogs.com/png.latex?P">-value of 0.005, which would indicate to many very low compatibility between the test model and the observed data; this would yield an <img src="https://latex.codecogs.com/png.latex?s"> value of <img src="https://latex.codecogs.com/png.latex?%E2%80%93%5Clog_%7B2%7D(0.005)%20=%207.6"> bits of information. <img src="https://latex.codecogs.com/png.latex?k"> which is the closest integer to <img src="https://latex.codecogs.com/png.latex?s"> would be 8. Thus, these data which yield a <img src="https://latex.codecogs.com/png.latex?P">-value of 0.005 are no more surprising than getting all heads on 8 fair coin tosses.</p>
<p>A table of various <img src="https://latex.codecogs.com/png.latex?P">-values and their corresponding <img src="https://latex.codecogs.com/png.latex?S">-values, maximum-likelihood ratios, and likelihood-ratio statistics can be found below from <a href="https://doi.org/10.1186/s12874-020-01105-9">Rafi &amp; Greenland (2020)</a>, which includes the general cutoffs used in different scientific fields such as high-energy physics and genome-wide association studies. It also shows how the traditional cutoffs used in these fields can be problematic.</p>
<p>For example, an <img src="https://latex.codecogs.com/png.latex?%5Calpha"> of 0.05, which only corresponds to seeing all heads on 4 fair coin tosses, is practically nothing when compared to the cutoffs used in particle physics and GWAS, which correspond to seeing all heads on 22 and 30 fair coin tosses, respectively.</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<table class="lightable-classic caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: left; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">P-value (compatibility)</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">S-value (bits)</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Maximum Likelihood Ratio</th>
<th data-quarto-table-cell-role="th" style="text-align: right; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Deviance Statistic 2ln(MLR)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.99</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.000e+00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.00</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.9</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.15</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.010e+00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.02</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.5</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.260e+00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">0.45</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.25</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.940e+00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.32</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.1</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">3.32</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">3.870e+00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.71</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.05</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">4.32</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">6.830e+00</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">3.84</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.025</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.32</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.230e+01</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.02</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.01</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">6.64</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">2.760e+01</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">6.63</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">0.005</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">7.64</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.140e+01</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">7.88</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">1e-04</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">13.29</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.935e+03</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">15.10</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">5 sigma (~ 2.9 in 10 million)</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">21.70</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">5.200e+05</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">26.30</td>
</tr>
<tr class="even">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">1 in 100 million (GWAS)</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">26.60</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.400e+07</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">32.80</td>
</tr>
<tr class="odd">
<td style="text-align: left; color: rgba(119, 119, 119, 255) !important;">6 sigma (~ 1 in a billion)</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">29.90</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">1.300e+08</td>
<td style="text-align: right; color: rgba(119, 119, 119, 255) !important;">37.40</td>
</tr>
</tbody><tfoot>
<tr class="odd">
<td style="text-align: left; padding: 0;"><span style="text-decoration: underline;">Abbreviations: </span></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
</tr>
<tr class="even">
<td style="text-align: left; padding: 0;"><sup></sup> Table 1: $P$-values and binary $S$-values, with corresponding maximum-likelihood ratios (MLR) and deviance (likelihood-ratio) statistics for a simple test hypothesis H under background assumptions A</td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
</tr>
</tfoot>

</table>
</div>
</div>
<hr>
<p>Unlike the <img src="https://latex.codecogs.com/png.latex?P">-value, the <img src="https://latex.codecogs.com/png.latex?S">-value is more intuitive as a measure of refutational evidence against the test hypothesis since its value (bits of information against the test hypothesis) increases with less compatibility, whereas the opposite is true for the <img src="https://latex.codecogs.com/png.latex?P">-value.</p>
<hr>
<section id="some-examples" class="level3">
<h3 class="anchored" data-anchor-id="some-examples">Some Examples</h3>
<hr>
<p>Let’s try using some data to see this in action. I’ll take a sample experimental dataset from <code>R</code> on the effects of different conditions on dried plant weight. We can plot the data and run a one-way ANOVA.</p>
<hr>
<div class="cell" data-layout-align="center">
<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">pg <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;">force</span>(PlantGrowth)</span>
<span id="cb3-2">(Hmisc<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;">describe</span>(pg))</span>
<span id="cb3-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; pg </span></span>
<span id="cb3-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb3-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  2  Variables      30  Observations</span></span>
<span id="cb3-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; --------------------------------------------------------------------------------</span></span>
<span id="cb3-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; weight </span></span>
<span id="cb3-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;        n  missing distinct     Info     Mean  pMedian      Gmd      .05 </span></span>
<span id="cb3-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;       30        0       29        1    5.073     5.09   0.8131    3.983 </span></span>
<span id="cb3-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;      .10      .25      .50      .75      .90      .95 </span></span>
<span id="cb3-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    4.170    4.550    5.155    5.530    6.038    6.132 </span></span>
<span id="cb3-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb3-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; lowest : 3.59 3.83 4.17 4.32 4.41, highest: 5.87 6.03 6.11 6.15 6.31</span></span>
<span id="cb3-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; --------------------------------------------------------------------------------</span></span>
<span id="cb3-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; group </span></span>
<span id="cb3-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;        n  missing distinct </span></span>
<span id="cb3-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;       30        0        3 </span></span>
<span id="cb3-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                             </span></span>
<span id="cb3-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Value       ctrl  trt1  trt2</span></span>
<span id="cb3-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Frequency     10    10    10</span></span>
<span id="cb3-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Proportion 0.333 0.333 0.333</span></span>
<span id="cb3-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; --------------------------------------------------------------------------------</span></span></code></pre></div></div>
</div>
<hr>
<p>Looks interesting. We can see some differences from the graph. Here’s what our test output gives us,</p>
<hr>
<div class="cell" data-layout-align="center">
<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">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;">anova</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(weight <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> pg))</span>
<span id="cb4-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ztable</span>(res)</span>
<span id="cb4-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Error in `ztable()`:</span></span>
<span id="cb4-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ! could not find function "ztable"</span></span></code></pre></div></div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<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">(obs_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> res[<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;">5</span>])</span>
<span id="cb5-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 0.01590996</span></span></code></pre></div></div>
</div>
<hr>
<p>If we had set our <img src="https://latex.codecogs.com/png.latex?%5Calpha"> to the traditional 0.05 level before the experiment, we can reject the test hypothesis (the null hypothesis), but that is not as interesting from a continuous evidential perspective. How can I interpret this <img src="https://latex.codecogs.com/png.latex?P">-value of 0.0159 more intuitively?</p>
<p>Let’s convert it into an <img src="https://latex.codecogs.com/png.latex?S">-value.</p>
<hr>
<div class="cell" data-layout-align="center">
<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="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log2</span>(obs_p)</span>
<span id="cb6-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [1] 5.973926</span></span></code></pre></div></div>
</div>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?%E2%80%93%5Clog_2(0.0159)%20=%205.97"></p>
<hr>
<p><img src="https://latex.codecogs.com/png.latex?s=%205.97"></p>
<hr>
<p>That is 5.97 bits of information against the null hypothesis.</p>
<p>Remember, <img src="https://latex.codecogs.com/png.latex?k"> is the nearest integer to the calculated value of <img src="https://latex.codecogs.com/png.latex?s"> and in this case, would be 6. So these results (the test statistic, <img src="https://latex.codecogs.com/png.latex?F">(4.85)) are as surprising as getting all heads on 6 fair coin tosses. Somewhat surprising, depending on the individual interpreting the results.</p>
<p>How would we interpret it within the context of a given confidence interval? The <img src="https://latex.codecogs.com/png.latex?S">-value tells us that values within the computed 95% CI: have at most 4.3 bits of information against them. That is because all parameter values within a 95% CI have <img src="https://latex.codecogs.com/png.latex?P">-values greater than 0.05.</p>
<p>So those parameter values that are inside the 95% interval estimate have less bits of information against them, than the parameter values that go further and further away from the center of the 95% interval estimate. The point estimate is the most compatible with the data (meaning it has the least refutational information against it), while those values near the limits have more information against them.</p>
<p>In other words, as values head in the directions outside the interval, there is more refutational information against them, as depicted by the following function from <a href="https://doi.org/10.1186/s12874-020-01105-9">Rafi &amp; Greenland, 2020</a>, which is known as the surprisal function.</p>
<table class="caption-top table">
<tbody>
<tr class="odd">
<td style="text-align: left;"></td>
</tr>
</tbody>
</table>
<p>The <img src="https://latex.codecogs.com/png.latex?S">-value is not meant to replace the <img src="https://latex.codecogs.com/png.latex?P">-value, and it isn’t superior to the <img src="https://latex.codecogs.com/png.latex?P">-value. It is merely a logarithmic transformation of it that rescales it on an additive scale and tells us how much information is embedded within the test statistic and can be used as evidence against the test hypothesis. It is meant to be a device to help interpret the information one obtains from a calculated <img src="https://latex.codecogs.com/png.latex?P">-value.</p>
<hr>
<p>I’ve <a href="https://data.lesslikely.com/concurve/articles/svalues.html">constructed a calculator</a> that converts observed <img src="https://latex.codecogs.com/png.latex?P">-values into <img src="https://latex.codecogs.com/png.latex?S">-values and provides an intuitive way to think about them. For a more detailed discussion of <img src="https://latex.codecogs.com/png.latex?S">-values, see this <a href="../../statistics/RG2020BMC">article</a>, in addition to the references below them.</p>
<hr>
</section>
</section>
<section id="s-value-calculator" class="level1">
<h1>S-value Calculator</h1>
<iframe src="https://zadrafi.shinyapps.io/shinyapp/" width="100%" height="1000px" allowfullscreen="allowfullscreen">
</iframe>
<hr>
<hr>
<blockquote class="blockquote">
<p><strong>Acknowledgments:</strong> I’m very grateful to <a href="https://twitter.com/Lester_Domes">Sander Greenland</a> for his extensive commentary and corrections on several versions of this article. My acknowledgment does not imply endorsement of my views by these colleagues, and I remain solely responsible for the views expressed herein.</p>
</blockquote>
<hr>
<p>The analyses were run on:</p>
<hr>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; R version 4.5.2 (2025-10-31)
#&gt; Platform: aarch64-apple-darwin20
#&gt; Running under: macOS Tahoe 26.3
#&gt; 
#&gt; Matrix products: default
#&gt; BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
#&gt; LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
#&gt; 
#&gt; Random number generation:
#&gt;  RNG:     Mersenne-Twister 
#&gt;  Normal:  Inversion 
#&gt;  Sample:  Rejection 
#&gt;  
#&gt; locale:
#&gt; [1] C.UTF-8/C.UTF-8/C.UTF-8/C/C.UTF-8/C.UTF-8
#&gt; 
#&gt; time zone: America/New_York
#&gt; tzcode source: internal
#&gt; 
#&gt; attached base packages:
#&gt;  [1] splines   grid      stats4    parallel  stats     graphics  grDevices
#&gt;  [8] utils     datasets  methods   base     
#&gt; 
#&gt; other attached packages:
#&gt;  [1] pbmcapply_1.5.1       texPreview_2.1.0      tinytex_0.58         
#&gt;  [4] rmarkdown_2.30        brms_2.23.0           bootImpute_1.3.0     
#&gt;  [7] knitr_1.51            boot_1.3-32           reshape2_1.4.5       
#&gt; [10] ProfileLikelihood_1.3 ImputeRobust_1.3-1    gamlss_5.5-0         
#&gt; [13] gamlss.dist_6.1-1     gamlss.data_6.0-7     mvtnorm_1.3-3        
#&gt; [16] performance_0.15.3.6  summarytools_1.1.5    tidybayes_3.0.7      
#&gt; [19] htmltools_0.5.9       Statamarkdown_0.9.6   car_3.1-3            
#&gt; [22] carData_3.0-5         qqplotr_0.0.7         ggcorrplot_0.1.4.1   
#&gt; [25] Amelia_1.8.3          Rcpp_1.1.1            blogdown_1.23        
#&gt; [28] doParallel_1.0.17     iterators_1.0.14      foreach_1.5.2        
#&gt; [31] lattice_0.22-7        bayesplot_1.15.0      wesanderson_0.3.7    
#&gt; [34] VIM_7.0.0             colorspace_2.1-2      here_1.0.2           
#&gt; [37] progress_1.2.3        loo_2.9.0             mi_1.2               
#&gt; [40] Matrix_1.7-4          broom_1.0.12          yardstick_1.3.2      
#&gt; [43] svglite_2.2.2         Cairo_1.7-0           cowplot_1.2.0        
#&gt; [46] mgcv_1.9-4            nlme_3.1-168          xfun_0.56            
#&gt; [49] broom.mixed_0.2.9.6   reticulate_1.44.1     kableExtra_1.4.0     
#&gt; [52] posterior_1.6.1       checkmate_2.3.3       parallelly_1.46.1    
#&gt; [55] miceFast_0.8.5        randomForest_4.7-1.2  missForest_1.6.1     
#&gt; [58] miceadds_3.18-36      mice_3.19.0           quantreg_6.1         
#&gt; [61] SparseM_1.84-2        MCMCpack_1.7-1        MASS_7.3-65          
#&gt; [64] coda_0.19-4.1         latex2exp_0.9.8       rstan_2.32.7         
#&gt; [67] StanHeaders_2.32.10   lubridate_1.9.4       forcats_1.0.1        
#&gt; [70] stringr_1.6.0         dplyr_1.1.4           purrr_1.2.1          
#&gt; [73] readr_2.1.6           tibble_3.3.1          ggplot2_4.0.1        
#&gt; [76] tidyverse_2.0.0       ggtext_0.1.2          concurve_3.0.0       
#&gt; [79] showtext_0.9-7        showtextdb_3.0        sysfonts_0.8.9       
#&gt; [82] future.apply_1.20.1   future_1.69.0         tidyr_1.3.2          
#&gt; [85] magrittr_2.0.4        rms_8.1-0             Hmisc_5.2-5          
#&gt; 
#&gt; loaded via a namespace (and not attached):
#&gt;   [1] dichromat_2.0-0.1       nnet_7.3-20             TH.data_1.1-5          
#&gt;   [4] vctrs_0.7.1             digest_0.6.39           png_0.1-8              
#&gt;   [7] shape_1.4.6.1           proxy_0.4-29            magick_2.9.0           
#&gt;  [10] fontLiberation_0.1.0    withr_3.0.2             ggpubr_0.6.2           
#&gt;  [13] survival_3.8-6          doRNG_1.8.6.2           emmeans_2.0.1          
#&gt;  [16] MatrixModels_0.5-4      systemfonts_1.3.1       ragg_1.5.0             
#&gt;  [19] zoo_1.8-15              V8_8.0.1                ggdist_3.3.3           
#&gt;  [22] DEoptimR_1.1-4          Formula_1.2-5           prettyunits_1.2.0      
#&gt;  [25] rematch2_2.1.2          httr_1.4.7              otel_0.2.0             
#&gt;  [28] rstatix_0.7.3           globals_0.18.0          ps_1.9.1               
#&gt;  [31] rstudioapi_0.18.0       extremevalues_2.4.1     pan_1.9                
#&gt;  [34] generics_0.1.4          processx_3.8.6          base64enc_0.1-3        
#&gt;  [37] curl_7.0.0              mitools_2.4             lgr_0.5.0              
#&gt;  [40] desc_1.4.3              xtable_1.8-4            svUnit_1.0.8           
#&gt;  [43] pracma_2.4.6            evaluate_1.0.5          hms_1.1.4              
#&gt;  [46] glmnet_4.1-10           rcartocolor_2.1.2       lmtest_0.9-40          
#&gt;  [49] palmerpenguins_0.1.1    robustbase_0.99-6       matrixStats_1.5.0      
#&gt;  [52] svgPanZoom_0.3.4        class_7.3-23            pillar_1.11.1          
#&gt;  [55] caTools_1.18.3          compiler_4.5.2          stringi_1.8.7          
#&gt;  [58] paradox_1.0.1           jomo_2.7-6              minqa_1.2.8            
#&gt;  [61] plyr_1.8.9              crayon_1.5.3            abind_1.4-8            
#&gt;  [64] metadat_1.4-0           sp_2.2-0                mathjaxr_2.0-0         
#&gt;  [67] rapportools_1.2         twosamples_2.0.1        sandwich_3.1-1         
#&gt;  [70] whisker_0.4.1           codetools_0.2-20        multcomp_1.4-29        
#&gt;  [73] textshaping_1.0.4       bcaboot_0.2-3           openssl_2.3.4          
#&gt;  [76] flextable_0.9.10        QuickJSR_1.9.0          e1071_1.7-17           
#&gt;  [79] gridtext_0.1.5          lme4_1.1-38             fs_1.6.6               
#&gt;  [82] itertools_0.1-3         listenv_0.10.0          Rdpack_2.6.5           
#&gt;  [85] pkgbuild_1.4.8.9000     estimability_1.5.1      ggsignif_0.6.4         
#&gt;  [88] callr_3.7.6             tzdb_0.5.0              pkgconfig_2.0.3        
#&gt;  [91] tools_4.5.2             rbibutils_2.4.1         viridisLite_0.4.2      
#&gt;  [94] DBI_1.2.3               numDeriv_2016.8-1.1     fastmap_1.2.0          
#&gt;  [97] scales_1.4.0            officer_0.7.3           opdisDownsampling_1.0.1
#&gt; [100] insight_1.4.5           rpart_4.1.24            farver_2.1.2           
#&gt; [103] reformulas_0.4.3.1      survminer_0.5.1         yaml_2.3.12            
#&gt; [106] foreign_0.8-90          cli_3.6.5               lifecycle_1.0.5        
#&gt; [109] askpass_1.2.1           bbotk_1.8.1             backports_1.5.0        
#&gt; [112] Brobdingnag_1.2-9       mlr3tuning_1.5.1        timechange_0.3.0       
#&gt; [115] gtable_0.3.6            arrayhelpers_1.1-0      metafor_4.8-0          
#&gt; [118] jsonlite_2.0.0          mitml_0.4-5             bitops_1.0-9           
#&gt; [121] qqconf_1.3.2            mlr3learners_0.14.0     zip_2.3.3              
#&gt; [124] ranger_0.18.0           RcppParallel_5.1.11-1   polspline_1.1.25       
#&gt; [127] bridgesampling_1.2-1    survMisc_0.5.6          distributional_0.6.0   
#&gt; [130] pander_0.6.6            details_0.4.0           KMsurv_0.1-6           
#&gt; [133] mlr3pipelines_0.10.0    glue_1.8.0              tcltk_4.5.2            
#&gt; [136] gdtools_0.4.4           rprojroot_2.1.1         mcmc_0.9-8             
#&gt; [139] gridExtra_2.3           mlr3_1.3.0              R6_2.6.1               
#&gt; [142] arm_1.14-4              km.ci_0.5-6             vcd_1.4-13             
#&gt; [145] clipr_0.8.0             cluster_2.1.8.1         rngtools_1.5.2         
#&gt; [148] nloptr_2.2.1            mlr3misc_0.19.0         rstantools_2.6.0       
#&gt; [151] tidyselect_1.2.1        htmlTable_2.4.3         tensorA_0.36.2.1       
#&gt; [154] xml2_1.5.2              inline_0.3.21           fontBitstreamVera_0.1.1
#&gt; [157] S7_0.2.1                furrr_0.3.1             laeken_0.5.3           
#&gt; [160] fontquiver_0.2.1        data.table_1.18.2.1     htmlwidgets_1.6.4      
#&gt; [163] RColorBrewer_1.1-3      rlang_1.1.7             uuid_1.2-2</code></pre>
</div>
<hr>
</section>
<section id="references" class="level1">
<h1>References</h1>
<hr>



</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" data-entry-spacing="2" data-line-spacing="2">
<div id="ref-gigerenzerStatisticalRitualsReplication2018" class="csl-entry">
1. Gigerenzer G. (2018). <span>“Statistical <span>Rituals</span>: <span>The Replication Delusion</span> and <span>How We Got There</span>.”</span> <em>Advances in Methods and Practices in Psychological Science</em>. <strong>1</strong>:198–218. doi: <a href="https://doi.org/10.1177/2515245918771329">10.1177/2515245918771329</a>.
</div>
<div id="ref-goodmanDirtyDozenTwelve2008" class="csl-entry">
2. Goodman S. (2008). <span>“A <span>Dirty Dozen</span>: <span>Twelve P</span>-<span>Value Misconceptions</span>.”</span> <em>Seminars in Hematology</em>. <strong>45</strong>:135–140. doi: <a href="https://doi.org/10.1053/j.seminhematol.2008.04.003">10.1053/j.seminhematol.2008.04.003</a>.
</div>
<div id="ref-greenlandStatisticalTestsValues2016" class="csl-entry">
3. Greenland S, Senn SJ, Rothman KJ, Carlin JB, Poole C, Goodman SN, et al. (2016). <span>“Statistical tests, <span>P</span> values, confidence intervals, and power: <span>A</span> guide to misinterpretations.”</span> <em>European Journal of Epidemiology</em>. <strong>31</strong>:337–350. doi: <a href="https://doi.org/10.1007/s10654-016-0149-3">10.1007/s10654-016-0149-3</a>.
</div>
<div id="ref-rafiSemanticCognitiveTools2020" class="csl-entry">
4. Rafi Z, Greenland S. (2020). <span>“Semantic and cognitive tools to aid statistical science: Replace confidence and significance by compatibility and surprise.”</span> <em>BMC Medical Research Methodology</em>. <strong>20</strong>:244. doi: <a href="https://doi.org/10.1186/s12874-020-01105-9">10.1186/s12874-020-01105-9</a>.
</div>
<div id="ref-greenlandValidPvaluesBehave2019" class="csl-entry">
5. Greenland S. (2019). <span>“Valid <span>P</span>-values behave exactly as they should: <span>Some</span> misleading criticisms of <span>P</span>-values and their resolution with <span>S</span>-values.”</span> <em>The American Statistician</em>. <strong>73</strong>:106–114. doi: <a href="https://doi.org/10.1080/00031305.2018.1529625">10.1080/00031305.2018.1529625</a>.
</div>
<div id="ref-greenlandSparseDataBias2016" class="csl-entry">
6. Greenland S, Mansournia MA, Altman DG. (2016). <span>“Sparse data bias: A problem hiding in plain sight.”</span> <em>BMJ</em>. <strong>352</strong>:i1981. doi: <a href="https://doi.org/10.1136/bmj.i1981">10.1136/bmj.i1981</a>.
</div>
<div id="ref-greenlandAidScientificInference2020" class="csl-entry">
7. Greenland S, Rafi Z. (2020). <span>“To <span>Aid Scientific Inference</span>, <span>Emphasize Unconditional Descriptions</span> of <span>Statistics</span>.”</span> <em>arXiv:190908583 [statME]</em>. <a href="https://arxiv.org/abs/1909.08583">https://arxiv.org/abs/1909.08583</a>.
</div>
<div id="ref-moskowitzFasterthanlightNeutrinosAren2012" class="csl-entry">
8. Moskowitz C. (2012). <span>“Faster-than-light neutrinos aren’t.”</span> <em>Scientific American</em>.
</div>
<div id="ref-perezgonzalezPvaluesPercentilesCommentary2015" class="csl-entry">
9. Perezgonzalez JD. (2015). <span>“P-values as percentiles. <span>Commentary</span> on: <span>‘<span>Null</span> hypothesis significance tests. <span>A</span> mixup of two different theories: The basis for widespread confusion and numerous misinterpretations’</span>.”</span> <em>Frontiers in Psychology</em>. <strong>6</strong>. doi: <a href="https://doi.org/10.3389/fpsyg.2015.00341">10.3389/fpsyg.2015.00341</a>.
</div>
<div id="ref-fraserPvalueFunctionStatistical2019" class="csl-entry">
10. Fraser DAS. (2019). <span>“The <span>P</span>-value function and statistical inference.”</span> <em>The American Statistician</em>. <strong>73</strong>:135–147. doi: <a href="https://doi.org/10.1080/00031305.2018.1556735">10.1080/00031305.2018.1556735</a>.
</div>
<div id="ref-sellkeCalibrationValuesTesting2001" class="csl-entry">
11. Sellke T, Bayarri MJ, Berger JO. (2001). <span>“Calibration of <span><img src="https://latex.codecogs.com/png.latex?%5Crho"></span> values for testing precise null hypotheses.”</span> <em>The American Statistician</em>. <strong>55</strong>:62–71. doi: <a href="https://doi.org/10.1198/000313001300339950">10.1198/000313001300339950</a>.
</div>
<div id="ref-greenlandTechnicalIssuesInterpretation2020" class="csl-entry">
12. Greenland S, Rafi Z. (2020). <span>“Technical <span>Issues</span> in the <span>Interpretation</span> of <span>S</span>-values and <span>Their Relation</span> to <span>Other Information Measures</span>.”</span> <em>arXiv:200812991 [statME]</em>. <a href="https://arxiv.org/abs/2008.12991">https://arxiv.org/abs/2008.12991</a>.
</div>
<div id="ref-shaferTestMartingalesBayes2011" class="csl-entry">
13. Shafer G, Shen A, Vereshchagin N, Vovk V. (2011). <span>“Test <span>Martingales</span>, <span>Bayes Factors</span> and p-<span>Values</span>.”</span> <em>Statistical Science</em>. <strong>26</strong>:84–101. doi: <a href="https://doi.org/10/fkcvt5">10/fkcvt5</a>.
</div>
<div id="ref-schuemieRobustEmpiricalCalibration2016" class="csl-entry">
14. Schuemie MJ, Hripcsak G, Ryan PB, Madigan D, Suchard MA. (2016). <span>“Robust empirical calibration of p-values using observational data.”</span> <em>Statistics in Medicine</em>. <strong>35</strong>:3883–3888. doi: <a href="https://doi.org/10/ghqmsb">10/ghqmsb</a>.
</div>
<div id="ref-gruberLimitationsEmpiricalCalibration2016" class="csl-entry">
15. Gruber S, Tchetgen ET. (2016). <span>“Limitations of empirical calibration of p-values using observational data.”</span> <em>Statistics in Medicine</em>. <strong>35</strong>:3869–3882. doi: <a href="https://doi.org/10/ghqmtn">10/ghqmtn</a>.
</div>
<div id="ref-neymanProblemMostEfficient1933" class="csl-entry">
16. Neyman J, Pearson ES. (1933). <span>“On the <span>Problem</span> of the <span>Most Efficient Tests</span> of <span>Statistical Hypotheses</span>.”</span> <em>Philosophical Transactions of the Royal Society of London Series A, Containing Papers of a Mathematical or Physical Character</em>. <strong>231</strong>:289–337. doi: <a href="https://doi.org/10.1098/rsta.1933.0009">10.1098/rsta.1933.0009</a>.
</div>
<div id="ref-whiteheadCaseFrequentismClinical1993" class="csl-entry">
17. Whitehead J. (1993). <span>“The case for frequentism in clinical trials.”</span> <em>Statistics in Medicine</em>. <strong>12</strong>:1405–1413. doi: <a href="https://doi.org/10.1002/sim.4780121506">10.1002/sim.4780121506</a>.
</div>
<div id="ref-rubinWhatTypeType2019" class="csl-entry">
18. Rubin M. (2019). <span>“What type of <span>Type I</span> error? <span>Contrasting</span> the <span>Neyman</span> and <span>Fisherian</span> approaches in the context of exact and direct replications.”</span> <em>Synthese</em>. doi: <a href="https://doi.org/10.1007/s11229-019-02433-0">10.1007/s11229-019-02433-0</a>.
</div>
<div id="ref-Lehmann2011-vs" class="csl-entry">
19. Lehmann EL. (2011). <span>“Fisher, <span>Neyman</span>, and the <span>Creation</span> of <span>Classical Statistics</span>.”</span> <span>Springer New York</span>. doi: <a href="https://doi.org/10.1007/978-1-4419-9500-1">10.1007/978-1-4419-9500-1</a>.
</div>
<div id="ref-fisherDesignExperiments1935" class="csl-entry">
20. Fisher RA. (1935). <span>“The <span>Design</span> of <span>Experiments</span>.”</span> <span>Oxford, England</span>: <span>Oliver &amp; Boyd</span>.
</div>
<div id="ref-fisherStatisticalMethodsScientific1955" class="csl-entry">
21. Fisher R. (1955). <span>“Statistical <span>Methods</span> and <span>Scientific Induction</span>.”</span> <em>Journal of the Royal Statistical Society Series B (Methodological)</em>. <strong>17</strong>:69–78. doi: <a href="https://doi.org/10.1111/j.2517-6161.1955.tb00180.x">10.1111/j.2517-6161.1955.tb00180.x</a>.
</div>
<div id="ref-bickelNullHypothesisSignificance2019" class="csl-entry">
22. Bickel DR. (2019). <span>“Null <span>Hypothesis Significance Testing Defended</span> and <span>Calibrated</span> by <span>Bayesian Model Checking</span>.”</span> <em>The American Statistician</em>. <strong>0</strong>:1–16. doi: <a href="https://doi.org/10.1080/00031305.2019.1699443">10.1080/00031305.2019.1699443</a>.
</div>
<div id="ref-jeffreysTestsSignificanceTreated1935" class="csl-entry">
23. Jeffreys H. (1935). <span>“Some <span>Tests</span> of <span>Significance</span>, <span>Treated</span> by the <span>Theory</span> of <span>Probability</span>.”</span> <em>Mathematical Proceedings of the Cambridge Philosophical Society</em>. <strong>31</strong>:203–222. doi: <a href="https://doi.org/10.1017/S030500410001330X">10.1017/S030500410001330X</a>.
</div>
<div id="ref-jeffreysTheoryProbability1998" class="csl-entry">
24. Jeffreys H. (1998). <span>“The <span>Theory</span> of <span>Probability</span>.”</span> <span>OUP Oxford</span>.
</div>
<div id="ref-royallStatisticalEvidenceLikelihood1997" class="csl-entry">
25. Royall R. (1997). <span>“Statistical <span>Evidence</span>: <span>A Likelihood Paradigm</span>.”</span> <span>CRC Press</span>.
</div>
<div id="ref-coleSurprise2020" class="csl-entry">
26. Cole SR, Edwards JK, Greenland S. (2020). <span>“Surprise!”</span> <em>American Journal of Epidemiology</em>. doi: <a href="https://doi.org/10/gg63md">10/gg63md</a>.
</div>
<div id="ref-Shannon1948-uq" class="csl-entry">
27. Shannon CE. (1948). <span>“A mathematical theory of communication.”</span> <em>The Bell System Technical Journal</em>. <strong>27</strong>:379–423. doi: <a href="https://doi.org/10.1002/j.1538-7305.1948.tb01338.x">10.1002/j.1538-7305.1948.tb01338.x</a>.
</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2018,
  author = {Panda, Sir and Rafi, Zad},
  title = {P-Values {Are} {Tough} {And} {S-values} {Can} {Help}},
  date = {2018-11-11},
  url = {https://lesslikely.com/posts/statistics/s-values.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2018" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2018). <span>‘P-values Are Tough And S-values Can
Help’</span>. <a href="https://lesslikely.com/posts/statistics/s-values.html">https://lesslikely.com/posts/statistics/s-values.html</a>.
</div></div></section></div> ]]></description>
  <category>statistics</category>
  <guid>https://lesslikely.com/posts/statistics/s-values.html</guid>
  <pubDate>Sun, 11 Nov 2018 05:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1605000180/Site/pvalueassumptions.png" medium="image" type="image/png"/>
</item>
<item>
  <title>We May Not Understand Control Groups</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/statistics/control-group-effects.html</link>
  <description><![CDATA[ 





<hr>
<p>It’s well known that randomized trials are some of the most efficient ways to make causal inferences and to determine how much something (an intervention) differs from the comparator (some sort of control). Random assignment helps make these goals easier by minimizing selection bias and making the distribution of prognostic factors between groups random (not balanced).[@Zhao2018-yf]</p>
<p>Discussions (similar to the one above) praising the efficiency of randomized trials are widespread, however, few of these discussions take a close look at some of the common assumptions that individuals hold regarding randomized trials. And unfortunately, these common assumptions may be based on outdated evidence and simplistic ideas.</p>
<section id="the-placebo-effect-isnt-what-we-often-think" class="level1">
<h1>The Placebo Effect Isn’t What We Often Think</h1>
<p>For example, in placebo-controlled trials, many individuals make the assumption that much of the improvement seen in the control group over time is due to the placebo effect, as modeled by the graph below.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1554700142/Site/PlaceboDominance.svg" alt="Bar graph depicting the placebo-dominant model"></p>
<hr>
<p>However, inquiries into this topic have yielded contradictory results, in that the placebo effect may not be as <a href="https://www.newyorker.com/magazine/2011/12/12/the-power-of-nothing">powerful as we assume</a>.</p>
<p>One systematic review[@Hrobjartsson2001-if] that looked at 130 clinical trials concluded the following,</p>
<hr>
<blockquote class="blockquote">
<p>“We found little evidence in general that placebos had powerful clinical effects. Although placebos had no significant effects on objective or binary outcomes, they had possible small benefits in studies with continuous subjective outcomes and for the treatment of pain. Outside the setting of clinical trials, there is no justification for the use of placebos.”</p>
</blockquote>
<hr>
<p>Thus, the placebo effect had some small effects in areas where it is difficult to objectively measure a phenomenon and where there is a higher likelihood for encountering measurement error. However, measurement error is not the only thing that could explain some of the improvements seen in control groups, which we often attribute to the placebo effect.</p>
<p>We simply need to reread two sections of a paper by the very anesthesiologist who popularized the placebo effect[@Beecher1955-yc] and who claimed that it had the ability to put patients’ conditions into remission.</p>
<p>Here, Henry Beecher (the anesthesiologist) claims that placebo effects are powerful:</p>
<hr>
<blockquote class="blockquote">
<p>“It is evident that placebos have a high degree of therapeutic effectiveness in treating subjective responses, decided improvement, interpreted under the unknowns technique as a real therapeutic effect, being produced in 35.2 ± 2.2% of cases….</p>
<p>Placebos have not only remarkable therapeutic power but also toxic effects. These are both subjective and objective. The reaction (psychological) component of suffering has power to produce gross physical change.”</p>
</blockquote>
<hr>
<p>Then he reports another observation from his patients.</p>
<blockquote class="blockquote">
<p>“The evidence is that placebos are most effective when the stress is greatest.”</p>
</blockquote>
<p>If you measured someone’s stress (let’s say objectively, via cortisol measurements) and they were extremely stressed and if you followed up after a certain period of time, it would be very likely that the next measurement of their stress (cortisol levels) would be less than the first measurement.</p>
<p>A slightly reverse situation would likely apply too: if you measured someone’s happiness (in some theoretical objective way) and they were extremely happy, it’s very likely that their next measurement of happiness would not be so high. This phenomenon is known as regression to the mean,[@Senn2011-fj] and it can explain why many individuals who are in an abnormal state, feel slightly more normal over time.</p>
<p>We can see this displayed below in the graph of simulated blood pressure data[@Atkinson2015-dd] where the change in blood pressure is predicted by baseline blood pressure. The individuals with higher blood pressure at baseline experienced a larger decrease in blood pressure over time.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1554700144/Site/RTM.svg" alt="Graph depicting regression to the mean with simulated blood pressure data"></p>
<hr>
<p>This could possibly explain why Beecher observed that placebo was most effective for situations in which stress was the greatest.</p>
<p>It may not have been <em>just</em> the patients’ minds that led to remission of symptoms, rather the combination of regressing towards an average from a more extreme value, the placebo effect, along with the subjectivity and measurement error of the instruments may have led to this phenomenon of experiencing relief as a function of time.[@mcdonaldHowMuchPlacebo1983]</p>
<p>This isn’t to say that placebo effects are nonexistent or that they’re not relevant, they still are because they serve as controls for various other phenomena that come along with them. For example, it seems very unlikely that in a clinical trial that recruits healthy participants and aims to improve their intelligence with an experimental drug, that regression to the mean could explain the improvements seen in the control group.</p>
<p>In a trial aiming to improve biomarkers in healthy participants, could regression towards the mean or noise explain all the variance we see in the control group? Probably not. It seems very feasible that the placebo effect can result in changes to both subjective <em>and</em> objective outcomes, irrespective of the effects of regression to the mean and measurement error, however, I’m inclined to believe that many of the claims regarding the placebo effect may be <a href="https://www.newyorker.com/magazine/2011/12/12/the-power-of-nothing">exaggerated</a>.</p>
<p>Thus, a more accurate way to think of control group effects would be to incorporate phenomena such as regression to the mean, the placebo effect, and other factors, as shown below.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1554700146/Site/Unspecific.svg" alt="Bar graph depicting the unspecific model"></p>
<hr>
<p>Of course, the proportion of these individual effects would likely vary depending on the scenario(s). Here, the proportions of effects in the control group reflect <em>my</em> beliefs about what contributes to improvements seen in sick individuals who are followed over time.</p>
<p>While the model above is certainly an improvement over the first bar graph in the article all the way above, it too may also be simplistic… and may even be wrong.[@Kube2017-jt] I’ll first discuss some theoretical examples and then present some evidence.</p>
<hr>
</section>
<section id="the-additive-model-is-too-simple" class="level1">
<h1>The Additive Model Is Too Simple</h1>
<hr>
<p>If we add up all the possible effects that lead to improvements in the control group, such as regression to the mean, the placebo effect, measurement error, unspecific effects etc, we can call this giant block (the blue block) the “total control group effect”, at least for the sake of this discussion. This is shown in the bar graph below. Notice that it has a total effect of 6.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1554700108/Site/Additivity.svg" alt="Bar graph depicting the additive model, where treatment effects add on to control group effects"></p>
<hr>
<p>Again, here we are assuming that all the possible things that lead to improvements in the control group are represented by the blue bar. Thus, we design a clinical trial with the assumption that the total control group effect, AKA that represented by the blue bar, will also be the same in the treatment group. This is the “Additive Model” because it simply adds the treatment effect (red bar) on top of the control effect (blue bar), giving a total effect of 10. We subtract the total effect of the treatment group (10) from the total control group effect (6) to get:</p>
<p>Treatment-specific effect (4) = Total treatment group effect (10) - Total control group effect (6)</p>
<p>Therefore, we estimate that the drug has an effect of 4 whereas all the effects that contribute to the control result in an effect of 6. In the form of a linear model, we would model this as y = constant + b(group), where b is the difference between the treatment group and the control group, and group would be coded as 0 or 1, etc.</p>
<p>This idea may be too <em>simplistic</em> as it assumes that the control effect (the blue bar) will be <em>constant</em> between groups.</p>
<p>However, several studies have shown disparities in placebo/control effects between groups, with placebo/control effects sometimes being <em>larger</em> in control groups than in treatment groups.[@Finnerup2010-kw; @Finnerup2015-ga; @Rutherford2014-ye]</p>
<p>Experimental studies have also found that the sum of the drug effect and the placebo effect is often larger than the total treatment effect.[@Hammami2010-ud; @Lund2014-if] This doesn’t seem to support the additive model, where we assume the total control effect is constant in both groups.</p>
<p>It doesn’t take into account that there may be an interaction[@Corraini2017-xi; @Rothman1974-ky] that occurs between the control group effects and the treatment effects, especially if there are possible factors that could lead the participants in the clinical trial to discover that they’ve been allocated to the treatment group.</p>
<p>Thus, a more inclusive model of these possible factors, in the form of a linear model, would be:</p>
<p><em>y</em> = *c<strong>o</strong>n<strong>s</strong>t<strong>a</strong>n<strong>t <em>+</em> β</strong><sup>gr<strong>o</strong>u<strong>p</strong></sup> + β<sup>in<strong>t</strong>e<strong>r</strong>a<strong>c</strong>t<strong>i</strong>o**n<em>(</em>s<em>)</em></sup> + ϵ*</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1554700127/Site/Interactivity.svg" alt="Bar graph depicting the interactive model"></p>
<hr>
<p>These interactions could result in many scenarios, but let’s look at two simple ones.</p>
<p>If a participant in a drug trial is aware of the side effects of the drug beforehand, and receives the drug and experiences side effects, he/she may now have some confirmation that they’ve received the actual intervention, and may overestimate their improvement in a subjective outcome and/or may experience placebo/physiological mechanisms that overlap and interact, thus amplifying the control effects. The overall treatment group effect would increase. This would be a synergistic interaction[@Rothman1974-ky], as shown below. Notice the control group has a total effect of 6, while the drug group has a total effect of 13.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1554700145/Site/Synergism.svg" alt="Bar graph depicting the synergistic interactive model"></p>
<hr>
<p>Now let’s say in another scenario, a patient in a drug trial was unaware of the possible side effects of the drug and experienced some side effects, which has somehow convinced the participant that they may not improve, or the physiological interaction in the mechanisms between the drug and placebo result in negative outcomes. This may lead to a reduction in the placebo effect and a reduction in other unspecific control effects. This would be an antagonistic interaction[@Rothman1974-ky], as shown below. It’s reduced the overall treatment group effect from 13 to 8.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1554700108/Site/Antagonism.svg" alt="Bar graph depicting the antagonistic interactive model"></p>
<hr>
<p>Thus, when we design clinical trials with comparators, we’re often assuming that the treatment-specific effect can be estimated by taking the difference between the total treatment group effect and the total control group effect, because we assume the control effect is constant between groups. But again, as shown above, this may be far too simplistic.</p>
<hr>
</section>
<section id="possible-directions" class="level1">
<h1>Possible Directions</h1>
<hr>
<p>So what’s the solution? How can we design clinical trials to better account for these possible interactions between the intervention and the control group effects? A potential solution that’s been put forth by several researchers over the years is the balanced-placebo design.[@Atlas2012-lr; @Hammami2010-ud; @Kube2017-jt; @Lund2014-if; @Schenk2014-pa] The balanced-placebo design is essentially a 2 x 2 factorial design where two groups will receive the drug and two groups will receive placebo.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700109/Site/Balanced.png" alt="Depiction of a balanced placebo design" style="width:80%"></p>
<hr>
<p>Out of the two groups receiving the drug, one will be told that they’re receiving placebo, while the other is told they’re receiving the drug. The same would apply to the two groups receiving the placebo. One will be told that they’re receiving the placebo, while the other is told they’re receiving the drug. While this design may account for interactions between control group effects and the intervention, I can’t say I’m much of a fan of it as it requires more groups (therefore more participants) and doesn’t use blinding. It may also be unethical.</p>
<p>A very simple solution to me (out of <a href="https://www.sciencedirect.com/science/article/pii/S1359644616304500?via%3Dihub">several proposed designs</a>) is the use of an “active placebo.”[@Kube2017-jt] Active placebos are substances that don’t yield any beneficial effects, but are designed to mimic some of the side effects of the intervention (pretty sure a more appropriate term for them would be <a href="https://en.wikipedia.org/wiki/Nocebo">nocebo</a>). Thus, controlling for the possible interaction(s) that could occur if the participant is affected by the side effects of the intervention. This will make it harder for the participant to know whether they got the intervention or the placebo.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700108/Site/ActivePlacebo.png" alt="Depiction of using a design that includes an active placebo and an inert placebo" style="width:80%"></p>
<hr>
<p>Psychiatrist Scott Alexander of <a href="http://slatestarcodex.com/2014/07/07/ssris-much-more-than-you-wanted-to-know/">Slate Star Codex</a> and <a href="https://www.lesswrong.com/">LessWrong</a> is skeptical of active placebos and believes that <a href="https://ajp.psychiatryonline.org/doi/full/10.1176/appi.ajp.157.3.327">the research</a> doesn’t support their usage.[@Quitkin2000-st] In his article about selective serotonin reuptake inhibitors he writes,</p>
<hr>
<blockquote class="blockquote">
<p>“In other words, active placebo research has fallen out of favor in the modern world. Most studies that used active placebo are very old studies that were not very well conducted. Those studies failed to find an active-placebo-vs.-drug difference because they weren’t good enough to do this. But they also failed to find an active-placebo-vs.-inactive-placebo difference. So they provide no support for the idea that active placebos are stronger than inactive placebos in depression and in fact somewhat weigh against it.”</p>
</blockquote>
<hr>
<p>Scott uses a narrative review from 2000[@Quitkin2000-st] that looked at previous active-placebo trials to support this perspective, but several other studies that have used active placebos have been carried out since</p>
<ol type="1">
<li>Several of these are of much higher quality than the studies discussed in the review he cites. A more recent methodological review,[@Jensen2017-jp] published by one of the authors who systematically searched the literature to find that placebo effects were underwhelming in trials with objective outcomes,[@Hrobjartsson2001-if] concludes the following,</li>
</ol>
<hr>
<blockquote class="blockquote">
<p>Pharmacological active placebo control interventions are rarely used in randomized clinical trials, but they constitute a methodological tool which merits serious consideration. We suggest that active placebos are used more often in trials of drugs with noticeable side effects, especially in situations where the expected therapeutic effects are modest and the risk of bias due to unblinding is high.</p>
</blockquote>
<hr>
<p>Luckily, active placebo research doesn’t seem to have <a href="https://clinicaltrials.gov/ct2/show/NCT03666390">fallen out of favor</a>. Is active placebo research the solution to the problems mentioned above? I’m not sure. There are several other proposed designs that attempt to account for possible interactions that can occur and they may be more practical or less biased. It seems like recognizing that such interactions could occur in the first place would be the first step towards finding a solution.</p>
<p><strong>Acknowledgements</strong>: I’d like to thank <a href="https://twitter.com/avigotsky">Andrew Vigotsky</a> for bringing my attention to several of the pieces cited in this article and for offering comments on an early version of this piece.</p>
<hr>
</section>
<section id="references" class="level1">
<h1>References</h1>
<hr>


</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2018,
  author = {Panda, Sir and Rafi, Zad},
  title = {We {May} {Not} {Understand} {Control} {Groups}},
  date = {2018-10-28},
  url = {https://lesslikely.com/posts/statistics/control-group-effects.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2018" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2018). <span>‘We May Not Understand Control
Groups’</span>. <a href="https://lesslikely.com/posts/statistics/control-group-effects.html">https://lesslikely.com/posts/statistics/control-group-effects.html</a>.
</div></div></section></div> ]]></description>
  <guid>https://lesslikely.com/posts/statistics/control-group-effects.html</guid>
  <pubDate>Sun, 28 Oct 2018 04:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700144/Site/RTM.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>Analytical Issues In That New Low-Carb/LDL Study</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/nutrition/low-carb-ldl.html</link>
  <description><![CDATA[ 




<hr>
<p>Recently, <a href="https://www.sciencedirect.com/science/article/pii/S0021915018314321">a randomized trial</a> that investigated the impact of a low-carbohydrate diet on plasma low density lipoprotein cholesterol (LDL-C) in young and healthy adults was published. The study was done in Norway between 2011 and the end of 2012. A total of 30 participants completed the study, where they were either randomized to a low-carbohydrate group (&lt;20 grams/d) or a control group.</p>
<p>Basically, the investigators found a difference between the groups,</p>
<blockquote class="blockquote">
<p>“In the LCHF diet group (n=15), plasma LDL-C increased from (mean±SD) 2.2±0.4 mmol/l before intervention to 3.1±0.8 after, while in the control group (n=15), LDL-C remained unchanged: 2.5±0.8 mmol/l(p&lt;0.001 between groups)</p>
<p>An LCHF diet for three weeks increased LDL-C with 44% versus controls. The individual response on LCHF varied profoundly.”</p>
</blockquote>
<p>I really don’t find any of these results even slightly surprising, however, there were several aspects of the trial that concerned me.</p>
<hr>
<p>First, I found the preregistration of the trial to be incredibly bizarre. The study was <a href="https://clinicaltrials.gov/ct2/history/NCT01476436...">registered here</a> and updated during recruitment, around 2012.</p>
<p>It’s not very thorough for a preregistration (no analyses plans mentioned etc), but this is to be expected given that it was registered and updated around 2011-2012, long before registrations were as comprehensive as they are today and have been in the past few years.</p>
<p>This isn’t what concerned me. What did concern me was their chosen primary outcome, which was listed on their registration as,</p>
<blockquote class="blockquote">
<p>“Percent change in mean LDL-cholesterol after intervention with low carbohydrate diet from baseline to study end.”</p>
</blockquote>
<p>This is baffling to me. They’re running a randomized controlled trial, yet they’re indicating that the primary outcome is a within-group analysis looking at how LDL changes in the low-carbohydrate group over time.</p>
<p>These types of analyses can be <a href="https://www.ncbi.nlm.nih.gov/pubmed/26354536">pretty misleading</a> because of things like nonspecific effects/interactions, regression to the mean, and the placebo effect. The latter two wouldn’t apply as much here because the study was done in healthy individuals and the primary outcome is a biomarker. However, I still don’t understand what the point of an RCT is if you’re not going to focus on the treatment contrasts AKA the difference in final LDL scores between groups or the difference in changes in LDL scores over time between groups</p>
<p>Given that the study was done in Norway, and began in 2011-2012, I’m hoping that it was just a fluke in registration wording, because otherwise, the investigators didn’t seem to understand at the time what the point of a randomized trial is.</p>
<hr>
<p>Second, the investigators did end up doing between-group analyses for several of the variables (good on them, they’re using their control group) along with several within-group analyses (I still don’t know why they would run these, and they discuss the results of these changes from baseline extensively in the conclusions, again misleading.)</p>
<p>If the authors cared so much about baseline measures and changes from them over time, what they should’ve done is compared changes over time (change scores) if there was a high correlation between the baseline results and the final results, or they could’ve included baseline characteristics as a predictor in an ANCOVA to adjust for the scores and give a less biased estimate.</p>
<p>It would’ve been easy to construct such a model as:</p>
<p><img src="https://latex.codecogs.com/png.latex?y=intercept+%5Cbeta%5E%7Bgroup%7D+%5Cbeta%5E%7Bbaseline%7D"></p>
<p>Yet, instead of doing this, they conducted several within-group analyses, which again, is confounded by other issues for which we use a control group. Easily misleading.</p>
<p>Here’s a graph they produced (I remade it on R and tried to get similar numbers using <a href="https://automeris.io/WebPlotDigitizer/">WebPlotDigitizer</a>) showing the change of LDL in individuals.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1554700129/Site/LDLBars.svg" alt="Bar graph showing people's LDL scores changed from their baseline scores"></p>
<hr>
<blockquote class="blockquote">
<p>Authors’ notes on the graph: “Each bar represents one subject’s percent change in plasma lipids, as indicated by the text in each panel. The fasting plasma levels at baseline were compared to fasting plasma levels after using LCHF for 3 weeks expressed as percent change. Subjects were ranked in order after the percent increase in LDL-C, from least change to the left side in the panel and the largest change to the right side of the panel. All subjects were ranked in the same order according to the percent increase of LDL-C to visualize the association of individual change in LDL-C and changes in other lipid parameters.</p>
</blockquote>
<p>All this graph shows is that people’s LDL scores changed from their baseline scores. It’s not displaying the differences in means between groups at the end or differences in change scores between groups. This is not very useful data visualization.</p>
<hr>
<p>Third and final, there are a <em>large</em> number of comparisons in this trial. <a href="../../statistics/multiplicity-explained">As I’ve discussed before</a>, the family-wise error rate skyrockets when you run so many statistical tests, and without any procedure to account for these, you’re going to run into many false positives within the <a href="../../statistics/classical-lehmann">Neyman-Pearson framework</a>. Here’s a table of all the variables they measured with between-group analyses and within-group analyses.</p>
<hr>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700145/Site/Table1.png" alt="List of all the analyses that were run, which increases the risk of a false positive"></p>
<hr>
<p>Unfortunately, the lack of a solid preregistration with clear analytical plans and the lack of correction for multiple comparisons concerns me here.</p>
<p>Luckily, they did mention that their gene-expression studies, which included several more statistical comparisons, were exploratory and that they didn’t apply a correction for multiple comparisons.</p>
<blockquote class="blockquote">
<p>“However, our gene expression studies are hypothesis-driven and not correction for multiple testing and should thus be interpreted with care.”</p>
</blockquote>
<p>That’s great. I just wish they had done that for all of the other variables shown above.</p>
<p>Overall, the outcomes and conclusions of the study are not surprising to me. There are a myriad of studies showing similar outcomes. However, I think we need to be more aware of issues in the design and analysis of studies, even if the results support our beliefs.</p>


<!-- -->


<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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2018,
  author = {Panda, Sir and Rafi, Zad},
  title = {Analytical {Issues} {In} {That} {New} {Low-Carb/LDL} {Study}},
  date = {2018-10-27},
  url = {https://lesslikely.com/posts/nutrition/low-carb-ldl.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2018" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2018). <span>‘Analytical Issues In That New
Low-Carb/LDL Study’</span>. <a href="https://lesslikely.com/posts/nutrition/low-carb-ldl.html">https://lesslikely.com/posts/nutrition/low-carb-ldl.html</a>.
</div></div></section></div> ]]></description>
  <category>nutrition</category>
  <guid>https://lesslikely.com/posts/nutrition/low-carb-ldl.html</guid>
  <pubDate>Sat, 27 Oct 2018 04:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700129/Site/LDLBars.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>Influential Errors | The Diet Heart Tale</title>
  <dc:creator>Sir Panda</dc:creator>
  <dc:creator>Zad Rafi</dc:creator>
  <link>https://lesslikely.com/posts/nutrition/influential-errors.html</link>
  <description><![CDATA[ 





<hr>
<p>Earlier this year, my colleagues and I were discussing the relationship between saturated fat and cardiovascular disease and one of us was writing an article on a very unusual trial often included in meta-analyses of the topic.</p>
<p>That trial is the <a href="https://www.ncbi.nlm.nih.gov/pubmed/393644">Finnish Mental Hospital Study</a>,<span class="citation" data-cites="Mozaffarian2010-vt"><sup>1</sup></span> a crossover study that compared patients on a control diet with a certain amount of saturated fat to patients on an intervention diet that replaced the saturated fat with polyunsaturated fats.</p>
<p>Here is a summary of the trial,</p>
<hr>
<blockquote class="blockquote">
<p>“A controlled intervention trial, with the purpose of testing the hypothesis that the incidence of coronary heart disease (CHD) could be decreased by the use of serum-cholesterol-lowering (SCL) diet, was carried out in 2 mental hospitals near Helsinki in 1959–71.</p>
<p>The subjects were hospitalized middle-aged men. One of the hospitals received the SCL diet, i.e.&nbsp;a diet low in saturated fats and cholesterol and relatively high in polyunsaturated fats, while the other served as the control with a normal hospital diet. Six years later the diets were reversed, and the trial was continued another 6 years.”</p>
</blockquote>
<hr>
<p>The study didn’t just include men, it also included women and is <a href="https://academic.oup.com/ije/article-abstract/12/1/17/738638?redirectedFrom=fulltext">discussed in a separate paper</a> by the same research group.</p>
<p>In total, the “two studies” (really just one study) had a sample size of 818 participants (for hard CVD events), so they often weigh quite a bit in meta-analyses.</p>
<p>I’d like to bring attention to one particular meta-analysis published eight years ago by <a href="https://journals.plos.org/plosmedicine/article?id=10.1371/journal.pmed.1000252">Mozaffarian, Micha, &amp; Wallace, 2010</a>. It’s one of the most cited meta-analyses on this topic, with <a href="https://scholar.google.com/scholar?um=1&amp;ie=UTF-8&amp;lr&amp;cites=7640707627085212867">Google Scholar</a> indicating that it’s been cited by over 900+ academic sources. Web of Science indicates that it’s been cited by 466 papers at the time of writing this post.</p>
<hr>
<center>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700110/Site/Citation-Count.png" alt="Web of Science metrics showing the number of times the Mozaffarian meta-analysis has been cited" style="width:40%"></p>
<p align="center">
</p><p>Source: Web of Science</p>
<p></p>
</center>
<hr>
<p>Clearly, it’s a well known study.</p>
<p>The meta-analysis of interest describes its inclusion and exclusion criteria as,</p>
<hr>
<blockquote class="blockquote">
<p>“We searched for all RCTs that randomized adults to increased total or n-6 PUFA consumption for at least 1 year without other major concomitant interventions (e.g., blood pressure or smoking control, other multiple dietary interventions, etc.), had an appropriate control group without this dietary intervention, and reported (or had obtainable from the authors) sufficient data to calculate risk estimates with standard errors for effects on occurrence of”hard” CHD events (myocardial infarction, CHD death, and/or sudden death). Studies were excluded if they were observational or otherwise nonrandomized.”</p>
</blockquote>
<hr>
<p>So the authors state that the included studies must be <em>randomized</em> trials that are at least a year long and that they are excluding studies that are <em>non-randomized</em> or observational.</p>
<p>Here’s a list of the studies they included. Note the design of the Finnish studies (Turpeinen, 1979 &amp; Miettinen, 1983), which I’ll touch upon below.</p>
<hr>
<center>
<img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700133/Site/Meta-Table.png" alt="Characteristics of the included studies in the meta-analysis">
</center>
<hr>
<section id="what-were-the-results" class="level1">
<h1>What Were the Results?</h1>
<hr>
<center>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700138/Site/Mozaffarian-Meta-Analysis.png" alt="Forest plot from the Mozaffarian meta-analysis showing a reduction in CVD events by replacing saturated fat intake with polyunsaturated fat intake"></p>
<p align="center">
</p><p>Mozaffarian D, Micha R, Wallace S (2010)</p>
<p></p>
</center>
<hr>
<blockquote class="blockquote">
<p>“Combining all trials, the pooled risk reduction for CHD events was 19% (RR = 0.81, 95% CI 0.70–0.95, p = 0.008)”</p>
</blockquote>
<hr>
<p>The 2010 meta-analysis found that replacing saturated fats in the diet with polyunsaturated fats had a notable, statistically significant reduction on CHD events. A 19% reduction is certainly, nothing to ignore and the confidence interval (CI) leans towards an effect. It seems promising as a dietary intervention. That could be a reason why the study is cited so widely. The quality of the trials included in the meta-analysis was low to moderate,</p>
<hr>
<blockquote class="blockquote">
<p>“Many of the trials had design limitations, such as single-blinding, inclusion of electrocardiographically defined clinical endpoints, or open enrollment. All trials utilized blinded endpoint assessment. Quality scores were in the modest range and relatively homogeneous: all trials had quality scores of either 2 or 3.”</p>
</blockquote>
<hr>
<p>And there was some suggestion of publication bias (could also be <a href="https://www.bmj.com/content/323/7304/101">small-study effects</a>),</p>
<hr>
<center>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700136/Site/Mozaffarian-Funnel-Plot.jpg" alt="Characteristics of the included studies in the meta-analysis"></p>
<p align="center">
</p><p>Mozaffarian D, Micha R, Wallace S (2010)</p>
<p></p>
</center>
<hr>
<blockquote class="blockquote">
<p>“Visual inspection of the resulting funnel plot indicated some potential for publication bias (Figure S1), with a borderline Begg’s test (continuity corrected p = 0.07), although such determinations are limited when the number of studies is relatively small.”</p>
</blockquote>
<p>Regardless, the effects are quite interesting and worth exploring further.</p>
<hr>
</section>
<section id="what-went-wrong" class="level1">
<h1>What Went Wrong?</h1>
<hr>
<p>A major problem in this meta-analysis is that the two Finnish studies included in the quantitative analysis were <em>not</em> randomized. The authors made it clear with their inclusion criteria that they only wanted to include trials that were <em>randomized</em>.</p>
<p>The two Finnish Mental Hospital studies were labeled as “cluster randomized”, which you can see in the table of characteristics from above. When this meta-analysis was published, several individuals were critical that a “cluster-randomized trial” was being labeled as a randomized trial, especially when there were only two clusters (two hospitals). This is a valid criticism because a cluster-randomized trial with only one cluster per condition is invalid for any between-group statistical comparisons. <a href="https://academic.oup.com/ajcn/article/102/2/241/4662865">Brown et al., 2015</a> explain in this comprehensive article,</p>
<hr>
<blockquote class="blockquote">
<p>A particularly pernicious and invalid design that requires recognition is the inclusion of only one cluster per condition… Such designs are unable to support any valid analysis for an intervention effect, absent strong and untestable assumptions (11, 12). In such designs, the variation that is due to the cluster is not identifiable apart from the variation due to the condition.</p>
<p>A one-cluster-per-condition design is analogous to assigning one person to the treatment and one person to the control in an ordinary (nonclustered) RCT, measuring each person’s outcome multiple times, treating the multiple observations per person like independent observations, and interpreting the results like a valid RCT. In such a situation, the observations on person A can be tested as to whether they are significantly different from those on person B but cannot support an inference about the effect of treatment per se.</p>
</blockquote>
<hr>
<p>So it is clear that a one-cluster-per-condition design is not valid to ascertain much about the intervention. However, many individuals (if not all) failed to notice that the Finnish Mental Hospital studies were not even cluster randomized! There is no indication in any of the five published papers from these two studies that there is any randomization. You can check all five papers here:</p>
<hr>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<table class="lightable-classic caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Published Journal</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Year</th>
<th data-quarto-table-cell-role="th" style="text-align: center; font-weight: bold; color: rgba(119, 119, 119, 255) !important;">Publication Title</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">International Journal of Epidemiology</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1983</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Dietary Prevention of Coronary Heart Disease in Women: The Finnish Mental Hospital Study</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Circulation</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1979</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Effect of Cholesterol-Lowering Diet on Mortality from Coronary Heart Disease and Other Causes</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">American Journal of Clinical Nutrition</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1968</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Dietary Prevention of Coronary Heart Disease: Long-Term Experiment: I. Observations on Male Subjects</td>
</tr>
<tr class="even">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">International Journal of Epidemiology</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1979</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Dietary Prevention of Coronary Heart Disease: The Finnish Mental Hospital Study</td>
</tr>
<tr class="odd">
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">The Lancet</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">1972</td>
<td style="text-align: center; color: rgba(119, 119, 119, 255) !important;">Effect of Cholesterol-Lowering Diet on Mortality from Coronary Heart-Disease and Other Causes a Twelve-Year Clinical Trial in Men and Women</td>
</tr>
</tbody>
</table>
</div>
</div>
<hr>
<p>Furthermore, cluster-randomized trials were not common when these studies were being conducted, which is why we should be skeptical of these being cluster-randomized trials.</p>
<p>Yet, these two studies were mistakenly labeled as being “cluster randomized” and therefore were included in the meta-analysis. Both of these studies contributed a total weight of 16% to the analysis.</p>
<p>And again, the authors found a pretty notable reduction in CVD events (RR: 0.81, 95% CI: 0.70, 0.95, p = 0.008)</p>
<hr>
</section>
<section id="correcting-the-error" class="level1">
<h1>Correcting the Error</h1>
<hr>
<p>So what happens to the results when you correct this mistake by removing the two studies?</p>
<p>Let’s open <code>R</code> and find out. If you’d like to reproduce the analysis on your own, you can find all the code at the bottom of this blog post.</p>
<hr>
<center>
<p><img src="https://res.cloudinary.com/less-likely/image/upload/v1554700111/Site/Custom_ForestPlot.svg" alt="My reanalysis of Mozaffarian's study with the exclusion of the Finnish study graphed onto a forest plot, showing a substantial reduction in the effect size"></p>
<p align="center">
</p><p>My reanalysis</p>
<p></p>
</center>
<hr>
<p>As you can see above, rerunning the analysis after removing the Finnish studies results in the effect size shrinking from a 19% reduction to a 13% reduction <strong>(RR: 0.87, 95% CI: 0.76, 1.00)</strong>. That’s a large difference!</p>
<p>If we’re concerned about statistical significance, the results are no longer significant. It’s worth noting that the upper bound of the confidence interval barely contains the null value (1) and the lower bound includes a value as low as 0.76. It’s clear that the CI still seems to lean towards an effect.</p>
<p>Regardless of your statistical philosophy, this was a noteworthy, objective mistake. It was a mistake in labeling two studies as meeting the inclusion criteria, and correcting for this mistake leads to a substantial change in the results. Yet, this error has not been corrected for in the journal. In fact, this study has been around for eight years with no corrections or retractions.</p>
<p>I reached out to both the authors and the editors of PLOS, but to date, there are no updates or corrections on the article itself. Therefore, I suspect several people who read the article or cite it, are not aware that the summary effects are incorrect and that some of the studies in the analysis should not be there!</p>
<p>It is very important to note that correcting for the errors in this study does not lead to completely different conclusions. Although the effect is no longer statistically significant, it is still there based on the effect size and coverage of the confidence intervals. However, the effect is reduced.</p>
<p>Systematic reviews by other groups including <a href="https://www.cochranelibrary.com/cdsr/doi/10.1002/14651858.CD011737/abstract#0">Cochrane</a> did <em>not</em> include the Finnish studies in their meta-analyses because the authors didn’t believe that a “cluster randomized trial” with so few clusters (2) met the inclusion criteria for a randomized trial (also worth remembering, that there is no indication in any of the papers that this was even cluster randomized!). Some of these systematic reviews that exclude the Finnish studies still find a benefit to replacing saturated fats in the diet with polyunsaturated fats.</p>
<p>However, other <a href="https://www.ncbi.nlm.nih.gov/pubmed/28526025">meta-analyses</a> have also found no statistically significant benefit to replacing saturated fats with polyunsaturated fats.</p>
<p>Clearly, there is quite a bit of disagreement on this topic. Regardless, the meta-analysis in question still made a large error and it is a problem for the following reasons (even if the overall conclusions of it were not to change after the correction):</p>
<hr>
<ul>
<li>Two prominent studies were misclassified</li>
</ul>
<hr>
<ul>
<li>The studies did not meet the inclusion criteria but were included</li>
</ul>
<hr>
<ul>
<li>Inclusion in the analysis leads to a substantially different effect size than without inclusion</li>
</ul>
<hr>
<ul>
<li>The meta-analysis is constantly cited and misleading other readers and future researchers</li>
</ul>
<hr>
<p>I’m certainly not suggesting that errors do not happen, especially when undertaking such large, comprehensive projects. In fact, I would probably be suspicious if there were never any errors when such large projects were conducted!</p>
<p>However, I believe that when such errors are pointed out, they should be corrected as quickly and transparently as possible. Hopefully, the authors and the editors address this issue soon to prevent any further confusion.</p>
<hr>
</section>
<section id="reanalysis-script" class="level1">
<h1>Reanalysis Script</h1>
<hr>
<p>Here is the <a href="https://lesslikely.com/uploads/PUFA.csv">dataset</a> to load into <code>R</code> as a dataframe. We will then use the <a href="https://cran.r-project.org/package=metafor">metafor</a><span class="citation" data-cites="viechtbauerConductingMetaanalysesMetafor2010"><sup>2</sup></span> <code>R</code> package.</p>
<hr>
<div class="cell" data-layout-align="center">
<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">likelyPUFA <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"https://lesslikely.com/uploads/PUFA.csv"</span></span>
<span id="cb1-2">pufaMETA <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>(likelyPUFA, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(pufaMETA)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="kable-table">
<table class="caption-top table table-sm table-striped small">
<colgroup>
<col style="width: 23%">
<col style="width: 17%">
<col style="width: 16%">
<col style="width: 22%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Study_ID</th>
<th style="text-align: right;">PUFA_Events</th>
<th style="text-align: right;">PUFA_Total</th>
<th style="text-align: right;">Control_Events</th>
<th style="text-align: right;">Control_Total</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">DARTS</td>
<td style="text-align: right;">132</td>
<td style="text-align: right;">1018</td>
<td style="text-align: right;">144</td>
<td style="text-align: right;">1015</td>
</tr>
<tr class="even">
<td style="text-align: left;">LA Veterans</td>
<td style="text-align: right;">53</td>
<td style="text-align: right;">424</td>
<td style="text-align: right;">71</td>
<td style="text-align: right;">422</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Minnesota CS</td>
<td style="text-align: right;">131</td>
<td style="text-align: right;">4541</td>
<td style="text-align: right;">121</td>
<td style="text-align: right;">4516</td>
</tr>
<tr class="even">
<td style="text-align: left;">MRC Soy</td>
<td style="text-align: right;">45</td>
<td style="text-align: right;">199</td>
<td style="text-align: right;">51</td>
<td style="text-align: right;">194</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Oslo Diet Heart</td>
<td style="text-align: right;">61</td>
<td style="text-align: right;">206</td>
<td style="text-align: right;">81</td>
<td style="text-align: right;">206</td>
</tr>
<tr class="even">
<td style="text-align: left;">STARS</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">27</td>
<td style="text-align: right;">5</td>
<td style="text-align: right;">28</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="cell" data-layout-align="center">
<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>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metafor"</span>)</span>
<span id="cb2-2"></span>
<span id="cb2-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Meta-Analysis</span></span>
<span id="cb2-4"></span>
<span id="cb2-5">dat <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;">escalc</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"RR"</span>,</span>
<span id="cb2-6">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ai =</span> PUFA_Events, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n1i =</span> PUFA_Total,</span>
<span id="cb2-7">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ci =</span> Control_Events, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n2i =</span> Control_Total,</span>
<span id="cb2-8">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> pufaMETA)</span>
<span id="cb2-9">dat[, <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;">6</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;">7</span>)]</span></code></pre></div></div>
<div class="cell-output-display">
<div class="kable-table">
<table class="caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;">Study_ID</th>
<th style="text-align: right;">yi</th>
<th style="text-align: right;">vi</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">DARTS</td>
<td style="text-align: right;">-0.090</td>
<td style="text-align: right;">0.013</td>
</tr>
<tr class="even">
<td style="text-align: left;">LA Veterans</td>
<td style="text-align: right;">-0.297</td>
<td style="text-align: right;">0.028</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Minnesota CS</td>
<td style="text-align: right;">0.074</td>
<td style="text-align: right;">0.015</td>
</tr>
<tr class="even">
<td style="text-align: left;">MRC Soy</td>
<td style="text-align: right;">-0.151</td>
<td style="text-align: right;">0.032</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Oslo Diet Heart</td>
<td style="text-align: right;">-0.284</td>
<td style="text-align: right;">0.019</td>
</tr>
<tr class="even">
<td style="text-align: left;">STARS</td>
<td style="text-align: right;">-0.880</td>
<td style="text-align: right;">0.627</td>
</tr>
</tbody>
</table>
</div>
</div>
<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">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;">rma</span>(yi, vi, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat)</span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">confint</span>(res)</span>
<span id="cb3-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb3-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;        estimate  ci.lb   ci.ub </span></span>
<span id="cb3-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; tau^2    0.0066 0.0000  0.3010 </span></span>
<span id="cb3-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; tau      0.0812 0.0000  0.5486 </span></span>
<span id="cb3-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; I^2(%)  21.4317 0.0000 92.5694 </span></span>
<span id="cb3-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; H^2      1.2728 1.0000 13.4578</span></span>
<span id="cb3-9"></span>
<span id="cb3-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">par</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mar =</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;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</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;">2</span>))</span>
<span id="cb3-11"></span>
<span id="cb3-12">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;">rma</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ai =</span> PUFA_Events, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n1i =</span> PUFA_Total,</span>
<span id="cb3-13">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ci =</span> Control_Events, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n2i =</span> Control_Total,</span>
<span id="cb3-14">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"RR"</span>,</span>
<span id="cb3-15">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slab =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(Study_ID, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <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;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DL"</span>)</span>
<span id="cb3-16"></span>
<span id="cb3-17">res_REML <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;">rma</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ai =</span> PUFA_Events, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n1i =</span> PUFA_Total,</span>
<span id="cb3-18">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ci =</span> Control_Events, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n2i =</span> Control_Total,</span>
<span id="cb3-19">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"RR"</span>,</span>
<span id="cb3-20">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slab =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(Study_ID, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>),</span>
<span id="cb3-21">                <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;">"REML"</span>)</span></code></pre></div></div>
</div>
<hr>
<p>Although I have used both the Dersimonian-Laird estimator, as used in the original analysis by the authors, I have chosen to also do a sensitivity analyses<span class="citation" data-cites="morrisChoosingSensitivityAnalyses2014"><sup>3</sup></span> using the restricted maximum likelihood estimator (REML) and plot that instead, as it often gives wider interval estimates, often with better coverage properties.</p>
<hr>
<div class="cell" data-layout-align="center">
<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;"># Data Visualization - Forest Plot Structure</span></span>
<span id="cb4-2"></span>
<span id="cb4-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">forest</span>(res_REML, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xlim =</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;">16</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>),</span>
<span id="cb4-4">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">at =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</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;">2</span>)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">atransf =</span> exp,</span>
<span id="cb4-5">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ilab =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cbind</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>PUFA_Events,</span>
<span id="cb4-6">                    dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>PUFA_Total, dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Control_Events,</span>
<span id="cb4-7">                    dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Control_Total),</span>
<span id="cb4-8">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ilab.xpos =</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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">9.5</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;">8</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;">6</span>, <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;">4.5</span>),</span>
<span id="cb4-9">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylim =</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;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">8.6</span>),</span>
<span id="cb4-10">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xlab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Risk Ratio"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mlab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb4-11">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">psize =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.7</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>)</span>
<span id="cb4-12"></span>
<span id="cb4-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Heterogeneity</span></span>
<span id="cb4-14"></span>
<span id="cb4-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">text</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;">16</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;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pos =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>,</span>
<span id="cb4-16">     <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bquote</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Random Effects (Q = "</span>,</span>
<span id="cb4-17">   .(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">formatC</span>(res_REML<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>QE, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"f"</span>)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">",</span></span>
<span id="cb4-18"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   df = "</span>, .(res_REML<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>k <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p),</span>
<span id="cb4-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", p = "</span>, .(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">formatC</span>(res_REML<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>QEp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"f"</span>)),</span>
<span id="cb4-20">   <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"; "</span>, I<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;">2</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" = "</span>,</span>
<span id="cb4-21">     .(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">formatC</span>(res_REML<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>I2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</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;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"f"</span>)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%)"</span>)))</span>
<span id="cb4-22"></span>
<span id="cb4-23">op <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;">par</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">font =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb4-24"></span>
<span id="cb4-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Bold Font</span></span>
<span id="cb4-26"></span>
<span id="cb4-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">par</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">font =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb4-28"></span>
<span id="cb4-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Columns</span></span>
<span id="cb4-30"></span>
<span id="cb4-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">text</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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">9.5</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;">8</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;">6</span>, <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;">4.5</span>), <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">7.5</span>,</span>
<span id="cb4-32">     <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;">"Events "</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" Total"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Events "</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" Total"</span>))</span>
<span id="cb4-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">text</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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">8.75</span>, <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;">5.25</span>),     <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">8.5</span>,</span>
<span id="cb4-34">     <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;">"PUFA Diet"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Control Diet"</span>))</span>
<span id="cb4-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">text</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;">16</span>,                <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">7.5</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Study Name"</span>,  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pos =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb4-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">text</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>,                  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">7.5</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Risk Ratio [95% CI]"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pos =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/nutrition/influential-errors_files/figure-html/unnamed-chunk-6-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<div class="cell" data-layout-align="center">
<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">res_REML</span>
<span id="cb5-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb5-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Random-Effects Model (k = 6; tau^2 estimator: REML)</span></span>
<span id="cb5-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb5-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; tau^2 (estimated amount of total heterogeneity): 0.0066 (SE = 0.0183)</span></span>
<span id="cb5-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; tau (square root of estimated tau^2 value):      0.0812</span></span>
<span id="cb5-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; I^2 (total heterogeneity / total variability):   21.43%</span></span>
<span id="cb5-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; H^2 (total variability / sampling variability):  1.27</span></span>
<span id="cb5-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb5-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Test for Heterogeneity:</span></span>
<span id="cb5-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Q(df = 5) = 5.9549, p-val = 0.3106</span></span>
<span id="cb5-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb5-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Model Results:</span></span>
<span id="cb5-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb5-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; estimate      se     zval    pval    ci.lb   ci.ub    </span></span>
<span id="cb5-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  -0.1361  0.0720  -1.8911  0.0586  -0.2771  0.0050  . </span></span>
<span id="cb5-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb5-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; ---</span></span>
<span id="cb5-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</span></span></code></pre></div></div>
</div>
<hr>
<p>Now suppose we also wished to see the <img src="https://latex.codecogs.com/png.latex?P">-value function<span class="citation" data-cites="rafiSemanticCognitiveTools2020"><sup>4</sup></span> of these results, we could simply do so using the <a href="https://cran.r-project.org/package=concurve"><code>concurve</code></a><span class="citation" data-cites="rafiConcurveComputesPlots2020"><sup>5</sup></span> <code>R</code> package’s <a href="https://data.lesslikely.com/concurve/reference/curve_meta.html"><code>curve_meta()</code></a> function.</p>
<hr>
<div class="cell" data-layout-align="center">
<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;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concurve"</span>)</span>
<span id="cb6-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ggplot2"</span>)</span>
<span id="cb6-3">PUFA_curve <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;">curve_meta</span>(res_REML, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">measure =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ratio"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cores =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb6-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggcurve</span>(PUFA_curve[[<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;">nullvalue =</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>
<span id="cb6-5">        <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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span>),</span>
<span id="cb6-6">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P-value Function of PUFA Meta-Analysis"</span>,</span>
<span id="cb6-7">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Reanalysis of Mozaffarian et al. 2010"</span>,</span>
<span id="cb6-8">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xaxis =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Risk Ratio"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Restricted Maximum Likelihood Estimator used"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/nutrition/influential-errors_files/figure-html/unnamed-chunk-8-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>Although I believe the results still suggest an effect, if another analyst was not convinced by these effects and set interval nulls that spanned from risk ratios from 0.9 to 1.1, as being equivalent to no effect, then these results would be in some trouble! We can see this easily with <a href="https://cran.r-project.org/package=concurve"><code>concurve</code></a>,<span class="citation" data-cites="rafiConcurveComputesPlots2020"><sup>5</sup></span> which allows us to set the interval null regions.</p>
<hr>
<div class="cell" data-layout-align="center">
<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;">ggcurve</span>(PUFA_curve[[<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;">nullvalue =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.1</span>),</span>
<span id="cb7-2">        <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="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span>),</span>
<span id="cb7-3">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P-value Function of PUFA Meta-Analysis"</span>,</span>
<span id="cb7-4">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Reanalysis of Mozaffarian et al. 2010"</span>,</span>
<span id="cb7-5">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xaxis =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Risk Ratio"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.50</span>,</span>
<span id="cb7-7">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Interval Null Region </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">(Assumed No Meaningful Effect)"</span>,</span>
<span id="cb7-8">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#000000"</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.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb7-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Restricted Maximum Likelihood Estimator used"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/nutrition/influential-errors_files/figure-html/unnamed-chunk-9-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>The above was the <img src="https://latex.codecogs.com/png.latex?P">-value function for the summary effect, but we can also construct <img src="https://latex.codecogs.com/png.latex?P">-value functions for each of the individual studies in the meta-analysis, and plot them together, and also construct prediction ranges for them. This is known as the drapery plot,<span class="citation" data-cites="ruckerForestPlotDrapery2020"><sup>6</sup></span> and we can construct them using the <a href="https://cran.r-project.org/package=meta">meta</a> package in <code>R</code>.</p>
<hr>
<div class="cell" data-layout-align="center">
<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>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"meta"</span>)</span>
<span id="cb8-2"></span>
<span id="cb8-3">res_drapery <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;">metabin</span>(PUFA_Events, PUFA_Total,</span>
<span id="cb8-4">                      Control_Events, Control_Total,</span>
<span id="cb8-5">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">studlab =</span> dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Study_ID,</span>
<span id="cb8-6">                      <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;">"MH"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method.tau =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"REML"</span>)</span>
<span id="cb8-7"></span>
<span id="cb8-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">drapery</span>(res_drapery,  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xlim =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>),</span>
<span id="cb8-9">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">main =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Drapery Plot of of PUFA Meta-Analysis Studies"</span>,</span>
<span id="cb8-10">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xaxis =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Restricted Maximum Likelihood Estimator"</span>,</span>
<span id="cb8-11">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"studlab"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">study.results =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb8-12">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.fixed =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#3f8f9b"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.random =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d46c5b"</span>,</span>
<span id="cb8-13">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.predict =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lightgray"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">las =</span>.<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>,</span>
<span id="cb8-14">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.001</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb8-15">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty.alpha =</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lwd.alpha =</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb8-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.alpha =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex.alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/nutrition/influential-errors_files/figure-html/unnamed-chunk-10-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
<p>We can also conduct further sensitivity analyses using the <code>metasens</code> <code>R</code> package using the copas selection method, which fits a joint model to investigate selection bias and an upper bound is also calculated within a separate function for reporting bias.</p>
<hr>
<div class="cell" data-layout-align="center">
<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;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metasens"</span>)</span>
<span id="cb9-2">cop1 <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;">copas</span>(res_drapery)</span>
<span id="cb9-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(cop1)</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/nutrition/influential-errors_files/figure-html/unnamed-chunk-11-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
<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"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(cop1)</span>
<span id="cb10-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Copas selection model analysis</span></span>
<span id="cb10-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;               p.publ     RR           95%-CI  tau^2    tau  p.trt  p.rsb N</span></span>
<span id="cb10-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;               1.0000 0.8799 [0.7802; 0.9924]      0      0 0.0371 0.1701 0</span></span>
<span id="cb10-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;               0.7737 0.8972 [0.7686; 1.0473]      0      0 0.1692 0.2037 1</span></span>
<span id="cb10-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;               0.6672 0.9101 [0.7856; 1.0544]      0      0 0.2098 0.1794 1</span></span>
<span id="cb10-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;               0.5768 0.9258 [0.7875; 1.0883]      0      0 0.3501 0.1869 2</span></span>
<span id="cb10-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;               0.5735 0.9321 [0.7929; 1.0957]      0      0 0.3940 0.2744 2</span></span>
<span id="cb10-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;               0.5090 0.9412 [0.7808; 1.1345]      0      0 0.5247 0.1924 3</span></span>
<span id="cb10-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;               0.4502 0.9574 [0.7573; 1.2103]      0      0 0.7157 0.1534 4</span></span>
<span id="cb10-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                                                                           </span></span>
<span id="cb10-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    Adjusted estimate 0.8799 [0.7802; 0.9924]      0      0 0.0371 0.1701 0</span></span>
<span id="cb10-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Unadjusted estimate 0.8728 [0.7579; 1.0050] 0.0066 0.0812 0.0586         </span></span>
<span id="cb10-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Significance level for test of residual selection bias: 0.1 </span></span>
<span id="cb10-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                       min   max</span></span>
<span id="cb10-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  range of gamma0:  -0.463 2.000</span></span>
<span id="cb10-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  range of gamma1:   0.000 0.168</span></span>
<span id="cb10-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Largest standard error (SE): 0.792 </span></span>
<span id="cb10-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Range of probability publishing trial with largest SE:</span></span>
<span id="cb10-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    min   max</span></span>
<span id="cb10-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  0.322 0.987</span></span>
<span id="cb10-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Calculation of orthogonal line:</span></span>
<span id="cb10-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  level nobs adj.r.square   slope se.slope</span></span>
<span id="cb10-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  -0.12   31        0.885 -1.4844   0.0974</span></span>
<span id="cb10-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  -0.10   30        0.937 -2.1557   0.1039</span></span>
<span id="cb10-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  -0.08   27        0.989 -2.6296   0.0555</span></span>
<span id="cb10-34"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  -0.06   28        0.977 -2.9494   0.0865</span></span>
<span id="cb10-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  -0.04   23        0.968 -3.1586   0.1220</span></span>
<span id="cb10-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  -0.02   18        0.901 -2.1275   0.1705</span></span>
<span id="cb10-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  -0.02    3       -0.953 -0.3790   2.4462</span></span>
<span id="cb10-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.00   12        0.992 -2.3601   0.0630</span></span>
<span id="cb10-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.00    5       -0.329 -0.0586   0.6287</span></span>
<span id="cb10-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.02    8        0.991 -2.1769   0.0775</span></span>
<span id="cb10-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.02    5       -0.329 -0.0586   0.6287</span></span>
<span id="cb10-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.04    5        0.995 -1.8883   0.0660</span></span>
<span id="cb10-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   0.06    2     -100.000 -1.7687      NaN</span></span>
<span id="cb10-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Legend:</span></span>
<span id="cb10-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  p.publ - Probability of publishing study with largest SE</span></span>
<span id="cb10-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  p.trt  - P-value for test of overall treatment effect</span></span>
<span id="cb10-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  p.rsb  - P-value for test of residual selection bias</span></span>
<span id="cb10-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  N      - Estimated number of unpublished studies</span></span>
<span id="cb10-50"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">limitmeta</span>(res_drapery)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb10-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Results for individual studies</span></span>
<span id="cb10-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; (left: original data; right: shrunken estimates)</span></span>
<span id="cb10-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;                     RR       95%-CI      RR       95%-CI</span></span>
<span id="cb10-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; DARTS             0.91 [0.73; 1.14]    0.99 [0.80; 1.23]</span></span>
<span id="cb10-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; LA Veterans       0.74 [0.53; 1.03]    0.93 [0.67; 1.30]</span></span>
<span id="cb10-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Minnesota CS      1.08 [0.84; 1.37]    1.09 [0.86; 1.39]</span></span>
<span id="cb10-58"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; MRC Soy           0.86 [0.61; 1.22]    1.00 [0.70; 1.42]</span></span>
<span id="cb10-59"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Oslo Diet Heart   0.75 [0.57; 0.99]    0.91 [0.70; 1.20]</span></span>
<span id="cb10-60"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; STARS             0.41 [0.09; 1.96]    1.00 [0.21; 4.74]</span></span>
<span id="cb10-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Result of limit meta-analysis:</span></span>
<span id="cb10-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-64"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Random effects model   RR       95%-CI     z   pval</span></span>
<span id="cb10-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Adjusted estimate 0.99 [0.78; 1.26] -0.11 0.9142</span></span>
<span id="cb10-66"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;   Unadjusted estimate 0.87 [0.76; 1.00] -1.89 0.0586</span></span>
<span id="cb10-67"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-68"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Quantifying heterogeneity:</span></span>
<span id="cb10-69"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; tau^2 = 0.0066; I^2 = 16.0% [0.0%; 78.7%]; G^2 = 99.5%</span></span>
<span id="cb10-70"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-71"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Test of heterogeneity:</span></span>
<span id="cb10-72"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;     Q d.f. p-value</span></span>
<span id="cb10-73"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  5.95    5  0.3106</span></span>
<span id="cb10-74"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-75"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Test of small-study effects:</span></span>
<span id="cb10-76"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  Q-Q' d.f. p-value</span></span>
<span id="cb10-77"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  1.88    1  0.1701</span></span>
<span id="cb10-78"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-79"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Test of residual heterogeneity beyond small-study effects:</span></span>
<span id="cb10-80"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    Q' d.f. p-value</span></span>
<span id="cb10-81"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  4.07    4  0.3962</span></span>
<span id="cb10-82"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-83"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Adjustment method: expectation (beta0)</span></span>
<span id="cb10-84"></span>
<span id="cb10-85">orb1 <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;">orbbound</span>(res_drapery, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k.suspect =</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;">5</span>)</span>
<span id="cb10-86"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(orb1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb10-87"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-88"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;         Sensitivity Analysis for Outcome Reporting Bias (ORB)</span></span>
<span id="cb10-89"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-90"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Number of studies combined: k=6</span></span>
<span id="cb10-91"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Between-study variance: tau^2 = 0.0066</span></span>
<span id="cb10-92"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-93"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Common effect model</span></span>
<span id="cb10-94"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-95"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  k.suspect maxbias   RR       95%-CI     z p-value</span></span>
<span id="cb10-96"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          0    1.00 0.89 [0.79; 1.01] -1.86  0.0624</span></span>
<span id="cb10-97"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          1    1.04 0.93 [0.83; 1.05] -1.16  0.2471</span></span>
<span id="cb10-98"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          2    1.07 0.96 [0.85; 1.08] -0.73  0.4672</span></span>
<span id="cb10-99"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          3    1.09 0.98 [0.86; 1.10] -0.40  0.6887</span></span>
<span id="cb10-100"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          4    1.11 0.99 [0.88; 1.12] -0.14  0.8915</span></span>
<span id="cb10-101"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          5    1.13 1.01 [0.89; 1.13]  0.09  0.9318</span></span>
<span id="cb10-102"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-103"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Random effects model</span></span>
<span id="cb10-104"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-105"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  k.suspect maxbias   RR       95%-CI     z p-value</span></span>
<span id="cb10-106"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          0    1.00 0.87 [0.76; 1.00] -1.89  0.0586</span></span>
<span id="cb10-107"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          1    1.04 0.91 [0.79; 1.05] -1.29  0.1984</span></span>
<span id="cb10-108"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          2    1.07 0.94 [0.81; 1.08] -0.92  0.3590</span></span>
<span id="cb10-109"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          3    1.09 0.96 [0.83; 1.10] -0.64  0.5238</span></span>
<span id="cb10-110"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          4    1.11 0.97 [0.84; 1.12] -0.41  0.6810</span></span>
<span id="cb10-111"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;          5    1.13 0.98 [0.85; 1.13] -0.22  0.8252</span></span>
<span id="cb10-112"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; </span></span>
<span id="cb10-113"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; Details on meta-analytical method:</span></span>
<span id="cb10-114"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; - Mantel-Haenszel method (common effect model)</span></span>
<span id="cb10-115"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; - Inverse variance method (random effects model)</span></span>
<span id="cb10-116"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; - Restricted maximum-likelihood estimator for tau^2</span></span>
<span id="cb10-117"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">forest</span>(orb1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xlim =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://lesslikely.com/posts/nutrition/influential-errors_files/figure-html/unnamed-chunk-11-2.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<hr>
</section>
<section id="major-update" class="level1">
<h1>Major Update</h1>
<hr>
<p>Edit: Dr.&nbsp;Mozaffarian has <a href="https://journals.plos.org/plosmedicine/article/comment?id=10.1371/annotation/0378bddc-3be5-4ede-a657-53d50d1a41b8">replied</a> to some of these criticisms in the comments section of his paper on PLOS Medicine (mostly because I had pressured the PLOS editors to issue a correction), and unfortunately, I have found the responses to be very poor. The response pretty much sums up to, “to the best of our knowledge when we were critically appraising the literature, this study seemed like a randomized trial, so we labeled it as such, and it may be appropriate to label it ‘quasi-randomized’ because it seemed appropriate at the time.”</p>
<p>Unfortunately, I don’t think that’s how good science progresses at all, and in fact, this error has the potential to cause serious confusion in the future if it goes uncorrected.</p>
<p>His response, in full, is the following:</p>
<hr>
<blockquote class="blockquote">
<p>Dariush Mozaffarian, MD DrPH</p>
<p>It has been noted by some comments that, in our investigation “Effects on Coronary Heart Disease of Increasing Polyunsaturated Fat in Place of Saturated Fat: A Systematic Review and Meta-Analysis of Randomized Controlled Trials,”1 the cross-over intervention design for the two clusters in the Finnish Mental Hospital study (1959-1971) was not randomized. One hospital started with the control diet and the other with the intervention diet for 6 years, and then these diets were reversed for another 6 years. Thus, over the 12 year intervention, each hospital served as its own control, with each hospital receiving each diet in alternating order.</p>
<p>Because this trial was conceived and designed in the 1950s, before current standardized designs and reporting were widely accepted for randomized cross-over trials, we considered this equivalent to a cluster-randomized cross-over trial in our meta-analysis. While the method for determining which hospital started with which diet was not described, both hospitals received both interventions, in differing order over time.</p>
<p>As we noted in the Discussion of our manuscript:</p>
<p>“Many of the identified randomized trials in our meta-analysis had important design limitations (Table 1). For example, some trials provided all or most meals, increasing compliance but perhaps limiting generalizability to effects of dietary recommendations alone; whereas other trials relied only on dietary advice, increasing generalizability to dietary recommendations but likely underestimating efficacy due to noncompliance. Several of these trials were not double-blind, raising the possibility of differential classification of endpoints by the investigators that could overestimate benefits of the intervention. One trial used a cluster-randomization cross-over design that intervened on sites rather than individuals; and two trials used open enrollment that allowed participants to both drop-in and drop-out during the trial. The methods for estimating and reporting PUFA and SFA consumption in each trial varied, which could cause errors in our estimation of the quantitative benefit per %E replacement.”</p>
<p><strong>It is reasonable that one could disagree with our description of “cluster-randomization,” and describe this as a “cluster-quasi-experimental intervention” instead. Given the nature of this trial and its time period of implementation, this was our best interpretation.</strong></p>
<p>Due to the design limitations of several of the trials, we performed several secondary analyses excluding studies based on different design characteristics. Combining all trials, the pooled RR for CHD events was 0.81 (95% CI=0.70-0.95, p=0.008). As we reported in the manuscript: “Excluding the Finnish mental hospital trial (2 reports) that used a cluster-randomization design, the overall pooled RR was 0.87 (95% CI=0.76-1.00, p=0.05).” None of these subgroup analyses were significantly different from the main pooled result, as demonstrated by the 95% CIs in each subgroup analysis including the value of the main pooled RR estimate of 0.81.</p>
<p>As we concluded in our Discussion:</p>
<p>“Given these limitations of each individual trial, the quantitative pooled risk estimate should be interpreted with some caution. Nevertheless, this is the best current worldwide evidence from RCTs for effects on CHD events of replacing SFA with PUFA, and, as discussed above, the pooled risk estimate from this meta-analysis (10% lower risk per 5%E greater PUFA) is well within the range of estimated benefits from randomized controlled feeding trials of changes in lipid levels (9% lower risk per 5%E greater PUFA) and prospective observational studies of clinical CHD events (13% lower risk per 5%E greater PUFA). The consistency of the findings across these different lines of evidence provides substantial confidence in both the qualitative benefits and also a fairly narrow range of quantitative uncertainty.”</p>
<p>Since the publication of our meta-analysis in 2010, multiple additional studies have further supported cardiometabolic benefits of PUFA consumption. Notably, these studies suggest that benefits are largely related to increased PUFA consumption, rather than decreased SFA consmption per se. For example, a meta-analysis of prospective cohort studies demonstrated that total dietary PUFA is associated with lower risk of clinical events in cohort studies whether replacing total SFA or total carbohydrate.2 A meta-analysis of 102 randomized controlled feeding trials demonstrated that dietary PUFA produces multiple beneficial effects on glycemic control, including lowering of fasting glucose, HbA1C, and insulin resistance and improving pancreatic beta cell function as measured by gold-standard insulin secretion capacity.3 Of note, glycemic benefits are seen whether PUFA replaces carbohydrate, SFA, or even MUFA.3 And, a pooling of new, harmonized, individual-level analysis including 39,740 individuals from 20 prospective cohort studies across ten nations demonstrated that objective blood or tissue biomarkers of linoleic acid (the predominant dietary PUFA) are associated with 35% lower risk of diabetes (per interquintile range, RR=0.65, 95% CI=0.60–0.72, p &lt; 0.0001).4</p>
<p>In sum, the overall evidence confirms cardiometabolic benefits of PUFA consumption, including based on evidence from controlled feeding studies of blood lipids, controlled feeding studies of glucose-insulin homeostasis, prospective cohort studies of estimated dietary PUFA and clinical outcomes, prospective cohort studies of objective PUFA biomarkers and clinical outcomes, and controlled clinical trials of PUFA consumption and clinical outcomes.</p>
<ol type="1">
<li><p>Mozaffarian D, Micha R, Wallace S. Effects on coronary heart disease of increasing polyunsaturated fat in place of saturated fat: a systematic review and meta-analysis of randomized controlled trials. PLoS Med 2010;7(3):e1000252.</p></li>
<li><p>Farvid MS, Ding M, Pan A, et al.&nbsp;Dietary linoleic acid and risk of coronary heart disease: a systematic review and meta-analysis of prospective cohort studies. Circulation 2014;130(18):1568-78. doi: 10.1161/circulationaha.114.010236 [published Online First: 2014/08/28]</p></li>
<li><p>Imamura F, Micha R, Wu JH, et al.&nbsp;Effects of Saturated Fat, Polyunsaturated Fat, Monounsaturated Fat, and Carbohydrate on Glucose-Insulin Homeostasis: A Systematic Review and Meta-analysis of Randomised Controlled Feeding Trials. PLoS medicine 2016;13(7):e1002087. doi: 10.1371/journal.pmed.1002087 [published Online First: 2016/07/21]</p></li>
<li><p>Wu JHY, Marklund M, Imamura F, et al.&nbsp;Omega-6 fatty acid biomarkers and incident type 2 diabetes: pooled analysis of individual-level data for 39 740 adults from 20 prospective cohort studies. Lancet Diabetes Endocrinol 2017;5(12):965-74. doi: 10.1016/S2213-8587(17)30307-8 [published Online First: 2017/10/17]</p></li>
</ol>
<p><strong>Competing interests declared</strong>: Dr.&nbsp;Mozaffarian reports research funding from the National Institutes of Health and the Gates Foundation; personal fees from GOED, DSM, Nutrition Impact, Pollock Communications, Bunge, Indigo Agriculture, Amarin, Acasti Pharma, Cleveland Clinic Foundation, and America’s Test Kitchen; scientific advisory board, Elysium Health (with stock options), Omada Health, and DayTwo; and chapter royalties from UpToDate; all outside the submitted work.</p>
</blockquote>
<hr>
<p>I hope that readers can decide for themselves whether this response is adequate.</p>
<hr>
</section>
<section id="environment" class="level1">
<h1>Environment</h1>
<hr>
<p>The analyses were run on:</p>
<div class="cell" data-layout-align="center">
<pre><code>#&gt; R version 4.5.2 (2025-10-31)
#&gt; Platform: aarch64-apple-darwin20
#&gt; Running under: macOS Tahoe 26.3
#&gt; 
#&gt; Matrix products: default
#&gt; BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
#&gt; LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
#&gt; 
#&gt; Random number generation:
#&gt;  RNG:     Mersenne-Twister 
#&gt;  Normal:  Inversion 
#&gt;  Sample:  Rejection 
#&gt;  
#&gt; locale:
#&gt; [1] C.UTF-8/C.UTF-8/C.UTF-8/C/C.UTF-8/C.UTF-8
#&gt; 
#&gt; time zone: America/New_York
#&gt; tzcode source: internal
#&gt; 
#&gt; attached base packages:
#&gt;  [1] splines   grid      stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     
#&gt; 
#&gt; other attached packages:
#&gt;  [1] metasens_1.5-3        meta_8.2-1            metafor_4.8-0         numDeriv_2016.8-1.1   metadat_1.4-0        
#&gt;  [6] texPreview_2.1.0      tinytex_0.58          rmarkdown_2.30        brms_2.23.0           bootImpute_1.3.0     
#&gt; [11] boot_1.3-32           JuliaCall_0.17.6      reshape2_1.4.5        ProfileLikelihood_1.3 ImputeRobust_1.3-1   
#&gt; [16] gamlss_5.5-0          gamlss.dist_6.1-1     gamlss.data_6.0-7     mvtnorm_1.3-3         performance_0.15.3   
#&gt; [21] summarytools_1.1.5    tidybayes_3.0.7       htmltools_0.5.9       Statamarkdown_0.9.6   car_3.1-3            
#&gt; [26] carData_3.0-6         qqplotr_0.0.7         ggcorrplot_0.1.4.1    mitml_0.4-5           pbmcapply_1.5.1      
#&gt; [31] Amelia_1.8.3          Rcpp_1.1.1            blogdown_1.23         doParallel_1.0.17     iterators_1.0.14     
#&gt; [36] foreach_1.5.2         lattice_0.22-7        bayesplot_1.15.0      wesanderson_0.3.7     VIM_7.0.0            
#&gt; [41] colorspace_2.1-2      here_1.0.2            progress_1.2.3        loo_2.9.0             mi_1.2               
#&gt; [46] Matrix_1.7-4          broom_1.0.12          yardstick_1.3.2       svglite_2.2.2         Cairo_1.7-0          
#&gt; [51] cowplot_1.2.0         mgcv_1.9-4            nlme_3.1-168          xfun_0.56             broom.mixed_0.2.9.6  
#&gt; [56] reticulate_1.44.1     kableExtra_1.4.0      posterior_1.6.1       checkmate_2.3.3       parallelly_1.46.1    
#&gt; [61] miceFast_0.8.5        randomForest_4.7-1.2  missForest_1.6.1      miceadds_3.18-36      quantreg_6.1         
#&gt; [66] SparseM_1.84-2        MCMCpack_1.7-1        MASS_7.3-65           coda_0.19-4.1         latex2exp_0.9.8      
#&gt; [71] rstan_2.32.7          StanHeaders_2.32.10   lubridate_1.9.4       forcats_1.0.1         stringr_1.6.0        
#&gt; [76] dplyr_1.1.4           purrr_1.2.1           readr_2.1.6           tibble_3.3.1          tidyverse_2.0.0      
#&gt; [81] ggtext_0.1.2          concurve_3.0.0        showtext_0.9-7        showtextdb_3.0        sysfonts_0.8.9       
#&gt; [86] future.apply_1.20.1   future_1.69.0         tidyr_1.3.2           magrittr_2.0.4        mice_3.19.0          
#&gt; [91] rms_8.1-0             Hmisc_5.2-5           ggplot2_4.0.1         knitr_1.51           
#&gt; 
#&gt; loaded via a namespace (and not attached):
#&gt;   [1] dichromat_2.0-0.1       nnet_7.3-20             TH.data_1.1-5           vctrs_0.7.1             digest_0.6.39          
#&gt;   [6] png_0.1-8               shape_1.4.6.1           proxy_0.4-29            magick_2.9.0            fontLiberation_0.1.0   
#&gt;  [11] withr_3.0.2             ggpubr_0.6.2            survival_3.8-6          doRNG_1.8.6.2           emmeans_2.0.1          
#&gt;  [16] MatrixModels_0.5-4      systemfonts_1.3.1       ragg_1.5.0              zoo_1.8-15              V8_8.0.1               
#&gt;  [21] ggdist_3.3.3            DEoptimR_1.1-4          Formula_1.2-5           prettyunits_1.2.0       rematch2_2.1.2         
#&gt;  [26] httr_1.4.7              otel_0.2.0              rstatix_0.7.3           globals_0.19.0          rstudioapi_0.18.0      
#&gt;  [31] extremevalues_2.4.1     pan_1.9                 generics_0.1.4          base64enc_0.1-6         curl_7.0.0             
#&gt;  [36] mitools_2.4             lgr_0.5.2               desc_1.4.3              xtable_1.8-4            svUnit_1.0.8           
#&gt;  [41] pracma_2.4.6            evaluate_1.0.5          hms_1.1.4               glmnet_4.1-10           lmtest_0.9-40          
#&gt;  [46] palmerpenguins_0.1.1    robustbase_0.99-6       matrixStats_1.5.0       svgPanZoom_0.3.4        class_7.3-23           
#&gt;  [51] pillar_1.11.1           caTools_1.18.3          compiler_4.5.2          stringi_1.8.7           paradox_1.0.1          
#&gt;  [56] jomo_2.7-6              minqa_1.2.8             plyr_1.8.9              crayon_1.5.3            abind_1.4-8            
#&gt;  [61] sp_2.2-0                mathjaxr_2.0-0          rapportools_1.2         twosamples_2.0.1        sandwich_3.1-1         
#&gt;  [66] whisker_0.4.1           codetools_0.2-20        multcomp_1.4-29         textshaping_1.0.4       bcaboot_0.2-3          
#&gt;  [71] openssl_2.3.4           flextable_0.9.10        QuickJSR_1.9.0          e1071_1.7-17            gridtext_0.1.5         
#&gt;  [76] lme4_1.1-38             fs_1.6.6                itertools_0.1-3         listenv_0.10.0          Rdpack_2.6.5           
#&gt;  [81] pkgbuild_1.4.8          estimability_1.5.1      ggsignif_0.6.4          tzdb_0.5.0              pkgconfig_2.0.3        
#&gt;  [86] tools_4.5.2             rbibutils_2.4.1         viridisLite_0.4.2       DBI_1.2.3               fastmap_1.2.0          
#&gt;  [91] scales_1.4.0            officer_0.7.3           opdisDownsampling_1.0.1 insight_1.4.5           rpart_4.1.24           
#&gt;  [96] farver_2.1.2            reformulas_0.4.4        survminer_0.5.1         yaml_2.3.12             foreign_0.8-91         
#&gt;  [ reached 'max' / getOption("max.print") -- omitted 58 entries ]</code></pre>
</div>
<hr>
</section>
<section id="references" class="level1">
<h1>References</h1>
<hr>


<!-- -->


</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" data-entry-spacing="2" data-line-spacing="2">
<div id="ref-Mozaffarian2010-vt" class="csl-entry">
1. Mozaffarian D, Micha R, Wallace S. (2010). <span>“Effects on coronary heart disease of increasing polyunsaturated fat in place of saturated fat: A systematic review and meta-analysis of randomized controlled trials.”</span> <em>PLoS Med</em>. <strong>7</strong>:e1000252. doi: <a href="https://doi.org/10.1371/journal.pmed.1000252">10.1371/journal.pmed.1000252</a>.
</div>
<div id="ref-viechtbauerConductingMetaanalysesMetafor2010" class="csl-entry">
2. Viechtbauer W. (2010). <span>“Conducting meta-analyses in <span>R</span> with the metafor package.”</span> <em>J Stat Softw</em>. <strong>36</strong>. doi: <a href="https://doi.org/10.18637/jss.v036.i03">10.18637/jss.v036.i03</a>.
</div>
<div id="ref-morrisChoosingSensitivityAnalyses2014" class="csl-entry">
3. Morris TP, Kahan BC, White IR. (2014). <span>“Choosing sensitivity analyses for randomised trials: principles.”</span> <em>BMC Medical Research Methodology</em>. <strong>14</strong>:11. doi: <a href="https://doi.org/10.1186/1471-2288-14-11">10.1186/1471-2288-14-11</a>.
</div>
<div id="ref-rafiSemanticCognitiveTools2020" class="csl-entry">
4. Rafi Z, Greenland S. (2020). <span>“Semantic and cognitive tools to aid statistical science: Replace confidence and significance by compatibility and surprise.”</span> <em>BMC Medical Research Methodology</em>. <strong>20</strong>:244. doi: <a href="https://doi.org/10.1186/s12874-020-01105-9">10.1186/s12874-020-01105-9</a>.
</div>
<div id="ref-rafiConcurveComputesPlots2020" class="csl-entry">
5. Rafi Z, Vigotsky AD. (2020). <span>“Concurve: <span>Computes</span> &amp; <span>Plots Compatibility</span> (<span>Confidence</span>), <span>Surprisal</span>, &amp; <span>Likelihood Distributions</span>.”</span>
</div>
<div id="ref-ruckerForestPlotDrapery2020" class="csl-entry">
6. Rücker G, Schwarzer G. (2020). <span>“Beyond the forest plot: <span>The</span> drapery plot.”</span> <em>Research Synthesis Methods</em>. doi: <a href="https://doi.org/10.1002/jrsm.1410">10.1002/jrsm.1410</a>.
</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">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{panda2018,
  author = {Panda, Sir and Rafi, Zad},
  title = {Influential {Errors} \textbar{} {The} {Diet} {Heart} {Tale}},
  date = {2018-10-11},
  url = {https://lesslikely.com/posts/nutrition/influential-errors.html},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-panda2018" class="csl-entry quarto-appendix-citeas">
1. Panda S, Rafi Z. (2018). <span>‘Influential Errors | The Diet Heart
Tale’</span>. <a href="https://lesslikely.com/posts/nutrition/influential-errors.html">https://lesslikely.com/posts/nutrition/influential-errors.html</a>.
</div></div></section></div> ]]></description>
  <category>nutrition</category>
  <guid>https://lesslikely.com/posts/nutrition/influential-errors.html</guid>
  <pubDate>Thu, 11 Oct 2018 04:00:00 GMT</pubDate>
  <media:content url="https://res.cloudinary.com/less-likely/image/upload/f_auto,q_auto/v1554700138/Site/Mozaffarian-Meta-Analysis.png" medium="image" type="image/png"/>
</item>
</channel>
</rss>
