<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Drew Dimmery</title><description>Methods in Causal Inference, Data Science and Social Science</description><link>https://ddimmery.com/</link><language>en-us</language><item><title>AI Evaluations for conviviality</title><link>https://ddimmery.com/posts/ai-eval-class/</link><guid isPermaLink="true">https://ddimmery.com/posts/ai-eval-class/</guid><description>A new class at Hertie on the human use of AI systems</description><pubDate>Wed, 05 Aug 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This fall, I’m teaching a brand-new course at Hertie on AI evaluation.
I think it’s going to be a lot of fun.&lt;/p&gt;
&lt;p&gt;We aren’t going to spend the semester running standard model benchmarks or debating sci-fi capabilities.
Instead, the angle is to carefully develop experiments to tie these complex systems into the real human lives they affect.
This post will dive into how I think about the class, how I’ve designed it and what I’m hoping to get out of it.&lt;/p&gt;
&lt;h2 id=&quot;why-ai-evaluation-needs-this-class&quot;&gt;Why AI evaluation needs this class&lt;/h2&gt;
&lt;p&gt;One of my big frustrations with AI evaluation is the way that so much of it is completely stuck in a category error.
Put simply, I don’t particularly care about abstract “model capabilities”.
I’m a humanist in the sense that I believe the only evaluations of tools that really matter are the ones that measure &lt;em&gt;how they improve the ability of humans to achieve their aims&lt;/em&gt;.
Far too few AI evaluations focus on this component, as they’re too busy working in a science-fiction world of creating new sentient life and trying to measure… whatever they mean by that.
Consider a benchmark like &lt;a href=&quot;https://lastexam.ai/&quot;&gt;“Humanity’s Last Exam”&lt;/a&gt;: the name alone tells you it’s measuring performance on frontier-of-human-knowledge trivia, with no theory at all of which humans are helped by a model answering such questions&lt;sup&gt;&lt;a href=&quot;#user-content-fn-hle&quot; id=&quot;user-content-fnref-hle&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;.
To me, models are useful when they help me accomplish &lt;em&gt;my&lt;/em&gt; goals.
This class is about helping me work out more clearly what that should look like in terms of evaluation methodologies.&lt;/p&gt;
&lt;p&gt;To take an example of how even AI skeptics miss the mark on this: I respect a lot of Arvind Narayanan’s work on AI and its role in society.
The work he’s been doing with Sayash Kapoor on &lt;a href=&quot;https://www.normaltech.ai/p/open-world-evaluations-for-measuring&quot;&gt;“open world” AI evals&lt;/a&gt; is very interesting, but I find that it retains the original sin of AI evaluation, which treats the AI system as largely distinct from the social system in which it operates.
The same spirit animates another recent AI evaluation: it’s &lt;em&gt;interesting&lt;/em&gt; whether a given model + harness can &lt;a href=&quot;https://cursor.com/blog/agent-swarm-model-economics&quot;&gt;rewrite a working SQLite clone from the manual&lt;/a&gt;, but this doesn’t ultimately tell us much about whether a non-techie home gardener can use an agentic AI system to put together a coherent way of managing their irrigation.
“The most important elements of people’s quality of life are plural and qualitatively distinct”&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn1&quot; id=&quot;user-content-fnref-fn1&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; and, in the modern world, increasingly play out in digital spaces.
The promise of agentic tools is that they make people better able to personally manipulate these spaces and bend them to their whims.
The relevant manipulations we should be testing are not whether Joe Schmoe D.D.S. can rewrite SQLite from scratch (how would he even ask for this? why does he need it?), but whether his office can set up an appointment system exactly tailored to their working style without any technical knowledge.
Realism of environment (a la open world evals) is good, but realism of &lt;em&gt;purpose&lt;/em&gt; is what I’m looking to engender through this class.&lt;/p&gt;
&lt;p&gt;The kind of evaluation I have in mind does exist.
&lt;a href=&quot;https://metr.org/blog/2025-07-10-early-2025-ai-experienced-os-dev-study/&quot;&gt;METR’s randomized trial&lt;/a&gt; of experienced open-source developers is one example&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn0&quot; id=&quot;user-content-fnref-fn0&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.
Whatever you make of the result, it is fundamentally a study of the &lt;em&gt;joint&lt;/em&gt; human-AI system doing real work.
The gap between perceived and actual benefit is exactly the kind of thing capability benchmarks struggle to surface.&lt;/p&gt;
&lt;h2 id=&quot;where-the-course-comes-from&quot;&gt;Where the course comes from&lt;/h2&gt;
&lt;p&gt;In general, the course comes from a place of thinking about AI via experimentation.
It started with me deciding I wanted to teach a class on experimentation.
Cyrus Samii designed an amazing class called “&lt;a href=&quot;https://web.archive.org/web/20240803003606/https://cyrussamii.com/?page_id=3566&quot;&gt;Quant Field Methods&lt;/a&gt;” (note: this is the old version of the course I pivoted off of, but &lt;a href=&quot;https://cyrussamii.com/?page_id=3787&quot;&gt;Cyrus has since updated it&lt;/a&gt;).
The idea was that students would leave the course with a complete pre-analysis plan ready to take into the field: actually &lt;em&gt;multiple&lt;/em&gt; plans, as groups of students would &lt;em&gt;repeatedly&lt;/em&gt; go through the process of identifying a societal problem, designing an intervention around it, and then working through the design issues to prepare the experiment for the field.
I wrote a syllabus roughly based on this idea, which I’ve had in my back pocket for a while.
One of the main differences is that Cyrus believes in mechanisms in a way that I don’t.
His version emphasized those mechanisms, while I wanted to dig into methods more explicitly.
I slowed it down relative to his planned three-cycle class to a two-cycle version that left more room for lectures on methodological problems specifically geared towards experimentation.&lt;/p&gt;
&lt;p&gt;I’ve had this syllabus since around 2023, but as I prepared for this fall, I decided that I wanted to target it more directly around a particular problem (rather than leaving it fully generic).
Thus, I’ve decided to focus on AI evaluation.
It’s very hot right now!
&lt;a href=&quot;https://www.ft.com/content/ac15aa4a-960f-4957-90c6-ff1b4a390fa4?syn-25a6b1a6=1&quot;&gt;Andy Hall recently wrote an argument for why AI evaluation is so important&lt;/a&gt;.
I think what he’s talking about is important, but it also fails to see exactly what “AI” is: it isn’t just a model, it’s a harness and a large socio-technical &lt;em&gt;system&lt;/em&gt;.
Things like his &lt;a href=&quot;https://www.dictatoreval.org/&quot;&gt;dictatorship eval&lt;/a&gt; are great, but when I worry about the &lt;a href=&quot;https://en.wikipedia.org/wiki/Tools_for_Conviviality&quot;&gt;conviviality&lt;/a&gt; of AI systems, I really do think one has to consider the system as a whole, not just “what is emitted by a model”.
I’m hoping to push on this through the class, and I think the framing of experimentation is critical to this turn.
As Kevin and I write, &lt;a href=&quot;https://muse.jhu.edu/article/956838&quot;&gt;experiments are ontological tools which create new states of the world&lt;/a&gt;.
This class is about tracing out and evaluating the ontological interventions in human action that AI systems are making and measuring their performance relative to human goals.&lt;/p&gt;
&lt;h2 id=&quot;design-decisions&quot;&gt;Design decisions&lt;/h2&gt;
&lt;p&gt;I’ve made a variety of changes to try and bring this together. The main one is that students will work on just a single project, but they will actually field it, too.
This was one of the major decisions I agonized over, because while it’s extremely difficult to successfully get an experiment into the field during a one-semester course, I think there are a few reasons to do this anyway:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;AI evaluation moves extremely quickly. If you don’t actually do your evaluation quickly, your design will get stale. There isn’t a lot of value in just leaving a plan around for a long time. Students should also learn how to deploy data science skills in the nimble way this requires: it’s how things work in “the real world” of applied data science.&lt;/li&gt;
&lt;li&gt;Running the actual experiment is a massive learning opportunity. Almost everyone’s first experiment goes off the rails in some way, and the best way to get past this is &lt;em&gt;through&lt;/em&gt; it.&lt;/li&gt;
&lt;li&gt;I want to see actual results! Getting a PAP is great, but the feeling of satisfaction from seeing how the experiment actually turns out is beyond compare.&lt;/li&gt;
&lt;li&gt;Coding assistants make it easier than ever to do it. I think ramping up expectations is a good way to preserve the value of higher education in the face of AI.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Roughly, my plan is to devote the first two-thirds of the class to developing a really complete pre-analysis plan, and then the last third will be devoted to fielding the experiment, analyzing the results and writing them up.&lt;/p&gt;
&lt;h2 id=&quot;whats-in-the-class&quot;&gt;What’s in the class&lt;/h2&gt;
&lt;p&gt;Each meeting (we have 12 at Hertie, of ~1h50m each) is split roughly in half: a workshop where students share their work-in-progress (and get feedback), and then a lecture at the end preparing for the next week’s milestone.
Topics are reinforced a few times: first in lecture, then in the reading, then in execution and the workshop.
The arc runs from a survey of the evaluation landscape (benchmarks versus human experiments) and student pitches, through measurement theory and construct validity, defining the interventional system (a model plus a prompt plus a scaffold plus …), outcome measurement and scorer validation, randomization and threats to validity, and the analysis plan.
At this point the pre-analysis plan is registered and the class flips to execution: pilot results, troubleshooting and documented deviations, draft findings, and final presentations.
Teams of four carry one project across the whole term and produce four deliverables: an ethics and responsible-evaluation self-assessment, a registered pre-analysis plan, two deliberately informal work-in-progress code demos, and a final report with reproducible code and data.
Each of these is coordinated by a different member of the team to ensure shared accountability.
There are some other, smaller assignments to make sure students read and reflect on the material as well.
All of it happens in the open on GitHub: pull requests, issues, and a project board, so that I can actually see how the work got done and not just what landed at the end&lt;sup&gt;&lt;a href=&quot;#user-content-fn-ai&quot; id=&quot;user-content-fnref-ai&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;h2 id=&quot;what-counts-as-a-project&quot;&gt;What counts as a project&lt;/h2&gt;
&lt;p&gt;The original template assumed human-subjects field experiments, but for a class on AI evaluation, that seemed too prescriptive.
I will allow students to focus on developing a well-defined benchmark, a clear annotation task, or a human-subjects experiment.
I’m the most skeptical of the first of these, for all the reasons above, but I’d rather leave the option open than rule it out by fiat.
The critical thing for each of these is that they must be focused on understanding something about a &lt;em&gt;joint human-AI&lt;/em&gt; task, and a benchmark doesn’t get a pass on this.
Whatever form a project takes, students will have to justify it on the same human-focused grounds, repeatedly, at every stage of the design.
The turn I have in mind here is to focus not just on whether AI can write good code, but on whether it helps a particular population of people better perform whatever they see as their tasks.
I suspect a large part of the class will be spent discussing exactly who the audience is, what their goals are and exactly what must be measured about how well they can accomplish them.&lt;/p&gt;
&lt;h2 id=&quot;summing-up&quot;&gt;Summing up&lt;/h2&gt;
&lt;p&gt;To bring this back to my big picture, I think the metaphor of tending a garden from &lt;a href=&quot;https://ddimmery.com/posts/back-to-basics/&quot;&gt;a previous post&lt;/a&gt; is useful.
Suppose we’re enrolled in a quantitative horticulture program.
There’s a lot of stuff we can measure about plants: how tall they grow, how much input (water, fertilizer, and so on) they need, how much they yield.
These may be cool to measure, and you might be able to optimize any of them, but at some point you have to be really specific about what you’re looking for from the garden.
If you grow the largest eggplants in the world, but what you really cared about was how the flowers made you feel, then your highly optimized garden is still useless.
Cyrus’s initial framing of the class is ultimately right that theory is critically important, but I think he was wrong about what &lt;em&gt;kind&lt;/em&gt; of theory was needed.
In contrast to his original pitch, which focused on theoretical mechanisms, I think it might be more important to focus on &lt;em&gt;normative&lt;/em&gt; theory&lt;sup&gt;&lt;a href=&quot;#user-content-fn-problem&quot; id=&quot;user-content-fnref-problem&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;.
This is roughly the bet behind &lt;a href=&quot;https://kmunger.github.io/pdfs/syllabus_citp.pdf&quot;&gt;“Building the Society We Want”&lt;/a&gt;, a syllabus I helped Kevin put together a few years back, which organizes everything around &lt;em&gt;Values&lt;/em&gt; first and analytical &lt;em&gt;Tools&lt;/em&gt; second.
That’s the direction I’m pushing this class in, at least; I’m excited to see how it goes!&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-hle&quot;&gt;
&lt;p&gt;Indeed, it feels much more like the opposite: measuring whether models are ready to kill us all in our sleep, making it truly our &lt;em&gt;last&lt;/em&gt; exam. &lt;a href=&quot;#user-content-fnref-hle&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn1&quot;&gt;
&lt;p&gt;Martha Nussbaum, &lt;a href=&quot;https://www.hup.harvard.edu/books/9780674072350&quot;&gt;&lt;em&gt;Creating Capabilities: The Human Development Approach&lt;/em&gt;&lt;/a&gt; &lt;a href=&quot;#user-content-fnref-fn1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn0&quot;&gt;
&lt;p&gt;Alas, there were some issues with this trial. &lt;a href=&quot;https://www.argmin.net/p/are-developers-finally-out-of-a-job&quot;&gt;Recht has written&lt;/a&gt; about them, and I won’t recapitulate that here. The overall idea of measuring this is, in my view, much better than their &lt;a href=&quot;https://metr.org/time-horizons/&quot;&gt;more famous chart of time horizons&lt;/a&gt; insomuch as it focuses on a human reference. &lt;a href=&quot;#user-content-fnref-fn0&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-ai&quot;&gt;
&lt;p&gt;I have a set of scripts that provide a full dashboard of how students worked on projects together, which makes it easy to see how work was distributed. I think this is really important for group projects, especially in an age of AI, so that I can actually grade on progress and process rather than just the final product. &lt;a href=&quot;#user-content-fnref-ai&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-problem&quot;&gt;
&lt;p&gt;You might even call this the &lt;a href=&quot;https://doi.org/10.1093/oxfordhb/9780192868282.013.35&quot;&gt;“Problem Solving”&lt;/a&gt; approach to AI evaluation. &lt;a href=&quot;#user-content-fnref-problem&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><category>technology</category><category>teaching</category><category>experiments</category><category>ai</category></item><item><title>Better testing through concentration</title><link>https://ddimmery.com/posts/pytest-stochastic/</link><guid isPermaLink="true">https://ddimmery.com/posts/pytest-stochastic/</guid><description>A pytest plugin that replaces ad-hoc stochastic tests with concentration inequalities based on supplied assumptions: pytest-stochastic.</description><pubDate>Tue, 30 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Basically every piece of software I write eventually uses some form of stochasticity.
Writing tests of random functions is frustrating: you write a test that draws 1,000 samples&lt;sup&gt;&lt;a href=&quot;#user-content-fn-why&quot; id=&quot;user-content-fnref-why&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; and asserts it’s the right value (or within some tolerance I pick by feel).
It passes and I move on with my life.
Then, three months later, when I need to push a small fix somewhere, it starts failing and I have no idea why.&lt;/p&gt;
&lt;p&gt;The usual response is either (a) crank up the sample count until the failures stop, (b) widen the tolerance until the test is effectively vacuous, or (c) mark the test as flaky and move on with my life&lt;sup&gt;&lt;a href=&quot;#user-content-fn-or&quot; id=&quot;user-content-fnref-or&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.
I’m sure this sounds familiar, but these solutions suck.
They’re fundamentally symptoms of the same underlying problem: there’s no principled connection between the test’s statistical properties and the sample count and tolerance chosen.&lt;/p&gt;
&lt;p&gt;This has always been annoying, but it’s become a more urgent problem recently.
When writing code with AI, whether code is &lt;em&gt;actually&lt;/em&gt; good tracks the quality of tests and evaluations.
Strong tests mean strong code: the model writes something, the tests catch what’s wrong, the model fixes it, and you converge to a working piece of software at the end of the session.
Bad, vacuous tests break this loop.
The model “passes” the tests by writing a test that always passes (“Oh, this test is flaky. I’ll just crank up the tolerance.” Yes, unfortunately, Claude has the same bad habits I do, sometimes), and you don’t find out until production.
Stochastic code is especially vulnerable here, because the failure mode is silent: a test with a too-wide tolerance or a too-small sample count may happily pass code that’s subtly wrong, but you’ll feel confident because you have a test written supposedly verifying its behavior.&lt;/p&gt;
&lt;p&gt;This bothered me enough to (try to) do something about it.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-claude&quot; id=&quot;user-content-fnref-claude&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;h2 id=&quot;the-idea&quot;&gt;The idea&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/ddimmery/pytest-stochastic&quot;&gt;pytest-stochastic&lt;/a&gt; is a pytest plugin that makes the connection between test and statistical guarantee explicit.
You declare what you know about your test statistic---its bounds, variance, sub-Gaussian parameter, whatever you’ve got---and the framework does the rest.
It selects the tightest applicable &lt;a href=&quot;https://en.wikipedia.org/wiki/Concentration_inequality&quot;&gt;concentration inequality&lt;/a&gt; from a registry of ten I chose “stochastically”, computes the minimum sample size to hit the acceptable flakiness budget, and runs the test.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; pytest_stochastic &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; stochastic_test&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;@stochastic_test&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    expected&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0.5&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    atol&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0.01&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    bounds&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    failure_prob&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1e-8&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; test_uniform_mean&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(rng):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; rng.uniform(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That &lt;code&gt;failure_prob=1e-8&lt;/code&gt; is guaranteed based on the invariants you provide: the test will produce a false failure less than once in 100 million runs (so long as your assumptions are correct).
The framework figures out that it needs exactly 7,394 samples to deliver that guarantee via &lt;a href=&quot;https://en.wikipedia.org/wiki/Hoeffding%27s_inequality&quot;&gt;Hoeffding’s inequality&lt;/a&gt;, and runs them.&lt;/p&gt;
&lt;p&gt;The key insight is that you don’t need to carefully figure out the right concentration inequality, you just express the assumptions that you know.
If you only know the range of your statistic, you get Hoeffding and pay for the worst case.
Declare the variance and &lt;a href=&quot;https://en.wikipedia.org/wiki/Bernstein_inequalities_(probability_theory)&quot;&gt;Bernstein&lt;/a&gt; kicks in---often much tighter.
Know the &lt;a href=&quot;https://en.wikipedia.org/wiki/Sub-Gaussian_distribution&quot;&gt;sub-Gaussian&lt;/a&gt; parameter and you can do even better still.
In the worked example in the docs, testing an OLS slope estimator goes from 75,000 samples (bounds only) to 100 (sub-Gaussian): a reduction of multiple orders of magnitude for the same probabilistic guarantee.&lt;/p&gt;
&lt;h2 id=&quot;but-i-dont-know-my-variance&quot;&gt;But I don’t know my variance&lt;/h2&gt;
&lt;p&gt;Yeah, no shit, why would you?
Deriving variance analytically &lt;em&gt;for a unit test&lt;/em&gt; is absurdly overkill.
This is what tune mode is for:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;pytest&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; --stochastic-tune&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This profiles each test empirically (50,000 samples by default), computes an upper confidence bound on the variance, and writes the result to &lt;code&gt;.stochastic.toml&lt;/code&gt;.
Commit that file, and subsequent runs automatically use the tighter Bernstein bound.&lt;/p&gt;
&lt;h2 id=&quot;what-else&quot;&gt;What else&lt;/h2&gt;
&lt;p&gt;There’s also a &lt;code&gt;@distributional_test&lt;/code&gt; decorator for goodness-of-fit testing (KS, chi-squared, Anderson-Darling against a reference distribution), automatic RNG injection with seed reporting on failure for reproducibility, and sensible error messages when you misconfigure things.
The &lt;a href=&quot;https://ddimmery.github.io/pytest-stochastic/&quot;&gt;documentation&lt;/a&gt; covers all of this.&lt;/p&gt;
&lt;h2 id=&quot;why-bother&quot;&gt;Why bother&lt;/h2&gt;
&lt;p&gt;Ad-hoc thresholds and magic sample counts are technical debt that compounds quietly, and this is an attempt to do better.
For many use cases, alas, the sample counts that concentration inequalities require are still too large to be practical.
I tried this on a recent project and ended up just fixing a seed anyway, because I couldn’t afford 10—100 evaluations of the test statistic (which each required letting a neural network converge).
When individual evaluations are cheap, though, this should be helpful to get faster, more reliable tests (or at least figure out what the tradeoff is between the two).
I think &lt;a href=&quot;https://ddimmery.github.io/pytest-stochastic/guide/example/&quot;&gt;the worked example&lt;/a&gt; in the docs is a pretty good example of how this could be useful.&lt;/p&gt;
&lt;p&gt;This isn’t new math or anything, but maybe someone finds it useful.&lt;/p&gt;
&lt;p&gt;The code is &lt;a href=&quot;https://github.com/ddimmery/pytest-stochastic&quot;&gt;on GitHub&lt;/a&gt;.
Try it out and let me know about how it goes.
I’m making no guarantees, here!&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-why&quot;&gt;
&lt;p&gt;Why 1,000? Because it’s a nice round number, and nice round numbers are inherently trustworthy. &lt;a href=&quot;#user-content-fnref-why&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-or&quot;&gt;
&lt;p&gt;Or more likely, just choose a random seed that works for a single run and hardcode it. It’s future-Drew’s problem when a change makes it randomly start failing. &lt;a href=&quot;#user-content-fnref-or&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-claude&quot;&gt;
&lt;p&gt;Read as: bothered me enough to make &lt;em&gt;Claude&lt;/em&gt; do something about it. Pretty nearly one-shot the thing, too, but as always the long-tail of iteration still took a while. GitHub shows 15 PRs and about 50 commits, so that’s probably about how much prompting I had to do (each PR represented one initial prompt that I iterated on a couple times fixing errors and providing feedback). &lt;a href=&quot;#user-content-fnref-claude&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><category>methodology</category><category>technology</category><category>open-source</category></item><item><title>Causal ML (the class)</title><link>https://ddimmery.com/posts/causal-ml-class/</link><guid isPermaLink="true">https://ddimmery.com/posts/causal-ml-class/</guid><description>Notes on teaching causal machine learning at Hertie---the course philosophy, the syllabus, and my continuing effort to find synthesis between the design-based paradigm and CML.</description><pubDate>Mon, 16 Feb 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;teaching-causalml&quot;&gt;Teaching CausalML&lt;/h2&gt;
&lt;p&gt;The most important paper I’ve ever read was David Freedman’s &lt;a href=&quot;https://doi.org/10.2307/270939&quot;&gt;Statistical Models and Shoe Leather&lt;/a&gt;. As always, when I mention this paper, I must provide the following quote:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Given the limits to present knowledge, I doubt that models can be rescued by technical fixes. Arguments about the theoretical merit of regression or the asymptotic behavior of specification tests for picking one version of a model over another seem like arguments about how to build desalination plants with cold fusion as the energy source. The concept may be admirable, the technical details may be fascinating, but thirsty people should look elsewhere.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I find this to be a critically important lens through which to view the field of Causal Machine Learning, a class I just taught in the Fall at Hertie about a field that forms the core of a lot of my research. In many ways, this class is about me trying to square my love for design-based causal inference with the realities of modern Causal Machine Learning which is maddeningly focused on cold-fusion-powered desalination. A large amount of the literature in this field is beset by strong super-population assumptions, asymptotic theory and, thanks to the fundamental problem of causal inference, little way to determine what will actually be effective on the data that one has in front of them.&lt;/p&gt;
&lt;p&gt;As such, my overriding goal for the course was to make students skeptical and informed consumers and producers of CML. I tried to get them to think about actual experiments whenever possible, and to think about the conditions under which methods work and do not work (and how you might be able to know)&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn1&quot; id=&quot;user-content-fnref-fn1&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. Then I expected everyone to get their hands dirty by actually implementing these methods and testing them through simulation studies. They did this both as part of in-class demos as well as a final project meant to extend and flesh out the demo (and fix any issues surfaced during the demo).&lt;/p&gt;
&lt;p&gt;I expected a lot from students. Of the nearly two-hour class, I lectured for only around 30 minutes, while students led discussion for the remainder. They gave presentations about papers (with my intervention when I wanted to add additional color / complaints) and performed high quality simulation studies set up so their colleagues could tweak things about the setting or the method to see the results.&lt;/p&gt;
&lt;p&gt;The course, therefore, operated on a few operating principles:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Read papers&lt;/strong&gt;: If you can’t read new work, the field will leave you behind.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Present main ideas&lt;/strong&gt;: Nothing forces you to understand a paper like presenting its main ideas to your classmates.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Write code&lt;/strong&gt;: Implementing and stress testing methods is a powerful way to get a deep understanding of how they work.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Don’t fight AI&lt;/strong&gt;: Focus on in-class performance. If students just let AI create a slide deck/demo and don’t understand it, this will be very obvious when they get up to talk about their work. In practice, there were very few moments when students had offloaded too much of their preparation to AI. I think the incentives here are good. Students can use AI however helps them, but they cannot avoid learning enough of what they need to know to feel comfortable standing in front of the room to talk about it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The nagging problem is this: we spent the semester stress-testing methods through simulation to see how they work and where they break. This is genuinely useful. But it only tells us how methods perform in worlds we can imagine (and the world is much more complicated than that). The whole point of causal inference is that we never observe the counterfactual, so we can never confirm on our &lt;em&gt;actual&lt;/em&gt; dataset that a method did what it promised. I don’t think the course resolves this---I don’t think anything really can. What I think it does is produce people who understand the machinery well enough to know exactly where the leap of faith is, and who can be honest about when they’re making it. I think that matters, even if it’s not enough. There’s still a lot of work to be done on understanding what we can actually learn from these methods and what we can’t---and frankly, a lot of the field doesn’t always seem particularly interested in that question.&lt;/p&gt;
&lt;p&gt;With that, check out the syllabus I landed on:&lt;/p&gt;
&lt;h1 id=&quot;syllabus&quot;&gt;Syllabus&lt;/h1&gt;
&lt;h2 id=&quot;course-overview&quot;&gt;Course overview&lt;/h2&gt;
&lt;p&gt;The syllabus begins with the building blocks---design-based inference, covariate adjustment, and propensity scores---before moving to the doubly robust and semiparametric methods that form the core of modern CML. From there it turns to heterogeneous treatment effects (first with forests and meta-learners, then neural networks), policy learning, and experimental design. The final weeks cover topics where the standard assumptions start to break down: panel data, partial identification, adaptive experimentation, and interference. Students wrote a referee report on one paper, presented another, gave a live code demonstration of one week’s methods, and produced a final expository project extending the demonstration. All readings are papers; there is no textbook.&lt;/p&gt;
&lt;h2 id=&quot;session-by-session&quot;&gt;Session-by-session&lt;/h2&gt;
&lt;h3 id=&quot;session-1-design-based-causal-inference-and-monte-carlo-simulation&quot;&gt;Session 1: Design-based Causal Inference and Monte Carlo Simulation&lt;/h3&gt;
&lt;p&gt;The potential outcomes framework, what randomization buys you, and the &lt;a href=&quot;https://doi.org/10.1002/sim.8086&quot;&gt;ADEMP framework&lt;/a&gt; for simulation studies that students use to stress-test every method in the course.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://conjugateprior.org/&quot;&gt;Will Lowe&lt;/a&gt; teaches a fantastic Causal course at Hertie that focuses more on DAG-world, so laying out some strong arguments around manipulability and the implied metaphysics of potential outcomes. This comes early to set the stage for the rest of the course. My computational demo aimed at understanding the difference between inference on the SATE and the PATE as a way to get them thinking about sources of randomization (and better prepare them for the many superpopulations to come).&lt;/p&gt;
&lt;h3 id=&quot;session-2-covariate-adjustment&quot;&gt;Session 2: Covariate Adjustment&lt;/h3&gt;
&lt;p&gt;If randomization already gives you unbiased estimates, should you adjust for covariates at all? If not, is there any role for ML? I think there are actually pretty good answers in this setting! So we talked about the &lt;a href=&quot;https://doi.org/10.1214/12-AOAS583&quot;&gt;Lin-style regression&lt;/a&gt; and AIPW as ways to be both safe &lt;em&gt;and&lt;/em&gt; efficient.&lt;/p&gt;
&lt;h3 id=&quot;session-3-balancing-weights&quot;&gt;Session 3: Balancing Weights&lt;/h3&gt;
&lt;p&gt;Only in this session are we really getting to the observational world at all. What is “balance”? Why might we want it? How should we define it? We went through a variety of modern approaches to this including &lt;a href=&quot;https://proceedings.mlr.press/v139/arbour21a.html&quot;&gt;permutation weighting&lt;/a&gt;, which holds a special place in my heart as it reframes the problem as classification.&lt;/p&gt;
&lt;h3 id=&quot;session-4-doubly-robust-methods-double-ml-and-tmle&quot;&gt;Session 4: Doubly Robust Methods, Double ML, and TMLE&lt;/h3&gt;
&lt;p&gt;Sessions 2 and 3 each model one side of the problem; doubly robust methods combine both, giving you two chances to get it right. Is it actually useful to get two chances at this? We work through the error decompositions that show why it might be helpful even when you get &lt;em&gt;neither&lt;/em&gt; right. We hammer back on this many times throughout the course, too.&lt;/p&gt;
&lt;p&gt;A recent paper we read was &lt;a href=&quot;https://arxiv.org/abs/2203.06469&quot;&gt;Kennedy (2022)&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;session-5-heterogeneous-treatment-effects-i&quot;&gt;Session 5: Heterogeneous Treatment Effects I&lt;/h3&gt;
&lt;p&gt;How do effects vary across individuals? This is categorically harder than estimating averages---there is no observed target, no natural loss function, and no straightforward way to validate predictions, which is why my lecture focuses on the &lt;a href=&quot;https://doi.org/10.1080/01621459.1986.10478354&quot;&gt;Fundamental Problem of Causal Inference&lt;/a&gt;. I’m just categorically unable to let people have fun.&lt;/p&gt;
&lt;h3 id=&quot;session-6-heterogeneous-treatment-effects-ii-----neural-networks&quot;&gt;Session 6: Heterogeneous Treatment Effects II --- Neural Networks&lt;/h3&gt;
&lt;p&gt;This session focuses on using neural networks. My lecture focused on representation learning and why this is actually really tricky in the causal setting: what do you mean we require an invertible representation? In &lt;strong&gt;this&lt;/strong&gt; economy?&lt;/p&gt;
&lt;p&gt;Some recent papers we read were &lt;a href=&quot;https://doi.org/10.1093/biomet/asaa068&quot;&gt;Nie &amp;#x26; Wager (2021)&lt;/a&gt; and &lt;a href=&quot;https://arxiv.org/abs/2506.10914&quot;&gt;Ma et al. (2025)&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;session-7-off-policy-evaluation-and-optimization&quot;&gt;Session 7: Off-Policy Evaluation and Optimization&lt;/h3&gt;
&lt;p&gt;A pivot from “how large is the effect?” to “who should we treat?” I pull in the discussion over causal decision making (i.e. ignore causal effects, &lt;a href=&quot;https://doi.org/10.1287/ijds.2021.0006&quot;&gt;Learning the Sign is All You Need&lt;/a&gt;), as I think it’s worth problematizing what the actual task is. Is there actually an important role for understanding HTEs for decision-making? For many reasons, I still think the answer is yes.&lt;/p&gt;
&lt;p&gt;Some recent papers we read were &lt;a href=&quot;https://doi.org/10.3982/ECTA15732&quot;&gt;Athey &amp;#x26; Wager (2021)&lt;/a&gt; and &lt;a href=&quot;https://doi.org/10.1038/s43588-025-00814-9&quot;&gt;Kern et al. (2025)&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;session-8-experimental-design&quot;&gt;Session 8: Experimental Design&lt;/h3&gt;
&lt;p&gt;Probably the session most near and dear to my heart. Always take the opportunity to give ‘em the Fisher quote:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;To consult the statistician after an experiment is finished is often merely to ask him to conduct a post mortem examination. He can perhaps say what the experiment died of.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Some recent papers we read were &lt;a href=&quot;https://arxiv.org/abs/1911.03071&quot;&gt;Harshaw et al. (2019)&lt;/a&gt; and &lt;a href=&quot;https://proceedings.mlr.press/v162/arbour22a.html&quot;&gt;Arbour et al. (2022)&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;session-9-panel-data-and-modern-difference-in-differences&quot;&gt;Session 9: Panel Data and Modern Difference-in-Differences&lt;/h3&gt;
&lt;p&gt;The course turns to settings without randomization (but, of course, problematizes this framing). We go over the “New Diff-in-diff” and pivot quickly to &lt;a href=&quot;https://doi.org/10.1198/jasa.2009.ap08746&quot;&gt;synthetic control&lt;/a&gt;, because I want to keep as much attention on the actual &lt;em&gt;identification&lt;/em&gt; problems of the setting (which I think are often elided because they do not admit simple technical fixes: they require thinking about the actual problem setting).&lt;/p&gt;
&lt;p&gt;Some recent papers we read were &lt;a href=&quot;https://doi.org/10.1080/01621459.2021.1929245&quot;&gt;Ben-Michael et al. (2021)&lt;/a&gt; and &lt;a href=&quot;https://doi.org/10.1214/22-AOAS1654&quot;&gt;Ben-Michael et al. (2023)&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;session-10-partial-identification&quot;&gt;Session 10: Partial Identification&lt;/h3&gt;
&lt;p&gt;We cover &lt;a href=&quot;https://www.jstor.org/stable/2006592&quot;&gt;Manski’s no-assumptions bounds&lt;/a&gt; and look at a variety of ways that ML can be used to support tighter intervals. I find this really important as a way to tie together the class, but I find that students don’t get that excited by the idea of estimating an interval rather than getting a single holy point estimate.&lt;/p&gt;
&lt;p&gt;Some recent papers we read were &lt;a href=&quot;https://proceedings.mlr.press/v235/khan24b.html&quot;&gt;Khan, Saveski &amp;#x26; Ugander (2024)&lt;/a&gt; and &lt;a href=&quot;https://arxiv.org/abs/2309.08985&quot;&gt;Samii, Wang &amp;#x26; Zhou (2023)&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;session-11-adaptive-experimentation-and-reinforcement-learning&quot;&gt;Session 11: Adaptive Experimentation and Reinforcement Learning&lt;/h3&gt;
&lt;p&gt;I always tell students that explore-exploit is a natural framework that can be helpful to them generally as they live their lives (do we go to the same sushi spot as always or try somewhere new?). I spend a lot of time talking about how simple effect estimators fail. We don’t get much into the solutions for this, unfortunately (I am not fully happy with how this has been solved thus far in the literature).&lt;/p&gt;
&lt;p&gt;Some recent papers we read were &lt;a href=&quot;https://arxiv.org/abs/2203.02155&quot;&gt;Ouyang et al. (2022)&lt;/a&gt; and &lt;a href=&quot;https://doi.org/10.1073/pnas.2014602118&quot;&gt;Hadad et al. (2021)&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;session-12-interference&quot;&gt;Session 12: Interference&lt;/h3&gt;
&lt;p&gt;We end by blowing up the possibility of causal inference via exponential explosion of potential outcomes under interference. Is it possible to do anything about it? I throw in a lot of attention to &lt;a href=&quot;https://doi.org/10.1145/2487575.2487695&quot;&gt;design-based solutions&lt;/a&gt; which (alas, don’t they always?) require understanding things about the world.&lt;/p&gt;
&lt;p&gt;A recent paper we read was &lt;a href=&quot;https://doi.org/10.1073/pnas.2322232121&quot;&gt;Shirani &amp;#x26; Bayati (2024)&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;closing-thoughts&quot;&gt;Closing thoughts&lt;/h2&gt;
&lt;p&gt;That was my attempt to square the circle. I think it went pretty well all things considered. There’s such a huge amount to cover (jamming DR + DML + TMLE into one session is crazy, as is combining CB + RL into one session). Alas, there was a lot I wanted to cover. I think more than half the classes had some kind of important design-based connection, which I think is good. The machinery is all genuinely useful and extremely interesting, but it doesn’t replace knowing where your identification comes from. I would much rather send students out the door a little paranoid than too comfortable that technical fixes will solve their problems.&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-fn1&quot;&gt;
&lt;p&gt;One of many frustrations I have is with the term “testing assumptions”. If you can test it, then it isn’t an assumption! &lt;a href=&quot;#user-content-fnref-fn1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><category>methodology</category><category>teaching</category></item><item><title>Website Refresh</title><link>https://ddimmery.com/posts/website-refresh/</link><guid isPermaLink="true">https://ddimmery.com/posts/website-refresh/</guid><description>Automating publication updates with Semantic Scholar, setting up email newsletters with Listmonk, and optimizing fonts and performance. Tending my corner of the web, one small improvement at a time.</description><pubDate>Wed, 19 Nov 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I’ve made a few changes and updates to this website. None of them are particularly earth-shattering, but I think building one’s own tools—rather than accepting the constraints of platforms—is worth the effort.&lt;/p&gt;
&lt;p&gt;Here’s what I’ve been working on:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Semantic Scholar integration for updating publication records&lt;/li&gt;
&lt;li&gt;Listmonk tools for sharing blog posts as a newsletter&lt;/li&gt;
&lt;li&gt;Improvements to the design and performance, particularly around fonts&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I think these changes are consistent with &lt;a href=&quot;/posts/back-to-basics/&quot;&gt;the philosophy I introduced in the last post&lt;/a&gt;. I’ll introduce each briefly and discuss how they work—perhaps they’ll be useful to others building their own corners of the web.&lt;/p&gt;
&lt;h2 id=&quot;semantic-scholar-integration&quot;&gt;Semantic Scholar integration&lt;/h2&gt;
&lt;p&gt;I’ve had a consistent desire to avoid tedious data entry in updating my website. This was part of my intention when I &lt;a href=&quot;/posts/quarto-website/&quot;&gt;moved it to Quarto in the first place&lt;/a&gt;: Quarto gives great opportunity to programmatically generate a static website. I can easily mix in rich documents that combine code (R and Python in particular) and easily formatted Markdown text. This is all great. It let me hack together a nice way to display my publications in a consistent format based on data stored in a hand-curated YAML file. The next step was to automate the process of updating the publication records. I used the &lt;a href=&quot;https://api.semanticscholar.org/api-docs/&quot;&gt;Semantic Scholar API&lt;/a&gt; to fetch the latest information about my publications and then used &lt;a href=&quot;https://quarto.org/docs/websites/&quot;&gt;Quarto’s templating capabilities&lt;/a&gt; to generate the updated publication list.&lt;/p&gt;
&lt;p&gt;Most of the work of this system is in two functions which, because I vibe-coded it, I’ve never really even looked at.&lt;/p&gt;
&lt;details&gt;&lt;summary&gt;See the code&lt;/summary&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; fetch_author_papers&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(author_id):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;    &quot;&quot;&quot;Fetch papers from Semantic Scholar API&quot;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    base_url &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;https://api.semanticscholar.org/graph/v1&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    fields &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;paperId,title,authors,year,venue,publicationDate,externalIds,openAccessPdf,url&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    url &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;base_url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;/author/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;author_id&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;/papers&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    params &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;fields&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: fields, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;limit&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    try&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        response &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; requests.get(url, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;params&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;params)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        response.raise_for_status()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; response.json()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    except&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; requests.RequestException &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; e:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;        print&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;Error fetching data from Semantic Scholar: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; None&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; create_yaml_entry_from_ss_paper&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(paper):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;    &quot;&quot;&quot;Convert Semantic Scholar paper to YAML entry format&quot;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    paper_id &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; paper.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;paperId&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    title &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; paper.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;title&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;Untitled&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    year &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; paper.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;year&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    venue &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; paper.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;venue&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;    # Process authors&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    authors &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; []&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; author &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; paper.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;authors&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, []):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        author_name &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; author.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;name&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;Dimmery&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; author_name:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;            authors.append(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;me&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;        else&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;            authors.append(author_name)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    entry &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;        &apos;title&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: title,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;        &apos;authors&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: authors,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;        &apos;year&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: year,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;        &apos;venue&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: venue &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; venue &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;        &apos;visible&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;False&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;,  &lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;# Default to not visible&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;        &apos;ssid&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: paper_id,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;    # Add external links if available&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    external_ids &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; paper.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;externalIds&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, {})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; external_ids.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;DOI&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        entry[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;published_url&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;https://doi.org/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;external_ids[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;DOI&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; external_ids.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;ArXiv&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        entry[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;preprint&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;https://arxiv.org/abs/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;external_ids[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;ArXiv&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;    # Add open access PDF if available&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    open_access &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; paper.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;openAccessPdf&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; open_access &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;and&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; open_access.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;url&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        entry[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;pdf_url&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; open_access[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;url&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; entry&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;p&gt;Critically, this is all pretty trivial, but it’s also &lt;em&gt;boring&lt;/em&gt;, so I’m glad I didn’t need to think particularly hard about it. It also means I didn’t need to personally dig through the Semantic Scholar API documentation. The code quality is not great, but neither was my own code before!&lt;/p&gt;
&lt;p&gt;So now when I build the site, it automatically updates the YAML with my latest papers. I can just browse through them and flip the &lt;code&gt;visible&lt;/code&gt; flag to show them once I’m satisfied they’re right.&lt;/p&gt;
&lt;h2 id=&quot;listmonk-tools&quot;&gt;Listmonk tools&lt;/h2&gt;
&lt;p&gt;The second main improvement I made was to add an email distribution list to my website’s blog. This was pretty easy because of the great open source email distribution software, &lt;a href=&quot;https://listmonk.app/&quot;&gt;Listmonk&lt;/a&gt;, and the super easy deployment option at &lt;a href=&quot;https://www.pikapods.com/&quot;&gt;Pikapods&lt;/a&gt;. The system I’ve come up with is basically the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Write a blog post in a Quarto document.&lt;/li&gt;
&lt;li&gt;Push it to a branch if I want to have sensitivity readers.&lt;/li&gt;
&lt;li&gt;Once I’m satisfied, push it to main, which automatically triggers a Quarto build of the website and makes the blog post “live” on the website (and RSS feed)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Manually trigger a Github Actions workflow to schedule a Listmonk email campaign.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It’s this last part that I think is particularly cool. Basically the way it works is I vibecoded an over-engineered system that pulls the necessary metadata from a given blog post (in the &lt;code&gt;.qmd&lt;/code&gt; file), renders the post to an HTML version, extracts the HTML from that, and sends all of this through Listmonk’s API to schedule an email campaign with nicely formatted HTML content. I’m not going to embed all of the scripts for this here, but you can take a look at them in my website’s Github: &lt;a href=&quot;https://github.com/ddimmery/quarto-website/tree/main/scripts&quot;&gt;&lt;code&gt;scripts/&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To actually trigger this monstrosity, I used a nice feature that Github Actions provides: &lt;code&gt;workflow_dispatch&lt;/code&gt; event triggers. Basically, what this means is that &lt;a href=&quot;https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manually-run-a-workflow&quot;&gt;you can configure a Github Action to trigger manually through the Github UI&lt;/a&gt;. It looks something like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Workflow Dispatch example&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;638&quot; height=&quot;1010&quot; src=&quot;/_astro/workflow-dispatch.o8d8-HCo_1zKJeS.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;So basically all I need to do is tell the workflow what post to schedule (the &lt;code&gt;post_slug&lt;/code&gt; part), when to schedule it (the &lt;code&gt;send_at&lt;/code&gt;). There are also a few optional things I can plug in, such as which list to send to (Listmonk lets me manage multiple lists easily), or I can send test emails.&lt;/p&gt;
&lt;p&gt;This is a solution I’m mostly happy with. I think there’s still a bit of tweaking about some of the practicalities. I think there are two things I’m trying to figure out:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Whether I should maintain separate lists for different categories of post. It wouldn’t be hard to maintain category-specific lists so that people could easily opt-out of posts about (e.g.) how I built things on my website.&lt;/li&gt;
&lt;li&gt;How exactly to manage the sending of emails. When I sent out the last email, it only sent to like two-thirds of my subscribers because my email provider is Protonmail setup with a custom &lt;code&gt;blog@&lt;/code&gt; email address for sending/receiving. Unfortunately, there were some rate limits that I didn’t adequately respect the first time.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I’m overall pretty pleased with this system. You’re welcome to &lt;a href=&quot;https://list.ddimmery.com/subscription/form&quot;&gt;subscribe here!&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;improvements-in-design-and-performance&quot;&gt;Improvements in design and performance&lt;/h2&gt;
&lt;p&gt;Within me are two wolves: Sometimes I miss the days of HTML-only websites. Other days, I long for the ability to have nicely reactive and responsive design elements that require richer web frameworks. On some personal projects over the last few months, I’ve learned a bit more about modern webdev tools. One thing I’m particularly taken by is the way that modern webdev tools like &lt;a href=&quot;https://vitejs.dev/&quot;&gt;Vite&lt;/a&gt; manage javascript dependencies.&lt;/p&gt;
&lt;p&gt;In short, the problem with a lot of these big web frameworks is that they’re really big (duh)! They have a lot of stuff that you never use in a small personal website like mine, but they still get bundled into the library that is sent down to the website viewer. We don’t need to do that: we can be smarter. That’s basically what tools like Vite do. They only bundle together the parts of code that are necessary for the particular site being built. They also can help with lazy loading (so they’re only loaded when needed).&lt;/p&gt;
&lt;p&gt;That’s all a bit of a tangent, but it’s gotten me thinking about why I actually need to load so many Javascript libraries. Quarto ultimately doesn’t seem to be particularly optimized on this front. This is kind of the tradeoff you get: sure, it’s easy to throw something together with Quarto that has a lot of the bells and whistles a data scientist craves, but that doesn’t mean it’s going to be super efficient. There’s a &lt;a href=&quot;https://emilhvitfeldt.com/post/quarto-performance/&quot;&gt;really nice post by Emil Hvitfeldt discussing performance considerations in Quarto&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;purge-unused-resources&quot;&gt;Purge unused resources&lt;/h3&gt;
&lt;p&gt;I in-lined many icons to embedded svgs, but, alas, Quarto still loads the &lt;code&gt;bootstrap-icons.css&lt;/code&gt; that it does not, as far as I can tell, use anywhere. The solution to this was described in &lt;a href=&quot;https://github.com/orgs/quarto-dev/discussions/9330&quot;&gt;a discussion about Quarto performance by Charles Nepote&lt;/a&gt;. Quarto makes it possible to add a post-rendering step to builds which purges unused CSS and minifies JS and CSS (&lt;a href=&quot;https://github.com/ddimmery/quarto-website/blob/main/scripts/purge-css.sh&quot;&gt;see here&lt;/a&gt;). I found that this did a really nice job of reducing the size of resources that needed to be fetched from my site. This helped, and brought the critical path latency down a good bit. After reducing as much of these resources as I could, &lt;a href=&quot;https://pagespeed.web.dev/analysis/https-ddimmery-com/2zf25s9mbr?form_factor=mobile&quot;&gt;the critical path is currently loading &lt;code&gt;quarto.js&lt;/code&gt;&lt;/a&gt;. I think this is probably about as good as it gets&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn1&quot; id=&quot;user-content-fnref-fn1&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. Or, at least, as good as it gets without me just basically giving up on letting Quarto manage this at all.&lt;/p&gt;
&lt;h3 id=&quot;fonts&quot;&gt;Fonts&lt;/h3&gt;
&lt;p&gt;Here’s some fun Drew-lore: I’m weirdly into fonts. In the summer before my PhD I read like 3 books about fonts that I marked up more than almost anything else I’ve read.&lt;/p&gt;
&lt;h4 id=&quot;my-font-choices&quot;&gt;My font choices&lt;/h4&gt;
&lt;p&gt;Long story short, I’ve currently landed on the following font styling that I intend to use pretty generally across the web, in documents and on presentations&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn2&quot; id=&quot;user-content-fnref-fn2&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Headers in &lt;a href=&quot;https://en.wikipedia.org/wiki/Optima#Clones_and_derivatives&quot;&gt;URW Classico&lt;/a&gt;. This is a font based largely on &lt;a href=&quot;https://en.wikipedia.org/wiki/Optima&quot;&gt;Optima&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Body text in &lt;a href=&quot;https://en.wikipedia.org/wiki/Palatino#Derivatives&quot;&gt;Domitian&lt;/a&gt;. This is a font based largely on the venerable &lt;a href=&quot;https://en.wikipedia.org/wiki/Palatino&quot;&gt;Palatino&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Code in &lt;a href=&quot;https://monaspace.githubnext.com/&quot;&gt;&lt;code&gt;Monaspace Argon&lt;/code&gt;&lt;/a&gt;. This is part of the suite of fonts developed by Github Next. It’s also the primary font I use locally in my IDE. It’s a Humanist Sans font (I have tried to use Serifed fonts for coding, but it just looks utterly wrong to me).&lt;/li&gt;
&lt;li&gt;Math in &lt;a href=&quot;https://en.wikipedia.org/wiki/AMS_Euler&quot; aria-label=&quot;Neo-Euler&quot;&gt;&lt;mjx-container class=&quot;MathJax&quot; jax=&quot;SVG&quot; overflow=&quot;scroll&quot; style=&quot;position: relative;&quot;&gt;&lt;svg style=&quot;vertical-align: -0.029ex;&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;10.326ex&quot; height=&quot;1.469ex&quot; role=&quot;img&quot; focusable=&quot;false&quot; viewBox=&quot;0 -694 4977 708&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; aria-hidden=&quot;true&quot;&gt;&lt;defs&gt;&lt;path id=&quot;MJX-3-GP-N-4E&quot; d=&quot;M704 694L624 678C645 374 648 275 648 173C648 171 647 165 642 165C638 165 634 170 631 173C514 299 352 514 219 690L57 690L49 683L53 656C74 651 116 641 117 641C123 640 128 635 132 630C138 624 138 616 138 608C142 407 136 205 126 4L135-5L205 25C194 199 181 418 181 547C181 553 181 562 187 564C191 565 196 559 199 555C249 499 331 404 433 278L592 80C622 42 636 26 659 0L695 0C695 227 697 459 710 686Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-3-GP-N-65&quot; d=&quot;M198 396C219 422 249 438 282 438C301 438 314 435 326 428C350 412 366 379 372 354C373 351 373 347 373 344C373 328 366 320 360 318L158 238L154 242C153 248 152 254 152 260C152 309 159 354 198 396M438 319C445 322 455 327 458 332C459 333 459 336 459 340C459 382 442 423 409 450C383 471 350 478 317 478C241 478 169 445 120 388C81 343 69 284 69 226C69 177 76 126 95 80C104 57 117 34 137 18C165-4 200-12 235-12C277-12 318 2 354 23C394 45 430 73 463 104L450 122L439 124C416 106 392 91 367 78C341 65 314 56 285 56C255 56 225 64 203 85C173 113 159 164 156 197Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-3-GP-N-6F&quot; d=&quot;M150 316C156 341 164 365 182 384C208 412 246 426 276 426C303 426 330 419 350 400C400 356 408 284 408 220C408 193 406 166 400 139C394 112 384 85 365 64C342 39 311 27 277 27C250 27 224 36 205 53C154 98 142 173 142 239C142 265 144 291 150 316M250-14C320-14 392 6 439 59C483 108 497 174 497 239C497 306 480 377 429 424C393 456 346 465 299 465C229 465 158 443 111 391C63 339 56 265 56 196C60 133 77 69 125 26C158-4 206-14 250-14Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-3-GP-N-2D&quot; d=&quot;M498 236L504 276L47 276L40 236Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-3-GP-N-45&quot; d=&quot;M456 336L462 384L456 391C379 385 259 383 220 386C213 387 210 391 210 398L210 564C210 587 213 619 221 631C224 636 229 639 234 640L274 640C281 640 414 634 483 630L487 637L489 687C476 688 461 688 443 688C372 688 271 682 201 682L53 681L46 674L47 654C68 651 98 644 106 638C113 633 121 628 123 622C132 602 132 572 132 558L132 66C132 52 133 37 138 25C143 15 149 5 158 0L546 0L559 53L554 58C390 44 367 44 320 44C292 44 266 45 254 50C242 56 230 64 224 76C210 101 209 150 209 188L209 327C209 334 212 338 219 339C237 340 300 342 338 342C377 342 417 339 456 336Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-3-GP-N-75&quot; d=&quot;M644 105L636 107C619 95 604 85 586 77C575 71 562 65 549 65C537 65 525 70 516 79C500 95 500 145 500 181C500 273 504 366 512 459L499 470L422 435C425 381 423 212 422 104C397 89 376 78 350 66C332 58 312 51 291 51C268 51 244 58 228 74C201 101 201 185 201 244C201 296 201 379 199 399C197 419 195 439 181 453C169 465 151 468 135 468C116 468 98 459 81 450C52 434 25 415-1 395L12 375C35 388 69 405 83 405C95 405 105 403 111 396C124 382 128 366 128 275C128 246 124 145 124 112C124 91 129 42 149 19C168-3 201-10 229-10C254-10 279-3 302 7C342 24 380 43 417 65L425 64C427 45 430 24 444 10C457-3 476-8 494-8C518-8 540 4 561 16C594 36 625 60 655 86Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-3-GP-N-6C&quot; d=&quot;M338 112C323 99 308 87 292 77C281 70 266 65 252 65C238 66 227 71 219 83C210 98 208 115 206 132C204 157 204 217 204 259C204 399 214 539 218 679L212 686L47 666L41 661L41 638C61 637 82 636 101 632C114 630 125 621 128 608C133 584 133 541 133 508L126 130C126 52 133 33 156 8C169-5 189-11 208-11C237-10 265 2 289 19C318 41 341 69 360 100L349 112Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-3-GP-N-72&quot; d=&quot;M361 339L415 388C413 410 406 435 392 449C378 463 355 467 336 467C318 467 303 457 289 448C266 433 245 415 226 397L216 401C213 421 207 442 193 456C180 469 162 473 144 473C125 473 107 463 89 454C61 438 34 418 9 398L21 381C46 395 76 412 99 412C110 412 120 407 126 397C142 372 142 296 142 243C141 163 137 76 130 6L145-3L215 18C211 110 212 201 213 294C214 308 214 328 219 340C231 367 255 402 296 402C309 402 321 397 330 388C341 376 346 360 349 344Z&quot;&gt;&lt;/path&gt;&lt;/defs&gt;&lt;g stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; transform=&quot;scale(1,-1)&quot;&gt;&lt;g data-mml-node=&quot;math&quot; data-latex=&quot;\text{Neo-Euler}&quot;&gt;&lt;g data-mml-node=&quot;mtext&quot; data-latex=&quot;\text{Neo-Euler}&quot;&gt;&lt;use data-c=&quot;4E&quot; xlink:href=&quot;#MJX-3-GP-N-4E&quot;&gt;&lt;/use&gt;&lt;use data-c=&quot;65&quot; xlink:href=&quot;#MJX-3-GP-N-65&quot; transform=&quot;translate(829,0)&quot;&gt;&lt;/use&gt;&lt;use data-c=&quot;6F&quot; xlink:href=&quot;#MJX-3-GP-N-6F&quot; transform=&quot;translate(1328,0)&quot;&gt;&lt;/use&gt;&lt;use data-c=&quot;2D&quot; xlink:href=&quot;#MJX-3-GP-N-2D&quot; transform=&quot;translate(1891,0)&quot;&gt;&lt;/use&gt;&lt;use data-c=&quot;45&quot; xlink:href=&quot;#MJX-3-GP-N-45&quot; transform=&quot;translate(2435,0)&quot;&gt;&lt;/use&gt;&lt;use data-c=&quot;75&quot; xlink:href=&quot;#MJX-3-GP-N-75&quot; transform=&quot;translate(3039,0)&quot;&gt;&lt;/use&gt;&lt;use data-c=&quot;6C&quot; xlink:href=&quot;#MJX-3-GP-N-6C&quot; transform=&quot;translate(3681,0)&quot;&gt;&lt;/use&gt;&lt;use data-c=&quot;65&quot; xlink:href=&quot;#MJX-3-GP-N-65&quot; transform=&quot;translate(4046,0)&quot;&gt;&lt;/use&gt;&lt;use data-c=&quot;72&quot; xlink:href=&quot;#MJX-3-GP-N-72&quot; transform=&quot;translate(4545,0)&quot;&gt;&lt;/use&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;&lt;mjx-assistive-mml unselectable=&quot;on&quot; display=&quot;inline&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; data-latex=&quot;\text{Neo-Euler}&quot;&gt;&lt;mtext data-latex=&quot;\text{Neo-Euler}&quot;&gt;Neo-Euler&lt;/mtext&gt;&lt;/math&gt;&lt;/mjx-assistive-mml&gt;&lt;/mjx-container&gt;&lt;/a&gt;. When I use math, I want it to stand out as distinct from the surrounding text. I think Neo-Euler does a good job of walking the line between being a little weird while remaining easy to read.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;why-humanist-fonts-matter&quot;&gt;Why humanist fonts matter&lt;/h4&gt;
&lt;p&gt;These fonts are all strongly humanist in orientation and &lt;a href=&quot;https://www.gnu.org/philosophy/free-sw.en.html&quot;&gt;free&lt;/a&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn3&quot; id=&quot;user-content-fnref-fn3&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;. Despite a brief flirtation with &lt;a href=&quot;https://en.wikipedia.org/wiki/Futura_(typeface)&quot;&gt;Futura&lt;/a&gt;, I have come around to the importance of fonts which embrace more complexity than such geometric renderings. Ultimately, I think the omni-presence of sans-serifed fonts on the web is a reflection of its inhumanity. Good text should have character in style as well as in substance. I think the ubiquity of sans-serifs on the web is indicative of the fact that it isn’t really a place for &lt;em&gt;reading&lt;/em&gt;. The medium corresponding to sans-serifs is the microblog, not the book. Bringing back subtle variations in stroke width, text-oriented serifs and other organic qualities of humanist fonts is a (very) small step towards reclaiming the web.&lt;/p&gt;
&lt;h4 id=&quot;loading-fonts-performantly&quot;&gt;Loading fonts performantly&lt;/h4&gt;
&lt;p&gt;To use these custom fonts on the web without screwing with performance too much, I used &lt;a href=&quot;https://css-tricks.com/how-to-load-fonts-in-a-way-that-fights-fout-and-makes-lighthouse-happy/&quot;&gt;the solution detailed here&lt;/a&gt; to make sure fonts can be preloaded and also that they aren’t part of the critical path for rendering. When you load a page here, you might see a replacement background font for a split-second before the font faces are loaded into the CSS.&lt;/p&gt;
&lt;h2 id=&quot;remaining-concerns&quot;&gt;Remaining concerns&lt;/h2&gt;
&lt;p&gt;I’m happy with a lot of what has come together. There are a few issues that I think can be improved. I’m considering whether it might make sense to switch to a hybrid system which would use Quarto to build minimal HTML or Markdown documents which are then knit together using a modern web development framework like &lt;a href=&quot;https://docs.astro.build/en/tutorial/0-introduction/&quot;&gt;Astro&lt;/a&gt;. This would allow much more granular control over the website and how it loads resources, but could still get the benefits of Quarto where it is most useful (for pre-rendering rich documents full of Python and R code). This is probably a bigger project than I imagine it to be, so I don’t intend to commit to it soon&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn4&quot; id=&quot;user-content-fnref-fn4&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;I’m also considering whether it would make more sense to switch to a different hosting solution. I’m not particularly pleased with the quality of Netlify’s CDN, which seems to be a bit slow in Europe (I suspect they just have fewer edge locations)&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn5&quot; id=&quot;user-content-fnref-fn5&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;. I’m considering whether it might make sense to switch to a system which is self-hosted in a VPS like DigitalOcean/Hetzner (possibly with a tool like Coolify to manage deployment) and then add a CDN like Cloudflare over the top. The benefit to this is that it would combine control (from the self-hosted VPS) with the performance benefits of a reliable CDN through Cloudflare, but it would remain quite cheap (albeit not free).&lt;/p&gt;
&lt;h2 id=&quot;tending-the-garden&quot;&gt;Tending the garden&lt;/h2&gt;
&lt;p&gt;There’s something satisfying about all of this tinkering that I find hard to articulate. It’s not that any individual piece is particularly impressive or novel. Rather, it’s the act of construction itself—of shaping raw materials into something that reflects intention and care. McLuhan observed that we shape our tools, and thereafter our tools shape us. The platforms we’ve ceded our digital lives to have shaped us into consumers of content, optimized for something outside of our control. Building my own corner of the web is a small act of resistance against this.&lt;/p&gt;
&lt;p&gt;I don’t think everyone needs to hand-roll their entire tech-stack or obsess over font choices (I will tell you fonts are a huge net-negative on my measurable productivity). But I do think there’s value in the process of understanding and improving the systems we inhabit, even if only to understand what we’ve given up by outsourcing them. The web was supposed to be a place where anyone could plant a flag and build something. Somewhere along the way, we traded that for the convenience of renting space in someone else’s domain.&lt;/p&gt;
&lt;p&gt;These updates—the automation, the newsletters, the performance tweaks, the typography—are all just ways of making this place more my own. The work is never finished. There’s always another edge to smooth, another inefficiency to address. But that’s the point, isn’t it?&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-fn1&quot;&gt;
&lt;p&gt;It seems like there are also some other problems, as Firefox and Chrome both intermittently show several seconds to establish a SSL connection to the website (i.e. before any resources are actually loaded). Unclear what’s going on with this… &lt;a href=&quot;#user-content-fnref-fn1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn2&quot;&gt;
&lt;p&gt;The ease of writing Markdown documents which are rendered into &lt;a href=&quot;https://revealjs.com/&quot;&gt;reveal.js&lt;/a&gt; HTML presentations is really nice, and yet another way that I’m aiming at convergence between these media. I ask myself whether I should also move away from directly writing LaTeX, too. Ensuring visual consistency by using literally identical styling directives is very appealing. &lt;a href=&quot;#user-content-fnref-fn2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn3&quot;&gt;
&lt;p&gt;We’re &lt;a href=&quot;https://en.wikipedia.org/wiki/Hermann_Zapf&quot;&gt;Hermann Zapf&lt;/a&gt; fans over here if you couldn’t tell. &lt;a href=&quot;#user-content-fnref-fn3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn4&quot;&gt;
&lt;p&gt;Truly famous last words. &lt;a href=&quot;#user-content-fnref-fn4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn5&quot;&gt;
&lt;p&gt;Making a connection via HTTPS occasionally takes 3s or more, which is just absurd and is by far the slowest part of page-load, although it is also intermittent which makes me suspect something with CDNs. &lt;a href=&quot;#user-content-fnref-fn5&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><category>technology</category><category>website</category></item><item><title>Back to Basics</title><link>https://ddimmery.com/posts/back-to-basics/</link><guid isPermaLink="true">https://ddimmery.com/posts/back-to-basics/</guid><description>Platforms reduce complexity by constraining possibility, but its easier than ever to build one&apos;s own systems. Those who can should forge their own path, paving the way for a more convivial web.</description><pubDate>Mon, 27 Oct 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I started a Substack not that long ago, because I wanted to get back into blogging. I think blogging is great and &lt;a href=&quot;https://ddimmery.com/posts/stop-looking-for-the-next-twitter/&quot;&gt;microblogs are bad&lt;/a&gt;. I’ve had a bit of time to think over the past year about my usage of technology. I’ve come to believe that most platforms are (at best) not really for me, or (at worst) broadly &lt;a href=&quot;https://en.wikipedia.org/wiki/Considered_harmful&quot;&gt;considered harmful&lt;/a&gt;. If you previously subscribed to my Substack, I’ve migrated you to a subscription service of my own. If this isn’t what you signed up for, please unsubscribe&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn1&quot; id=&quot;user-content-fnref-fn1&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;I think there are a few dimensions to my thinking that I’m aiming to work out in this post:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Platforms constrain freedom&lt;/li&gt;
&lt;li&gt;Platforms enshittify&lt;/li&gt;
&lt;li&gt;AI coding tools make smaller projects feasible&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I’ll then talk about why I think we should fight against the ease of platforms. Let’s get into it.&lt;/p&gt;
&lt;h2 id=&quot;platforms-constrain-freedom&quot;&gt;Platforms constrain freedom&lt;/h2&gt;
&lt;p&gt;Platforms exist to make it easier to do things by creating one streamlined avenue to accomplish a goal. A canonical example is Facebook winning over other social media sites like MySpace. It might be hard to recall now, but one of the main reasons for this was that, in contrast to MySpace, Facebook provided a simple, clean, consistent user experience. On MySpace you would arrive on a page, have music randomly play at you and be barraged by weird fonts, colors and images. Facebook constrained how users could express themselves quite substantially, and this was very popular. It let people ignore all this wacky design stuff created by thirteen-year-olds and focus on what they wanted to do with social media: poke each other, write weird status updates and check out relationship statuses&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn2&quot; id=&quot;user-content-fnref-fn2&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;I think this is a pretty common pattern for new platforms: They do, in fact, generally make &lt;em&gt;something&lt;/em&gt; that people want to do easier! Of course, given the nature of this post, I need to address the Substack in the room. Substack is generally a good platform. It makes it easy to write (certain kinds of) blogs and it makes (certain kinds of) monetization easier. The parentheticals, however, are what I find frustrating about platforms. By their nature, they constrain the user to a particular form of the thing they provide.&lt;/p&gt;
&lt;p&gt;Scale means that Substack can’t and won’t cater to all of the small, weird features that people want. If I were designing my own blog system, I would want (a) control over exactly the fonts and styles my content is displayed with, (b) easy integration of math via the great tools like MathJax, (c) the ability to have code-rich documents like Quarto in which code runs in-line and displays output in-line, (d) the ability to embed any kinds of content I want wherever I want it. Ultimately, I think this is the dream of the web: I can have a little homestead on the internet that is exactly the way I want it: &lt;a href=&quot;https://ddimmery.com/posts/is-bluesky-convivial/&quot;&gt;a &lt;em&gt;convivial&lt;/em&gt; web&lt;/a&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn3&quot; id=&quot;user-content-fnref-fn3&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;. Platforms cannot provide this: their &lt;em&gt;raison d’être&lt;/em&gt; is reducing complexity as they make human behavior digitally legible down a particular prescribed path.&lt;/p&gt;
&lt;p&gt;I dislike this constraint: I want to use tools that work the way I choose for them to work.&lt;/p&gt;
&lt;h2 id=&quot;platforms-enshittify&quot;&gt;Platforms enshittify&lt;/h2&gt;
&lt;p&gt;Even if you feel well-served by a platform now, this is no guarantee that the platform will continue to serve you well in the future once you’re stuck there. I won’t belabor this point, because it’s been &lt;a href=&quot;https://www.versobooks.com/products/3341-enshittification&quot;&gt;talked about ad nauseum&lt;/a&gt; by others&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn4&quot; id=&quot;user-content-fnref-fn4&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;. Platforms, as they mature, need to monetize more aggressively as well as build moats to competitors. This often leads to more constraining of user freedom. I think the real “break-glass” moment for Substack is the ability to collect and export all subscribers’ email addresses. This is, right now, a defining feature of Substack that makes it safe for people to use. This drastically reduces their moat, however. At the moment, switching to &lt;a href=&quot;https://ghost.org/&quot;&gt;Ghost&lt;/a&gt; is (technically, at least) pretty trivial. Switching to a Quarto blog deployed through Github Actions and which sends a newsletter through &lt;a href=&quot;https://listmonk.app/&quot;&gt;Listmonk&lt;/a&gt; (deployed via &lt;a href=&quot;https://www.pikapods.com/&quot;&gt;Pikapods&lt;/a&gt;) when triggered through Github Actions is not trivial, but it also wasn’t exactly &lt;em&gt;hard&lt;/em&gt; to setup&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn5&quot; id=&quot;user-content-fnref-fn5&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;The main way that Substack appears to be aiming at constructing a moat is in their push for discovery. That is, they want to make it easy to find &lt;em&gt;Substack&lt;/em&gt; writers on Substack. They have no interest in doing this with writers hosted elsewhere. This provides an incentive for people to stick around, even if the actual writing and publishing experience is worse. I don’t think Substack is made up of evil people, quite the opposite, I think they truly wish to help writers make a living (while taking their cut). The problem is that they have few incentives to make it possible for writers to truly experiment. Why would they? Writers will want to stick around because they can get more subscribers there, not because the CMS is uniquely good or they can uniquely realize their vision there. The one exception is that many writers’ visions are simply “to be able to feed themselves through their writing”. I think this goal would be better served by increased experimentation&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn6&quot; id=&quot;user-content-fnref-fn6&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;, but I recognize beggars feel that they can’t be choosers. I think this is a false dilemma, because:&lt;/p&gt;
&lt;h2 id=&quot;ai-coding-tools-make-smaller-projects-feasible&quot;&gt;AI coding tools make smaller projects feasible&lt;/h2&gt;
&lt;p&gt;Platforms work by making a particular workflow easy enough that we accept lock-in. An alternative path exists, however, which is to build our own tools to support that workflow. A critical fact of contemporary society is that this is becoming increasingly easy. I think a lot of people have, thus far, only interacted with LLM systems through the lens of the chat interface. While this is impressive technology,  I think it blinds a lot of people to what is now possible. Let me briefly detail an example.&lt;/p&gt;
&lt;p&gt;For &lt;a href=&quot;https://ddimmery.com/posts/quarto-website/&quot;&gt;my website&lt;/a&gt;, I decided I didn’t want to manually write out the metadata for my publications anymore. So in one afternoon, I vibecoded &lt;a href=&quot;https://github.com/ddimmery/quarto-website/blob/main/research.qmd&quot;&gt;a system&lt;/a&gt; which connects to the &lt;a href=&quot;https://www.semanticscholar.org/product/api&quot;&gt;Semantic Scholar API&lt;/a&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn7&quot; id=&quot;user-content-fnref-fn7&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;, checks for new papers on my profile and if it finds them, sets up the metadata in &lt;a href=&quot;https://github.com/ddimmery/quarto-website/blob/main/papers.yaml&quot;&gt;&lt;code&gt;papers.yaml&lt;/code&gt;&lt;/a&gt;. It doesn’t display until I flip a switch from &lt;code&gt;visible: false&lt;/code&gt; (the default) to &lt;code&gt;visible: true&lt;/code&gt;. Thus, I’m not too worried about the system going haywire: nothing is posted without me getting the chance to review it, but it reduces tedious data entry. The technology is there to vastly reduce the time between an idea and a prototype of that idea. For this Semantic Scholar system, it took me just a few minutes to set Claude up with instructions, and I had a complete and functional prototype no more than one hour later, most of which did not require me to be thinking about the implementation (verified via &lt;a href=&quot;https://github.com/ddimmery/quarto-website/commits/main/?since=2025-08-05&amp;#x26;until=2025-08-05&quot;&gt;commit log&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;It’s substantially easier to build things now. As the effort to build novel computing systems shrinks, it’s easier to build exactly the systems you want for yourself (or for yourself and a few others). We should do more of this, on the margin. Individuals’ capabilities to personalize their computing environment has literally never been higher than it now is. Choosing not to take advantage of this is a choice to let other people (who &lt;em&gt;do not have your best interests at heart&lt;/em&gt;) choose your tools for you. The point of platforms is to capture you by making it easy for you to achieve particular goals (but restrict you to those goals they deem worthy), but the thing that’s different &lt;em&gt;now&lt;/em&gt; is that it’s also easier than ever for you to build what you need for yourself.&lt;/p&gt;
&lt;h2 id=&quot;technological-vanguardism&quot;&gt;Technological vanguardism&lt;/h2&gt;
&lt;p&gt;Open source software is a critical part of this story, as it serves as the backbone for building any kind of new software in the current era. This is recognized in a variety of initiatives as part of &lt;a href=&quot;https://eurostack.eu/&quot;&gt;EuroStack&lt;/a&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn8&quot; id=&quot;user-content-fnref-fn8&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;8&lt;/a&gt;&lt;/sup&gt;. That is, the idea is that Europe can’t or shouldn’t try to compete with American and Chinese hyperscalers by trying to incubate European hyperscalers as competitors. Rather, Europe should commit to smaller alternatives based on a robust shared digital infrastructure of open-source software. AI-supported individuals able to mix-and-match together the computing systems they want to support their lives is a rare hopeful vision of the future.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.bbc.com/news/articles/cly7n2jm5m5o&quot;&gt;A lot of the maintainers of critical open source projects are getting older&lt;/a&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn9&quot; id=&quot;user-content-fnref-fn9&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;9&lt;/a&gt;&lt;/sup&gt;. I wonder whether the next generation will have the same commitment to the principles that underlie the open source movement. In particular, we’ve all discussed how “the youths” increasingly don’t understand file-systems or whatever your preferred concern is. My worry is that they have become so used to an Internet made up entirely of platforms that they can’t even imagine anything different: an Internet where when you want to create a space to chat with friends or colleagues the only option is Discord or Slack controlled by someone else, never hosting &lt;a href=&quot;https://en.wikipedia.org/wiki/Ventrilo&quot;&gt;a Ventrilo server&lt;/a&gt;, a &lt;a href=&quot;https://en.wikipedia.org/wiki/PhpBB&quot;&gt;phpBB forum&lt;/a&gt;, an IRC server or, in modern terms, software like &lt;a href=&quot;https://zulip.com/&quot;&gt;Zulip&lt;/a&gt; or &lt;a href=&quot;https://matrix.org/&quot;&gt;Matrix&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Extensible tools like this often have a higher entry cost than platforms do: they may require standing up servers, writing some code or doing some non-obvious configuration. This has been a major problem with Open Source Software for ages: they’re built by developers for developers.
Open source developers and maintainers of open source projects are a sort of technological vanguard who accept some of these costs on themselves. They build tools, often &lt;a href=&quot;https://archive.org/details/justforfun00linu&quot;&gt;just for fun&lt;/a&gt;, because they &lt;em&gt;can&lt;/em&gt; and it scratches a weird itch they have in their own lives. Sometimes, these projects fit the needs of the moment and take off, but many times they remain personal or niche. It’s important that the people who can build such tools do so to pave a (code)path for others to follow, but they are not usually about making that path highly accessible.&lt;/p&gt;
&lt;p&gt;The costs of building one’s own systems are lower than they’ve ever been because of AI code assistance. This provides a critical link between the Open Source Software ecosystem (which is the fundamental infrastructure underlying modern software of all kinds) and personal use. That big open source project which was &lt;em&gt;almost&lt;/em&gt; right for you? It’s not hard to make minor modifications to it now to make it &lt;em&gt;just right&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The problem, however, is that every person who accepts Platforms into their hearts does create a social cost as well. If everyone only goes to Substack to get blogs, then blogs hosted elsewhere (no matter their quality) will be read less. This is what Substack is hoping to achieve, and I think it’s important for those of us comfortable with forging a different path to try.&lt;/p&gt;
&lt;p&gt;I’m a technological determinist: I believe that the technologies we create fundamentally transform our lives and societies. I also believe strongly in the power of human agency: we can reshape the technostructure to harness these technologies the way that we want. We can &lt;a href=&quot;https://blog.citp.princeton.edu/2024/04/29/a-syllabus-of-actions-for-building-the-society-we-want/&quot;&gt;build the society we want&lt;/a&gt;, but that does mean that we need to actually do the building. I, for one, am planning to become much more serious about putting in the work on this. Moving this blog back to my own website is a first step in this direction, but it is not the last.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;Image source&lt;/em&gt;: [&lt;a href=&quot;https://brooklynrail.org/2017/10/criticspage/Hidden-Figures/%5D(Papilla&quot;&gt;https://brooklynrail.org/2017/10/criticspage/Hidden-Figures/](Papilla&lt;/a&gt; Estelar: Remedios Varo)&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-fn1&quot;&gt;
&lt;p&gt;The link is at the bottom of the email, or let me know at &lt;a href=&quot;mailto:blog@ddimmery.com&quot;&gt;blog@ddimmery.com&lt;/a&gt; &lt;a href=&quot;#user-content-fnref-fn1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn2&quot;&gt;
&lt;p&gt;Or “connect the world” depending on how you feel about Facebook &lt;a href=&quot;#user-content-fnref-fn2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn3&quot;&gt;
&lt;p&gt;Note also the importance of open-source software in what I’m looking for. &lt;a href=&quot;#user-content-fnref-fn3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn4&quot;&gt;
&lt;p&gt;Apoorva Lal has a nice &lt;a href=&quot;https://apoorvalal.github.io/lalgorithms/eternalizing_septembers&quot;&gt;formal model of this&lt;/a&gt; &lt;a href=&quot;#user-content-fnref-fn4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn5&quot;&gt;
&lt;p&gt;I’ll write a rundown of how I did this in a later post. &lt;a href=&quot;#user-content-fnref-fn5&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn6&quot;&gt;
&lt;p&gt;crypto! micropayments! easy ways to bundle or unbundle author’s writings! different models of payment beyond mere “subscriptions”! &lt;a href=&quot;#user-content-fnref-fn6&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 6&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn7&quot;&gt;
&lt;p&gt;I am increasingly a fan of the work Semantic Scholar is doing as a more palatable alternative to Google Scholar. Unfortunately, they are probably doomed to failure because Google Scholar uses an expansive definition of citation that means their numbers are bigger. Even as a fan of Semantic Scholar, I definitely provide the Google Scholar citation count and h-index for annual reviews. &lt;a href=&quot;#user-content-fnref-fn7&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 7&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn8&quot;&gt;
&lt;p&gt;Of course, EuroStack is a bit of a classic European idea in which everyone who talks about it means something slightly different than one another. Nevertheless! &lt;a href=&quot;#user-content-fnref-fn8&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 8&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn9&quot;&gt;
&lt;p&gt;In some sense, we all are. &lt;a href=&quot;#user-content-fnref-fn9&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 9&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><category>technology</category><category>website</category></item><item><title>What&apos;s the point of RCTs?</title><link>https://ddimmery.com/posts/whats-the-point-of-rcts/</link><guid isPermaLink="true">https://ddimmery.com/posts/whats-the-point-of-rcts/</guid><description>An ontological perspective on the value of experimentation</description><pubDate>Thu, 13 Feb 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Kevin Munger and I recently had the joy to write a &lt;a href=&quot;https://arxiv.org/abs/2501.12161&quot;&gt;response&lt;/a&gt; to “&lt;a href=&quot;https://arxiv.org/abs/2108.11342&quot;&gt;Nonparametric Identification is not enough, but randomized controlled trials are&lt;/a&gt;” by the all-star team of Aronow, Robins, Saarinen, Sävje and Sekhon (ARSSS). You can tell Kevin and I like this paper because as of this moment, we make up about &lt;a href=&quot;https://scholar.google.com/scholar?start=0&amp;#x26;hl=en&amp;#x26;as_sdt=2005&amp;#x26;sciodt=0,5&amp;#x26;cites=1083203567583178174&amp;#x26;scipsc=&quot;&gt;one quarter of its total citations on Google Scholar&lt;/a&gt;. I believe a number of other responses will be coming out soon; I’m very excited to read them.&lt;/p&gt;
&lt;p&gt;I’m going to riff a bit more here about &lt;a href=&quot;https://arxiv.org/abs/2501.12161&quot;&gt;our response, “Enough?”&lt;/a&gt;. In particular, I want to dig into what I see as the most important perspective we articulate in the paper and some of its further implications. Namely, we argue that the biggest value of experiments is ontological&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn1&quot; id=&quot;user-content-fnref-fn1&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;h1 id=&quot;how-to-respond-to-a-great-paper&quot;&gt;How to respond to a great paper&lt;/h1&gt;
&lt;p&gt;This was my first reaction to thinking about how to do this. I love the paper, and I refer to it a lot. But a response isn’t that interesting if you’re just saying “ditto”. We started out with Kevin wanting to talk more about how uniform consistency of the SATE was still insufficient for science (plus various other big picture philosophy of science points) and me wanting to discuss different reasons why RCTs &lt;em&gt;are&lt;/em&gt; special (e.g. correct specification through shoe-leather)&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn2&quot; id=&quot;user-content-fnref-fn2&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;. Regardless, we quickly latched onto the most provocative word in the title: “enough”. What does it mean for a method to be “enough”? Musing on this formed the core of our response.&lt;/p&gt;
&lt;h2 id=&quot;enough-for-what&quot;&gt;Enough for what?&lt;/h2&gt;
&lt;p&gt;We started off by trying to think through what it would, conceivably, take for an estimate to be generalizable knowledge. We identified 4 things that we certainly want to be able to generalize over: (1) sample, (2) site, (3) realization of a theory, and (4) time. The first two are fairly well-trodden. Convenience samples may make it hard to generalize to populations of interest, and &lt;a href=&quot;https://academic.oup.com/qje/article-abstract/130/3/1117/1933105&quot;&gt;site-selection bias&lt;/a&gt; may make it difficult to generalize to the locations we’d like to know for future policy choices. Tal Yarkoni has &lt;a href=&quot;https://www.cambridge.org/core/journals/behavioral-and-brain-sciences/article/abs/generalizability-crisis/AD386115BA539A759ACB3093760F4824&quot;&gt;already talked through the multiple challenges of generalizations&lt;/a&gt; across various dimensions in the language of random effects in Psychology.&lt;/p&gt;
&lt;p&gt;The third element is kind of weird. What exactly is the set of treatments we could have defined based on a particular theory we’re trying to test? I have a bit of a pre-occupation with this question because it was my experience running message-tests at Facebook that while psychological mechanisms may be important, so are the specifics of wording that are largely unrelated to the mechanisms. If you write text that sounds like a robot, it’s gonna suck even if you’re pulling on the right mechanism. If we want to generalize the results to the &lt;em&gt;theory&lt;/em&gt; being good or bad, then you have to be able to abstract away from this.&lt;/p&gt;
&lt;p&gt;The final point, on time, is a long-time hobby horse of Kevin’s. One of the main criticisms of this focus is that it isn’t actually any different than other forms of generalizability. We identify one extremely important way that time is different: there’s no ‘shoe-leather’ based solution for it. You can random sample from a population, a set of sites or from potential treatment definitions. You cannot randomly sample time. This is an extraordinarily important difference, because it means, ultimately, that you must rely on modeling assumptions that may not be necessary in these other cases (for exactly the reasons ARSSS spell out: randomization is an extremely powerful tool to eliminate such assumptions).&lt;/p&gt;
&lt;p&gt;I strongly believe in the power of shoe-leather&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn3&quot; id=&quot;user-content-fnref-fn3&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;. The fact that it is insufficient for temporal generalization should be concerning&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn4&quot; id=&quot;user-content-fnref-fn4&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;. Regardless, our point is just that randomization is good, sure, but it doesn’t get us to where we want to go scientifically. What &lt;em&gt;does&lt;/em&gt; makes it good?&lt;/p&gt;
&lt;h2 id=&quot;control-of-what&quot;&gt;Control of what?&lt;/h2&gt;
&lt;p&gt;I think the best part of the paper focuses on the ontological value of experimentation. That is, experiments create novel states of the world, and this is a powerful way to imagine alternatives to the social reality we currently inhabit. It creates incentives for people to create cooler and more ambitious changes to the world while measuring what those changes do. But I think this gets at another reason that RCTs are particularly useful.&lt;/p&gt;
&lt;p&gt;Observational methods &lt;em&gt;assume&lt;/em&gt; a complicated ontology in the course of creating a DAG: how to chunk up the social world into nodes and how to assign values for those nodes to each unit. Put simply, the social world is extremely complex, and this process is subject to extraordinary error. RCTs circumvent this difficulty entirely: their accuracy does not depend on such ontological assumptions. Instead, they &lt;em&gt;impose&lt;/em&gt; their ontology. In the paper, we focused on the ontology of &lt;em&gt;the treatment&lt;/em&gt;, but the argument is much broader and deeper.&lt;/p&gt;
&lt;p&gt;For example, suppose that we run some field experiment that changes substantial aspects of people’s media diet and we measure effects on various constructs that we think are interesting: ideology, perhaps, beliefs about facts, etc. It isn’t just that the RCT imposes the ontology of treatment and control, the RCT provides information on all of these constructs that we create (i.e. &lt;em&gt;causal effects&lt;/em&gt; on these constructs). In survey research a common recommendation is to avoid regressing one survey construct on another&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn5&quot; id=&quot;user-content-fnref-fn5&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;. But the truth is, we do this with all observational research, as we make assumptions about constructs everywhere. With the RCTs, we only do this on one side of the equation. The treatment ontology is imposed, but this allows us to weaken the assumptions of ontology in the outcomes. We will still have valid causal effects on whatever ontology we choose.&lt;/p&gt;
&lt;p&gt;Or maybe in our field experiment, we measure something collected administratively about behavior (e.g. turnout in an election). In this case, both the treatment and the outcome have some ontological precision in their meaning&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn6&quot; id=&quot;user-content-fnref-fn6&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;. What about the heterogeneity we may observe? Well, we don’t rely on the ontology the same way we do in observational settings: to take an ontology that is currently the subject of political contention, consider measuring heterogeneity by gender identity. There are different ways to construct this ontology, but when we choose such a construction, we can simply measure the heterogeneity &lt;em&gt;according to&lt;/em&gt; this ontology. If we’re instead in an observational world, we would need to care much more about getting this ontology “correct” in some way as it pertains to selection into treatment&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn7&quot; id=&quot;user-content-fnref-fn7&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;. In an RCT, we do not &lt;em&gt;rely&lt;/em&gt; on this correctness. We can explore variation with respect to whatever ontology we choose and, perhaps, even make judgments about which ontology better reflects the variation in response.&lt;/p&gt;
&lt;p&gt;RCTs give us a solid foundation from which to explore these questions, while observational work cannot do this so easily.&lt;/p&gt;
&lt;h2 id=&quot;for-whom&quot;&gt;For whom?&lt;/h2&gt;
&lt;p&gt;Critically, however, the ontological power of experiments is premised on control of the world. It is power not just in the statistical sense of charts and numbers, but in the sense of guns and laws. Wielding this form of power requires responsibility and humility.&lt;/p&gt;
&lt;p&gt;Experimentation can be a tool for &lt;a href=&quot;https://en.wikipedia.org/wiki/Achieving_Our_Country&quot;&gt;achieving our country&lt;/a&gt;. By trying out new social possibilities, we can provide the foundation on which a better society can be built. Doing this requires venturing past &lt;em&gt;is&lt;/em&gt; and into &lt;em&gt;ought&lt;/em&gt;. This is fraught territory for scientists, so must be part of a &lt;a href=&quot;https://scholarship.law.columbia.edu/faculty_scholarship/2038/&quot;&gt;larger democratic process&lt;/a&gt;. As the fabric of society is increasingly constructed of bits and code, we can increasingly implement creative new interventions that are meaningful to people’s lives. I think, in fact, we’re ethically &lt;em&gt;&lt;a href=&quot;https://medium.com/mit-media-lab/the-obligation-to-experiment-83092256c3e9&quot;&gt;obligated&lt;/a&gt;&lt;/em&gt;&lt;a href=&quot;https://medium.com/mit-media-lab/the-obligation-to-experiment-83092256c3e9&quot;&gt; to do so&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By making our focus broader in this framing, we do something that ARSSS could not: draw distinctions between &lt;em&gt;types&lt;/em&gt; of experiments and demonstrate the value of experimentation within a larger &lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1541-0072.1973.tb00128.x&quot;&gt;experimenting society&lt;/a&gt;. All experiments enjoy the statistical benefits that ARSSS describe. Not all experiments are similarly powerful ontological tools for considering new social worlds. The experiments that measure up best under this perspective are the ones that attempt ambitious changes to social reality. The experiments that do poorly are, mostly, what we have: survey experiments. These are, surely, not &lt;em&gt;enough&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://arxiv.org/abs/2501.12161&quot;&gt;Read the paper&lt;/a&gt; and let us know what you think!&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-fn1&quot;&gt;
&lt;p&gt;You may have read some about &lt;a href=&quot;https://kevinmunger.substack.com/p/the-ontological-case-for-rcts&quot;&gt;this perspective on Kevin’s blog&lt;/a&gt;. &lt;a href=&quot;#user-content-fnref-fn1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn2&quot;&gt;
&lt;p&gt;Chris Harshaw &lt;a href=&quot;http://www.chrisharshaw.com/wp-content/uploads/2025/01/ine-comment.pdf&quot;&gt;has a response to ARSSS&lt;/a&gt; that goes more in this direction focused on the importance of the design-based frame of thought (and its rhetorical power). &lt;a href=&quot;#user-content-fnref-fn2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn3&quot;&gt;
&lt;p&gt;If you’re reading this blog, I hope you’re already familiar with the beautiful David Freedman paper on this subject, &lt;a href=&quot;https://www.jstor.org/stable/270939&quot;&gt;Statistical Models and Shoe Leather&lt;/a&gt;. If you aren’t, read it immediately. &lt;a href=&quot;#user-content-fnref-fn3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn4&quot;&gt;
&lt;p&gt;&lt;a href=&quot;https://upload.wikimedia.org/wikipedia/commons/0/03/David_Hume_Ramsay.jpg&quot;&gt;Shoutout to the GOAT.&lt;/a&gt; &lt;a href=&quot;#user-content-fnref-fn4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn5&quot;&gt;
&lt;p&gt;I’ve done a little searching, but I’d be interested in some citation archeology / intellectual history. Where does this recommendation originate? &lt;a href=&quot;#user-content-fnref-fn5&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn6&quot;&gt;
&lt;p&gt;Or at least something like phenomenological precision. &lt;a href=&quot;#user-content-fnref-fn6&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 6&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn7&quot;&gt;
&lt;p&gt;If you’ve ever read into the literature on measurement error of covariates for observational causal inference (its a nearly intractable problem), this should make you sweat. &lt;a href=&quot;#user-content-fnref-fn7&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 7&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><category>methodology</category><category>experiments</category></item><item><title>What was US2020?</title><link>https://ddimmery.com/posts/what-was-us2020/</link><guid isPermaLink="true">https://ddimmery.com/posts/what-was-us2020/</guid><description>The dialectics of big internet research</description><pubDate>Wed, 29 Jan 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;The US 2020 Facebook and Instagram Election Project (US2020) was a sprawling project with dozens of people involved at various levels: like little ol’ me (on the Meta side). Meta spent more than $20 million on it and committed the time of numerous experienced data scientists and engineers. It was huge. But it was also very small compared to the size of Meta.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn1&quot; id=&quot;user-content-fnref-fn1&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; In this post, I want to reflect on what, exactly, it was, particularly in light of the eLetters to &lt;a href=&quot;https://www.science.org/doi/10.1126/science.abp9364&quot;&gt;one of its marquee studies&lt;/a&gt; and &lt;a href=&quot;https://www.tandfonline.com/eprint/YGEGF9UQYJTMEAGSUFRF/full?target=10.1080/10584609.2024.2446351&quot;&gt;Kevin Munger’s nice article asking what we learned from the project&lt;/a&gt;. The fairest reading of the project is the result of a dialogue between internal and external researchers, so that’s the direction I’m going to work towards.&lt;/p&gt;
&lt;p&gt;The idea here is that I want to try to develop a theory of what this project was&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn2&quot; id=&quot;user-content-fnref-fn2&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;. That is, why does the collaboration exist? Should it exist? If and when we want to do Big Social Science like this, what will we be doing? What &lt;em&gt;should&lt;/em&gt; we be doing?&lt;/p&gt;
&lt;p&gt;To make the argument that US2020 is best understood as a dialogue, I need to start by talking through what and how large Facebook (the company) was and how experimentation works in that context which is defined by the scope of the collective endeavor that is Facebook (the platform). After that I can address what I see as fundamental misperceptions about the nature of US2020: the idea that the project was either industrial research or independent research. It wasn’t, and trying to fit it into one of these molds leads to many confused discussions about the research.&lt;/p&gt;
&lt;p&gt;Independence in future projects should not be the goal, but this does not mean that we need to sacrifice reliability or trustworthiness. Quite the opposite. The very human trustworthiness of the project is as a result of the combination of the non-independence (of the internal researchers) and independence (of the academic researchers). The* tension* between the two of these was what made this project valuable. We can accept that this tension will exist, but resolve much of it through the use of pre-analysis plans. This will better allow us to express the agency and expertise of everyone involved in the project and, hopefully, make future projects more likely to exist and be better.&lt;/p&gt;
&lt;p&gt;So, where to start?&lt;/p&gt;
&lt;h2 id=&quot;what-was-facebook&quot;&gt;What was Facebook?&lt;/h2&gt;
&lt;p&gt;&lt;img alt=&quot;Image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;716&quot; height=&quot;271&quot; src=&quot;/_astro/image_1.WSP2mnVY_ZyetdG.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Facebook was an internet technology company from 2004 to 2021. It no longer exists, having been succeeded by “Meta”. At its peak in 2021, it had&lt;a href=&quot;https://www.statista.com/statistics/273563/number-of-facebook-employees/&quot;&gt; 70,000 employees&lt;/a&gt; and &lt;a href=&quot;https://www.statista.com/statistics/268604/annual-revenue-of-facebook/&quot;&gt;118 billion in revenue&lt;/a&gt;, truly staggering numbers that are difficult to comprehend. Around half of those employees were in technical roles&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn3&quot; id=&quot;user-content-fnref-fn3&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;: they directly worked on changing and improving the functioning of the services that Facebook offered. Can you imagine working on a project with 30,000 other people? It’s critical to understand that this is part of what it means to work at Facebook. And it really felt like this, sometimes! Internal tooling changed often (because people were actively working on it!), the use of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Monorepo&quot;&gt;Monorepo&lt;/a&gt; meant that all engineers pushed code to the same repository and there were meaningful connections &lt;em&gt;in code&lt;/em&gt; between projects. To land a commit at Facebook famously only required you to get one other engineer to sign off on it&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn4&quot; id=&quot;user-content-fnref-fn4&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;. The number of commits to the repository was so large that you couldn’t expect to have the same ground truth from one second to the next&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn5&quot; id=&quot;user-content-fnref-fn5&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;. For a sense of the speed at which Facebook changed, read &lt;a href=&quot;https://engineering.fb.com/2017/08/31/web/rapid-release-at-massive-scale/&quot;&gt;this post detailing some of the deployment systems Facebook used&lt;/a&gt; written by Chuck Rossi, a famous&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn6&quot; id=&quot;user-content-fnref-fn6&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;6&lt;/a&gt;&lt;/sup&gt; release engineering guru at the company.&lt;/p&gt;
&lt;h2 id=&quot;experimentation-at-scale&quot;&gt;Experimentation at scale&lt;/h2&gt;
&lt;p&gt;Facebook changed quickly. Temporal validity is a real problem when things change at this pace. But the problem was actually even worse than the sheer scale would suggest! Many of the biggest changes to how Facebook work were gated not by commits of code, but by A/B testing&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn7&quot; id=&quot;user-content-fnref-fn7&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;. The number of active experiments at any one time was on the order of &lt;em&gt;thousands&lt;/em&gt;. Even assuming each test had only two groups, this number implies that no two people were likely to experience the same Facebook&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn8&quot; id=&quot;user-content-fnref-fn8&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;8&lt;/a&gt;&lt;/sup&gt;. I wouldn’t be surprised if, given the increase in employees relative to when we roughed out this number in around 2016, that number was an order of magnitude higher by 2021&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn9&quot; id=&quot;user-content-fnref-fn9&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;9&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;It’s worth thinking about how these experiments worked a little bit. One thing the handful of people implementing a single test absolutely could not do was to control everything about how the other 30k engineers run &lt;em&gt;their&lt;/em&gt; tests. This is simply the reality of working on a project with this many other people.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn10&quot; id=&quot;user-content-fnref-fn10&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;10&lt;/a&gt;&lt;/sup&gt; This led to difficulties occasionally, in which stuff about the platform changed and rendered a prior test uninformative or incorrect about the current state of the world. On my team, this is why we encouraged two practices: (1) long-run holdouts (where for important features, the rollout of the feature would be to ~99% of users rather than 100%) (2) rerunning important tests to verify results continued to hold.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn11&quot; id=&quot;user-content-fnref-fn11&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;11&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;Everything is evaluated relative to the sum total of other &lt;em&gt;stuff&lt;/em&gt; Facebook is doing on the platform.&lt;/p&gt;
&lt;p&gt;The reality of massive simultaneous experimentation and change resulted in internal experiments using the term “status quo” condition rather than “control” condition in experiments. Everything was evaluated relative to the sum total of other &lt;em&gt;stuff&lt;/em&gt; Facebook was doing on the platform. As an example, &lt;a href=&quot;https://ax.dev/tutorials/human_in_the_loop/human_in_the_loop.html&quot;&gt;check out the software my former team developed for doing complicated experimentation at platform scale&lt;/a&gt;. There is no “control” group, there’s just the “status quo”: what the platform is &lt;em&gt;currently&lt;/em&gt; doing. The other groups are potential modifications of that behavior. The reason we evaluate relative to this group is because &lt;em&gt;experimentation is a means of optimization&lt;/em&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn12&quot; id=&quot;user-content-fnref-fn12&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;12&lt;/a&gt;&lt;/sup&gt;*. *Experimentation was a tool to improve how the system worked, so we wanted to evaluate our &lt;em&gt;one change&lt;/em&gt; relative to the otherwise current state of the system. We never care about comparing to the state of the system 1 day or even 5 minutes ago.&lt;/p&gt;
&lt;p&gt;This is one reason why I welcomed the &lt;a href=&quot;https://www.science.org/doi/10.1126/science.abp9364#elettersSection&quot;&gt;eLetter by Bagchi et al at Science&lt;/a&gt;: it’s important to remember that “Facebook” (the platform) is a moving target&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn13&quot; id=&quot;user-content-fnref-fn13&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;13&lt;/a&gt;&lt;/sup&gt;. In short, during the course of US2020, the company implemented a number of other measures aimed at combatting bad behavior during the election (“break-glass” measures). A lot of people forget how large and diverse an organization Facebook (the company) is. The “break-glass” measures discussed in the eLetter are a great example of this. One hand certainly can’t control what the other hand is doing, but it often isn’t even aware of what that hand is doing&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn14&quot; id=&quot;user-content-fnref-fn14&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;14&lt;/a&gt;&lt;/sup&gt;. Unfortunately, I think this important message is undercut by another one in the eLetter:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This can lead to situations where social media companies could conceivably change their algorithms to improve their public image if they know they are being studied.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This implies a single-minded agency of the daily practice of Facebook engineers that is unreasonable (and largely impossible). As I tried to emphasize above, the company is huge, diverse and fast-moving&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn15&quot; id=&quot;user-content-fnref-fn15&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;15&lt;/a&gt;&lt;/sup&gt;. The vision of a monolithic company exercising its will is simply inaccurate, especially when considering a project as small as US2020. Lots of things were changing during the course of this study; that’s (a) entirely normal at this scale and (b) why it’s important for us to be humble about its temporal validity (which I think we were)! The thing to be angry about here is not that the company tried to tweak the results of US2020 to make them come out hunky-dory: the thing to be mad about is that we have no truly reliable measures of the effects of these break-glass measures!&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn16&quot; id=&quot;user-content-fnref-fn16&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;16&lt;/a&gt;&lt;/sup&gt; We need &lt;em&gt;more&lt;/em&gt; testing, not less.&lt;/p&gt;
&lt;p&gt;The thing to be angry about here is not that the company tried to tweak the results of US2020 to make them come out hunky-dory: the thing to be mad about is that we have no truly reliable measures of the effects of these break-glass measures!&lt;/p&gt;
&lt;h2 id=&quot;was-us2020-independent-or-industrial-research&quot;&gt;Was US2020 independent or industrial research?&lt;/h2&gt;
&lt;p&gt;This leads to what I think is a more important question about the nature of this project. Was US2020 industrial research, guided primarily by the needs of Facebook (the company)? The answer is clearly no. The academics proposed the designs, they had final control rights on the resulting papers and their salaries were in no way dependent on the results of these papers&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn17&quot; id=&quot;user-content-fnref-fn17&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;17&lt;/a&gt;&lt;/sup&gt;. This is all critical, as there is an important difference between the Facebook and academic researchers in the project: Academia has academic freedom, while industry researchers do not. Does that mean that these papers are actually independent, then? Of course not. Seeking independence is a category error for this project. The internal researchers have incentives, &lt;em&gt;as do the academics&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Fundamentally, these parties have different things they bring to the project: internal researchers knew how the platform works in detailed ways that no external person could and they had the capacity to actually work with internal platform data. They had been studying the ins-and-outs of this platform full-time for years. External researchers, on the other hand, were not burdened by corporate incentives and they had the academic freedom to speak freely about the project and their beliefs&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn18&quot; id=&quot;user-content-fnref-fn18&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;18&lt;/a&gt;&lt;/sup&gt;. All of these perspectives are necessary for a successful collaboration, but it would be incorrect to suggest that they were equal partners. They cannot be equal, because they contribute in radically different ways.&lt;/p&gt;
&lt;p&gt;The best one can hope for is to reconcile competing interests by writing down what everyone wants from the project, having an argument about which things can be agreed upon and then choosing to do those things or not. We already have a great tool for this kind of collaboration&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn19&quot; id=&quot;user-content-fnref-fn19&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;19&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;h2 id=&quot;pre-registration-as-a-contract&quot;&gt;Pre-registration as a contract&lt;/h2&gt;
&lt;p&gt;The solution, I think, is setting out a clear contract between the parties at the start of the project. We actually already know what these are: pre-registrations. The pre-registration serves as a contract about exactly what you plan to study and how you plan to do that&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn20&quot; id=&quot;user-content-fnref-fn20&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;20&lt;/a&gt;&lt;/sup&gt;. Filing it publicly in advance can then tie your hands and commit you to doing what you said. While problems inevitably arise post-data, it’s easy to file amendments as necessary. &lt;a href=&quot;https://cyrussamii.com/?p=3154&quot;&gt;Cyrus Samii wrote about how he (and EGAP) sees pre-registrations&lt;/a&gt; that I think relates very nicely to this view, as he talks about the value of pre-registration as a conversation about the research you plan to do. It very much strengthens the quality of the work you will end up producing!&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn21&quot; id=&quot;user-content-fnref-fn21&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;21&lt;/a&gt;&lt;/sup&gt; When parties are collaborating on research and the parties have different incentives, a pre-registration serves as a Memorandum of Understanding. It gives you a specific document on which you can have an explicit negotiation about what you will do in a transparent way. For example, if the parties can’t agree on a definition of the ‘control’ group, then it must be redefined to reflect what can be agreed on. If in the course of executing the project, one side makes a unilateral decision about something substantively important that would not have been agreed to by the other side, then this is an error in the contract for lacking specificity over something important. Take the lesson and apply it to the next project.&lt;/p&gt;
&lt;p&gt;This is the most critical part of the design of US2020. Take expert internal researchers who have a clear conflict of interest (but know more about the actual workings of the platform than anyone outside it) and combine that with independent researchers who are not beholden to the company and are only interested in learning something about how it works. Let these two sides negotiate on what would make a mutually beneficial research project, write it down, do that project&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn22&quot; id=&quot;user-content-fnref-fn22&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;22&lt;/a&gt;&lt;/sup&gt;. The appropriate reading, then, of these studies is as the result of a dialogue&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn23&quot; id=&quot;user-content-fnref-fn23&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;23&lt;/a&gt;&lt;/sup&gt;. And to the point of the eLetter which sparked this meditation, the pre-registration documents we put together make clear our choice of comparison group &lt;em&gt;which is exactly why these documents are so valuable&lt;/em&gt;.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn24&quot; id=&quot;user-content-fnref-fn24&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;24&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;Early on, it was decided that the project should speak with a single voice.  This makes sense given how an academic paper typically works with only a couple authors: consensus works, and every author can speak their mind about the paper. In my opinion, it doesn’t work for a collaboration as large and diverse as US2020. In US2020, only the academics have the freedom to say what they think, and the design of the project means that they are always the ones who have the final determination over what gets written. In practice, this almost always resulted in decision by consensus. There was really very little disagreement because everyone sought the best scientific result. That said, disagreements existed. For example, from &lt;a href=&quot;https://www.science.org/doi/10.1126/science.adi2430&quot;&gt;Michael Wagner’s report&lt;/a&gt; as the rapporteur of US2020:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Specifically, Meta researchers wanted to be able to expressly disagree with lead author interpretations of findings or other matters in articles they coauthored. Stroud and Tucker opposed this effort, noting that collaborators can remove their name from a paper if they have a fundamental disagreement.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;From the way the project was designed, this was the appropriate decision (downstream from choosing to speak with only a single voice), but for the design of future projects, I vehemently disagree with this structure. All members of US2020 are expert scientists, many of whom have different perspectives. The remediation for disagreeing with anything that appears in one of these papers is, for Meta researchers, to entirely take their name off of a project which they have poured, likely, hundreds of hours into: the nuclear option. Much better to have some forum (an appendix?) for authors to include a personal statement clarifying their &lt;em&gt;personal&lt;/em&gt; perspective on the paper and how that diverges from the main text&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn25&quot; id=&quot;user-content-fnref-fn25&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;25&lt;/a&gt;&lt;/sup&gt;. This acknowledges that no written document can perfectly express the views of dozens of scientists, and provides far more information about what the project shows and what may be debateable matters of interpretation. Anyone who has talked with a scientist knows that if you put two together in a room together you’ll have &lt;em&gt;at least&lt;/em&gt; two perspectives on any topic under the sun. It also better expresses the reality that everyone involved in the project is a scientific expert: not merely those in academia. This sets up what I think is a common misapprehension about the project.&lt;/p&gt;
&lt;h2 id=&quot;facebook-researchers-were-not-robots&quot;&gt;Facebook researchers were not robots&lt;/h2&gt;
&lt;p&gt;In the editorial published along with the eLetters, &lt;a href=&quot;https://www.science.org/doi/10.1126/science.adt2983&quot;&gt;Holden Thorp and Valda Vinson wrote&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In a statement for this editorial, Chad Kiewiet de Jonge, a research director at the company, Meta, insisted (to H.H.T.) that it had been forthcoming about the emergency measures to the researchers.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Reading this, it might surprise you to learn that not only is Chad an author of the published paper in question, he’s in fact one of the lead authors. That is, he has been in all of these meetings where such things would be discussed! To quote from the detailed list of contributions:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;N.J.S. and J.A.T. were joint principal investigators for the academic involvement on this project, responsible for management and coordination. &lt;strong&gt;C.K.d.J.&lt;/strong&gt;, A.F., and W.M. &lt;strong&gt;led Meta’s involvement on this project&lt;/strong&gt; and were responsible for management and coordination. [emphasis mine]&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Frankly, this has been a problem from the beginning. As I said immediately on publication, “&lt;a href=&quot;https://x.com/DrewDim/status/1684660868133351426&quot;&gt;This project was a deep collaboration, and generally, I think, not an adversarial one, either. Everyone wanted to get this right!&lt;/a&gt;” Nevertheless, it hasn’t always been presented like this. If you read the project as a dialogue between internal and external researchers (the accurate view, I believe), the only way that this could possibly be &lt;a href=&quot;https://www.science.org/doi/epdf/10.1126/science.adi2430&quot;&gt;“independent” as in the standard set by Michael Wagner&lt;/a&gt; is if the Meta coauthors were robots who merely carried out the precise will of the academics&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn26&quot; id=&quot;user-content-fnref-fn26&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;26&lt;/a&gt;&lt;/sup&gt;. This is clearly bad for the scientific output, and it isn’t what actually happened, as Wagner notes:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;On occasion, this, and advice they received from Meta researchers, led the outside academics to reshape what it is they sought to study, or how they sought to study it, as they learned details about what data were collected and structured by Meta for analysis. For example, the outside academics were not precisely aware of how Facebook groups were joined and, in some cases, left, by users. Coming to understand this led to changes in the working paper examining behavioral polarization.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;And yet, there is an implication that Meta researchers were trying to hide things, as in the quote he shares from a former employee saying,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Facebook researchers will answer every question they get from the professors honestly; they are ethical professionals. However, they are also corporate employees. If the professors don’t ask the exact right question, Facebook staff won’t volunteer that they know how to get what you (outside academics) are really asking for.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It’s very weird that this is attributed to a former employee rather than either the academics or to anyone involved in the project. From everything I saw, Meta researchers didn’t just narrowly answer direct questions, but bent over backward to try and re-interpret requests to get at what the academics’ questions intended. For my part, on one paper I spent a lot of time on, I wrote dozens of pages trying to redefine an unworkable analysis an external academic suggested to one that would be workable — while preserving the research questions. Other Meta employees did similar work on basically every single paper. That work is, in effect, an act of persuasion aimed getting the academics, who have the control over the content, to adopt the change or redefinition based on their view of the scientific merit. To what extent was it based on corporate incentives and to what extent was it based on scientific judgment? Likely a combination: I believe more of the latter than the former. But the negotiation of the pre-analysis plan is the way that this is adjudicated, and in US2020, the external academics were the only ones with the power to decide.&lt;/p&gt;
&lt;p&gt;I think the problem is that people can’t help but see Meta as a monolithic organization which exhibits a single will. This is seriously incorrect in almost obvious ways: employees disagree about, well, basically everything! &lt;a href=&quot;https://profilebooks.com/work/the-unaccountability-machine/&quot;&gt;Dan Davies’ book&lt;/a&gt; on the flows of accountability through the cybernetic lens is a useful correction to this vision. The company “Meta” is distinct from the sum of its individual parts: the procedures and processes that it uses to determine how to operate are largely not under the control of any singular person. In short, it is an organization and this imposes constraints on employees. And yet, journalists and editors of Science seem to have trouble understanding this. Internal researchers must seek permission to do this kind of research (a heavy constraint), but conditional on permission to do so, there is no instrument of Facebook’s will hanging over every discussion and decision they make. This is simply not how information is transmitted within the company&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn27&quot; id=&quot;user-content-fnref-fn27&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;27&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;Specifically on US2020, employees fought for years to enable this kind of research. There was extreme skepticism among executives precisely due to a belief that there’s no way that the project could be “good” for Facebook. The project exists despite the fact that Facebook (the company) was not particularly in favor of it. Rather, the researchers you see listed as coauthors are on there specifically because &lt;em&gt;they&lt;/em&gt; thought it was important to do rigorous, transparent social science about the effects of social media. As a personal anecdote, I was advised against participating in the project if I wanted to optimize my career at Facebook: it’s much more professionally rewarding to make the system work better than it is to do this kind of evaluative work&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn28&quot; id=&quot;user-content-fnref-fn28&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;28&lt;/a&gt;&lt;/sup&gt;. That said, I don’t mean to paint all internal researchers as exactly like people who choose not to work for Facebook. The internal researchers are unlikely to have seriously negative beliefs about the platform, so they may demand stronger standards of evidence for harm than might be acceptable to people more willing to see the inherent evil of the company.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn29&quot; id=&quot;user-content-fnref-fn29&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;29&lt;/a&gt;&lt;/sup&gt; That’s why you have the argument before you see the evidence: in a pre-analysis plan.&lt;/p&gt;
&lt;h1 id=&quot;what-does-the-future-hold&quot;&gt;What does the future hold?&lt;/h1&gt;
&lt;p&gt;I think there’s a real danger in misrepresenting what this project was, but that danger isn’t about falling prey to Facebook’s manipulation. Instead, the danger is that there may never be something else like it, even though it’s the single best way we’ve managed to study the crucial question of how social media affects societal outcomes. I think that collapsing all of the internal researchers into a single “Facebook” blob risks poisoning the well. This project exists only because of individual people—many working within Facebook—working hard to make it exist. Mark Zuckerberg, or any other embodiment of Facebook (the company), did not ask for this project. He did not push for it to exist, and he certainly did not ask for the rigorous structure imposed on how the collaboration would work. The right way to think about this project is that Mark Zuckerberg was willing to humor the desires of people within his organization for rigorous social science. After all, &lt;strong&gt;how much worse could the results be than what people already believed?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For my part, future research collaborations I have with industry researchers will not pretend to independence. Where possible, I will manage conflicts of interest with pre-analysis plans (advocating for what I see as scientific merit), but I think aiming at subordination of these researchers is ultimately self-defeating. When interpretations of results differ, I will resolve disagreements through an appendix (like a “deviations from PAP” section) identifying the different camps of belief: thus bringing it out into the open of scientific discussion. I will bring the dialogue to the forefront, not hide it out of a misguided (and impossible) search for independence.&lt;/p&gt;
&lt;p&gt;By far the most important lesson for social science when faced with a complex entity like the Facebook platform is that we should not be content with a single snapshot about its impact. Acknowledging the size and scale of the engineering effort behind this company must mean acknowledging the necessity to run and rerun tests about important potential interventions.&lt;/p&gt;
&lt;p&gt;Would the results of the chronological feed experiment hold in a different election? Without the break-glass measures?&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn30&quot; id=&quot;user-content-fnref-fn30&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;30&lt;/a&gt;&lt;/sup&gt; In a different country? The only way we can ever know is if we run more tests. The only way we can run those tests is if we understand what US2020 was and try to improve it so that the next version is better. Either way, when I was at Facebook, we would never leave something un-tested and un-optimized if we thought it was important. &lt;a href=&quot;https://drewdimmery.substack.com/p/a-blueprint-for-the-regulation-of&quot;&gt;Maybe the only way we’ll get such tests is if governments require them&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;On October 29, &lt;a href=&quot;https://thehill.com/policy/technology/4960052-meta-study-impact-2024-election/&quot;&gt;Senator Markey sent a letter to Zuckerberg urging further independent research on the societal effects of Meta in the vein of US2020&lt;/a&gt;. A Meta spokesperson just pointed back at the work from 2020 (much of which is still yet to be published), as if this is the final word on the subject. There won’t be a US2024, and it looks like there won’t be a US2028, either.&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-fn1&quot;&gt;
&lt;p&gt;Kevin and I were noodling on what kind of commitment US2020 was on the scale of Meta, and he came up with the following: “Millions of dollars and thousands of hours by highly-paid employees — let’s go nuts and say it cost them $25 million. This is compared against $134 billion in revenue for 2023. That’s .019% of their annual revenue devoted to this 6-year project.” &lt;a href=&quot;https://kevinmunger.substack.com/p/seeing-like-a-newsfeed&quot;&gt;[source]&lt;/a&gt; This is a huge commitment to social science research, but this is simply not a large scale project by Facebook standards. Reality Labs burns like $15 billion per year.In contrast, financial institutions &lt;a href=&quot;https://www.economist.com/finance-and-economics/2019/05/02/the-past-decade-has-brought-a-compliance-boom-in-banking&quot;&gt;commit around 15% of their employees to compliance&lt;/a&gt;. &lt;a href=&quot;#user-content-fnref-fn1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn2&quot;&gt;
&lt;p&gt;See &lt;a href=&quot;https://kevinmunger.substack.com/p/the-theory-of-the-academic-firm&quot;&gt;Kevin’s post on this&lt;/a&gt;, I think it’s a critical standpoint for understanding modern scientific production. &lt;a href=&quot;#user-content-fnref-fn2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn3&quot;&gt;
&lt;p&gt;I can’t find a definitive answer online, but a &lt;a href=&quot;https://www.quora.com/How-many-Facebook-employees-are-engineers-or-work-in-technical-positions-and-how-many-non-engineers-are-there-working-on-Facebook-products-vs-infrastructure-backend-etc#:~:text=Of%20these%20employees%2C%20around%2058,%2C%20human%20resources%2C%20and%20finance.&quot;&gt;Quora answer quotes 58%&lt;/a&gt;  and &lt;a href=&quot;https://newsletter.pragmaticengineer.com/p/facebook&quot;&gt;Gergely Orosz cites 43%&lt;/a&gt;. 50% seems like it roughly jibes with my intuition. &lt;a href=&quot;#user-content-fnref-fn3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn4&quot;&gt;
&lt;p&gt;The number of major SEVs (read as “major bad thing”) caused by a commit reviewed by a colleague with only the four letters “LGTM” as the review is… a lot.Note: if you do this in “someone else’s code” they are liable to get extremely mad at you. &lt;a href=&quot;#user-content-fnref-fn4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn5&quot;&gt;
&lt;p&gt;A lot of the blame for this falls on bots that do “automatic” commits. &lt;a href=&quot;#user-content-fnref-fn5&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn6&quot;&gt;
&lt;p&gt;Infamous? Certainly had some of the best war stories of deployment at early Facebook I received in bootcamp. &lt;a href=&quot;#user-content-fnref-fn6&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 6&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn7&quot;&gt;
&lt;p&gt;This also led to plenty of bugs that only popped up in particular combinations of features gated by A/B tests, code, and a variety of other technical means. &lt;a href=&quot;#user-content-fnref-fn7&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 7&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn8&quot;&gt;
&lt;p&gt;(2 treatments per test) ^ (number of independent tests) is much larger than 8 billion for any reasonable number of independent tests. There are a lot of independent tests at Facebook due to the “universe” concept (the same &lt;a href=&quot;https://dl.acm.org/doi/abs/10.1145/1835804.1835810&quot;&gt;basic idea described by Google here&lt;/a&gt;). &lt;a href=&quot;#user-content-fnref-fn8&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 8&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn9&quot;&gt;
&lt;p&gt;If A/B tests scale linearly with employees. There were 17k employees in 2016 and 72k in 2021, an increase of 4x. &lt;a href=&quot;#user-content-fnref-fn9&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 9&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn10&quot;&gt;
&lt;p&gt;There are, of course, some exceptions: global holdouts that all employees have to respect, or particular features which interfere with each other strongly. These are both handled with technical solutions. The former by allowing global restrictions on who can be put in experiments and the latter through the use of “universes” (for more, see &lt;a href=&quot;https://hci.stanford.edu/publications/2014/planout/planout-www2014.pdf&quot;&gt;the paper on PlanOut&lt;/a&gt;, for instance) that ensure that users cannot be put in multiple conflicting tests. &lt;a href=&quot;#user-content-fnref-fn10&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 10&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn11&quot;&gt;
&lt;p&gt;If this post wasn’t already way too long, I would provide some examples. One notable one was when, between iterations of text optimization, the translation systems changed, vastly affecting our results. &lt;a href=&quot;#user-content-fnref-fn11&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 11&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn12&quot;&gt;
&lt;p&gt;This perspective, more than maybe any other, was key to what our team was good at. Figuring out what metric to optimize (metric definition) and what levers to pull were often (treatment definition) more essential than the ML toolkit we used for actually doing the optimization, which was fancy and useful, but also ultimately subservient to the problem definition. &lt;a href=&quot;#user-content-fnref-fn12&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 12&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn13&quot;&gt;
&lt;p&gt;They frame this as an issue of “validity”. In our response, we note that they are only referring to external validity, but I find the term misleading in general as Kevin and I discuss in &lt;a href=&quot;http://osf.io/wmhc4&quot;&gt;our working paper on partial identification and temporal validity&lt;/a&gt;: This word has the unfortunate implication of being binary; computer login passwords and driver’s licenses are either valid or invalid. To say that a driver’s license is “mostly valid” is to say that it is “not valid.” Scientific knowledge is not binary, and while most practitioners can successfully keep this reality in mind when discussing “external validity,” the term introduces unnecessary confusion.And as far as temporal validity goes, as I quoted in my &lt;a href=&quot;https://drewdimmery.substack.com/p/a-blueprint-for-the-regulation-of&quot;&gt;first post on this newsletter&lt;/a&gt;:&lt;a href=&quot;https://investor.fb.com/investor-events/event-details/2022/Q2-2022-Earnings/default.aspx&quot;&gt;Right now, about 15% of content in a person’s Facebook feed and a little more than that of their Instagram feed is recommended by our AI from people, groups, or accounts that you don’t follow. We expect these numbers to more than double by the end of next year.&lt;/a&gt;The current News Feed on Facebook is simply not the same thing we evaluated: the company moves too fast for that. If the only research we deem valid is research which is perfectly temporally valid 4 years on from its setting, we will have no evidence-base on which to make policy at all. This is an important problem we must contend with as a question of meta-science. &lt;a href=&quot;#user-content-fnref-fn13&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 13&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn14&quot;&gt;
&lt;p&gt;It’s hard for me to remember, but despite being an employee and working on US2020 I think I only heard about these break-glass measures through public reporting, rather than from internal communications, but I generally worked on methods stuff rather than specifically on applied civic stuff. &lt;a href=&quot;#user-content-fnref-fn14&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 14&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn15&quot;&gt;
&lt;p&gt;It is not without reason that employees have been described as &lt;a href=&quot;https://en.wikipedia.org/wiki/Chaos_Monkeys&quot;&gt;Chaos Monkeys&lt;/a&gt;. &lt;a href=&quot;#user-content-fnref-fn15&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 15&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn16&quot;&gt;
&lt;p&gt;As far as I know, these measures weren’t even implemented in a way to test things internally. but I could be wrong about that, I have no special vision into this. &lt;a href=&quot;#user-content-fnref-fn16&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 16&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn17&quot;&gt;
&lt;p&gt;I suppose you could say that the results would change the amount of prestige afforded to them. If this is the case, would the largely null results we found have been the best for their careers? &lt;a href=&quot;#user-content-fnref-fn17&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 17&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn18&quot;&gt;
&lt;p&gt;Unlike other participants in US2020 from the Meta side, I actually now have the benefit to speak freely, so I’ve got that going for me. &lt;a href=&quot;#user-content-fnref-fn18&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 18&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn19&quot;&gt;
&lt;p&gt;I’m specifically not referring to this as adversarial collaboration, because I don’t think that’s an accurate reading of the reality. It really wasn’t that adversarial, because the internal researchers also wanted to know the answers to these questions. We didn’t collect information on things like race or politics as a matter of course. &lt;a href=&quot;#user-content-fnref-fn19&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 19&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn20&quot;&gt;
&lt;p&gt;Note that my argument here is completely divorced from the statistical arguments in favor of pre-analysis plans. &lt;a href=&quot;#user-content-fnref-fn20&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 20&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn21&quot;&gt;
&lt;p&gt;Note that this justification isn’t a narrow one about getting a hypothesis test to cover at an appropriate rate, it’s about actual substantive concerns of what to study and how to study it. &lt;a href=&quot;#user-content-fnref-fn21&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 21&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn22&quot;&gt;
&lt;p&gt;Of course, no plan survives contact with the enemy and every data scientist knows that the only true enemy is data. &lt;a href=&quot;#user-content-fnref-fn22&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 22&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn23&quot;&gt;
&lt;p&gt;A dialectic? &lt;a href=&quot;#user-content-fnref-fn23&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 23&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn24&quot;&gt;
&lt;p&gt;Some selections from the pre-registrations: The News Feed of users who are assigned to the control condition will not change as a result of the experiment.from the Likeminded exposure PAPUsers assigned to the control condition will see their normal News Feed under existing Facebook policies and procedures.from an as-yet unpublished study’s PAPUsers who have consented are randomized into three treatment conditions (or a control condition shared with other studies).from the Chronofeed PAP (emphasis mine)The second statement, I think, makes this the most clear. Facebook has existing policies and procedures, and the scope of this study will not be changing that. Given the size of Facebook (which I have repeatedly emphasized), I don’t think this should be surprising! &lt;a href=&quot;#user-content-fnref-fn24&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 24&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn25&quot;&gt;
&lt;p&gt;Since the papers were not reviewed by Meta for content, this would give internal researchers some very small measure of the academic freedom that they do not, in general, enjoy. &lt;a href=&quot;#user-content-fnref-fn25&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 25&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn26&quot;&gt;
&lt;p&gt;Academics, mind you, who simply don’t know how internal systems, logging and metrics actually work. There’s no reason they could know this, in fact. &lt;a href=&quot;#user-content-fnref-fn26&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 26&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn27&quot;&gt;
&lt;p&gt;To fully think through the question would require a discussion about how performance is judged at Meta. I think the best way to think about this is that Facebook uses a form of &lt;a href=&quot;https://factorialhr.com/blog/stack-ranking/&quot;&gt;stack ranking&lt;/a&gt;, where your manager has about 20 seconds to advocate on your behalf before putting you in a ranked list of your colleagues in the same organization and at the same level. The stuff that will be most persuasive are large impacts of your work on important corporate KPIs. &lt;a href=&quot;#user-content-fnref-fn27&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 27&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn28&quot;&gt;
&lt;p&gt;Because you can measure the value of making a system work better: you run an A/B test and see what your change does. &lt;a href=&quot;#user-content-fnref-fn28&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 28&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn29&quot;&gt;
&lt;p&gt;This is another argument for RCTs, as I think this debate pops up much more clearly in observational causal inference where you have to determine your willingness to balance the potential for bias against the desire to get some answer to a thorny question no matter how flawed. To be explicit, I suspect internal researchers are much less willing to accept any bias, partially due to a strong internal culture in favor of RCTs. &lt;a href=&quot;https://www.tomleavitt.com/s/Leavitt_Fisher_Meets_Bayes.pdf&quot;&gt;Thomas Leavitt&lt;/a&gt; has a related argument on this point about the epistemic value of randomization. &lt;a href=&quot;#user-content-fnref-fn29&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 29&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn30&quot;&gt;
&lt;p&gt;Let’s leave a holdout of 0.5% of the Facebook population from receiving these measures next election to find out! &lt;a href=&quot;#user-content-fnref-fn30&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 30&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><category>social-media</category><category>metascience</category></item><item><title>Is Bluesky convivial?</title><link>https://ddimmery.com/posts/is-bluesky-convivial/</link><guid isPermaLink="true">https://ddimmery.com/posts/is-bluesky-convivial/</guid><description>Smalltalk and the impossibility of social toolmaking to empower end-users</description><pubDate>Thu, 21 Nov 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Back in November of 2023, I was lucky enough to participate in a “Morality in Tech” workshop hosted by Princeton’s CITP put on by Kevin Munger. It was a fascinating interdisciplinary group of people trying to wrap our heads around how to grapple with how to tie moral and ethical frameworks to technological change. It culminated in the “&lt;a href=&quot;https://kmunger.github.io/pdfs/syllabus_citp.pdf&quot;&gt;Building the Society We Want&lt;/a&gt;” syllabus.&lt;/p&gt;
&lt;p&gt;This post is a modified version of a talk I gave on the historical development of &lt;a href=&quot;https://en.wikipedia.org/wiki/Smalltalk&quot;&gt;Smalltalk&lt;/a&gt;, and how I see it as a fundamentally different way of thinking about technology than we’re used to today. Unfortunately, I ultimately don’t see it as a way out of the mess we’re in on the social web. Bluesky cannot resolve the fundamental problems with microblogging, which are fundamental to the technology.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;what-is-smalltalk&quot;&gt;What is Smalltalk?&lt;/h2&gt;
&lt;p&gt;Smalltalk was developed by Alan Kay, Dan Ingalls and Adele Goldberg at Xerox PARC in the 1970s. What it was is a little hard to frame in terms of our contemporary categories around computing. It was more than a programming language and not exactly an operating system as we’ve come to understand them. It was the software part of Alan Kay’s overarching personal computing vision (from back before computing was really &lt;em&gt;personal&lt;/em&gt; computing). Smalltalk had a lot of things that are now very common, but were very uncommon when it came out. It was an early iteration of Object-oriented programming&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn1&quot; id=&quot;user-content-fnref-fn1&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;, it had an early graphical interface, all code was just-in-time compiled (and could be recompiled on the fly), and it integrated a development environment into how the user interacted with the system. But Smalltalk was also a &lt;em&gt;philosophy&lt;/em&gt; of computing:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;look for the distinction between a programming language and a programming system, and consider the difference in providing a system in which the user can &lt;em&gt;feel individual mastery over complexity&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;(emphasis mine) The intention was to make the vast complexity of a computer system something that end-users could &lt;em&gt;control&lt;/em&gt;. The system should allow the complexity of the system to be comprehensible to the user, and allow them to adapt and reorient it at their will.&lt;/p&gt;
&lt;p&gt;A lot of what I’m drawing on here is from &lt;a href=&quot;https://archive.org/details/byte-magazine-1981-08/&quot;&gt;the 1981 issue of BYTE Magazine&lt;/a&gt; in which PARC chose to write a public introduction to the newest iteration of the Smalltalk system. It’s available online and a truly fascinating read that I can’t recommend enough.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;351&quot; height=&quot;470&quot; src=&quot;/_astro/image_1.CR_ig4PJ_1pEP5u.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Smalltalk was intended to give the User the power of God over the computing system. This isn’t really subtext. In this introduction to Smalltalk, they provide the following illustration:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;931&quot; height=&quot;427&quot; src=&quot;/_astro/image_2.beXyiidW_F33fA.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;On the far left, the System Programmer (God) creates a system (the Taj Mahal). The Programmer creates things (a bridge) for the end-user using the things provided by the System Programmer. Smalltalk was intended to democratize the power of creation, moving into the second figure from the left, in which the Programmer creates kits that the User can use to construct what they want. In Figure 3 this goes even further, as Users can create the kits themselves that they can assemble into what they want. On the far right, however, the idea is that Programmers / Users should be able to climb up above God and impose their own will over that of the System Programmer: to become God.&lt;/p&gt;
&lt;p&gt;It’s a vision of a radically empowered user who can manipulate every aspect of their computing environment. In my mind, this vision is exactly what it means to have a “convivial” tool in the sense of Ivan Illich: tools which empower human liberty rather than constrain.&lt;/p&gt;
&lt;p&gt;There are costs, however, as Smalltalk asks much more of users, as Kay and Goldberg write in 1977:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The burden of system design and specification is transferred to the user. This approach will only work if we […] allow ordinary users to casually and easily describe their desires for a specific tool.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;But the benefit is a fully “reactive” system&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn2&quot; id=&quot;user-content-fnref-fn2&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;. What did this look like?&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;366&quot; height=&quot;296&quot; src=&quot;/_astro/image_3.PumVhfpD_Z2948zY.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Essentially, you had a browser like the above, through which you could navigate through your system, then the panel at the bottom allowed you to edit the code defining how that part of your system worked. You could then choose to re-compile that part of your system and it would automagically update to follow your new instructions. Voila, complete control over the system, manipulable at runtime.&lt;/p&gt;
&lt;p&gt;But there’s one last quote, from Daniel Ingvalls from his article about the design principles of Smalltalk:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Natural Selection&lt;/strong&gt;: Languages and systems that are of sound design will persist, to be supplanted only by better ones.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Our computing is not based around Smalltalk these days, nor does it look very much like this: it died out in favor of opaque systems with a lack of user-control. It seems that users were, in the end, not willing to take the burden of full responsibility for the functioning of their own computing environment.&lt;/p&gt;
&lt;h2 id=&quot;empowerment-is-still-about-power&quot;&gt;Empowerment is still about power&lt;/h2&gt;
&lt;p&gt;I think the question of inevitability is what I really struggle with here. The dream of a system that radically empowers the user is beautiful. But are users willing to actually take this power? Can they? In grappling with this question, I tried to think about affordances of social media and the extent to which they align with Smalltalky principles.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://blueskyweb.xyz/blog/7-27-2023-custom-feeds&quot;&gt;Bluesky lets users choose their own Feed algorithm&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.archive.org/web/20140109112039/https://twitter.com/chrismessina/status/223115412&quot;&gt;The hashtag was created&lt;/a&gt; as a tool for users to take control of discovery and categorization themselves.&lt;/li&gt;
&lt;li&gt;Distributed social media services (e.g. Mastodon) seek to allow individuals to choose the community (and, therefore, community norms) they wish to belong to.&lt;/li&gt;
&lt;li&gt;individual choice about network links to create (e.g. friending on Facebook): &lt;a href=&quot;https://www.science.org/doi/10.1126/science.ade7138&quot;&gt;this is the source of a lot of ideological polarization&lt;/a&gt;, rather than something done “to” users by algorithms.
In each of these, the user gets pretty profound ability to shape what their social media &lt;em&gt;is&lt;/em&gt;. But it’s still not enough! My choice of a feed algorithm doesn’t give me the experience of using Bluesky that I would have if &lt;em&gt;everyone&lt;/em&gt; were to use my preferred feed. In order for me to “choose” my experience on the platform, I need the power to choose how &lt;em&gt;everyone&lt;/em&gt; experiences the platform. Empowering users doesn’t avoid the critical question of who holds the power to make such changes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In a previous post, I &lt;a href=&quot;https://drewdimmery.substack.com/p/stop-looking-for-the-next-twitter?r=bjnt&amp;#x26;triedRedirect=true&quot;&gt;claimed that there were four main definitional characteristics of microblogging&lt;/a&gt;: (1) short texts (2) virality (3) simple engagement possibilities and (4) an infinite feed. The users can’t alter these characteristics on BlueSky or on any other platform. &lt;a href=&quot;https://www.science.org/doi/abs/10.1126/science.add8424&quot;&gt;Removing reshares&lt;/a&gt; from your &lt;em&gt;own&lt;/em&gt; screen doesn’t change whether you experience virality and the associated &lt;a href=&quot;https://www.tandfonline.com/doi/abs/10.1080/10584609.2019.1687626&quot;&gt;credibility cascades&lt;/a&gt; and everything else associated with virality. To kill virality, you’d need to make aggressive changes like removing the visibility of likes from everyone’s screen, removing ranking based on likes, views, clickthroughs, killing reshares &lt;em&gt;globally&lt;/em&gt; and the list of changes goes on. After making all of those changes for &lt;em&gt;everyone&lt;/em&gt; then maybe you’ve done a good job of breaking virality. Can you give virality back to a single user, at that point?&lt;/p&gt;
&lt;p&gt;It is fundamentally impossible for &lt;em&gt;everyone&lt;/em&gt; to alter &lt;em&gt;everything&lt;/em&gt; about their social media experience to their whims, while continuing to make it meaningfully &lt;em&gt;social&lt;/em&gt;. Even in a world where everyone gets to choose everything about how &lt;em&gt;they&lt;/em&gt; interact with social media, they don’t get to choose how &lt;em&gt;everyone else&lt;/em&gt; interacts with social media&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn3&quot; id=&quot;user-content-fnref-fn3&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;. Our experiences online aren’t just shaped by our own choices, but by the choices of those around us&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn4&quot; id=&quot;user-content-fnref-fn4&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;. We can’t “solve” our experience by changing only our own affordances.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn5&quot; id=&quot;user-content-fnref-fn5&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt; Bluesky can only ever give the illusion of autonomy, it can never provide true control over the environment as envisioned by Smalltalk. That autonomy only works for a computing platform that is fundamentally a-social: it interacts &lt;em&gt;only&lt;/em&gt; with you and responds &lt;em&gt;only&lt;/em&gt; to your preferences.&lt;/p&gt;
&lt;p&gt;Convivial, anarchist empowerment to shape one’s own technical reality doesn’t offer a way out of the shared reality we create with technologies. At best, it can offer a patchwork of small fixes. We cannot fundamentally alter the medium, because the medium is defined by what is shared. The critical question is who has the power to choose the shape of the overall technology, and &lt;a href=&quot;https://drewdimmery.substack.com/p/a-blueprint-for-the-regulation-of&quot;&gt;who gets to study how the world is changed by those choices.&lt;/a&gt; Right now, only the platforms have these powers.&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-fn1&quot;&gt;
&lt;p&gt;In fact, Alan Kay doesn’t actually think modern OOP is at all related to what “OOP” was for Smalltalk. If I had to condense down what I understand he sees as the critical distinction, I’d say that it would be something about autonomy: his vision saw individual “objects” being more-or-less autonomous computing units, which would communicate with one another and this would allow the programmer to create complex systems based on these interactions. Crucially, he saw this as a lot more than a paradigm for writing and organizing a particular piece of software. &lt;a href=&quot;#user-content-fnref-fn1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn2&quot;&gt;
&lt;p&gt;“The Smalltalk programming environment is reactive: the user tells it what to do and it reacts, instead of the other way around.” Tesler 1981 &lt;a href=&quot;#user-content-fnref-fn2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn3&quot;&gt;
&lt;p&gt;And, in particular, a world in which collaborative filtering continues to play a strong role in what content your network (or other people more broadly) sees. &lt;a href=&quot;#user-content-fnref-fn3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn4&quot;&gt;
&lt;p&gt;The most banal and obvious platitude of social science: “other people matter for your experience of life” &lt;a href=&quot;#user-content-fnref-fn4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn5&quot;&gt;
&lt;p&gt;Well, you can just sign off completely. And maybe you should! But that’s a different question altogether. For what it’s worth, I’ve basically signed off. I don’t think the bargain is a positive one in my life. &lt;a href=&quot;#user-content-fnref-fn5&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><category>technology</category><category>social-media</category></item><item><title>Examining the Apparatus</title><link>https://ddimmery.com/posts/examining-the-apparatus/</link><guid isPermaLink="true">https://ddimmery.com/posts/examining-the-apparatus/</guid><description>The purpose of a system is what it does!</description><pubDate>Tue, 30 Jan 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Kevin Munger has &lt;a href=&quot;https://www.motherjones.com/politics/2024/01/the-algorithm-social-media-facebook-technology-the-apparatus/&quot;&gt;a great article out problematizing the idea of “The Algorithm”&lt;/a&gt;. You should read the Mother Jones article and then you should read &lt;a href=&quot;https://kevinmunger.substack.com/p/the-algorithm-is-the-only-critique&quot;&gt;his Substack&lt;/a&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn1&quot; id=&quot;user-content-fnref-fn1&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. They’re both great! And they touch on an important theme I’ll return to a lot, which is about the right ways to conceive of and examine complex systems.&lt;/p&gt;
&lt;p&gt;The argument, in brief, is that “the Algorithm” is a misleading frame that elides our participation in the system. He proposes (based on the hottest philosopher of 2024, Vilém Flusser) “the Apparatus” as a better term that acknowledges each of our presence within this greater system which defines much of what we actually mean by “the Algorithm”.&lt;/p&gt;
&lt;p&gt;In this blog, I’m going talk about the implications of re-formulating the source of our present weirdness as “the Apparatus”. How is the apparatus constructed? What are the nuts and bolts of how exactly we are implicated in its construction? Shockingly, I’ll argue we need more experiments.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;the-apparatus-explained&quot;&gt;The Apparatus, explained&lt;/h2&gt;
&lt;p&gt;I think it’s worth talking through how change happens in Tech. I’ll focus on Meta, because it’s the place I know best. This is basically the guts of how the Apparatus gets created.&lt;/p&gt;
&lt;p&gt;The problem faced by Tech companies is, put simply “how should we decide what to do?”. There are a number of approaches to this, but I’m going to contrast two:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Build stuff and then ask people how/whether they like it.&lt;/li&gt;
&lt;li&gt;Build stuff and then see how/whether people use it.
We have to keep in mind, however, that we’re fundamentally talking about making decisions for a product used by (e.g.) 2 billion people. We have to think about how these two approaches would work in that setting, i.e. asking the question “Will it scale?”&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The first approach would rely on large-scale surveys. There’s no real way to build up qualitative knowledge about 2 billion people, so we need to be quantitative, and surveys are pretty much the only game in town if you want to get folks’ opinions like this. There are hard limits here, though. At the limit, you can’t (for instance) ask every user how their experience of the site is every five minutes. At Facebook, the standard “cool-down” period after taking a survey was six months when I was there. This imposes hard limits on the precision with which you can actually measure the opinions of users&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn2&quot; id=&quot;user-content-fnref-fn2&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;The second approach would rely on directly observing behavior and encoding this into meaningful measures about what people are doing. Most of this is just counting things that people are doing&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn3&quot; id=&quot;user-content-fnref-fn3&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;. Because you don’t ask for any of your users’ attention to do this, there aren’t really any practical limits to your measurement of on-platform behaviors&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn4&quot; id=&quot;user-content-fnref-fn4&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;Given these practicalities, it’s unsurprising that the result is an almost ideological belief in &lt;em&gt;behavioralism&lt;/em&gt;: that the only way to understand what users want is to observe what they do&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn5&quot; id=&quot;user-content-fnref-fn5&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;. My understanding is that this was part of an inspiring introductory speech that Chris Cox would give to new hires&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn6&quot; id=&quot;user-content-fnref-fn6&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;h2 id=&quot;the-apparatus-sustained&quot;&gt;The Apparatus, sustained&lt;/h2&gt;
&lt;p&gt;This process results in a cycle of iterative improvement. &lt;a href=&quot;https://press.princeton.edu/books/hardcover/9780691159263/the-internet-trap&quot;&gt;Matt Hindman’s book&lt;/a&gt; does a good job of describing the power of this cycle. It’s also the basis of the Agile software development philosophy, expressed at Facebook as “ship early, ship often” or, more provocatively, “move fast and break things”.&lt;/p&gt;
&lt;p&gt;This saying has, I think, always been misinterpreted. The point is not that you’re okay with breaking things. The point is that you’re okay with &lt;em&gt;trying&lt;/em&gt; new things, because you know that you have systems in place for identifying when things break. Many of the neurotic high-performers that get hired in tech are perfectionists, so you need to encourage them to not spend years working on something before launching it and seeing how it works. This should really be interpreted through &lt;a href=&quot;https://agilemanifesto.org/&quot;&gt;a mantra of the Agile Manifesto&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Our highest priority is to &lt;strong&gt;satisfy the customer&lt;/strong&gt; through early and continuous delivery of valuable software.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Over time, trying a bunch of stuff (some of which might &lt;em&gt;seem&lt;/em&gt; crazy ex ante) and watching what users do in response to it is a great way to build a successful product. I think this is one of the defining features of the secret sauce of modern Big Tech.&lt;/p&gt;
&lt;p&gt;This perspective flows into incentives throughout the company. Software engineers are, in large part, promoted and compensated based on how well their changes result in user behavior that is deemed “good”. The number went up? Congratulations, you get a bonus. You can break apart this monolith, but this isn’t a bad first order approximation&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn7&quot; id=&quot;user-content-fnref-fn7&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;h2 id=&quot;the-apparatus-examined&quot;&gt;The Apparatus, examined&lt;/h2&gt;
&lt;p&gt;This discussion should make it clear that there’s no sense in which any person understands “the Algorithm”, as Kevin argues. Wouldn’t that be comforting? Stafford Beer had a famous saying, “&lt;a href=&quot;https://en.wikipedia.org/wiki/The_purpose_of_a_system_is_what_it_does&quot;&gt;The purpose of a system is what it does&lt;/a&gt;”. This isn’t a reassuring sentiment. We have to work extremely hard to see and measure what a system does. There’s no easy shortcut through “intentions” to understand a system. Even with a truth-serum, we can’t just ask Zuck what he intended to build and then decide if that’s good or bad&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn8&quot; id=&quot;user-content-fnref-fn8&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;8&lt;/a&gt;&lt;/sup&gt;. No engineer fully understands the entirety of the complex system they’re working on, so we can’t judge the worth of what they’ve built solely on what they intended to build.&lt;/p&gt;
&lt;p&gt;So what &lt;em&gt;is&lt;/em&gt; the purpose of the apparatus? Well, in one sense it’s essentially the aggregate of the incentives for all the people &lt;em&gt;building&lt;/em&gt; the apparatus: making the numbers go up. If we want to understand the purpose of the apparatus, we need to encode the things it does into numbers, and measure how changes to the apparatus result in changes to those numbers. There’s only one consistent way to do that: experimentation&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn9&quot; id=&quot;user-content-fnref-fn9&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;9&lt;/a&gt;&lt;/sup&gt;. And we need to find the right &lt;em&gt;new&lt;/em&gt; numbers to measure, because there will undoubtedly be unintended consequences.&lt;/p&gt;
&lt;p&gt;But we cannot forget that the essence of the behavioralism in Tech is that &lt;em&gt;we are those numbers&lt;/em&gt;. We are as much a part of the apparatus as the engineers who build the system: every post, every click, every message, every linger over a story is part of the apparatus. This isn’t just true in the sense of our being complicit in the system. It’s true mechanically in the way engineers &lt;em&gt;construct&lt;/em&gt; the system. The builders of the system &lt;em&gt;want&lt;/em&gt; to give us what we want.&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-fn1&quot;&gt;
&lt;p&gt;This editorial line of this blog is generally pro-Munger. &lt;a href=&quot;#user-content-fnref-fn1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn2&quot;&gt;
&lt;p&gt;It would be interesting to write down, under reasonable assumptions, exactly what this would impose as the minimal detectable effect. It would probably be small (for social science), but implausibly large (for the practical decisions about product made 1000 times a day in tech). &lt;a href=&quot;#user-content-fnref-fn2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn3&quot;&gt;
&lt;p&gt;There was a joke at Facebook that this was the main skill of data scientists: we invented a whole job just to do advanced counting. Move fast and count things! &lt;a href=&quot;#user-content-fnref-fn3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn4&quot;&gt;
&lt;p&gt;Technical limits exist. Tracking and storing all mouse movement for all 2 billion users would be an absurdly large amount of data collection. More commonly, the practice would be to radically downsample any of this kind of data that is collected. &lt;a href=&quot;#user-content-fnref-fn4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn5&quot;&gt;
&lt;p&gt;Of course, there’s also a “revealed preferences” element to this, but even if you ignore that, there’s still a practical matter of scaling. &lt;a href=&quot;#user-content-fnref-fn5&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn6&quot;&gt;
&lt;p&gt;Somehow, I didn’t get this either as an intern or when I started as a full-time. This is sad, as I’ve heard is was a fascinating romp through the history of technology in a very McLuhan way. Oh well. &lt;a href=&quot;#user-content-fnref-fn6&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 6&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn7&quot;&gt;
&lt;p&gt;I think you can break a lot of work in Tech into three groups (excluding support staff that doesn’t work directly on product): engineers (make numbers go up), UX researchers (make sure we choose the right numbers to go up), internal measurement tool builders (make sure when we say number goes up, it actually went up). &lt;a href=&quot;#user-content-fnref-fn7&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 7&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn8&quot;&gt;
&lt;p&gt;I think many critics would be surprised at the prevalence good intentions here. &lt;a href=&quot;#user-content-fnref-fn8&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 8&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn9&quot;&gt;
&lt;p&gt;There’s an argument here that this is granting too much to behavioralism: that framing the problem in these terms is already giving up the game. I don’t think this is true. A strong argument for behavioralism is that it grants a common epistemological playing field that leads to productive arguments about what should be measured and what should be valued: a regulatory framework. Those are much more productive, I think, than arguing about more basic epistemological points on which there can never be agreement. &lt;a href=&quot;#user-content-fnref-fn9&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 9&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><category>social-media</category><category>technology</category></item><item><title>Calibration as an HTE diagnostic</title><link>https://ddimmery.com/posts/calibration-as-an-hte-diagnostic/</link><guid isPermaLink="true">https://ddimmery.com/posts/calibration-as-an-hte-diagnostic/</guid><description>Paper just accepted to Information Systems Research</description><pubDate>Tue, 16 Jan 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In &lt;a href=&quot;https://open.substack.com/pub/drewdimmery/p/stop-looking-for-the-next-twitter?r=bjnt&amp;#x26;utm_campaign=post&amp;#x26;utm_medium=web&quot;&gt;an earlier post&lt;/a&gt;, I promised that rather than writing threads about papers, I’d talk about them here. That’s what this post is!&lt;/p&gt;
&lt;p&gt;I’ve just had &lt;a href=&quot;https://doi.org/10.1287/isre.2021.0343&quot;&gt;a paper (with Yan Leng)&lt;/a&gt; accepted to Information Systems Research titled “Calibration of Heterogeneous Treatment Effects in Randomized Experiments”. The entire motivation of the paper can be summed up in the following chart, showing that the HTEs are not alright:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;999&quot; height=&quot;619&quot; src=&quot;/_astro/image_1.CfOQEukK_1vKwwP.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;The data undergirding this chart came from a big (and important) experiment at Facebook which was run around 2019 or so. It is sufficiently sensitive that I (still) can’t talk about what the actual intervention was, but one of the big questions was about how much heterogeneity there was in the intervention. It would have been a big deal if a small fraction of people exhibited very large effects, so we needed to look into whether this was the case. We did this by applying some of the rapidly developing literature on ML estimation of heterogeneous effects.&lt;/p&gt;
&lt;p&gt;We threw machine learning at the problem using a bunch of covariates we collected about users’ behavior. We started with the simplest possible model, the venerable T-learner&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn1&quot; id=&quot;user-content-fnref-fn1&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. When I was at Facebook, I did a bunch of interviews in which I asked candidates to walk me through their model-building and model-testing process (starting with very simple gut-checks). One of the open-ended questions I would always ask was “how would you know if this particular model was good enough (e.g. to launch to production)?” With ML, you can often give pretty sensible answers to this question depending on what you’re trying to do and thinking carefully about what errors mean&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn2&quot; id=&quot;user-content-fnref-fn2&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;. We found this a surprisingly hard question to answer in the causal setting.&lt;/p&gt;
&lt;p&gt;How can we have a sense as to whether our HTEs are reasonable? In a standard machine learning setting, you have true labels which you can compare to your estimates to see how well you do at prediction. Even in the case of non-standard prediction models where you only learn about the truth long after you predict, you can use the truth to get a sense of how well you do. A great example of this was when &lt;a href=&quot;https://projects.fivethirtyeight.com/checking-our-work/&quot;&gt;FiveThirtyEight evaluated all of their predictive models they’d ever done&lt;/a&gt;. Of course, as you learn in the first lecture of any causal inference class, you never actually observe the true treatment effect: you only have exactly one of the treatment and control potential outcome for a unit.&lt;/p&gt;
&lt;p&gt;The standard answer in the causal setting is that while you cannot observe &lt;em&gt;individual&lt;/em&gt; effects, you can observe &lt;em&gt;average&lt;/em&gt; effects. To bring things back to the motivating graph at the top, we started with the very simple exercise of splitting up our data based on quintiles of the estimated HTEs (from the T-learner) and comparing the average model-based estimates against the standard difference-in-means estimates in each quintile.&lt;/p&gt;
&lt;p&gt;The results were pretty startling, as the ML-based HTEs were radically smaller in magnitude than the &lt;em&gt;known unbiased&lt;/em&gt; estimates from a difference-in-means. In short, this plot instantly alerted us to the fact that something was going very wrong. As you can see in the plot, these differences cannot simply be explained away as sampling variation in the difference-in-means. Rather, we found the issue to be that the plugin estimators make a fundamentally incorrect bias-variance tradeoff because they’re modeling &lt;em&gt;response-surfaces&lt;/em&gt; rather than &lt;em&gt;treatment effects&lt;/em&gt;. If you were to have infinite data, this problem might go away, but we’re ultimately never in asymptopia, and we need some heuristics and diagnostics to help us navigate this tradeoff.&lt;/p&gt;
&lt;p&gt;The core of our paper is thus to motivate people to &lt;em&gt;look at their data&lt;/em&gt;. Have your models actually done a good job of replicating the effects you know you can have some faith in? If not, you need to try and do something else. You can fit a new model (e.g. &lt;a href=&quot;https://ddimmery.github.io/tidyhte/&quot;&gt;a DR-learner with tidyhte&lt;/a&gt;), or you can use our method to do something basically like &lt;a href=&quot;https://en.wikipedia.org/wiki/Platt_scaling&quot;&gt;Platt scaling&lt;/a&gt;, which is what we talk through in the paper: take the aggregated data and find a linear transformation which makes the resulting estimates line up as best they can with the subgroup effects&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn3&quot; id=&quot;user-content-fnref-fn3&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;For the linear rescaling approach to work well, you have to make a lot of assumptions. The review process was very focused on demonstrating that this calibration procedure improves the underlying HTE estimates&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn4&quot; id=&quot;user-content-fnref-fn4&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;, but I think the best way to think about this is as, fundamentally, a diagnostic method. What we’re doing here is showing you how to look at your data and your model and see whether they align in any way whatsoever&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn5&quot; id=&quot;user-content-fnref-fn5&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;. The ultimate plot we landed on (and recommend) looks like the following, which is read basically like a QQ plot:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;716&quot; height=&quot;801&quot; src=&quot;/_astro/image_2.cvnTaFJm_Z3zBCF.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Note that the axes are scaled by the arcsin. In our settings, at least, this was very important, as estimated HTEs tended to have somewhat long tails (you can see that the vast majority of units are estimated to have effects with magnitude less than 1 or so, but there are still some pretty large estimated effects). To be clear, at the tails of the data, the HTE model understates true effects by around 50% (the difference in the blue dashed line defined by the difference-in-means and the red one from the estimated HTEs). When you care about what your intervention is actually doing, that’s an unacceptable error that you must do something to correct.&lt;/p&gt;
&lt;p&gt;In general, I think finite-sample performance for HTEs is vastly underrated in import. There’s some very weird asymptotic shenanigans that happen in some of these HTE papers that I think should be pushed on more. For instance, did you know that causal forests acquire a lot of their nice properties because asymptotically, each terminal node has a constant treatment effect? How often does our data have remotely constant treatment effects within estimated leaves when heterogeneity actually matters? A lot of how well CF will do on your particular data is going to come down to what your true CATE function looks like (just like a lot of other approaches). Luckily, random forests are generally pretty good models, so I don’t think this invalidates much, but it does suggest you need to think hard about model validation. You shouldn’t just rely on asymptotic results.&lt;/p&gt;
&lt;p&gt;Another result from our paper I like is that you can exactly characterize the (conditional) bias that you’ll get from fitting a T-learner with ridge regression: it’s purely a function of the regularization parameter: more regularization means more bias&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn6&quot; id=&quot;user-content-fnref-fn6&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;. With a T-learner, you typically manage the bias-variance tradeoff on the response surfaces &lt;em&gt;individually&lt;/em&gt;, so if you have a very noisy underlying response function, you’ll get a lot of bias &lt;em&gt;even if your true CATE function is very well behaved&lt;/em&gt;! If we want to be serious about estimating HTEs, we should take these kinds of finite sample properties seriously. It’s 100% a finite sample issue, as if your data gets big enough, you won’t need to regularize, so you won’t have any bias.&lt;/p&gt;
&lt;p&gt;In &lt;a href=&quot;https://arxiv.org/abs/2010.11332&quot;&gt;one of my papers&lt;/a&gt; (with David Arbour and Anup Rao), we come at this from a whole different angle, motivating an experimental design based on doing a good job for a particular (knn-based) HTE estimator. We show that one particular view of good design is explicitly trying to minimize the MSE of HTE estimators&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn7&quot; id=&quot;user-content-fnref-fn7&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;. I really like this paper, although it’s admittedly pretty weird&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn8&quot; id=&quot;user-content-fnref-fn8&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;8&lt;/a&gt;&lt;/sup&gt;. In particular, I think the connection between experimental design and the &lt;a href=&quot;https://en.wikipedia.org/wiki/Maximum_cut&quot;&gt;Maxcut problem&lt;/a&gt; is a fun insight that makes &lt;a href=&quot;https://arxiv.org/abs/1312.0531&quot;&gt;Kallus’s great design paper&lt;/a&gt; a little easier to understand.&lt;/p&gt;
&lt;p&gt;Anyway, try talking through all this in a Twitter thread!&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-fn1&quot;&gt;
&lt;p&gt;There are some reasons to expect that in an RCT a T-learner shouldn’t be too bad: you don’t need to correct for propensity scores (they’re all the same), so you really just want a model to help you extrapolate the tiny amount from nearby factuals to counterfactuals. &lt;a href=&quot;https://www.pnas.org/doi/10.1073/pnas.1804597116&quot;&gt;Soren’s paper&lt;/a&gt; on X-learner has some simulations that bear this out. I want to be very clear that I am not recommending that you just stick with T-learners in RCTs, though! I’m only making the very weak argument that it isn’t crazy to think they might do a decent job as a first-cut. &lt;a href=&quot;#user-content-fnref-fn1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn2&quot;&gt;
&lt;p&gt;A lot of very good computer scientists completely balked at the question, though. It requires actually thinking about the specifics of the application rather than just looking at an AUC number and making an evaluation. &lt;a href=&quot;#user-content-fnref-fn2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn3&quot;&gt;
&lt;p&gt;An alternative approach that may be even better is to use the &lt;a href=&quot;https://arxiv.org/abs/1712.04802v7&quot;&gt;Chernozhukov et al. procedure&lt;/a&gt;. We don’t directly compare to this, largely because our motivation starts from the position of diagnostics rather than estimation. &lt;a href=&quot;#user-content-fnref-fn3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn4&quot;&gt;
&lt;p&gt;This was definitely reasonable from their perspective: there’s no sense in which the procedure we’re proposing is a panacea to the problems of HTE estimation (I’m increasingly negative on whether there is such a “correct” procedure). &lt;a href=&quot;#user-content-fnref-fn4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn5&quot;&gt;
&lt;p&gt;The &lt;a href=&quot;https://grf-labs.github.io/grf/reference/test_calibration.html&quot;&gt;GRF package&lt;/a&gt; has something they refer to as a “test” of calibration, but I think it’s an important distinction to provide these kinds of tests in a visual way. You will almost certainly turn up more problems when you are looking at more than just a single number (e.g. criticisms of the NHST paradigm &lt;a href=&quot;https://www.johnmyleswhite.com/notebook/2012/05/14/criticism-3-of-nhst-essential-information-is-lost-when-transforming-2d-data-into-a-1d-measure/&quot;&gt;compressing all information into a single p-value&lt;/a&gt;). &lt;a href=&quot;#user-content-fnref-fn5&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn6&quot;&gt;
&lt;p&gt;Basically, what you get is the following, using the fact that ridge regression is basically just a linear rescaling of OLS (assuming the covariates form an orthonormal basis). The coefficient vector, β, is the set of “true” linear coefficients of the best linear predictor to the CATE function, λ is the regularization parameter. Technically we’re minimizing a bound on MSE (albeit a tight bound). We have a whole section (4.3 and 4.4) problematizing the idea of optimization here, because ultimately you just can’t know enough about your data a priori to make “optimization” something that fully makes sense. In particular, I like the counterexample we define in Section 4.4 which I think makes the dependence on unknown properties (the conditional variance) very clear. &lt;a href=&quot;#user-content-fnref-fn6&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 6&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn7&quot;&gt;
&lt;p&gt;Footnote 7 &lt;a href=&quot;#user-content-fnref-fn7&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 7&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn8&quot;&gt;
&lt;p&gt;The assignment process is basically not randomized, except up to a relabelling (i.e. swapping treatment and control). There are randomized extensions to this that would probably work quite well and efficiently, but which we haven’t spent the time to put together — feel free to reach out if you want to talk about them. &lt;a href=&quot;#user-content-fnref-fn8&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 8&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><category>methodology</category><category>experiments</category></item><item><title>Plagiarism is bad</title><link>https://ddimmery.com/posts/plagiarism-is-bad/</link><guid isPermaLink="true">https://ddimmery.com/posts/plagiarism-is-bad/</guid><description>Papers are what we do: we should try to do them well</description><pubDate>Thu, 04 Jan 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I think it’s important to make the simple point that &lt;strong&gt;plagiarism is bad&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn1&quot; id=&quot;user-content-fnref-fn1&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/strong&gt;. I won’t be drawn into specifics of current events which have precipitated this discussion, but there are a lot of academics saying absurd things that I want to publicly disagree with in order to uphold worthwhile norms. This post is less about questions of academic integrity than straightforward questions of what the academic enterprise is.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;what-are-we-doing&quot;&gt;What are we doing?&lt;/h2&gt;
&lt;p&gt;First, a digression. Latour and Woolgar (1979) is often credited with the idea that the main thing academics do is publish papers. Our incentive systems are fundamentally built around this idea: if you publish more papers that appear in good journals, you will be more successful. It will cause you to be paid more, have more prestige and, generally, wield more power. I used to think that this meant that what many academics were aiming to do was to simply &lt;em&gt;write more papers&lt;/em&gt;. I am increasingly feeling that this is incorrect. Academics want to &lt;em&gt;produce&lt;/em&gt; more papers, but they have no interest whatsoever in writing them&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn2&quot; id=&quot;user-content-fnref-fn2&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;In the course of events, a major perspective has arisen, probably expressed most forcefully like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1178&quot; height=&quot;414&quot; src=&quot;/_astro/image_1.CcZfMP7W_1402dv.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Andrew is a trained economist who does good empirical work in the way trained economists do it. And, as he is telling you here, he does not care that much about his lit review section. To be a bit more blunt, I think the argument is basically that empirical social scientists aren’t &lt;em&gt;writing papers&lt;/em&gt;, we’re &lt;em&gt;producing estimates&lt;/em&gt;. We produce a couple of these estimates per paper, and they are the only actual information in the paper. We’re forced to surround these numbers with words because of arcane medieval institutions, but we all recognize that this is absurd and nobody cares about the &lt;em&gt;words&lt;/em&gt;, only the &lt;em&gt;numbers&lt;/em&gt;. The right way to read a paper is to skip all the textual mumbo-jumbo, look at the charts, see the numbers, then maybe read the methods section if their approach isn’t obvious. This is reflected by the way we do meta-analysis: each paper is one dot on a single forest chart.&lt;/p&gt;
&lt;p&gt;To be clear, I think this is a heinous misrepresentation of what we should think of ourselves as doing. If what we were doing actually mattered, I might even say that I think this view is evil.&lt;/p&gt;
&lt;h2 id=&quot;ok-but-what-are-we-doing&quot;&gt;Ok, but what &lt;em&gt;are&lt;/em&gt; we doing?&lt;/h2&gt;
&lt;p&gt;The work of quantitative social science is to take an irreducibly complex system and reduce some aspect of it down to a 20 page pdf. If we have even the slightest amount of humility, we should instantly understand that this is an impossible task. It is an even more impossible task to reduce that same complex system down to a few quantitative estimates: &amp;#x3C;20 bits of information&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn3&quot; id=&quot;user-content-fnref-fn3&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;. The reason we have 19.9 pages of text around those numbers is for a few reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;because we’re trying to be humble by acknowledging all of the uncertainty and context around this impossible task&lt;/li&gt;
&lt;li&gt;because we’re trying to acknowledge all of the other human effort that has been put into understanding this aspect of the world before (“standing on the shoulders of giants”)&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn4&quot; id=&quot;user-content-fnref-fn4&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The idea that either objective is well served by copying from the abstract of another person’s work is starkly offensive. It brings to mind a conversation I was having about Ian Hacking the other day. One of the truly remarkable things he does in his writing is create fluent and meaningful reviews of complex work by other people. That it is so easy to read is because he takes the time and effort to translate that other work to the specific questions and topics he’s aiming to consider. This is a monumental effort! It requires a detailed understanding of both the task he has set before himself (e.g. “what do we know about what science is?”) and each of the distinct efforts before that touch on this question — including all the myriad ways that those prior efforts failed to answer the fundamental question, answered a slightly different question or otherwise went astray.&lt;/p&gt;
&lt;p&gt;Is what we’re doing different than this? Fundamentally, I argue it is not. Unless we are completely faithfully replicating an analysis that has been done before&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn5&quot; id=&quot;user-content-fnref-fn5&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;, we ought to have some fresh perspective we are bringing to the table: the relationship between the current work being performed and what has been done in the past will not be the same as pre-existing work. I think the discussion about copying summaries of papers back and forth completely misses the task. A much better term than “literature review” is, I think, “related work”. It highlights that what is being done in the section is highlighting &lt;em&gt;connections&lt;/em&gt; between works. Why on earth would you just provide a &lt;em&gt;generic&lt;/em&gt; summary of someone else’s work in your paper? A good summary of related work should be opinionated and it should deal in comparisons: it should be providing a contribution in its own right as a way of synthesizing existing work to come to conclusions about what is known, what isn’t known, and what the strengths and weaknesses are of the existing body of work.&lt;/p&gt;
&lt;p&gt;This is obviously not easy, and for shape-rotators like myself, this isn’t exactly work that is always &lt;em&gt;pleasant&lt;/em&gt;. But, like, it’s part of the job, man.&lt;/p&gt;
&lt;p&gt;I suppose the counter-argument is that time spent working on related work is time &lt;em&gt;not&lt;/em&gt; spent working on the quantitative estimates. That’s true, but there are two major counterarguments: (i) the thing we’re producing is the &lt;em&gt;paper&lt;/em&gt;, and the related work section is a meaningful fraction of that: Spend the time to make it better. (ii) Specialization means not everyone has to spread their time among all sections in the paper. If you’re doing a shitty job on one part of a paper, add a coauthor that can do a better job on that part&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn6&quot; id=&quot;user-content-fnref-fn6&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;h2 id=&quot;in-defense-of-thinking&quot;&gt;In defense of thinking&lt;/h2&gt;
&lt;p&gt;My point is simple. For historically contingent reasons (not necessarily &lt;em&gt;good&lt;/em&gt; reasons), academia has chosen that the primary way that we should communicate is through the medium of the academic paper. Given this choice, I think it’s pretty important that we actually care about what we can communicate through this medium, which has the capacity to share much more than a few quantitative estimates.&lt;/p&gt;
&lt;p&gt;An example given by Matt Blackwell&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn7&quot; id=&quot;user-content-fnref-fn7&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;7&lt;/a&gt;&lt;/sup&gt; is illustrative:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1184&quot; height=&quot;604&quot; src=&quot;/_astro/image_2.DO06OeEX_1EKHwd.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;This was particularly funny to me because I just wrote a paper where this common boilerplate sentence was probably my most highly edited one through the entire revision process. I will soon publish a broader blogpost around &lt;a href=&quot;https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3875850&quot;&gt;this (now forthcoming) paper&lt;/a&gt;, but first I will quote the relevant section:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This relationship closely accords with the definition of calibration in classiﬁcation and regression problems (Kuleshov et al. 2018), with &lt;strong&gt;the added challenge resulting from the fundamental problem of causal inference: Labels (i.e., ITEs) are never observed (Holland 1986).&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The bolded sentence roughly accords with Matt’s example of how people usually cite Holland (1986). Crucially, the boilerplate version is not useful for the specific point I wanted to make in this selection! I specifically wanted to indicate (by my use of the very machine-learning term “label” when referring to individual treatment effects) the challenge this well-trodden conceptual problem poses for simple supervised learning. This required &lt;em&gt;different words&lt;/em&gt;. It’s my contention that this is almost always the case. If you find yourself repeating something that has been said many times before, maybe you don’t actually need to say it!&lt;/p&gt;
&lt;p&gt;We should therefore not normalize the reuse of other people’s words (suited to one particular context, audience and purpose) and re-use them for our own (different!!) context, audience and purpose. I think it is both true that we have sleep-walked into reusing text pretty commonly, as in Matt’s example, and also that &lt;em&gt;we should not do that&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id=&quot;climbing-off-the-high-horse&quot;&gt;Climbing off the high horse&lt;/h2&gt;
&lt;p&gt;I recognize that it isn’t always possible to achieve the kind of writing that I’m talking about here. We live in a fallen world. I don’t particularly consider myself a good writer or editor, and everyone faces constraints that lead us to behave in ways that we don’t think are fully consistent with our values. But that doesn’t mean that it’s good or neutral when we make those compromises. It is bad. Plagiarism is bad.&lt;/p&gt;
&lt;p&gt;The real problem here is, of course, systemic. We are rewarded for producing as many papers as possible, not particularly for having a well crafted discussion on related work. I do, however, want to at least reinforce the norm here: you &lt;em&gt;should&lt;/em&gt; write your own papers, even the parts you don’t like (or get someone else to write them). You &lt;em&gt;should&lt;/em&gt; care about writing those sections well, even if they aren’t your favorite part of the paper. They are all part of the work you are signing your name to.&lt;/p&gt;
&lt;p&gt;We should not make light of the actual work we do as academics by implying that it is fine to reuse text that is not our own. It is not.&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-fn1&quot;&gt;
&lt;p&gt;Yes, this is also surprising to me. &lt;a href=&quot;#user-content-fnref-fn1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn2&quot;&gt;
&lt;p&gt;I’m very consciously not talking about GPT here, but, like, also that. &lt;a href=&quot;#user-content-fnref-fn2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn3&quot;&gt;
&lt;p&gt;A single number with 4 decimal precision is equal to log₂(10^4) = 13.3 bits, assume there are a couple of estimates. &lt;a href=&quot;#user-content-fnref-fn3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn4&quot;&gt;
&lt;p&gt;Citation also lets us bypass the hard limits of page limits, too — citations let us gesture at much more complicated ideas than we would be able to fully explain in our particular pdf. &lt;a href=&quot;#user-content-fnref-fn4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn5&quot;&gt;
&lt;p&gt;Even in this case, we are different people than the authors of the replicated work and probably have different opinions about how it relates to the world. At the very least, time has passed and the literature is in a different place! &lt;a href=&quot;#user-content-fnref-fn5&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn6&quot;&gt;
&lt;p&gt;Harder to do this on a dissertation which may not be able to be coauthored. But honestly, to a first approximation I’ve only cared about one person’s dissertation (&lt;a href=&quot;https://github.com/fhuszar/thesis/blob/master/submitted/thesis.pdf&quot;&gt;Ferenc Huszár’s&lt;/a&gt;). &lt;a href=&quot;#user-content-fnref-fn6&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 6&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn7&quot;&gt;
&lt;p&gt;I’m taking this example as a jumping off point, I don’t think it’s like, “academic misconduct” to use boilerplate language, and I think his example is a very good one, because tons of people have copied that kind of language. &lt;a href=&quot;#user-content-fnref-fn7&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 7&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><category>metascience</category></item><item><title>Stop looking for the next Twitter</title><link>https://ddimmery.com/posts/stop-looking-for-the-next-twitter/</link><guid isPermaLink="true">https://ddimmery.com/posts/stop-looking-for-the-next-twitter/</guid><description>BlueSky doesn&apos;t solve any of Twitter&apos;s real problems, nor will any other microblog</description><pubDate>Tue, 03 Oct 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Everyone seems to agree now that &lt;a href=&quot;https://kevinmunger.substack.com/p/ultima-ratio-twitterum&quot;&gt;Twitter/X is bad&lt;/a&gt;. They’re right. But the desire to recapture some idyllic ahistorical version of Twitter is wrongheaded. The nature of the platform has serious problems that cannot be solved by a different owner, CEO or by changes in content moderation/ranking. The medium is the message, and the medium is, overall, pretty bad for a lot of what we use it for.&lt;/p&gt;
&lt;p&gt;I’m going to trace through my argument around why the design of microblogging platforms are bad and then sketch out how I’m personally choosing to engage with them in light of this badness.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;all-microblogging-is-fundamentally-the-same&quot;&gt;All microblogging is fundamentally the same&lt;/h2&gt;
&lt;p&gt;There are differences between microblogging sites (I’m primarily thinking about Twitter/X, BlueSky, Mastodon and Threads, but I imagine anything else basically fits the same mold). Nevertheless, I think the core properties are basically the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Short text snippets&lt;/strong&gt;. I think this is definitional. If it weren’t based around this, it wouldn’t be microblogging.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Virality&lt;/strong&gt;. Content gets out of the small community in which it’s posted. This is fun (at first) for the poster and fun for the viewer. The nature of a viral platform means when you see stuff from outside your community, it has already been vetted, so it is almost definitionally ‘highly engaging’ for some highly specific definition of those words.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Simple engagement possibilities&lt;/strong&gt;. There are very simple, easy ways to engage with the content you see. A “like” or a “reskeet” is just a click of the mouse away. You don’t have to think very hard or construct a complete and cogent thought in order to “engage” with what you see&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn1&quot; id=&quot;user-content-fnref-fn1&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A “feed” of posts&lt;/strong&gt;. You are deluged with an infinitely scrolling progression of more content (making you &lt;a href=&quot;https://www.youtube.com/watch?v=i2qx5P0kQSM&quot;&gt;infinitely content&lt;/a&gt;, right?).
There are a lot of other features that matter on the margin. Exactly how long is a post? Can you Quote-tweet / Retweet? What content is allowed / promoted? This stuff matters, but I don’t think it really gets at the core of what microblogging is. (As an aside, I think we as social scientists are much better at testing the differences between possible affordances &lt;em&gt;within&lt;/em&gt; a single platform than we are at testing the big meaningful differences &lt;em&gt;between&lt;/em&gt; platforms).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The thing that I find really clear about this is that these affordances are not built to enable deep and thoughtful exchange of ideas. They’re built to enable surface-level engagement that you’ll come back for again and again.&lt;/p&gt;
&lt;h2 id=&quot;some-microblogging-is-different-but-not-better&quot;&gt;Some microblogging is different (but not better)&lt;/h2&gt;
&lt;p&gt;I think Jack may have learned exactly the wrong lessons from Twitter. It seems that the AT protocol which undergirds BlueSky is &lt;a href=&quot;https://atproto.com/guides/overview#speech-reach-and-moderation&quot;&gt;fundamentally built&lt;/a&gt; around the idea that &lt;em&gt;Jack shouldn’t have to be the person that everyone gets mad at&lt;/em&gt;. You don’t like how your feed is ranked? Not his fault, that’s a different layer than he controls. Don’t like how content moderation works? Well, you should be on a &lt;a href=&quot;https://blueskyweb.xyz/blog/4-13-2023-moderation&quot;&gt;different application with different rules&lt;/a&gt;. This goes to extremes with platforms like Mastodon, where some servers won’t do any moderation whatsoever, while others will ban you aggressively for not giving adequate content warnings. This is &lt;em&gt;different&lt;/em&gt; than other microblogging services, but I don’t think there’s much of a way to say it’s &lt;em&gt;better&lt;/em&gt;. For instance, &lt;a href=&quot;https://www.theverge.com/2023/7/24/23806093/mastodon-csam-study-decentralized-network&quot;&gt;the massive CSAM problems there&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;How this has worked in practice with AT/BlueSky is kind of different. BlueSky is the only real application built on AT, which means that Jack doesn’t just get to sit around dealing with AT issues, he has to deal with BlueSky issues, too. All of a sudden (and despite his original intentions), he’s having to manage an actual platform rather than just a protocol. This means that BlueSky is (slowly) developing content moderation standards, some of which are actually implemented at the protocol layer (e.g. in AT rather than in BlueSky). As I understand, CSAM, for instance, is a protocol-level concern for AT, it is not federated out to individual applications. I can’t see how this won’t continue to be a giant wellspring of conflicts.&lt;/p&gt;
&lt;h2 id=&quot;what-are-we-doing-on-here&quot;&gt;What are we doing On Here?&lt;/h2&gt;
&lt;p&gt;There are two main things I think happen on microblogs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;**Discovery. **There’s nothing I’ve seen that’s better at delivering interesting papers and news items to the front of my face (i.e. “pointing at things”). Microblogging is extremely effective at making serendipitous connections. Getting pointers to things of interest from people within a hop or two of you in a network which you form according to your whims is extremely powerful!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Jokes/entertainment&lt;/strong&gt;. There’s a reason that dril is the greatest poster on microblogs. One-liners are a classic joke format, and they’re enjoyable to consume on a feed (perhaps especially a feed that also has a lot of self-important academics on it).
What I think &lt;em&gt;doesn’t&lt;/em&gt; happen, is anything very much like “discussion”. Discussion requires grace between interlocutors, which is hard to extend given the threat of virality inherent in the platform. Discussion requires context, which is destroyed with virality and its associated &lt;a href=&quot;https://journals.sagepub.com/doi/10.1177/1461444810365313&quot;&gt;context collapse&lt;/a&gt;. And important discussions require depth, which is not really possible in short snippets of text. I also think that &lt;em&gt;privacy&lt;/em&gt; is often crucial to good discussion&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn2&quot; id=&quot;user-content-fnref-fn2&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;. Real privacy is anathema to virality: you can’t really have both. When discussions are ephemeral and low-cost its much easier to try out ideas to see if they seem compelling and convincing.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The easiest discussions to have on microblogs are ones in which the interlocutors already agree with one another and share full context (or which are just pointing to something and saying, essentially “good” or “bad”). In this case, a few words are all it takes to explain what one means and make one’s position clear. As discussions require more nuance and rely on context that is &lt;em&gt;not&lt;/em&gt; shared (i.e. on more complex topics), then the goal should not be to write in chunks of a few hundred characters.&lt;/p&gt;
&lt;p&gt;I think that a lot of the appreciation of tweet-length communication is a reflection of a failure of academic writing. For a lot of research, the first time someone takes the time to make it broadly accessible is when a tweet-thread is written out&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn3&quot; id=&quot;user-content-fnref-fn3&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;. I’ll bite the bullet, and freely admit that was true for me with our ICML paper about online balanced experimental design. The version we submitted (and which was accepted) was essentially just math. The paper’s structure was, essentially, introduction → math → simulations → the end. Reviewers didn’t &lt;em&gt;love&lt;/em&gt; it, but they were &lt;em&gt;intimidated&lt;/em&gt; by it&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn4&quot; id=&quot;user-content-fnref-fn4&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;. We &lt;a href=&quot;https://arxiv.org/abs/2203.02025&quot;&gt;cleaned it up&lt;/a&gt; for the camera-ready version (yes, that’s the easy-to-digest version), but the first time we really thought about how to communicate our results to a broader audience was &lt;a href=&quot;https://twitter.com/DrewDim/status/1556648259787149312&quot;&gt;when I wrote about it for Twitter&lt;/a&gt;. That’s bad!&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn5&quot; id=&quot;user-content-fnref-fn5&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt; While one solution to this problem is to just write papers that are more accessible, the incentives are currently entirely against this. Being rigorous but difficult to understand is, often, a &lt;em&gt;very&lt;/em&gt; &lt;em&gt;good&lt;/em&gt; move if your primary incentive is publication.&lt;/p&gt;
&lt;p&gt;Twitter, however, has incentives which at least preference some amount of accessibility. If you want your work to be shared and consumed, you have to hook people and encourage them to “engage.” In contrast to typical academicese, I think this is a nice change of pace, and is one of the reason I sometimes appreciate them. “Engagement,” however, is quite different than “accessible.” To be accessible, I think you want things like easy hyperlinks/citation, formatting, figures, quotations and, yes, more than a couple hundred characters. Maybe you also want to throw in some code or math as a treat! We can obviously do better than tweets for this.&lt;/p&gt;
&lt;h2 id=&quot;what-am-i-doing&quot;&gt;What am I doing?&lt;/h2&gt;
&lt;p&gt;I’m treating microblogging for what it is. I’m essentially indifferent between services, as I don’t think the differences are that meaningful relative to what’s the same. I enjoy finding things on these platforms, so I will peruse them, but I will not expect discussion, and I won’t use them as if I do. Since I think threads about new work are not a particularly good way to provide digestible versions of papers, I will avoid making them. I don’t want to push for “engagement” with my work; I want people to understand it and its context. Instead, I will share new work, and (if appropriate) will link to a longer-form accessible introduction for that work in this space (or somewhere like it)&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn6&quot; id=&quot;user-content-fnref-fn6&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;. In short, I will try to make it easy to &lt;em&gt;discover&lt;/em&gt; my work on microblogs, but I will not attempt to &lt;em&gt;explain&lt;/em&gt; my work in that setting. The platform is not conducive to such explanation. I may also make jokes, but, well, most of those are for the groupchats where I can be &lt;em&gt;spicy&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;I think this is ultimately the kind of recommendation Neil Postman makes about television in *Amusing Ourselves to Death, *too: TV is fantastic entertainment device, but &lt;em&gt;don’t mistake it for something that it’s not&lt;/em&gt;. Don’t treat it as a medium of explanation or of news or of education. What it &lt;em&gt;does&lt;/em&gt; is entertain.&lt;/p&gt;
&lt;p&gt;Microblogging platforms are not built for good discussion. I will avoid a poor facsimile of conversation there, and have conversations in places where those conversations can be at their best. For me, this means that my &lt;em&gt;conversation&lt;/em&gt; happens outside of the “clearnet”. I have a variety of WhatsApp / Slack / Discord groups for talking with collaborators or just randomers with shared interests. This is, I believe, a much more productive approach than trying to make microblogging into something that it can’t ever really do well. In these environments, you can set up affordances to enable the kind of discussion you want: you can make it easy to share LaTeX, or code. You can make spaces for highly moderated discussions or free-flowing sharing of memes. But most fundamentally, you can retain so much more control and privacy&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn7&quot; id=&quot;user-content-fnref-fn7&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;h2 id=&quot;build-alternative-communities&quot;&gt;Build alternative communities!&lt;/h2&gt;
&lt;p&gt;About a year ago I started up a Discord for discussion about experimentation which ultimately hasn’t seen much discussion in it. I’m continuing to hang out there, so if anyone wants somewhere outside of the clearnet to talk about experiments, &lt;a href=&quot;https://discord.com/invite/MrxjbHc3jD&quot;&gt;feel free to join&lt;/a&gt;! Or come there to tell me about why this post is bad.&lt;/p&gt;
&lt;p&gt;But also, use microblogs to create your own semi-private communities and make them easy to discover! The magic of the internet is that it’s all code and you can create whatever you want within those (weak) bounds. There are a ton of tools out there to create whatever kind of community you want, and you don’t need to troll around for “the next Twitter.” &lt;strong&gt;Twitter wasn’t ever all that good&lt;/strong&gt;, and you can just go ahead and make the &lt;em&gt;better&lt;/em&gt; community that you’d rather see! Many of those communities won’t work&lt;sup&gt;&lt;a href=&quot;#user-content-fn-fn8&quot; id=&quot;user-content-fnref-fn8&quot; data-footnote-ref=&quot;&quot; aria-describedby=&quot;footnote-label&quot;&gt;8&lt;/a&gt;&lt;/sup&gt;, and that’s totally fine; the process of figuring out what works is how we find a space for online discussion that’s &lt;em&gt;better&lt;/em&gt; than Twitter, which is what we should aspire to, anyway.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;876&quot; height=&quot;606&quot; src=&quot;/_astro/image_1.DUx-uEhe_Z2a4RND.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;What AI thinks “a twitter-like website” looks like. It isn’t &lt;em&gt;wrong&lt;/em&gt;.Thank you for reading Drew’s News. Now please microblog this in a long thread.&lt;/p&gt;
&lt;section data-footnotes=&quot;&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-fn1&quot;&gt;
&lt;p&gt;Note: this is bad. My hot take is that thinking is good and we should try to do more of it and improve how we do it. The simple binary “engagement” actions constrain human behavior into radically low dimensional signals. This is basically what Kevin means when he talks about &lt;a href=&quot;https://kevinmunger.substack.com/p/the-discourse-is-the-cybernetic-event&quot;&gt;online platforms making us behave like machines&lt;/a&gt;. This is not good! There are no posts for which my reaction can truly be summed up by a binary “Like” action! A RT sometimes is an endorsement, but sometimes it isn’t! None of this is expressible in the platforms! &lt;a href=&quot;#user-content-fnref-fn1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn2&quot;&gt;
&lt;p&gt;By privacy, I mean that the ability to pretty strongly control how wide the distribution of your content is (such as by sending something in a group chat where only your wife and brother-in-law can read it). Encryption, cybersecurity and data protection are important components of privacy, but not what I’m talking about. &lt;a href=&quot;#user-content-fnref-fn2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn3&quot;&gt;
&lt;p&gt;An analogy I like is that threads are in the style of a poetry slam (derogatory). It’s not inherently “bad”, but it is a very distinct style which focuses on having meaningful “beats” every couple dozen words or so. Good tweets in a thread often are basically glorified figures (with caption). That’s a very constraining style! &lt;a href=&quot;#user-content-fnref-fn3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn4&quot;&gt;
&lt;p&gt;Comments were essentially “the problem seems important and there’s a lot of math which seems correct”. Some reviewers even called it easy to read, which we all had a good laugh over. The math was abstruse and we literally introduced a parameter without ever explaining why it was important! &lt;a href=&quot;#user-content-fnref-fn4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn5&quot;&gt;
&lt;p&gt;It also hasn’t always been this way. A good example is Norbert Wiener’s Cybernetics, which is a ludicrous book in a lot of ways, but it was also not targeted solely at an in-group of very technical readers. Only some chapters are. &lt;a href=&quot;#user-content-fnref-fn5&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn6&quot;&gt;
&lt;p&gt;I think an Oped length of about 1000 words is a good one to shoot for (don’t check how long this post is, sorry), e.g. &lt;a href=&quot;https://www.nowpublishers.com/article/Details/QJPS-16112&quot;&gt;Alex’s nice paper&lt;/a&gt;. &lt;a href=&quot;#user-content-fnref-fn6&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 6&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn7&quot;&gt;
&lt;p&gt;Control and privacy seem to cut against the democratizing impulse, but they don’t have to. You can, for example, be gracious in admitting people and harsh in throwing them out when they don’t abide by community norms. The key democratizing element isn’t in making everything public, but in giving people a chance. Being public can actually be much worse in some cases: Imagine saying something kind of dumb and going viral as a grad student (when we are all very silly). Not good! &lt;a href=&quot;#user-content-fnref-fn7&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 7&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-fn8&quot;&gt;
&lt;p&gt;I don’t even know what “work” means here. Just think about this community formation as expanding the groupchats you’re already having good discussions in. Is it a “failed” groupchat if you stop talking in it at some point? Obviously not! Is a coffee meeting a failure if it doesn’t result in a permanent collaboration? Spin something up and see how it goes! &lt;a href=&quot;#user-content-fnref-fn8&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 8&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><category>social-media</category><category>technology</category></item><item><title>A Blueprint for the Regulation of Tech</title><link>https://ddimmery.com/posts/a-blueprint-for-the-regulation-of-tech/</link><guid isPermaLink="true">https://ddimmery.com/posts/a-blueprint-for-the-regulation-of-tech/</guid><description>Counterfactuals are the key to accurately assessing the risks of online platforms</description><pubDate>Mon, 11 Sep 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;The US2020 Facebook and Instagram Election Project (US2020 from here out), the first four papers of which were recently published in Science and Nature, can be the blueprint for meaningful regulation of large online platforms. It’s crucial not just to be satisfied in access to data, but in access to rigorous tests of how changes on platforms affect society.&lt;/p&gt;
&lt;p&gt;The key connection is to avoid examining the project through a purely academic lens about academic research and the knowledge gained through the studies.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://www.science.org/content/article/does-social-media-polarize-voters-unprecedented-experiments-facebook-users-reveal&quot;&gt;news post at Science by Kai Kupferschmidt&lt;/a&gt; focuses on this dimension, with input from Joe Bak-Coleman’s saying that “This is not how research on the potential dangers of social media should be conducted”. He focuses on the research and the project as a model for gaining academic knowledge.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://www.science.org/doi/10.1126/science.adi2430&quot;&gt;commentary by project rapporteur Michael Wagner&lt;/a&gt; focused, too, on the project as largely academic in nature. Wagner gets one element of the project exactly correct from this dimension: It requires the goodwill of Meta to work correctly, which makes a difficult model for future scholarly work.&lt;/p&gt;
&lt;p&gt;Meta &lt;a href=&quot;https://about.fb.com/news/2023/07/research-social-media-impact-elections/&quot;&gt;wants the project interpreted solely as the results of academic research based on Nick Clegg’s news post&lt;/a&gt;: “Its findings will be hugely valuable to us, and we hope they will also help policymakers as they shape the rules of the road for the internet”. The &lt;em&gt;findings&lt;/em&gt; of these studies should shape discourse on regulation, and not the &lt;em&gt;structure&lt;/em&gt; of the collaboration itself. These findings are (overall) pretty positive for Meta. They show that algorithms are *powerful *(they change a lot about on-platform behavior), but they aren’t &lt;em&gt;scary&lt;/em&gt; (they don’t swing elections). There are subtleties here, and I don’t mean to get into a detailed accounting of the exact substantive results, but I think this is the reading of the Project Meta wants to push to advertisers (the former story) and to regulators (the latter one).&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/brandonsilverm/status/1684976994449272832?s=20&quot;&gt;Brandon Silverman gets nearly to the quick&lt;/a&gt;: “That’s why ultimately &lt;em&gt;we need regulation&lt;/em&gt; if we want more of this sort of thing and for me, that represents one of the biggest promises of the Digital Services Act[…]” We should think about regulation as a way to free this kind of information from tech companies. But he doesn’t go nearly far enough. A model of data-sharing (proposed in the next tweet) does not go far enough, and it sets up perverse incentives for companies to neglect rigorous measurements of changes that might place them in a negative light.&lt;/p&gt;
&lt;p&gt;My argument in this piece is that the structure of collaboration of US2020—sophisticated experts telling online platforms what they must measure about societal impact—should be the future of the regulation of the internet. Don’t simply accept the framing that Nick Clegg pushes, that we should take these findings and make policies based solely on them (implicitly assuming they are the only evidence we might get). The way platforms work is constantly changing: we should not seek perfect &lt;a href=&quot;https://twitter.com/aecoppock/status/1684911539390652416?s=20&quot;&gt;generalizability of the findings&lt;/a&gt;, we should instead seek systems which allow us to continue to probe and measure how these platforms work flexibly, as they change.&lt;/p&gt;
&lt;h2 id=&quot;what-do-we-want-to-measure&quot;&gt;What do we want to measure?&lt;/h2&gt;
&lt;p&gt;Many of the most important questions we have about tech’s relationship to society are counterfactuals: If Facebook were otherwise identical but ranked Feed chronologically rather than by an algorithm, would there be more or less hate? If YouTube made different choices in recommendations, would it make people less extreme? A counterfactual, fundamentally, asks what would happen were the world just a little bit different. When thinking about the regulation of technology, we’re asking questions like these: if Facebook were to operate differently in some way, would society be better or would it be worse? This embeds two questions: One is a scientific question: what would society be like if Facebook were different? The second is a question of values: Would that counterfactual society be better or worse?&lt;/p&gt;
&lt;p&gt;The scientific question can be answered through randomized control trials (RCTs). Such RCTs, however, can only truly be implemented by and within these large tech platforms, so under the status quo the question of values can only be answered by people within those walls. Engineers, data scientists, managers and executives of tech companies: mostly good hearted people, but people who work within institutions that require they think about the good of the platform rather than the good of society.&lt;/p&gt;
&lt;p&gt;I worked within Meta for years on improving the process through which the company evaluated potential counterfactual versions of itself – in other words, testing changes through A/B tests. The entire business of software development is to try lots of stuff out but only keep the things that work towards the business’s goals. These goals are expressed in numbers (“KPIs” or “metrics”). &lt;a href=&quot;https://ax.dev/&quot;&gt;My team built machine learning tools&lt;/a&gt; to realize these business goals. When business values change, so too, can the platform. Look no further than &lt;a href=&quot;https://about.fb.com/news/2018/01/news-feed-fyi-bringing-people-closer-together/&quot;&gt;Facebook’s 2018 pivot to “meaningful social interactions”&lt;/a&gt;. Once new numbers are chosen as the target, machine learning gears turn and the platform (in many ways a black box to everyone) pivots on a dime to optimize these new metrics.&lt;/p&gt;
&lt;p&gt;Many of these business values are widely held societal norms: nobody in tech wants more spam or child sexual abuse material, for instance. As such, companies develop sophisticated (albeit &lt;a href=&quot;https://www.washingtonpost.com/technology/2023/06/07/meta-instagram-child-porn/&quot;&gt;imperfect&lt;/a&gt;) systems for detecting and removing such content and ensuring that it is not distributed widely. Other metrics, like the time spent on a platform, are less clear cut: essentially all internet platforms prize this as a KPI, but it does not necessarily align with what is best for society.&lt;/p&gt;
&lt;p&gt;Democratic societies have systems for answering questions of values: we elect representatives who enact policies so that society embodies the values we care about. When such values are contentious, there is conflict, of course, but there is a peaceful process for resolving that conflict through our institutions. Tech lacks the mechanism to ensure that it embodies societal values: even market pressure isn’t straightforward, since usage is free thanks to advertising.&lt;/p&gt;
&lt;h2 id=&quot;who-gets-to-measure-them&quot;&gt;Who gets to measure them?&lt;/h2&gt;
&lt;p&gt;The only real counterfactual evidence about tech’s effects is controlled by tech itself. This is the promise of US2020, a project I worked on while at Meta. The unique power of this project is that it reveals the counterfactuals which—but for the press of a button—Facebook can decide to make reality. Asking ‘Should Facebook remove algorithmic ranking?’ contains both a question of science and a question of values — and this project answers the question of science, &lt;a href=&quot;https://doi.org/%20doi:10.1126/science.abp9364&quot;&gt;showing precisely what would happen if Facebook did no algorithmic ranking on Feed&lt;/a&gt;. As a result, the question of values is finally exposed to democratic scrutiny. Do we measure the right things to effectively answer that question? The way forward can only be an iterative refinement of asking the question and trying to improve the answers we get.&lt;/p&gt;
&lt;p&gt;In short, the Election Project is a blueprint for the effective regulation of technology companies. The approach is straightforward and consistent with the language of &lt;a href=&quot;https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32022R2065&amp;#x26;qid=1666857835014#d1e3513-1-1&quot;&gt;Chapter III, Section 5 of the Digital Services Act&lt;/a&gt;. Regulators can require that for important, societally relevant changes, Very Large Online Platforms must run and report the results of RCTs. These are far more informative than audits of the &lt;em&gt;processes&lt;/em&gt; used in these platforms or providing data access without counterfactuals, or trying to explain the precise details of how underlying machine learning systems work (which are mostly black boxes to everyone internally, too). To reiterate: in general, many of the most important systems at VLOPs are not truly “understood” by those who create them. Rather, they are refined by measuring what they do, and launching the changes that push those measurements in a direction that those measurements deem positive.&lt;/p&gt;
&lt;p&gt;Philipp Lorenz-Spreen has already compellingly argued that &lt;a href=&quot;https://reclaimingautonomyonline.notion.site/reclaimingautonomyonline/Researcher-access-to-platform-data-under-the-DSA-Questions-and-answers-8f7390f3ae6b4aa7ad53d53158ed257c#82d252b2543f43cbb35489209884a230&quot;&gt;Article 40 of the DSA is a way to free the results of internal A/B tests to the public&lt;/a&gt;. Tech companies are already running lots of A/B tests, so maybe we can just require them to share those results! This is a very positive step, but it isn’t enough. The problem with limiting ourselves to these tests is that platforms can simply stop doing them on issues they feel present a regulation risk. We’re back in the same place we started where our ability to understand counterfactuals is dependent on the platforms’ goodwill.&lt;/p&gt;
&lt;p&gt;Platforms already limit what is measured internally for this reason. A direct example of this is race in the US. Put simply, Meta works hard to limit what it knows about race in order to preclude legal risks like &lt;a href=&quot;https://www.nytimes.com/2019/03/28/us/politics/facebook-housing-discrimination.html&quot;&gt;it faced around housing discrimination in 2019&lt;/a&gt;. When I left Meta, the primary way concerns about disparate impact were examined were through zip-code level demographics. This process ensures that individual users’ race was not &lt;em&gt;explicitly&lt;/em&gt; inferred, so race cannot be &lt;em&gt;explicitly&lt;/em&gt; taken into account in decisions. To be clear, this does not mean that systems do not have &lt;a href=&quot;https://www.justice.gov/crt/fcs/T6Manual7&quot;&gt;disparate racial impacts&lt;/a&gt;. It does, however, make it very hard to measure when those disparate impacts might exist.&lt;/p&gt;
&lt;p&gt;There are also precedents for requirements to run RCTs, such as with the &lt;a href=&quot;https://assets.publishing.service.gov.uk/media/6363b00de90e0705a8c3544d/CMA_Experiments_note.pdf&quot;&gt;UK’s Competition and Markets Authority requirement that Google test changes to third-party cookies&lt;/a&gt;. The logic here was that Google’s change to how cookies work might lead to big changes in how the advertising market works. Without understanding that impact, the regulator can not make an informed decision about whether it was anti-competitive or not. Hence, require Google to measure the impact, since they’re the only people who can.&lt;/p&gt;
&lt;p&gt;More traditionally, this is key to the FDA’s regulation of &lt;a href=&quot;https://www.fda.gov/patients/drug-development-process/step-3-clinical-research&quot;&gt;food and medicine&lt;/a&gt;. The regulator is not generally performing the clinical trials to demonstrate safety itself: it instead requires that the would-be producer carry out the required tests, and ensures that those tests meet the standards of scientific rigor necessary to ensure safety. We think it’s important to verify that drugs meet at least a minimal standard before pushing them out broadly to all citizens. The same should be true for large changes to internet platforms. Note that the structure of clinical trials under the FDA would be exactly subject to the same critiques that are being made of US2020.&lt;/p&gt;
&lt;p&gt;The point is not who is actually running the test, but who is defining what particular tests must be conducted and how resulting outcomes must be measured. As an insider to this process, let me be very clear: US2020 took &lt;em&gt;incredible&lt;/em&gt; care that external academics understood in detail the process by which concepts were operationalized and measured. A lot of the back-and-forth in the collaboration was specifically about this: academics didn’t understand how data is collected and stored internally, and internal researchers needed clear operationalizations to measure the concepts requested. I think I saw someone throw out that there were around 1000 variables to figure this out for.&lt;/p&gt;
&lt;p&gt;The DSA provides an avenue for this kind of accountability through counterfactual evidence, but it isn’t through Article 40. Instead, it’s through Article 34. Allow me to quote:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Providers of very large online platforms and of very large online search engines shall diligently identify, analyse and assess any systemic risks in the Union stemming from the design or functioning of their service and its related systems, including algorithmic systems, or from the use made of their services.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;By suggesting that these risks arise from the design or functioning of the service, this sentence invokes counterfactuals. The question at play is whether platform design &lt;em&gt;causes&lt;/em&gt; these risks. The only valid way to assess this is through counterfactuals as measured through randomized control trials. The counterfactual risk is what VLOPs should demonstrate in their risk assessments. I recognize that this plain-english reading is not formal legal analysis (and I am not a lawyer). Given the latitude of regulators to choose how this law should be interpreted, I hope that they do so in the way that will give them actual answers to the societally important questions of counterfactual risk. US2020 shows them how they can do that. Unfortunately, based on the &lt;a href=&quot;https://op.europa.eu/en/publication-detail/-/publication/c1d645d0-42f5-11ee-a8b8-01aa75ed71a1/language-de&quot;&gt;Commission’s current example of how to apply the risk management framework&lt;/a&gt;, this is not likely to be the approach taken to interpreting the DSA.&lt;/p&gt;
&lt;h2 id=&quot;when-are-they-measured&quot;&gt;When are they measured?&lt;/h2&gt;
&lt;p&gt;Time is a crucial element of this story. The number one complaint by everyone involved in US2020 is the time it took to make it happen. As &lt;a href=&quot;https://kevinmunger.substack.com/p/mark-zuckerberg-wants-you-to-think&quot;&gt;Kevin Munger emphasizes, it was 32 months after the US2020 studies were actually performed that they were published&lt;/a&gt;. Part of that delay was because of peer review (note that the chronological feed paper was originally received by Science on March 7, 2022, but was only published on July 27, 2023. The paper was definitely improved in that time, but it goes without saying that nothing about the intervention or outcome measurement could have been improved or changed as a result of this peer review. It had already happened.&lt;/p&gt;
&lt;p&gt;Surely nothing changed about Facebook in that time, right? Well, shortly after submission of chrono-feed, on July 27, 2022, Mark Zuckerberg made an announcement on the Q2 earnings call: “&lt;a href=&quot;https://investor.fb.com/investor-events/event-details/2022/Q2-2022-Earnings/default.aspx&quot;&gt;Right now, about 15% of content in a person’s Facebook feed and a little more than that of their Instagram feed is recommended by our AI from people, groups, or accounts that you don’t follow. We expect these numbers to more than double by the end of next year.&lt;/a&gt;” Shit. It’s at this point that I’ll note we found clear heterogeneity of the effects of chronological feed on variables like how much uncivil content and slurs show up on Feed, as well as on-platform political behavior on the dimension of inventory size. When there’s more content Feed could show you, there’s more potential for Feed algorithms to change what you see.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1032&quot; height=&quot;572&quot; src=&quot;/_astro/image_1.DUFILDiB_Z1LD1L2.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Larger inventory is associated with larger effects on on-platform political behavior.Kevin and I have a &lt;a href=&quot;https://osf.io/w38ye&quot;&gt;new working paper&lt;/a&gt; showing exactly how poorly agnostic approaches to generalizability fare when reality refuses to stay fixed. When reality is changing at internet speed, then it’s necessary that our knowledge generation process matches that speed. US2020 could do better on this. A lot of work had to be done to mitigate the risks that were inherent in the project as the first of its kind. There was a whole software infrastructure that had to be built from the ground up for protecting privacy, which was done at a pretty incredible speed. There was also a lot of work to build up the internal processes to make everything work both within the collaboration and within Meta (e.g. legal and privacy reviews to make sure user data was appropriately protected). And as stated above, there was a whole arduous process of defining meaningful operationalizations of everything: to a real extent, the scientific language of internal and external researchers wasn’t exactly the same, so translation was required.&lt;/p&gt;
&lt;p&gt;If we’re thinking about an ongoing regulatory process, however, a lot of these concerns go away: an infrastructure and set of systems will be set up (by necessity) to streamline processes. Variable definitions will be negotiated over time, so that’s largely just a fixed cost per variable. If the output is regulatory rather than academic, the results wouldn’t need to be gated by the fickle peer review process (just government bureaucracy!).&lt;/p&gt;
&lt;p&gt;Defining appropriate implementation of the regulations, too, must be a negotiated and long-term process. Meta has spent years defining specific internal metrics to understand the best dimensions of platform behavior to measure for business purposes. We cannot expect US2020 to have gotten the right societally important dimensions correct on the first try. DSA requires platforms to measure risks “on civic discourse and electoral processes, and public security”. How should these be operationalized? This can only be an iterative process as we see what kinds of measurements are both informative about what we care about in the world and sensitive to the kinds of changes VLOPs make. Iteration on the US2020 model is how to begin this process of refinement.&lt;/p&gt;
&lt;h2 id=&quot;wrapping-it-up&quot;&gt;Wrapping it up&lt;/h2&gt;
&lt;p&gt;If we want to truly understand a world where tech is different in some way, we must change it in that way and measure what happens as a result. This is how Meta ensures Feed aligns with its business values, and this is the only way to ensure Feed – alongside all other aspects of online platforms – aligns with our societal values, as well. This may require platforms to run RCTs they would not have already run: we may imagine changes that they have not previously tested. At the very least, it will almost certainly be necessary to require that they measure outcomes they might not otherwise measure. In the US, for instance, this might mean requiring that they collect data on race that they are otherwise reluctant to hold.&lt;/p&gt;
&lt;p&gt;US2020 has many of the features that are necessary for this kind of counterfactual accountability. It provides rigorous evidence of how Meta’s products would work if we were to change them. The RCTs were designed by external academics with full control rights, whose incentive is not to improve Meta’s bottom-line, but to expose answers to societally relevant questions. Meta had no substantial freedom to say no to such requests. It was not fast enough, nor was it large enough scale (e.g. it was only in the US). Regulators don’t currently have the expertise in-house to do the work that these academics did in asking good questions and co-designing studies to answer them. This is an important problem to solve, but other fields (like the FDA) have shown that such expertise can be acquired by regulatory agencies.&lt;/p&gt;
&lt;p&gt;The biggest problem with US2020 is that it &lt;a href=&quot;https://www.science.org/doi/full/10.1126/science.adi2430&quot;&gt;only exists out of Meta’s goodwill&lt;/a&gt;. And given how expensive it was for Meta, it’s not clear how much of that there is left. Look through the author list for the Meta employees – most worked primarily on this project for the last 3 years, and lots of other engineers and data scientists contributed substantial time as well. These people are all superstars and just their direct compensation over that time is a huge commitment from Meta: easily millions of dollars, likely tens of millions. Given recent belt-tightening, I wouldn’t count on Meta independently finding this a good tradeoff solely in order to be transparent. If we want to guarantee this kind of transparency from internet platforms, then we shouldn’t just hope that they will keep choosing to bring us rigorous counterfactual evaluation. Government should require it.&lt;/p&gt;</content:encoded><category>technology</category><category>metascience</category></item><item><title>Quarto for an Academic Website</title><link>https://ddimmery.com/posts/quarto-website/</link><guid isPermaLink="true">https://ddimmery.com/posts/quarto-website/</guid><description>I continue my long search for a way to generate a nicely formatted
website with publication list based on adding publication information to a single source of truth
without re-remembering how all the formatting works each time.</description><pubDate>Wed, 11 May 2022 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;intro&quot;&gt;Intro&lt;/h2&gt;
&lt;p&gt;I’ve never been good at keeping my website updated. I always go through two different phases of maintenance:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Rushing around creating a new website with bells and whistles using whatever the flavor of the month is&lt;/li&gt;
&lt;li&gt;Never updating an existing website&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I’m hoping to break out of this cycle, but am currently solidly within Phase 1.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;489&quot; height=&quot;732&quot; src=&quot;/_astro/tobias-meme.Dzor4WXT_Z2oFuxm.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;A highlight from my time in Phase 2 was when I forgot to update my DNS and I totally lost control of &lt;code&gt;drewdimmery.com&lt;/code&gt; (don’t go there, it has a squatter).
I think my website at that time was some Octopress monstrosity.
There are a few reasons I think &lt;a href=&quot;https://quarto.org/&quot;&gt;Quarto&lt;/a&gt; might help with my vicious circle.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Serving static HTML pages is about as easy as it gets&lt;/li&gt;
&lt;li&gt;Very little Quarto-specific syntax to recall (e.g. CLI commands or abstruse markup)&lt;/li&gt;
&lt;li&gt;Lots of flexibility (Python / R) in how to generate that static content&lt;/li&gt;
&lt;li&gt;Full programmability means that generation can be based on arbitrary data structures of my choosing&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I previously used Hugo Academic for building my website, which was much better than just editing the content directly, but I never remembered the right way to generate a new publication definition (there was a CLI, but I never remembered the syntax). Each publication got its own file describing its details, and I found this quite clunky. I wanted something extremely lightweight: there isn’t much reason for my individual publications to get pages of their own, and I really don’t need a lot of information on each of them. I just want some basic information about each and a set of appropriate links to more details.&lt;/p&gt;
&lt;p&gt;This post will detail how I’ve set up Quarto to accomplish this task. I’ve nearly completely separated the two main concerns around maintaining an academic website / CV, which to me are data on &lt;em&gt;publications&lt;/em&gt; and &lt;em&gt;software&lt;/em&gt; from the design elements of how to display them. It’s entirely possible that my particular issues are unique and this post won’t be useful to anyone else. Luckily, the marginal cost of words on the internet is essentially zero (and maybe the marginal value is, too).&lt;/p&gt;
&lt;h2 id=&quot;setup&quot;&gt;Setup&lt;/h2&gt;
&lt;p&gt;Setting up Quarto was very easy, so I won’t belabor this. The combination of the &lt;a href=&quot;https://quarto.org/docs/get-started/&quot;&gt;Get Started guide&lt;/a&gt; with the &lt;a href=&quot;https://quarto.org/docs/websites/&quot;&gt;Website Creation guide&lt;/a&gt; kept everything very straightforward. I also used &lt;a href=&quot;https://blog.djnavarro.net/posts/2022-04-20_porting-to-quarto/&quot;&gt;Danielle Navarro’s post&lt;/a&gt; and &lt;a href=&quot;https://github.com/djnavarro/quarto-blog&quot;&gt;her blog’s code&lt;/a&gt; to get everything set up.&lt;/p&gt;
&lt;p&gt;I decided late in the setup process to add a blog, so I will mention that it’s actually very easy to do: it basically just requires adding a &lt;a href=&quot;https://quarto.org/docs/websites/website-listings.html&quot;&gt;Listing page&lt;/a&gt; (i.e. the blog’s index), a folder to contain the various posts and a &lt;code&gt;_metadata.yml&lt;/code&gt; file in that folder to describe global settings to apply to all posts. I just created these manually without too much trouble. This is one of the great things about building sites with tools like Quarto: everything is extremely transparent: just put a couple files in the right places and you’re good to go.&lt;/p&gt;
&lt;h2 id=&quot;site-design&quot;&gt;Site Design&lt;/h2&gt;
&lt;p&gt;To demonstrate how I’ve set things up to populate the website from data about my academic life, I’ll focus on my &lt;a href=&quot;/research/&quot;&gt;publications&lt;/a&gt; page. There are two main files undergirding this page:&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;papers.yaml&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;a data file in YAML with standardized information on each publication. I chose YAML because it&apos;s fairly easy to write correctly formatted YAML by hand (and I&apos;ll be updating)&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;research.qmd&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The page which takes the data in &lt;code&gt;papers.yaml&lt;/code&gt; and turns it into nicely formatted Markdown / HTML. This is setup as a Jupyter-backed &lt;code&gt;qmd&lt;/code&gt; file (essentially a Jupyter notebook).&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;This idea of separating the data side (information about publications) from formatting is aimed at making my life easier. One of the reasons I often stop updating my website is because when I come back in 3 months with a new publication, I never remember all the details about how I formatted entries in whatever flavor of Bootstrap I happened to be using when I built the website. Moreover, because I know that there’s a barrier to understanding before I can get started, it’s extremely easy to put off (and therefore it never gets done).&lt;/p&gt;
&lt;p&gt;By separating out the data entry from the formatting, this simplifies matters substantially.&lt;/p&gt;
&lt;h3 id=&quot;data&quot;&gt;Data&lt;/h3&gt;
&lt;p&gt;I put data about each publication in a basic YAML format:&lt;/p&gt;
&lt;details&gt;&lt;summary&gt;See example data&lt;/summary&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;yaml&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;softblock&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;  title&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;Efficient Balanced Treatment Assignments for Experimentation&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;  authors&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    - &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;David Arbour&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    - &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;me&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    - &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;Anup Rao&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;  year&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;2021&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;  venue&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;AISTATS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;  preprint&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;https://arxiv.org/abs/2010.11332&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;  published_url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;https://proceedings.mlr.press/v130/arbour21a.html&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;  github&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;https://github.com/ddimmery/softblock&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;p&gt;This is basically like a simplified bibtex entry with more URLs so I can annotate where to find replication materials for a given paper, as well as distinguish between preprints (always freely accessible) versus published versions (not always open access). A convenience that I add in the markup here is referring to myself as &lt;code&gt;me&lt;/code&gt; in the author list (which is an ordered list). This allows me to add in extra post-processing to highlight where I sit in the author list.&lt;/p&gt;
&lt;p&gt;Some additional things I considered adding but chose to ignore for a first version:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An abstract&lt;/li&gt;
&lt;li&gt;A suggested bibtex entry&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both of these would be easy to add, but I chose to start simpler. I don’t love YAML for entering long blocks of text, which both of these are.&lt;/p&gt;
&lt;h3 id=&quot;formatting&quot;&gt;Formatting&lt;/h3&gt;
&lt;p&gt;Since I can write the generation logic for page in Python, this puts me on comfortable ground to hack something together. To knit the above publication data into HTML, I just literally bind together the programmatically generated raw HTML and print it onto the page.&lt;/p&gt;
&lt;p&gt;I do a couple additional useful things in this process:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Separate out working papers or non-archival papers from published work (I make this distinction based on whether I include a &lt;code&gt;published_url&lt;/code&gt; field or not).&lt;/li&gt;
&lt;li&gt;Order and categorize papers by year&lt;/li&gt;
&lt;li&gt;Provide nice Bootstrappy buttons for external links (e.g. to Preprints / Code / etc)&lt;/li&gt;
&lt;/ul&gt;
&lt;details&gt;&lt;summary&gt;See &lt;code&gt;research.qmd&lt;/code&gt; fragment&lt;/summary&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; yaml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; IPython.display &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; display, Markdown, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;HTML&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; readable_list&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(_s):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;  if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; len&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(_s) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos; and &apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;.join(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, _s))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;  *&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;a, b &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; _s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;, &apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;.join(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, a))&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;, and &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; button&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(url, str, icon):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    icon_base &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; icon[:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;&quot;&quot;&amp;#x3C;a class=&quot;btn btn-outline-dark btn-sm&quot;, href=&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;        &amp;#x3C;i class=&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;icon_base&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;icon&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot; role=&apos;img&apos; aria-label=&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;&gt;&amp;#x3C;/i&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;        {&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;    &amp;#x3C;/a&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;yaml_data &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; yaml.safe_load(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;papers.yaml&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;pub_strs &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;pubs&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: {}, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;wps&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: {}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; _, data &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; yaml_data.items():&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    title_str &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; data[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    authors &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; data.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;authors&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, [&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;me&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    authors &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        aut &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; aut &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;me&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; else&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;&amp;#x3C;strong&gt;Drew Dimmery&amp;#x3C;/strong&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; aut &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; authors&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    author_str &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; readable_list(authors)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    year_str &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; data[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;year&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    buttons &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; []&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    preprint &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; data.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;preprint&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; preprint &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;is&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; not&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        buttons.append(button(preprint, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;Preprint&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;bi-file-earmark-pdf&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    github &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; data.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;github&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; github &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;is&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; not&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        buttons.append(button(github, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;Github&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;bi-github&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    pub_url &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; data.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;published_url&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    venue &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; data.get(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;venue&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    working_paper &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; pub_url &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;is&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; None&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    pub_str &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;author_str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;. (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;year_str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;) &quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;title_str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;.&quot;&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; venue &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;is&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; not&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        pub_str &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot; &amp;#x3C;em&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;venue&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&amp;#x3C;/em&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; working_paper:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; year_str &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;not&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; pub_strs[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;wps&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;            pub_strs[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;wps&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;][year_str] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; []&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        pub_strs[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;wps&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;][year_str].append(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;            &quot;&amp;#x3C;li class=&apos;list-group-item&apos;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; pub_str &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;&amp;#x3C;br&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot; &quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;.join(buttons) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;&amp;#x3C;/li&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    else&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; year_str &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;not&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; pub_strs[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;pubs&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;            pub_strs[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;pubs&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;][year_str] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; []&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        buttons.append(button(pub_url, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;Published&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;ai-archive&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        pub_strs[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;pubs&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;][year_str].append(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;            &quot;&amp;#x3C;li class=&apos;list-group-item&apos;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; pub_str &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;&amp;#x3C;br&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot; &quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;.join(buttons) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;&amp;#x3C;/li&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;        )&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;p&gt;I then print this out using the &lt;code&gt;display&lt;/code&gt; functions from the IPython module and using the &lt;code&gt;asis&lt;/code&gt; chunk option:&lt;/p&gt;
&lt;details&gt;&lt;summary&gt;See &lt;code&gt;research.qmd&lt;/code&gt; fragment&lt;/summary&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; year &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; sorted&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(pub_strs[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;pubs&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;].keys(), &lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;reverse&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;True&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    display(Markdown(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;### &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;year&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;{#&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;published-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;year&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;}&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    display(HTML(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;        &quot;&amp;#x3C;ul class=&apos;list-group list-group-flush&apos;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;.join(pub_strs[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;pubs&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;][year]) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;&amp;#x3C;/ul&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    ))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;p&gt;The &lt;a href=&quot;https://github.com/ddimmery/quarto-website/blob/main/research.qmd&quot;&gt;full code is on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It’s worth noting that to get the years to show up in the Table of Contents its necessary to be careful exactly how the content is stuck onto the page. If you don’t use the &lt;code&gt;asis&lt;/code&gt; chunk option, you can still get all the right content to show up, but it won’t necessarily appear in the ToC. I also found it necessary to include &lt;code&gt;section-divs: false&lt;/code&gt; in the header, or else the output would get wrapped in additional &lt;code&gt;div&lt;/code&gt; tags which made it harder to get the right classes in the right divs. There are probably more elegant ways to do all of this.&lt;/p&gt;
&lt;p&gt;I use the same basic setup to populate the &lt;a href=&quot;/software/&quot;&gt;Software page&lt;/a&gt;, albeit with simpler logic.&lt;/p&gt;
&lt;h4 id=&quot;additions&quot;&gt;Additions&lt;/h4&gt;
&lt;p&gt;I debated adding an abstract that expands out on click (like the code folding above in this post). This would actually be more or less trivial to add using a &lt;code&gt;&amp;#x3C;details&gt;&lt;/code&gt; HTML tag if I wanted to provide the data in the YAML. I’m ignoring this for now because I want to minimize data entry for my future self (and it’s anyway just a click away at the Preprint link).&lt;/p&gt;
&lt;h2 id=&quot;deployment&quot;&gt;Deployment&lt;/h2&gt;
&lt;p&gt;It’s extremely easy to build a new version of the website locally (&lt;code&gt;quarto render&lt;/code&gt; from CLI), but there’s no guarantee I’ll remember that off the top of my head in a month without Googling, so I think it’s worthwhile to setup automatic building after I push a commit to GitHub.&lt;/p&gt;
&lt;p&gt;GitHub Actions is incredible. I adapted the &lt;a href=&quot;https://github.com/quarto-dev/quarto-actions/blob/main/examples/quarto-book-netlify.yaml&quot;&gt;example config from Quarto&lt;/a&gt; to the following  (also &lt;a href=&quot;https://github.com/ddimmery/quarto-website/blob/main/.github/workflows/build.yml&quot;&gt;on GitHub here&lt;/a&gt;):&lt;/p&gt;
&lt;details&gt;&lt;summary&gt;GitHub Actions for Netlify&lt;/summary&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;yaml&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;on&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;  push&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;    branches&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;main&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;  pull_request&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;    branches&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;main&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;  # to be able to trigger a manual build&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;  workflow_dispatch&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;Render and deploy website to Netlify&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;jobs&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;  build-deploy&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;    runs-on&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;ubuntu-latest&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;    steps&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;      - &lt;/span&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;uses&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;actions/checkout@v2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;      - &lt;/span&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;uses&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;actions/setup-python@v3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;        with&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          python-version&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;3.9&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          cache&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;pip&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;      - &lt;/span&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;run&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;pip install -r requirements.txt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;      - &lt;/span&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;uses&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;r-lib/actions/setup-r@v2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;        with&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          use-public-rspm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;      - &lt;/span&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;uses&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;r-lib/actions/setup-renv@v2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;      - &lt;/span&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;Install Quarto&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;        uses&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;quarto-dev/quarto-actions/install-quarto@v1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;        with&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;          # To install LaTeX to build PDF book&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          tinytex&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;          # uncomment below and fill to pin a version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;          # version: 0.9.105&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;      - &lt;/span&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;Render website&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;        # Add any command line argument needed&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;        run&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;          quarto render&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;      - &lt;/span&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;Deploy to Netlify&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;        id&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;netlify-deploy&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;        uses&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;nwtgck/actions-netlify@v1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;        with&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;          # The folder the action should deploy. Adapt if you changed in Quarto config&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          publish-dir&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;./_site&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          production-branch&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;main&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          github-token&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;${{ secrets.GITHUB_TOKEN }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          deploy-message&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;            &apos;Deploy from GHA: ${{ github.event.pull_request.title || github.event.head_commit.message }} (${{ github.sha }})&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          enable-pull-request-comment&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; #  Comment on pull request&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          enable-commit-comment&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # Comment on GitHub commit&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          enable-commit-status&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # GitHub commit status&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;        env&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          NETLIFY_AUTH_TOKEN&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;${{ secrets.NETLIFY_AUTH_TOKEN }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;          NETLIFY_SITE_ID&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;${{ secrets.NETLIFY_SITE_ID }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;        timeout-minutes&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;p&gt;This Action requires two pieces of information from Netlify entered as secrets in GitHub. The &lt;code&gt;NETLIFY_SITE_ID&lt;/code&gt; may be found in the site configuration settings, while the &lt;code&gt;NETLIFY_AUTH_TOKEN&lt;/code&gt; may be found in personal settings (the personal access token).&lt;/p&gt;
&lt;p&gt;One thing I have not yet done is set up an &lt;a href=&quot;https://rstudio.github.io/renv/index.html&quot;&gt;renv&lt;/a&gt; to ensure dependencies for blog posts are taken care of in GitHub Actions. This means that posts like the &lt;a href=&quot;/posts/softblock-demo/&quot;&gt;experimental design demo&lt;/a&gt; can’t be knit via GitHub Actions. I did this for two reasons (other than laziness). First, it’s a pain to get GIS tools working on any environment (ok, so its &lt;em&gt;part&lt;/em&gt; laziness). I’ve actually done this before for automated &lt;code&gt;R CMD check&lt;/code&gt;ing of the &lt;a href=&quot;https://github.com/ddimmery/regweight/blob/main/.github/workflows/check-full.yaml&quot;&gt;&lt;code&gt;regweight&lt;/code&gt; package&lt;/a&gt;, but didn’t feel like it was worthwhile here.&lt;/p&gt;
&lt;p&gt;The reason it’s not worth it is that Quarto has a &lt;a href=&quot;https://quarto.org/docs/projects/code-execution.html#freeze&quot;&gt;great feature called “freezing”&lt;/a&gt;. Essentially, it knits blog posts or pages, and only re-renders them when something about the source changes. This means that the vast majority of posts don’t need to be rendered on each build. If I’m working on a blog post, I can write it locally, render on my machine, commit that pre-rendered post and then all future builds on Actions won’t get held up by their inability to render that post.&lt;/p&gt;
&lt;p&gt;As I type this, it becomes clear that I’ll forget how to do this pretty often (given that there’s been about an 8 year delay since my next most recent blog, I likely won’t stay in practice). But blogs aren’t my main concern on my website: keeping a software and publication list up-to-date is.&lt;/p&gt;
&lt;p&gt;Setting up Actions means that simple updates to pages (or YAML files) can actually be done directly in the GitHub editing UI, which further lowers the barrier for my future self. I don’t even need to clone the repository to whatever computer I’m working on to add a publication!&lt;/p&gt;
&lt;h2 id=&quot;future-dreams&quot;&gt;Future dreams&lt;/h2&gt;
&lt;p&gt;I imagine my CV is similar to most academics’ in that it’s built like a house of cards (and overfull hboxs). Whenever I add something new to it, I have to copy some lines from elsewhere and modify them to fit the new entry. This always takes me way more time than I’d like. If I mashed together my current &lt;a href=&quot;/about/&quot;&gt;About page&lt;/a&gt; with the &lt;a href=&quot;/research/&quot;&gt;Research page&lt;/a&gt;, it’s like 90% of the way to a full CV. It should presumably be pretty easy to do explicitly combine them and output a reasonable-looking CV.&lt;/p&gt;
&lt;p&gt;This is a project for another day, though. Too much of the Research page directly outputs HTML, which makes it difficult to naïvely import into a &lt;mjx-container class=&quot;MathJax&quot; jax=&quot;SVG&quot; overflow=&quot;scroll&quot; style=&quot;position: relative;&quot;&gt;&lt;svg style=&quot;vertical-align: -0.447ex;&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;4.561ex&quot; height=&quot;1.893ex&quot; role=&quot;img&quot; focusable=&quot;false&quot; viewBox=&quot;0 -697 2198.5 912.5&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; aria-hidden=&quot;true&quot;&gt;&lt;defs&gt;&lt;path id=&quot;MJX-1-GP-I-1D43F&quot; d=&quot;M534 48L524 58C518 57 336 43 232 43C227 43 220 50 219 56C213 241 208 447 218 624C219 635 224 647 236 649C257 654 300 663 301 663L301 684L295 690L58 690L51 683L50 666C51 666 88 658 108 654C123 651 129 635 129 621L129 143C129 129 126 57 122 47C119 38 114 26 107 16L107 2C245 2 446 2 520-5Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-1-GP-I-1D434&quot; d=&quot;M536 76C543 50 553 16 567 3C574-5 583-10 594-10C609-10 624-8 639-4L743 26L742 52C728 51 713 49 699 49C691 49 683 50 676 51C659 55 644 64 635 79C599 139 572 236 550 317C517 437 472 597 457 680L263 680L263 653L353 638C362 636 365 630 365 627C365 624 365 623 364 620C259 412 144 208 25 8L28-2L119 17L236 265C238 269 242 273 246 273L471 273C474 273 480 268 482 264M382 572C382 573 385 576 388 576C391 576 394 574 395 572L465 328C465 327 467 319 467 319C467 316 465 312 460 312L272 312C269 312 265 316 265 319C265 320 265 326 266 328Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-1-GP-I-1D447&quot; d=&quot;M575 689L567 696C479 692 380 686 305 686C128 686 128 694 33 697L26 690L26 642L34 635C145 639 224 642 248 642C253 642 257 640 257 636C258 606 259 462 259 380C259 253 254 126 246-1L255-10L355 17C348 138 342 317 342 438C342 518 345 619 346 633C346 639 349 644 355 644C376 644 397 642 565 634L573 641Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-1-GP-I-1D438&quot; d=&quot;M456 336L462 384L456 391C379 385 259 383 220 386C213 387 210 391 210 398L210 564C210 587 213 619 221 631C224 636 229 639 234 640L274 640C281 640 414 634 483 630L487 637L489 687C476 688 461 688 443 688C372 688 271 682 201 682L53 681L46 674L47 654C68 651 98 644 106 638C113 633 121 628 123 622C132 602 132 572 132 558L132 66C132 52 133 37 138 25C143 15 149 5 158 0L546 0L559 53L554 58C390 44 367 44 320 44C292 44 266 45 254 50C242 56 230 64 224 76C210 101 209 150 209 188L209 327C209 334 212 338 219 339C237 340 300 342 338 342C377 342 417 339 456 336Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-1-GP-I-1D44B&quot; d=&quot;M632 672L632 687L537 674C537 674 492 603 460 557C427 512 362 427 357 422L348 422L201 688C156 685 80 681 55 680L48 674L48 649C67 644 84 639 98 634C116 627 142 608 153 590C199 508 294 346 298 345L27 16L27 0L121 11C137 45 190 129 228 182C256 223 297 279 311 296L323 296L466 57C480 35 494 13 512-5L526-11L636 16L636 32L631 36C623 38 601 52 594 59L534 131C495 180 378 367 378 380C382 387 415 431 445 466Z&quot;&gt;&lt;/path&gt;&lt;/defs&gt;&lt;g stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; transform=&quot;scale(1,-1)&quot;&gt;&lt;g data-mml-node=&quot;math&quot; data-latex=&quot;\LaTeX&quot;&gt;&lt;g data-mml-node=&quot;mi&quot; data-latex=&quot;L&quot;&gt;&lt;use data-c=&quot;1D43F&quot; xlink:href=&quot;#MJX-1-GP-I-1D43F&quot;&gt;&lt;/use&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mspace&quot; data-latex=&quot;\kern-.325em&quot; transform=&quot;translate(559,0)&quot;&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mpadded&quot; data-latex=&quot;{}&quot; transform=&quot;translate(234,0)&quot;&gt;&lt;g transform=&quot;translate(0,210)&quot;&gt;&lt;g data-mml-node=&quot;TeXAtom&quot; data-mjx-texclass=&quot;ORD&quot;&gt;&lt;g data-mml-node=&quot;mstyle&quot; transform=&quot;scale(0.707)&quot;&gt;&lt;g data-mml-node=&quot;TeXAtom&quot; data-latex=&quot;{A}&quot; data-mjx-texclass=&quot;ORD&quot;&gt;&lt;g data-mml-node=&quot;mi&quot; data-latex=&quot;A&quot;&gt;&lt;use data-c=&quot;1D434&quot; xlink:href=&quot;#MJX-1-GP-I-1D434&quot;&gt;&lt;/use&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mspace&quot; data-latex=&quot;\kern-.17em&quot; transform=&quot;translate(778.5,0)&quot;&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mi&quot; data-latex=&quot;T&quot; transform=&quot;translate(608.5,0)&quot;&gt;&lt;use data-c=&quot;1D447&quot; xlink:href=&quot;#MJX-1-GP-I-1D447&quot;&gt;&lt;/use&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mspace&quot; data-latex=&quot;\kern-.14em&quot; transform=&quot;translate(1183.5,0)&quot;&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mpadded&quot; data-latex=&quot;{}&quot; transform=&quot;translate(1043.5,0)&quot;&gt;&lt;g transform=&quot;translate(0,-215.5)&quot;&gt;&lt;g data-mml-node=&quot;TeXAtom&quot; data-mjx-texclass=&quot;ORD&quot;&gt;&lt;g data-mml-node=&quot;mi&quot; data-latex=&quot;E&quot;&gt;&lt;use data-c=&quot;1D438&quot; xlink:href=&quot;#MJX-1-GP-I-1D438&quot;&gt;&lt;/use&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mspace&quot; data-latex=&quot;\kern-.115em&quot; transform=&quot;translate(1647.5,0)&quot;&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mi&quot; data-latex=&quot;X&quot; transform=&quot;translate(1532.5,0)&quot;&gt;&lt;use data-c=&quot;1D44B&quot; xlink:href=&quot;#MJX-1-GP-I-1D44B&quot;&gt;&lt;/use&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;&lt;mjx-assistive-mml unselectable=&quot;on&quot; display=&quot;inline&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; data-latex=&quot;\LaTeX&quot;&gt;&lt;mi data-latex=&quot;L&quot;&gt;L&lt;/mi&gt;&lt;mspace width=&quot;-.325em&quot; linebreak=&quot;nobreak&quot; data-latex=&quot;\kern-.325em&quot;&gt;&lt;/mspace&gt;&lt;mpadded height=&quot;+.21em&quot; depth=&quot;-.21em&quot; voffset=&quot;+.21em&quot; data-latex=&quot;{}&quot;&gt;&lt;mrow data-mjx-texclass=&quot;ORD&quot;&gt;&lt;mstyle scriptlevel=&quot;1&quot;&gt;&lt;mrow data-mjx-texclass=&quot;ORD&quot; data-latex=&quot;{A}&quot;&gt;&lt;mi data-latex=&quot;A&quot;&gt;A&lt;/mi&gt;&lt;/mrow&gt;&lt;/mstyle&gt;&lt;/mrow&gt;&lt;/mpadded&gt;&lt;mspace width=&quot;-.17em&quot; linebreak=&quot;nobreak&quot; data-latex=&quot;\kern-.17em&quot;&gt;&lt;/mspace&gt;&lt;mi data-latex=&quot;T&quot;&gt;T&lt;/mi&gt;&lt;mspace width=&quot;-.14em&quot; linebreak=&quot;nobreak&quot; data-latex=&quot;\kern-.14em&quot;&gt;&lt;/mspace&gt;&lt;mpadded height=&quot;-.5ex&quot; depth=&quot;+.5ex&quot; voffset=&quot;-.5ex&quot; data-latex=&quot;{}&quot;&gt;&lt;mrow data-mjx-texclass=&quot;ORD&quot;&gt;&lt;mi data-latex=&quot;E&quot;&gt;E&lt;/mi&gt;&lt;/mrow&gt;&lt;/mpadded&gt;&lt;mspace width=&quot;-.115em&quot; linebreak=&quot;nobreak&quot; data-latex=&quot;\kern-.115em&quot;&gt;&lt;/mspace&gt;&lt;mi data-latex=&quot;X&quot;&gt;X&lt;/mi&gt;&lt;/math&gt;&lt;/mjx-assistive-mml&gt;&lt;/mjx-container&gt; CV.&lt;/p&gt;
&lt;p&gt;An almost completely naïve approach to directly importing the relevant pages creates &lt;a href=&quot;/posts/quarto-website/cv.pdf&quot;&gt;this ugly document&lt;/a&gt;.&lt;/p&gt;
&lt;details&gt;&lt;summary&gt;Naïve CV&lt;/summary&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;markdown&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;---&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;Curriculum Vitae&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#024C1A;--shiki-dark:#72F088&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;pdf&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;---&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;{{&amp;#x3C; include about.qmd &gt;}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;{{&amp;#x3C; include research.md &gt;}}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;p&gt;It’s definitely possible to improve on this. The easiest hacky approach is to just write a whole alternative version of the HTML formatting code which resides in &lt;code&gt;research.qmd&lt;/code&gt; to output appropriately formatted &lt;mjx-container class=&quot;MathJax&quot; jax=&quot;SVG&quot; overflow=&quot;scroll&quot; style=&quot;position: relative;&quot;&gt;&lt;svg style=&quot;vertical-align: -0.447ex;&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;4.561ex&quot; height=&quot;1.893ex&quot; role=&quot;img&quot; focusable=&quot;false&quot; viewBox=&quot;0 -697 2198.5 912.5&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; aria-hidden=&quot;true&quot;&gt;&lt;defs&gt;&lt;path id=&quot;MJX-2-GP-I-1D43F&quot; d=&quot;M534 48L524 58C518 57 336 43 232 43C227 43 220 50 219 56C213 241 208 447 218 624C219 635 224 647 236 649C257 654 300 663 301 663L301 684L295 690L58 690L51 683L50 666C51 666 88 658 108 654C123 651 129 635 129 621L129 143C129 129 126 57 122 47C119 38 114 26 107 16L107 2C245 2 446 2 520-5Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-2-GP-I-1D434&quot; d=&quot;M536 76C543 50 553 16 567 3C574-5 583-10 594-10C609-10 624-8 639-4L743 26L742 52C728 51 713 49 699 49C691 49 683 50 676 51C659 55 644 64 635 79C599 139 572 236 550 317C517 437 472 597 457 680L263 680L263 653L353 638C362 636 365 630 365 627C365 624 365 623 364 620C259 412 144 208 25 8L28-2L119 17L236 265C238 269 242 273 246 273L471 273C474 273 480 268 482 264M382 572C382 573 385 576 388 576C391 576 394 574 395 572L465 328C465 327 467 319 467 319C467 316 465 312 460 312L272 312C269 312 265 316 265 319C265 320 265 326 266 328Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-2-GP-I-1D447&quot; d=&quot;M575 689L567 696C479 692 380 686 305 686C128 686 128 694 33 697L26 690L26 642L34 635C145 639 224 642 248 642C253 642 257 640 257 636C258 606 259 462 259 380C259 253 254 126 246-1L255-10L355 17C348 138 342 317 342 438C342 518 345 619 346 633C346 639 349 644 355 644C376 644 397 642 565 634L573 641Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-2-GP-I-1D438&quot; d=&quot;M456 336L462 384L456 391C379 385 259 383 220 386C213 387 210 391 210 398L210 564C210 587 213 619 221 631C224 636 229 639 234 640L274 640C281 640 414 634 483 630L487 637L489 687C476 688 461 688 443 688C372 688 271 682 201 682L53 681L46 674L47 654C68 651 98 644 106 638C113 633 121 628 123 622C132 602 132 572 132 558L132 66C132 52 133 37 138 25C143 15 149 5 158 0L546 0L559 53L554 58C390 44 367 44 320 44C292 44 266 45 254 50C242 56 230 64 224 76C210 101 209 150 209 188L209 327C209 334 212 338 219 339C237 340 300 342 338 342C377 342 417 339 456 336Z&quot;&gt;&lt;/path&gt;&lt;path id=&quot;MJX-2-GP-I-1D44B&quot; d=&quot;M632 672L632 687L537 674C537 674 492 603 460 557C427 512 362 427 357 422L348 422L201 688C156 685 80 681 55 680L48 674L48 649C67 644 84 639 98 634C116 627 142 608 153 590C199 508 294 346 298 345L27 16L27 0L121 11C137 45 190 129 228 182C256 223 297 279 311 296L323 296L466 57C480 35 494 13 512-5L526-11L636 16L636 32L631 36C623 38 601 52 594 59L534 131C495 180 378 367 378 380C382 387 415 431 445 466Z&quot;&gt;&lt;/path&gt;&lt;/defs&gt;&lt;g stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; transform=&quot;scale(1,-1)&quot;&gt;&lt;g data-mml-node=&quot;math&quot; data-latex=&quot;\LaTeX&quot;&gt;&lt;g data-mml-node=&quot;mi&quot; data-latex=&quot;L&quot;&gt;&lt;use data-c=&quot;1D43F&quot; xlink:href=&quot;#MJX-2-GP-I-1D43F&quot;&gt;&lt;/use&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mspace&quot; data-latex=&quot;\kern-.325em&quot; transform=&quot;translate(559,0)&quot;&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mpadded&quot; data-latex=&quot;{}&quot; transform=&quot;translate(234,0)&quot;&gt;&lt;g transform=&quot;translate(0,210)&quot;&gt;&lt;g data-mml-node=&quot;TeXAtom&quot; data-mjx-texclass=&quot;ORD&quot;&gt;&lt;g data-mml-node=&quot;mstyle&quot; transform=&quot;scale(0.707)&quot;&gt;&lt;g data-mml-node=&quot;TeXAtom&quot; data-latex=&quot;{A}&quot; data-mjx-texclass=&quot;ORD&quot;&gt;&lt;g data-mml-node=&quot;mi&quot; data-latex=&quot;A&quot;&gt;&lt;use data-c=&quot;1D434&quot; xlink:href=&quot;#MJX-2-GP-I-1D434&quot;&gt;&lt;/use&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mspace&quot; data-latex=&quot;\kern-.17em&quot; transform=&quot;translate(778.5,0)&quot;&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mi&quot; data-latex=&quot;T&quot; transform=&quot;translate(608.5,0)&quot;&gt;&lt;use data-c=&quot;1D447&quot; xlink:href=&quot;#MJX-2-GP-I-1D447&quot;&gt;&lt;/use&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mspace&quot; data-latex=&quot;\kern-.14em&quot; transform=&quot;translate(1183.5,0)&quot;&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mpadded&quot; data-latex=&quot;{}&quot; transform=&quot;translate(1043.5,0)&quot;&gt;&lt;g transform=&quot;translate(0,-215.5)&quot;&gt;&lt;g data-mml-node=&quot;TeXAtom&quot; data-mjx-texclass=&quot;ORD&quot;&gt;&lt;g data-mml-node=&quot;mi&quot; data-latex=&quot;E&quot;&gt;&lt;use data-c=&quot;1D438&quot; xlink:href=&quot;#MJX-2-GP-I-1D438&quot;&gt;&lt;/use&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mspace&quot; data-latex=&quot;\kern-.115em&quot; transform=&quot;translate(1647.5,0)&quot;&gt;&lt;/g&gt;&lt;g data-mml-node=&quot;mi&quot; data-latex=&quot;X&quot; transform=&quot;translate(1532.5,0)&quot;&gt;&lt;use data-c=&quot;1D44B&quot; xlink:href=&quot;#MJX-2-GP-I-1D44B&quot;&gt;&lt;/use&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;&lt;mjx-assistive-mml unselectable=&quot;on&quot; display=&quot;inline&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; data-latex=&quot;\LaTeX&quot;&gt;&lt;mi data-latex=&quot;L&quot;&gt;L&lt;/mi&gt;&lt;mspace width=&quot;-.325em&quot; linebreak=&quot;nobreak&quot; data-latex=&quot;\kern-.325em&quot;&gt;&lt;/mspace&gt;&lt;mpadded height=&quot;+.21em&quot; depth=&quot;-.21em&quot; voffset=&quot;+.21em&quot; data-latex=&quot;{}&quot;&gt;&lt;mrow data-mjx-texclass=&quot;ORD&quot;&gt;&lt;mstyle scriptlevel=&quot;1&quot;&gt;&lt;mrow data-mjx-texclass=&quot;ORD&quot; data-latex=&quot;{A}&quot;&gt;&lt;mi data-latex=&quot;A&quot;&gt;A&lt;/mi&gt;&lt;/mrow&gt;&lt;/mstyle&gt;&lt;/mrow&gt;&lt;/mpadded&gt;&lt;mspace width=&quot;-.17em&quot; linebreak=&quot;nobreak&quot; data-latex=&quot;\kern-.17em&quot;&gt;&lt;/mspace&gt;&lt;mi data-latex=&quot;T&quot;&gt;T&lt;/mi&gt;&lt;mspace width=&quot;-.14em&quot; linebreak=&quot;nobreak&quot; data-latex=&quot;\kern-.14em&quot;&gt;&lt;/mspace&gt;&lt;mpadded height=&quot;-.5ex&quot; depth=&quot;+.5ex&quot; voffset=&quot;-.5ex&quot; data-latex=&quot;{}&quot;&gt;&lt;mrow data-mjx-texclass=&quot;ORD&quot;&gt;&lt;mi data-latex=&quot;E&quot;&gt;E&lt;/mi&gt;&lt;/mrow&gt;&lt;/mpadded&gt;&lt;mspace width=&quot;-.115em&quot; linebreak=&quot;nobreak&quot; data-latex=&quot;\kern-.115em&quot;&gt;&lt;/mspace&gt;&lt;mi data-latex=&quot;X&quot;&gt;X&lt;/mi&gt;&lt;/math&gt;&lt;/mjx-assistive-mml&gt;&lt;/mjx-container&gt; markup.&lt;/p&gt;
&lt;p&gt;For now, I’m pretty pleased with the system I have, but ask me again in three months.&lt;/p&gt;</content:encoded><category>website</category></item><item><title>Using SoftBlock to Design an Experiment</title><link>https://ddimmery.com/posts/softblock-demo/</link><guid isPermaLink="true">https://ddimmery.com/posts/softblock-demo/</guid><description>In this demo, I&apos;m going to walk through an example experimental design using methods from our recent paper on Balanced Design.</description><pubDate>Tue, 10 May 2022 00:00:00 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Abstract.&lt;/strong&gt; This is a demo of using SoftBlock for experimental design for a notional randomization of precincts in North Carolina. To optimize power, we focus on ensuring very similar patterns of prior voting patterns in treatment and in control. This demo walks through all the necessary steps for this process and shows how to perform estimation of average and heterogeneous effects.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;em&gt;This post was originally written as an executed Quarto document. The code below is
shown exactly as it ran; the figures, printed values and tables are the outputs
captured from that original render.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In particular, I’m going to imagine that I’m designing an experiment in which I assign different treatments to particular precincts in North Carolina. In order to optimize power, of course, we want to make sure that our two test groups look as similar as possible in terms of prior voting patterns.&lt;/p&gt;
&lt;p&gt;Thus, the steps in this design will be:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Collect relevant historical data.&lt;/li&gt;
&lt;li&gt;Define variables on which we wish to balance.&lt;/li&gt;
&lt;li&gt;Allocate treatment assignment using new methods.&lt;/li&gt;
&lt;li&gt;Simulate the power of hypothesis tests under the proposed design.&lt;/li&gt;
&lt;li&gt;Fake some outcome data and analyze it for average and heterogeneous treatment effects.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;implementation-of-methods&quot;&gt;Implementation of methods&lt;/h2&gt;
&lt;h3 id=&quot;description&quot;&gt;Description&lt;/h3&gt;
&lt;p&gt;The relevant API is a function with &lt;code&gt;tidyverse&lt;/code&gt; semantics called &lt;code&gt;assign_softblock&lt;/code&gt; (or &lt;code&gt;assign_greedy_neighbors&lt;/code&gt;). These functions accept a vector of columns to be used in the design. The SoftBlock version additionally accepts two arguments, &lt;code&gt;.s2&lt;/code&gt; for the bandwidth of the RBF kernel to use in the construction of a similarity matrix as well as &lt;code&gt;.neighbors&lt;/code&gt; which indicates the number of nearest neighbors to include in the graph on which to construct the spanning tree. These parameters don’t generally need to be modified.&lt;/p&gt;
&lt;h3 id=&quot;source-code&quot;&gt;Source Code&lt;/h3&gt;
&lt;details&gt;&lt;summary&gt;See source code&lt;/summary&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;writeLines&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;readLines&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;https://raw.githubusercontent.com/ddimmery/softblock/master/r_implementation.R&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;text&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;library(Matrix)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;library(igraph)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;library(FNN)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;library(hash)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;assign_greedily &amp;#x3C;- function(graph) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    adj_mat = igraph::as_adjacency_matrix(graph, type=&quot;both&quot;, sparse=TRUE) != 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    N = nrow(adj_mat)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    root_id = make.keys(sample(N, 1))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    a = rbinom(1, 1, 0.5)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    visited = hash()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    random_order = make.keys(sample(N))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    unvisited = hash(random_order, random_order)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    colors = hash()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    stack = hash()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    stack[[root_id]] &amp;#x3C;- a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    tentative_color = rbinom(N, 1, 0.5)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    while ((!is.empty(unvisited)) || (!is.empty(stack))) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        if (is.empty(stack)) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            cur_node = keys(unvisited)[1]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            del(cur_node, unvisited)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            color = tentative_color[as.integer(cur_node)]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        } else {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            cur_node = keys(stack)[1]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            color = stack[[cur_node]]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            del(cur_node, stack)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            del(cur_node, unvisited)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        visited[[cur_node]] = cur_node&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        colors[[cur_node]] = color&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        children = make.keys(which(adj_mat[as.integer(cur_node), ]))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        for (child in children) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            if(has.key(child, unvisited)) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;                stack[[child]] = 1 - color&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    values(colors, keys=1:N)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;assign_softblock &amp;#x3C;- function(.data, cols, .s2=2, .neighbors=6) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    expr &amp;#x3C;- rlang::enquo(cols)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    pos &amp;#x3C;- tidyselect::eval_select(expr, data = .data)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    df_cov &amp;#x3C;- rlang::set_names(.data[pos], names(pos))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    cov_mat = scale(model.matrix(~.+0, df_cov))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    N = nrow(cov_mat)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    st = lubridate::now()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    knn = FNN::get.knn(cov_mat, k=.neighbors)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    st = lubridate::now()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    knn.adj = Matrix::sparseMatrix(i=rep(1:N, .neighbors), j=c(knn$nn.index), x=exp(-c(knn$nn.dist) / .s2))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    knn.graph &amp;#x3C;- graph_from_adjacency_matrix(knn.adj, mode=&quot;plus&quot;, weighted=TRUE, diag=FALSE)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    E(knn.graph)$weight &amp;#x3C;- (-1 * E(knn.graph)$weight)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    st = lubridate::now()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    mst.graph = igraph::mst(knn.graph)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    E(mst.graph)$weight &amp;#x3C;- (-1 * E(mst.graph)$weight)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    st = lubridate::now()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    assignments &amp;#x3C;- assign_greedily(mst.graph)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    .data$treatment &amp;#x3C;- assignments&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    attr(.data, &quot;laplacian&quot;) &amp;#x3C;- igraph::laplacian_matrix(mst.graph, normalize=TRUE, sparse=TRUE)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    .data&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;assign_greedy_neighbors &amp;#x3C;- function(.data, cols) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    expr &amp;#x3C;- rlang::enquo(cols)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    pos &amp;#x3C;- tidyselect::eval_select(expr, data = .data)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    df_cov &amp;#x3C;- rlang::set_names(.data[pos], names(pos))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    cov_mat = scale(model.matrix(~.+0, df_cov))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    N = nrow(cov_mat)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    knn = FNN::get.knn(cov_mat, k=1)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    knn.adj = Matrix::sparseMatrix(i=1:N, j=c(knn$nn.index), x=c(knn$nn.dist))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    knn.graph &amp;#x3C;- graph_from_adjacency_matrix(knn.adj, mode=&quot;plus&quot;, weighted=TRUE, diag=FALSE)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    assignments &amp;#x3C;- assign_greedily(knn.graph)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    .data$treatment &amp;#x3C;- assignments&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    attr(.data, &quot;laplacian&quot;) &amp;#x3C;- igraph::laplacian_matrix(knn.graph, normalize=TRUE, sparse=TRUE)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    .data&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;assign_matched_pairs &amp;#x3C;- function(.data, cols, .s2=2, .neighbors=6) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    expr &amp;#x3C;- rlang::enquo(cols)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    pos &amp;#x3C;- tidyselect::eval_select(expr, data = .data)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    df_cov &amp;#x3C;- rlang::set_names(.data[pos], names(pos))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    cov_mat = scale(model.matrix(~.+0, df_cov))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    N = nrow(cov_mat)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    knn = FNN::get.knn(cov_mat, k=.neighbors)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    knn.adj = Matrix::sparseMatrix(i=rep(1:N, .neighbors), j=c(knn$nn.index), x=exp(-c(knn$nn.dist) / .s2))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    knn.graph &amp;#x3C;- graph_from_adjacency_matrix(knn.adj, mode=&quot;plus&quot;, weighted=TRUE, diag=FALSE)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    E(knn.graph)$weight &amp;#x3C;- (-1 * E(knn.graph)$weight)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    mwm.graph = igraph::max_bipartite_match(knn.graph)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    E(mwm.graph)$weight &amp;#x3C;- (-1 * E(mwm.graph)$weight)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    assignments &amp;#x3C;- assign_greedily(mwm.graph)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    .data$treatment &amp;#x3C;- assignments&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    attr(.data, &quot;laplacian&quot;) &amp;#x3C;- igraph::laplacian_matrix(mwm.graph, normalize=TRUE, sparse=TRUE)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    .data&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# library(tibble)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# data = tibble(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;#     x1=runif(10),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;#     x2=runif(10),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;#     x3=rbinom(10, 1, 0.5)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# library(dplyr)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# library(tidyr)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# library(ggplot2)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# data %&gt;% assign_softblock(c(x1, x2)) -&gt; newdata&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# ggplot(newdata, aes(x=x1, y=x2, color=factor(treatment), shape=factor(x3))) + geom_point() + theme_minimal()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# newdata %&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;#     attr(&quot;laplacian&quot;) %&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;#     ifelse(lower.tri(.), ., 0) %&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;#     as_tibble() -&gt; adj_df&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# names(adj_df) &amp;#x3C;- paste0(1:ncol(adj_df))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# adj_df %&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;#     group_by(id_1=as.character(row_number())) %&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;#     gather(id_2, weight, -id_1) %&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;#     filter(weight != 0)  %&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;#     mutate(id_2=as.character(id_2), id=paste(id_1, id_2, sep=&apos;-&apos;)) -&gt; adj_df&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# locs = newdata %&gt;% mutate(id=as.character(row_number())) %&gt;% select(id, x1, x2, x3)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# edges=bind_rows(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# adj_df  %&gt;% inner_join(locs, by=c(&apos;id_1&apos;=&apos;id&apos;)),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# adj_df  %&gt;% inner_join(locs, by=c(&apos;id_2&apos;=&apos;id&apos;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# ) %&gt;% arrange(id) %&gt;% ungroup()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# pp = ggplot(newdata, aes(x=x1, y=x2)) +&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# geom_line(aes(group=id, size=1), data=edges, color=&apos;grey&apos;) +&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# geom_point(aes(color=factor(treatment), shape=factor(x3), size=2), alpha=.9) +&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# scale_size_continuous(range=c(1, 3)) +&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# theme_minimal() + theme(legend.position=&apos;none&apos;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# print(pp)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;h2 id=&quot;data-preparation&quot;&gt;Data Preparation&lt;/h2&gt;
&lt;p&gt;This demo will be based on North Carolina data because their Board of Elections makes it very easy to get precinct level data. I’m also only going to use historical data from the most recent election to avoid needing to match precincts across elections.&lt;/p&gt;
&lt;p&gt;With access to a full voter file, this section could be drastically improved by incorporating other important elements into the design like demographics.&lt;/p&gt;
&lt;h3 id=&quot;get-precinct-data&quot;&gt;Get Precinct data&lt;/h3&gt;
&lt;h4 id=&quot;results-data&quot;&gt;Results Data&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;http://dl.ncsbe.gov/ENRS/2020_11_03/results_pct_20201103.zip&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;zip_file&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; tempfile&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;fileext&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;.zip&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;download.file&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; zip_file&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; mode&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;wb&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;spec&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; cols&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  County&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_character&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  `Election Date`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_character&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  Precinct&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_character&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  `Contest Group ID`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_double&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  `Contest Type`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_character&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  `Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_character&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  Choice&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_character&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  `Choice Party`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_character&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  `Vote For`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_double&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  `Election Day`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_double&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  `One Stop`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_double&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  `Absentee by Mail`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_double&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  Provisional&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_double&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  `Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_double&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  `Real Precinct`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_character&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;  X16&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; col_skip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;results&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; readr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;read_tsv&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;zip_file&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; col_types&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;spec&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;shapefiles&quot;&gt;Shapefiles&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;https://s3.amazonaws.com/dl.ncsbe.gov/ShapeFiles/Precinct/SBE_PRECINCTS_20201018.zip&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;temp&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; tempfile&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;temp2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; tempfile&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;download.file&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; temp&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;unzip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;zipfile&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; temp&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; exdir&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; temp2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;nc_SHP_file&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; list.files&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;temp2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; pattern&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;.shp$&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;full.names&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;shapes&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; sf&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;read_sf&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;nc_SHP_file&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;aggregate-data-and-join&quot;&gt;Aggregate Data and Join&lt;/h3&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;results&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    filter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Real Precinct`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;Y&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    group_by&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;County&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; Precinct&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    summarize&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        total_vote_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;US PRESIDENT&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; na.rm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        dem_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;US PRESIDENT&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; `Choice Party`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;DEM&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; na.rm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;total_vote_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        gop_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;US PRESIDENT&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; `Choice Party`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;REP&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; na.rm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;total_vote_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        total_vote_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;US SENATE&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; na.rm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        dem_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;US SENATE&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; `Choice Party`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;DEM&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; na.rm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;total_vote_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        gop_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;US SENATE&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; `Choice Party`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;REP&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; na.rm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;total_vote_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        total_vote_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;NC GOVERNOR&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; na.rm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        dem_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;NC GOVERNOR&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; `Choice Party`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;DEM&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; na.rm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;total_vote_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        gop_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;NC GOVERNOR&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; `Choice Party`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;REP&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; na.rm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;total_vote_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        total_vote_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;grepl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;US HOUSE OF REPRESENTATIVES DISTRICT&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; `Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; na.rm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        dem_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;grepl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;US HOUSE OF REPRESENTATIVES DISTRICT&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; `Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;&amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; `Choice Party`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;DEM&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; na.rm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;total_vote_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        gop_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;`Total Votes`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;grepl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;US HOUSE OF REPRESENTATIVES DISTRICT&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; `Contest Name`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;&amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; `Choice Party`&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;REP&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; na.rm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;total_vote_house&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    ) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; ungroup&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; results_agg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;inner_join&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;results_agg&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; shapes&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; by&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;County&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;county_nam&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;Precinct&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;prec_id&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;DT&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;datatable&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; sample_n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dplyr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;select&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;geometry&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; rownames&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; FALSE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; options&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;list&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;scrollX&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; autoWidth&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;overflow-x:auto&quot;&gt;












































































































































































































































&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;County&lt;/th&gt;&lt;th&gt;Precinct&lt;/th&gt;&lt;th&gt;total_vote_pres&lt;/th&gt;&lt;th&gt;dem_share_pres&lt;/th&gt;&lt;th&gt;gop_share_pres&lt;/th&gt;&lt;th&gt;total_vote_senate&lt;/th&gt;&lt;th&gt;dem_share_senate&lt;/th&gt;&lt;th&gt;gop_share_senate&lt;/th&gt;&lt;th&gt;total_vote_gov&lt;/th&gt;&lt;th&gt;dem_share_gov&lt;/th&gt;&lt;th&gt;gop_share_gov&lt;/th&gt;&lt;th&gt;total_vote_house&lt;/th&gt;&lt;th&gt;dem_share_house&lt;/th&gt;&lt;th&gt;gop_share_house&lt;/th&gt;&lt;th&gt;id&lt;/th&gt;&lt;th&gt;enr_desc&lt;/th&gt;&lt;th&gt;of_prec_id&lt;/th&gt;&lt;th&gt;county_id&lt;/th&gt;&lt;th&gt;blockid&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;WAKE&lt;/td&gt;&lt;td&gt;16-07&lt;/td&gt;&lt;td&gt;462&lt;/td&gt;&lt;td&gt;0.3182&lt;/td&gt;&lt;td&gt;0.632&lt;/td&gt;&lt;td&gt;455&lt;/td&gt;&lt;td&gt;0.3099&lt;/td&gt;&lt;td&gt;0.6176&lt;/td&gt;&lt;td&gt;460&lt;/td&gt;&lt;td&gt;0.3978&lt;/td&gt;&lt;td&gt;0.5804&lt;/td&gt;&lt;td&gt;457&lt;/td&gt;&lt;td&gt;0.3414&lt;/td&gt;&lt;td&gt;0.6018&lt;/td&gt;&lt;td&gt;2319&lt;/td&gt;&lt;td&gt;16-07&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;92&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;WAKE&lt;/td&gt;&lt;td&gt;20-11&lt;/td&gt;&lt;td&gt;626&lt;/td&gt;&lt;td&gt;0.3371&lt;/td&gt;&lt;td&gt;0.631&lt;/td&gt;&lt;td&gt;621&lt;/td&gt;&lt;td&gt;0.3076&lt;/td&gt;&lt;td&gt;0.6264&lt;/td&gt;&lt;td&gt;622&lt;/td&gt;&lt;td&gt;0.3923&lt;/td&gt;&lt;td&gt;0.5932&lt;/td&gt;&lt;td&gt;605&lt;/td&gt;&lt;td&gt;0.3355&lt;/td&gt;&lt;td&gt;0.6264&lt;/td&gt;&lt;td&gt;2363&lt;/td&gt;&lt;td&gt;20-11&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;92&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;SWAIN&lt;/td&gt;&lt;td&gt;WHCH&lt;/td&gt;&lt;td&gt;2005&lt;/td&gt;&lt;td&gt;0.5711&lt;/td&gt;&lt;td&gt;0.405&lt;/td&gt;&lt;td&gt;1976&lt;/td&gt;&lt;td&gt;0.5273&lt;/td&gt;&lt;td&gt;0.3917&lt;/td&gt;&lt;td&gt;1988&lt;/td&gt;&lt;td&gt;0.583&lt;/td&gt;&lt;td&gt;0.3888&lt;/td&gt;&lt;td&gt;1960&lt;/td&gt;&lt;td&gt;0.5485&lt;/td&gt;&lt;td&gt;0.3908&lt;/td&gt;&lt;td&gt;2460&lt;/td&gt;&lt;td&gt;WHCH&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;87&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;CRAVEN&lt;/td&gt;&lt;td&gt;20&lt;/td&gt;&lt;td&gt;2615&lt;/td&gt;&lt;td&gt;0.356&lt;/td&gt;&lt;td&gt;0.6333&lt;/td&gt;&lt;td&gt;2598&lt;/td&gt;&lt;td&gt;0.3499&lt;/td&gt;&lt;td&gt;0.6159&lt;/td&gt;&lt;td&gt;2610&lt;/td&gt;&lt;td&gt;0.3782&lt;/td&gt;&lt;td&gt;0.6142&lt;/td&gt;&lt;td&gt;2559&lt;/td&gt;&lt;td&gt;0.3369&lt;/td&gt;&lt;td&gt;0.6631&lt;/td&gt;&lt;td&gt;1498&lt;/td&gt;&lt;td&gt;FAIRFIELD HARBOUR&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;25&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BUNCOMBE&lt;/td&gt;&lt;td&gt;21.1&lt;/td&gt;&lt;td&gt;919&lt;/td&gt;&lt;td&gt;0.7367&lt;/td&gt;&lt;td&gt;0.2448&lt;/td&gt;&lt;td&gt;911&lt;/td&gt;&lt;td&gt;0.7179&lt;/td&gt;&lt;td&gt;0.2448&lt;/td&gt;&lt;td&gt;911&lt;/td&gt;&lt;td&gt;0.7684&lt;/td&gt;&lt;td&gt;0.2151&lt;/td&gt;&lt;td&gt;904&lt;/td&gt;&lt;td&gt;0.7334&lt;/td&gt;&lt;td&gt;0.2367&lt;/td&gt;&lt;td&gt;1808&lt;/td&gt;&lt;td&gt;HAW CREEK ELEMENTARY SCHOOL&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;11&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ORANGE&lt;/td&gt;&lt;td&gt;CS1&lt;/td&gt;&lt;td&gt;176&lt;/td&gt;&lt;td&gt;0.3409&lt;/td&gt;&lt;td&gt;0.625&lt;/td&gt;&lt;td&gt;175&lt;/td&gt;&lt;td&gt;0.3371&lt;/td&gt;&lt;td&gt;0.6286&lt;/td&gt;&lt;td&gt;176&lt;/td&gt;&lt;td&gt;0.3977&lt;/td&gt;&lt;td&gt;0.5511&lt;/td&gt;&lt;td&gt;173&lt;/td&gt;&lt;td&gt;0.3815&lt;/td&gt;&lt;td&gt;0.6185&lt;/td&gt;&lt;td&gt;178&lt;/td&gt;&lt;td&gt;COLES STORE&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;68&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;GUILFORD&lt;/td&gt;&lt;td&gt;OR2&lt;/td&gt;&lt;td&gt;291&lt;/td&gt;&lt;td&gt;0.2062&lt;/td&gt;&lt;td&gt;0.7629&lt;/td&gt;&lt;td&gt;292&lt;/td&gt;&lt;td&gt;0.1849&lt;/td&gt;&lt;td&gt;0.75&lt;/td&gt;&lt;td&gt;294&lt;/td&gt;&lt;td&gt;0.2449&lt;/td&gt;&lt;td&gt;0.7279&lt;/td&gt;&lt;td&gt;289&lt;/td&gt;&lt;td&gt;0.2215&lt;/td&gt;&lt;td&gt;0.7785&lt;/td&gt;&lt;td&gt;966&lt;/td&gt;&lt;td&gt;OR2&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;41&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;HENDERSON&lt;/td&gt;&lt;td&gt;SM&lt;/td&gt;&lt;td&gt;2513&lt;/td&gt;&lt;td&gt;0.2475&lt;/td&gt;&lt;td&gt;0.7374&lt;/td&gt;&lt;td&gt;2491&lt;/td&gt;&lt;td&gt;0.2316&lt;/td&gt;&lt;td&gt;0.7206&lt;/td&gt;&lt;td&gt;2504&lt;/td&gt;&lt;td&gt;0.276&lt;/td&gt;&lt;td&gt;0.7065&lt;/td&gt;&lt;td&gt;2483&lt;/td&gt;&lt;td&gt;0.2384&lt;/td&gt;&lt;td&gt;0.7334&lt;/td&gt;&lt;td&gt;793&lt;/td&gt;&lt;td&gt;SOUTH MILLS RIVER&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;45&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;HOKE&lt;/td&gt;&lt;td&gt;01&lt;/td&gt;&lt;td&gt;274&lt;/td&gt;&lt;td&gt;0.3723&lt;/td&gt;&lt;td&gt;0.6095&lt;/td&gt;&lt;td&gt;270&lt;/td&gt;&lt;td&gt;0.3889&lt;/td&gt;&lt;td&gt;0.5667&lt;/td&gt;&lt;td&gt;273&lt;/td&gt;&lt;td&gt;0.4505&lt;/td&gt;&lt;td&gt;0.5385&lt;/td&gt;&lt;td&gt;269&lt;/td&gt;&lt;td&gt;0.3903&lt;/td&gt;&lt;td&gt;0.6097&lt;/td&gt;&lt;td&gt;736&lt;/td&gt;&lt;td&gt;ALLENDALE&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;47&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;GUILFORD&lt;/td&gt;&lt;td&gt;G32&lt;/td&gt;&lt;td&gt;270&lt;/td&gt;&lt;td&gt;0.3481&lt;/td&gt;&lt;td&gt;0.6222&lt;/td&gt;&lt;td&gt;271&lt;/td&gt;&lt;td&gt;0.3284&lt;/td&gt;&lt;td&gt;0.6458&lt;/td&gt;&lt;td&gt;270&lt;/td&gt;&lt;td&gt;0.4111&lt;/td&gt;&lt;td&gt;0.5704&lt;/td&gt;&lt;td&gt;261&lt;/td&gt;&lt;td&gt;0.3602&lt;/td&gt;&lt;td&gt;0.6398&lt;/td&gt;&lt;td&gt;919&lt;/td&gt;&lt;td&gt;G32&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;41&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;The original post rendered this as an interactive &lt;code&gt;DT::datatable&lt;/code&gt; widget showing a
random sample of 100 precincts. It has been replaced here by the first 10 rows as a
static table — truncated for the static rebuild, so no client-side JavaScript is
needed.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;add-some-geographic-features&quot;&gt;Add some geographic features&lt;/h3&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;geometry&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    st_centroid&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    st_transform&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;+init=epsg:4326&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    st_coordinates&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; latlong&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;longitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; latlong&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;X&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;latitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; latlong&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;Y&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;area&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;geometry&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; st_transform&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;+init=epsg:4326&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; st_area&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;area_km2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; units&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;drop_units&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;area&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 1e6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # convert m^2 to km^2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; mutate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;vote_density_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; total_vote_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; area_km2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;assign-treatment-four-ways&quot;&gt;Assign treatment four ways&lt;/h2&gt;
&lt;h3 id=&quot;softblock&quot;&gt;Softblock&lt;/h3&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;start_time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; lubridate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; assign_softblock&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    longitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; latitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; area_km2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; vote_density_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # geographic&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 presidential&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 senate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 governor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 house&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;rename&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;treatment_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;treatment&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;softblock_weights&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; attr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;laplacian&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;end_time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; lubridate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;end_time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; start_time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;text&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Time difference of 0.7473469 secs&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;greedy-nearest-neighbors&quot;&gt;Greedy nearest neighbors&lt;/h3&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;start_time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; lubridate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; assign_greedy_neighbors&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    longitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; latitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; area_km2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; vote_density_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # geographic&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 presidential&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 senate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 governor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 house&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;rename&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;treatment_nn&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;treatment&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;nn_weights&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; attr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;laplacian&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;end_time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; lubridate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;end_time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; start_time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;text&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Time difference of 1.482411 secs&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;quickblock&quot;&gt;QuickBlock&lt;/h3&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;start_time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; lubridate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dplyr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;select&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    longitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; latitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; area_km2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; vote_density_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # geographic&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 presidential&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 senate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 governor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 house&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_qb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;qb_blocks&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; quickblock&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;as.data.frame&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; size_constraint&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 6L&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;treatment_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; as.integer&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;as.character&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;assign_treatment&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;qb_blocks&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; treatments&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;0&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &apos;1&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;end_time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; lubridate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;end_time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; start_time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;text&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Time difference of 0.03046703 secs&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;matched-pairs&quot;&gt;Matched Pairs&lt;/h3&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;# This is extremely slow.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;# start_time = lubridate::now()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;# df_joined %&gt;% assign_matched_pairs(c(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;#     longitude, latitude, area_km2, vote_density_pres, # geographic&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;#     total_vote_pres, dem_share_pres, gop_share_pres, # 2020 presidential&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;#     total_vote_senate, dem_share_senate, gop_share_senate, # 2020 senate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;#     total_vote_gov, dem_share_gov, gop_share_gov, # 2020 governor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;#     total_vote_house, dem_share_house, gop_share_house # 2020 house&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;# )) %&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;# rename(treatment_mp=treatment)-&gt; df_joined&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;# mp_weights &amp;#x3C;- attr(df_joined, &quot;laplacian&quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;# end_time = lubridate::now()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt;# print(end_time - start_time)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;power-simulation&quot;&gt;Power simulation&lt;/h2&gt;
&lt;p&gt;To do power calculations consistently across methods, I will do the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Calculate the implied regression adjustment for each design, applied to vote share in 2020 as the outcome.&lt;/li&gt;
&lt;li&gt;Find the residual for each point.&lt;/li&gt;
&lt;li&gt;Permute residuals over units.&lt;/li&gt;
&lt;li&gt;Estimate power for a given effect size by pulling additional permutations.&lt;/li&gt;
&lt;li&gt;Sweep over a range of effect sizes.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;create_power_simulator&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; Y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    dL&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; diag&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    Dinv&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    estimates&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; drop&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;Dinv&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; Y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    residuals&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; Y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; estimates&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    x_mat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; cbind&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    xlx&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x_mat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; x_mat&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    bread&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; MASS&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;ginv&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;as.matrix&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;xlx&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    detect_effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        sim_outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; estimates&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; sample&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;residuals&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; effect&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        coefs&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; bread&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x_mat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; sim_outcome&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        r&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; diag&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;drop&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;sim_outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x_mat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; coefs&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;^&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        meat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x_mat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; x_mat&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        vcv&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; bread&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; meat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; bread&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        upr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; coefs&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; qnorm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0.975&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; sqrt&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;vcv&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        lwr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; coefs&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; qnorm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0.025&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; sqrt&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;vcv&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        lwr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    detect_effect&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;create_power_simulator_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;blocks&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; Y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    estimate_by_block&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; tapply&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; blocks&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; mean&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; tapply&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; blocks&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; mean&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    estimates&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; unlist&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;purrr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;blocks&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate_by_block&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;as.character&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)]))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    residuals&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; Y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; estimates&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    detect_effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        sim_outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; estimates&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; sample&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;residuals&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; effect&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        result&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; quickblock&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;blocking_estimator&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;sim_outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; blocks&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        upr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; result&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; qnorm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0.975&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; sqrt&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;result&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect_variances&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        lwr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; result&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; qnorm&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0.025&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; sqrt&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;result&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect_variances&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        lwr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    detect_effect&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;simulate-each-design&quot;&gt;Simulate each design&lt;/h3&gt;
&lt;h4 id=&quot;softblock-1&quot;&gt;Softblock&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;simulate_power&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; create_power_simulator&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;softblock_weights&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;treatment_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;dem_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate_power_for_effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;mean&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;replicate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; simulate_power&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; seq&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 0.05&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; length&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;power_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; unlist&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;purrr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; estimate_power_for_effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;greedy-neighbors&quot;&gt;Greedy Neighbors&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;simulate_power&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; create_power_simulator&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;nn_weights&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;treatment_nn&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;dem_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate_power_for_effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;mean&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;replicate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; simulate_power&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;power_nn&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; unlist&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;purrr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; estimate_power_for_effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;quickblock-1&quot;&gt;QuickBlock&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;simulate_power&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; create_power_simulator_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;qb_blocks&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;treatment_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;dem_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate_power_for_effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;mean&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;replicate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; simulate_power&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; seq&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 0.05&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; length&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;power_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; unlist&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;purrr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; estimate_power_for_effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;power-comparison&quot;&gt;Power Comparison&lt;/h3&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;ggplot&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    tibble&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        power&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;power_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; power_nn&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; power_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        design&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;rep&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;SoftBlock&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; length&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;power_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; rep&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;Greedy Neighbors&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; length&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;power_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; rep&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;QuickBlock&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; length&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;power_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    )&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; aes&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; power&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; color&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;design&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; geom_line&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    scale_x_continuous&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;Effect (pp)&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; labels&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;scales&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;percent&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    scale_y_continuous&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;Power&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; labels&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;scales&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;percent&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    scale_color_discrete&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;Design&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    theme_minimal&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img alt=&quot;Power by effect size for each design&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1344&quot; height=&quot;960&quot; src=&quot;/_astro/power_plot-1.CcSkI-OA_ZX6Xoe.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;analysis&quot;&gt;Analysis&lt;/h2&gt;
&lt;h3 id=&quot;average-effects&quot;&gt;Average Effects&lt;/h3&gt;
&lt;p&gt;The effect estimates here use the appropriate design-based estimators for each design.&lt;/p&gt;
&lt;p&gt;First, I’m going to generate a fake outcome to use. I’ll leave the average effect near zero (0.5pp), but individual effects are random draws from around that vale, but with heterogeneous effects based on democratic vote share in 2020 (i.e. positive effects in democratic precincts and vice versa).&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;dem_share_pres&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;ite&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; with&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 0.005&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 0.005&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;plogis&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;dem_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; median&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;dem_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; sd&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;dem_share_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;outcome_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; with&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; treatment_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; ite&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;outcome_nn&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; with&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; treatment_nn&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; ite&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;outcome_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; with&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; treatment_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; ite&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;softblock-2&quot;&gt;Softblock&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate_effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; Y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    dL&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; diag&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    Dinv&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    x_mat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; cbind&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    xlx&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x_mat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; x_mat&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    bread&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; MASS&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;ginv&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;as.matrix&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;xlx&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    coefs&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; bread&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x_mat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; Y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    r&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; diag&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;drop&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x_mat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; coefs&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;^&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    meat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; t&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x_mat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; r&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; W&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; x_mat&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    vcv&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; bread&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; meat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %*%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; bread&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    list&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;coefs&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; std.error&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sqrt&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;vcv&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;sb_est&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; estimate_effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;softblock_weights&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;treatment_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;outcome_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;greedy-neighbors-1&quot;&gt;Greedy Neighbors&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;nn_est&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; estimate_effect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;nn_weights&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;treatment_nn&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;outcome_nn&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;quickblock-2&quot;&gt;QuickBlock&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;result&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; quickblock&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;blocking_estimator&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;outcome_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; qb_blocks&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;treatment_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;qb_est&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; list&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;result&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effects&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; std.error&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;sqrt&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;result&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;effect_variances&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;plot-average-effects&quot;&gt;Plot Average Effects&lt;/h3&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;tibble&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    estimate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;sb_est&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; nn_est&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; qb_est&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    std.error&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;sb_est&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;std.error&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; nn_est&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;std.error&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; qb_est&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;std.error&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    design&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;SoftBlock&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;Greedy Neighbors&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt; &quot;QuickBlock&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;ggplot&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;aes&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;design&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; ymin&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1.96&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;std.error&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; ymax&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;estimate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1.96&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;std.error&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    geom_pointrange&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    scale_x_discrete&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;Design&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    scale_y_continuous&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;ATE (pp)&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; labels&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;scales&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;percent&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    coord_flip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;    theme_minimal&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img alt=&quot;Average treatment effect estimates with 95% intervals, by design&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1344&quot; height=&quot;960&quot; src=&quot;/_astro/plot_fx-1.D-zI40eb_2iBEFm.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;
&lt;h3 id=&quot;heterogeneous-effects&quot;&gt;Heterogeneous Effects&lt;/h3&gt;
&lt;p&gt;These effects will be estimated using DR-learner of &lt;a href=&quot;https://arxiv.org/abs/2004.14497&quot;&gt;Kennedy (2020)&lt;/a&gt;. For simplicity, I will estimate nuisance functions using &lt;code&gt;glmnet&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;predict.hte.split&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; predict.s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    s.pi&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;predict.s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    s.mu&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;predict.s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    s.dr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;predict.s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    pihat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; predict&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;cv.glmnet&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s.pi&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s.pi&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; family&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;binomial&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; nfolds&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; newx&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;response&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;lambda.min&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    mu0hat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; predict&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;cv.glmnet&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s.mu&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s.mu&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; nfolds&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; newx&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;response&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;lambda.min&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    mu1hat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; predict&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;cv.glmnet&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s.mu&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s.mu&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; nfolds&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;newx&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;response&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;lambda.min&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    pseudo&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; ((&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;pihat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;pihat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;pihat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)))&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;mu1hat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;mu0hat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; mu1hat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; mu0hat&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    drl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; predict&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;cv.glmnet&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s.dr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;pseudo&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s.dr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;])&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;newx&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;predict.s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; ]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;lambda.min&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    drl&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;predict.hte.crossfit&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    N&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; length&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; sample&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; N&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; replace&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    hte&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; rep&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;NA_real_&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; N&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;    for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;        hte&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; predict.hte.split&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; y&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; predict.s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    hte&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;calculate_hte&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;.data&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; cols&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; .treatment&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;treatment&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; .outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;outcome&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    expr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; rlang&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;enquo&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;cols&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    pos&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; tidyselect&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;eval_select&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;expr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; data&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; .data&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    df_cov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; &amp;#x3C;-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; rlang&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;set_names&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;.data&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;pos&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; names&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;pos&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    cov_mat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; scale&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;model.matrix&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;~&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_cov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    .data&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; predict.hte.crossfit&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;cov_mat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; .data&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;.treatment&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; .data&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;[[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;.outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;]])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    .data&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;estimate-htes&quot;&gt;Estimate HTEs&lt;/h3&gt;
&lt;h4 id=&quot;softblock-3&quot;&gt;Softblock&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; calculate_hte&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    longitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; latitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; area_km2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; vote_density_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # geographic&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 presidential&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 senate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 governor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 house&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; .treatment&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;treatment_sb&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; .outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;outcome_sb&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; rename&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;text&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;-0.010306  0.004135  0.007536  0.007148  0.009029  0.033580 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;greedy-neighbors-2&quot;&gt;Greedy Neighbors&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; calculate_hte&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    longitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; latitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; area_km2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; vote_density_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # geographic&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 presidential&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 senate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 governor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 house&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; .treatment&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;treatment_nn&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; .outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;outcome_nn&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; rename&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte_nn&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte_nn&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;text&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;0.005742 0.006825 0.007388 0.007670 0.008596 0.010863 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;quickblock-3&quot;&gt;QuickBlock&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt; %&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; calculate_hte&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    longitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; latitude&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; area_km2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; vote_density_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # geographic&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_pres&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 presidential&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_senate&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 senate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_gov&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 governor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;    total_vote_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; dem_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; gop_share_house&lt;/span&gt;&lt;span style=&quot;--shiki-light:#66707B;--shiki-dark:#BDC4CC&quot;&gt; # 2020 house&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; .treatment&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;treatment_qb&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; .outcome&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;outcome_qb&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;%&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; rename&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; df_joined&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;text&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      Min.    1st Qu.     Median       Mean    3rd Qu.       Max. &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;-0.0007862  0.0070832  0.0083612  0.0082249  0.0094074  0.0398552 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;plot-hte-distributions&quot;&gt;Plot HTE distributions&lt;/h3&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light-high-contrast github-dark-high-contrast&quot; style=&quot;--shiki-light:#0e1116;--shiki-dark:#f0f3f6;--shiki-light-bg:#ffffff;--shiki-dark-bg:#0a0c10; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;&quot; tabindex=&quot;0&quot; data-language=&quot;r&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;ggplot&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;df_joined&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt; aes&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;geom_histogram&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;aes&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte_sb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; fill&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;SoftBlock&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; bins&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; alpha&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0.4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;geom_histogram&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;aes&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte_nn&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; fill&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;Greedy Neighbors&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; bins&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; alpha&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0.4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;geom_histogram&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;aes&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;hte_qb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; fill&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&apos;QuickBlock&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; bins&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; alpha&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#023B95;--shiki-dark:#91CBFF&quot;&gt;0.4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;scale_x_continuous&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032563;--shiki-dark:#ADDCFF&quot;&gt;&quot;Effect (pp)&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt; labels&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;scales&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--shiki-light:#702C00;--shiki-dark:#FFB757&quot;&gt;percent&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0111F;--shiki-dark:#FF9492&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#622CBC;--shiki-dark:#DBB7FF&quot;&gt;theme_minimal&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0E1116;--shiki-dark:#F0F3F6&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img alt=&quot;Distributions of estimated heterogeneous treatment effects by design&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1344&quot; height=&quot;960&quot; src=&quot;/_astro/hte_plot-1.COiopiVs_Za6X54.webp&quot; srcset=&quot;&quot;&gt;&lt;/p&gt;</content:encoded><category>experiments</category><category>demo</category></item></channel></rss>