<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Causal Conversations - with Basse and Bojinov</title><link>/</link><description>Recent content on Causal Conversations - with Basse and Bojinov</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Mon, 28 Jun 2021 00:00:00 +0000</lastBuildDate><atom:link href="/index.xml" rel="self" type="application/rss+xml"/><item><title>Correlation and Causation: Are regressions always wrong?</title><link>/post/correlation-causation/</link><pubDate>Mon, 28 Jun 2021 00:00:00 +0000</pubDate><guid>/post/correlation-causation/</guid><description>&lt;p>If you hang around causal folks for long enough, you&amp;rsquo;ll probably hear a
version of the sentence: &amp;ldquo;you can&amp;rsquo;t just run a regression on observational
data&amp;rdquo; sooner or later. Is that really true? Statisticians (and other
scientists) have been running regressions for a very long time, surely it
can&amp;rsquo;t be &lt;em>that&lt;/em> bad? Let&amp;rsquo;s have a closer look!&lt;/p>
&lt;h2 id="two-stories">Two stories&lt;/h2>
&lt;h3 id="a-first-example">A first example&lt;/h3>
&lt;p>Let&amp;rsquo;s say you&amp;rsquo;re working for an online music streaming service that
recently introduced a paid premium subscription service that allows
members to listen to music ad-free. The premium account model was
rolled out a few months ago and you wish to assess its impact on the
listening habits of users. You dig into the logs collected
by the service and you find something disturbing: it looks like subscribing
to the premium account &lt;strong>reduces&lt;/strong> (rather than increases) the listening time,
adjusting for the number of playlists a user has created. At the next team
meeting, you present the following plot:&lt;/p>
&lt;link rel="stylesheet" href="/css/hugo-easy-gallery.css" />
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/noncausal-fit.jpg" />
&lt;/div>
&lt;a href="/image/noncausal-fit.jpg" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>Observed data and fit.&lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;p>You explain that you ran the regression&lt;/p>
&lt;p>\[
Y_i = \alpha + \tau \, Z_i + \beta \, X_i + \epsilon_i
\]&lt;/p>
&lt;p>and found that the causal effect of signing up for a premium account is \(\hat{\tau}^{ols} = -3.24\) hours of
the member&amp;rsquo;s weekly listening time. What&amp;rsquo;s worse is that this estimate is
statistically significant from \(0\)!&lt;/p>
&lt;p>Thankfully one of your colleagues points out that among users with any
given number of playlists (\(X_i=x\)), older ones are both more likely
to be premium subscribers, and also likely to spend less time listening
to music than younger users: in other words, age is likely to be a
&lt;em>confounder&lt;/em>! Indeed, you dig a little more and plot \(Y\) against \(X\)
again, but this time you overlay the age \(U\):&lt;/p>
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/correlation-age.jpg" />
&lt;/div>
&lt;a href="/image/correlation-age.jpg" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>Illustrating age as a confounder.&lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;p>Which lends support to your colleague&amp;rsquo;s suspicion. In fact, we know the
ground truth (since, well, this is a fictional example and we generated
the data!). Indeed, the data was generated so that \(Y_i(1) = Y_i(0)\);
that is, the membership has absolutely &lt;strong>no effect&lt;/strong> on the listening time!&lt;/p>
&lt;p>Clearly, &amp;lsquo;&amp;lsquo;just running a regression&amp;rsquo;&amp;rsquo; did not work out so well. Perhaps
those causal folks are onto something.&lt;/p>
&lt;h3 id="a-second-example">A second example&lt;/h3>
&lt;p>One of your teammates working on the infrastructure noticed your plot and
was very interested. Indeed, the infrastructure team is having a hard time
figuring out how quickly they should increase their streaming capacity: too
quickly and they are wasting money; too slowly and they are providing
suboptimum bandwidth to the users. Based on your plot, she wonders whether
she could use the number of playlists (\(X\)) and the premium membership
status (\(Z\)) to &lt;strong>predict&lt;/strong> the amount of streaming time per user (\(Y\)),
which would be helpful in calibrating the bandwidth. Having learnt your lesson,
you flattly assert that regressions are evil, and that nothing good can come
off it.&lt;/p>
&lt;p>Your colleague is persistent though. She fits the regression on the available
data, then waits patiently for new data to come in to checks her predictions
against those new observations; the results are displayed in the Figure below.&lt;/p>
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/correlation_pred.jpg" />
&lt;/div>
&lt;a href="/image/correlation_pred.jpg" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>Checking quality of predictions&lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;p>Well, &amp;lsquo;&amp;lsquo;sorry dude but it just works,&amp;rsquo;&amp;rsquo; she says, as she goes back to her office
to use her predictions to improve the infrastructure.&lt;/p>
&lt;p>You scratch your head in confusion&amp;hellip; so regression works?&lt;/p>
&lt;h2 id="correlation-vs-causation">Correlation vs Causation&lt;/h2>
&lt;h3 id="what-happened">What happened?&lt;/h3>
&lt;p>So, what happened there? In the first example, regression gave us the wrong answer;
in the second example, it gave us the right answer. Why?&lt;/p>
&lt;p>Well, in the first example, you asked a &lt;strong>causal question&lt;/strong>: what
would be the causal effect of giving everyone a premium
subscription. As we saw in our &lt;a href="/post/causal-inf-intro">previous post &lt;/a> ,
answering such questions with observational data (as opposed to data
from a randomized experiment) requires care: in particular, it
requires that one adjust for all confounders (we will discuss
observational studies in more details in another post).&lt;/p>
&lt;p>The second example, however, has nothing to do with causal inference:
we asked a purely &lt;strong>predictive question&lt;/strong>. Now, of course, you still
need to be mindful of the usual prediction challenges (e.g. the
bias-variance tradeoff, overfitting, etc&amp;hellip;), but unmeasured confounders
have no special role here.&lt;/p>
&lt;h3 id="takeaway">Takeaway&lt;/h3>
&lt;p>So can you &amp;lsquo;&amp;lsquo;just run a regression&amp;rsquo;&amp;rsquo;? It depends on the type of
question you&amp;rsquo;re asking. If you&amp;rsquo;re asking a causal question, then you
should be worrying about unmeasured confounders (among other things);
if you&amp;rsquo;re asking a predictive question (or indeed, a simple
descriptive question), then you can use your usual tools without being
paranoid about unmeasured confounders.&lt;/p></description></item><item><title>A Leader's Guide to Causal Inference</title><link>/post/causal-inf-intro/</link><pubDate>Mon, 24 May 2021 00:00:00 +0000</pubDate><guid>/post/causal-inf-intro/</guid><description>&lt;h2 id="what-is-causal-inference">What is causal inference?&lt;/h2>
&lt;p>Causal inference is a vast field that seeks to address questions relating causes to effects. We more formally (but still not very rigorously) define causal inference as the study of how a &lt;strong>treatment&lt;/strong> (aka &lt;strong>action&lt;/strong> or &lt;strong>intervention&lt;/strong>) affects outcomes of interest relative to an alternate &lt;strong>treatment&lt;/strong>. Often, one of the treatments represents a baseline or status quo: it is then called a &lt;strong>control&lt;/strong>. Academics have used causal reasoning for over a century to establish many scientific findings we now consider as facts. In the past decade, there has been a rapid increase in the adoption of causal thinking by firms, and it is now an integral part of data science.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Examples: causal questions&lt;/strong>&lt;/p>
&lt;ol>
&lt;li>What is the effect on the throughput time (outcome) of introducing a new drill to a production line (treatment) relative to the current process (control)?&lt;/li>
&lt;li>What is the effect of changing the text on the landing page&amp;rsquo;s button (treatment) on the clickthrough rate (outcome), relative to the current text (control)?&lt;/li>
&lt;li>Which of two hospital admission processess (treatment 1 vs treatment 2) leads to the better health results (outcome)?&lt;/li>
&lt;/ol>
&lt;/blockquote>
&lt;p>The most reliable way to establish causal relationships is to run a randomized experiment. Different fields have different names for these, including A/B tests, clinical trials, randomized control trials, etc&amp;hellip; but basically, a randomized experiment involves randomly assigning subjects (e.g., customers, divisions, companies) to either receive a treatment or a control intervention. The effectiveness of the treatment is then assessed by contrasting the outcomes of the treated subjects to the outcomes of the control subjects.&lt;/p>
&lt;p>The simple idea of running experiments has had a profound impact on how managers make decisions, as it allows them to discern their customers&amp;rsquo; preferences, evaluate their initiatives, and ultimately test their hypotheses. Experimentation is now an integral part of the product development process at most technology companies. It is increasingly being adopted by non-technology companies as well, as they recognize that experimentation allows managers to continuously challenge their working hypotheses and perform pivots that ultimately lead to better innovations.&lt;/p>
&lt;p>Unfortunately, we cannot always run experiments because of ethical concerns, high costs, or an inability to control the random assignment directly. Luckily, this is a challenge that academics have grappled with for a long time, and they have developed many different strategies for identifying causal effects from non-experimental (i.e., observational) data. For example, we know that smoking causes cancer even though no one ever ran a randomized experiment to measure the effect of smoking. However, it is important to understand that causal claims from observational data are inherently less reliable than claims derived from experimental evidence and can be subject to severe biases.&lt;/p>
&lt;p>This post provides a high-level overview of these two methods.&lt;/p>
&lt;h2 id="observational-studies">Observational Studies&lt;/h2>
&lt;p>The vast majority of statistics courses begin and end with the premise that correlation is not causation. But they rarely explain why we can not directly assume that correlation is not causation.&lt;/p>
&lt;h3 id="does-signing-up-to-a-premium-account-reduce-music-streaming">Does signing up to a premium account reduce music streaming?&lt;/h3>
&lt;p>Let&amp;rsquo;s consider a simple example. Imagine you are working as a data scientist for Musicfi, a firm that offers on-demand music streaming services. To keep things simple, let&amp;rsquo;s assume the firm has two account types: a free account and a premium account. Musicfi&amp;rsquo;s main measure of customer engagement is the total streaming minutes that measure how many minutes each customer spent on the service per day. As a data scientist, you want to understand your customers, so you decide to perform a simple analysis that compares the total streaming minutes across the two account types. To put this in causal terms:&lt;/p>
&lt;ul>
&lt;li>Our treatment is having a premium account.&lt;/li>
&lt;li>Our control is having a free account.&lt;/li>
&lt;li>Our outcome is total streaming minutes.&lt;/li>
&lt;/ul>
&lt;link rel="stylesheet" href="/css/hugo-easy-gallery.css" />
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/StreamingMinutesByAccountType.png" />
&lt;/div>
&lt;a href="/image/StreamingMinutesByAccountType.png" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>Barplot of Streaming Minutes Split by Account Type.&lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;p>From the figure, we can see that the customers with premium accounts had lower total streaming minutes than customers with free accounts! The average in the premium group was 71 minutes compared to 81 minutes in the free group, meaning that (on average) customers with a premium account listened to less music!! We can use a t-test to check if this observed difference is statistically significant:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-R" data-lang="R">&lt;span class="c1"># UPDATE&lt;/span>
&lt;span class="nf">t.test&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">StreamingMinutes[AccountType&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s">&amp;#34;Free&amp;#34;&lt;/span>&lt;span class="n">]&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">StreamingMinutes[AccountType&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s">&amp;#34;Premium&amp;#34;&lt;/span>&lt;span class="n">]&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="n">Welch&lt;/span> &lt;span class="n">Two&lt;/span> &lt;span class="n">Sample&lt;/span> &lt;span class="n">t&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">test&lt;/span>
&lt;span class="n">data&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="n">StreamingMinutes[AccountType&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s">&amp;#34;Free&amp;#34;&lt;/span>&lt;span class="n">]&lt;/span> &lt;span class="n">and&lt;/span> &lt;span class="n">StreamingMinutes[AccountType&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s">&amp;#34;Premium&amp;#34;&lt;/span>&lt;span class="n">]&lt;/span>
&lt;span class="n">t&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="m">13.756&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">df&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="m">428.07&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">p&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">value&lt;/span> &lt;span class="o">&amp;lt;&lt;/span> &lt;span class="m">2.2e-16&lt;/span>
&lt;span class="n">alternative&lt;/span> &lt;span class="n">hypothesis&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="n">true&lt;/span> &lt;span class="n">difference&lt;/span> &lt;span class="n">in&lt;/span> &lt;span class="n">means&lt;/span> &lt;span class="n">is&lt;/span> &lt;span class="n">not&lt;/span> &lt;span class="n">equal&lt;/span> &lt;span class="n">to&lt;/span> &lt;span class="m">0&lt;/span>
&lt;span class="m">95&lt;/span> &lt;span class="n">percent&lt;/span> &lt;span class="n">confidence&lt;/span> &lt;span class="n">interval&lt;/span>&lt;span class="o">:&lt;/span>
&lt;span class="m">8.244544&lt;/span> &lt;span class="m">10.993385&lt;/span>
&lt;span class="n">sample&lt;/span> &lt;span class="n">estimates&lt;/span>&lt;span class="o">:&lt;/span>
&lt;span class="n">mean&lt;/span> &lt;span class="n">of&lt;/span> &lt;span class="n">x&lt;/span> &lt;span class="n">mean&lt;/span> &lt;span class="n">of&lt;/span> &lt;span class="n">y&lt;/span>
&lt;span class="m">81.49807&lt;/span> &lt;span class="m">71.87910&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Suppose we take the above results at face value. In that case, we might incorrectly conclude that having a premium account reduces customer engagement. But this seems unlikely! Our general understanding suggests that buying a premium account should have the opposite effect. So what&amp;rsquo;s going on? Well, we are likely falling victim to what is often called &lt;strong>selection bias&lt;/strong>. Selection bias occurs when the treatment group is systematically different from the control group before the treatment has occurred, making it hard to disentangle differences due to the treatment from those due to the systematic difference between the two groups.&lt;/p>
&lt;p>Mathematically, we can model selection bias as a third variable&amp;mdash;often called a confounding variable&amp;mdash;associated with both a unit&amp;rsquo;s propensity to receive the treatment and that unit&amp;rsquo;s outcome. In our Musicfi example, this variable could be the age of the customer: younger customers tend to listen to more music and are less likely to purchase a premium account. Therefore, the age variable is a confounding variable as it limits our ability to draw causal inferences.&lt;/p>
&lt;p>To see this, we can compare how age is related to total streaming minutes and the account type.&lt;/p>
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/StreamingMinutesByAge.png" />
&lt;/div>
&lt;a href="/image/StreamingMinutesByAge.png" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>There is a clear relationship between Streaming Minutes and Age: Younger users stream a lot more than older users!&lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;p>If we wanted to adjust for the age variable (assuming it is observed), we could run a linear regression:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-R" data-lang="R">&lt;span class="c1"># Need to update&lt;/span>
&lt;span class="o">&amp;gt;&lt;/span> &lt;span class="nf">summary&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nf">lm&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">StreamingMinutes&lt;/span> &lt;span class="o">~&lt;/span> &lt;span class="n">AccountType&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="n">Age&lt;/span>&lt;span class="p">))&lt;/span>
&lt;span class="n">Call&lt;/span>&lt;span class="o">:&lt;/span>
&lt;span class="nf">lm&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">formula&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">StreamingMinutes&lt;/span> &lt;span class="o">~&lt;/span> &lt;span class="n">AccountType&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="n">Age&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="n">Residuals&lt;/span>&lt;span class="o">:&lt;/span>
&lt;span class="n">Min&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="n">Q&lt;/span> &lt;span class="n">Median&lt;/span> &lt;span class="m">3&lt;/span>&lt;span class="n">Q&lt;/span> &lt;span class="n">Max&lt;/span>
&lt;span class="m">-10.9809&lt;/span> &lt;span class="m">-1.9480&lt;/span> &lt;span class="m">0.2115&lt;/span> &lt;span class="m">2.0191&lt;/span> &lt;span class="m">8.3711&lt;/span>
&lt;span class="n">Coefficients&lt;/span>&lt;span class="o">:&lt;/span>
&lt;span class="n">Estimate&lt;/span> &lt;span class="n">Std.&lt;/span> &lt;span class="n">Error&lt;/span> &lt;span class="n">t&lt;/span> &lt;span class="n">value&lt;/span> &lt;span class="nf">Pr&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="o">&amp;gt;|&lt;/span>&lt;span class="n">t&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="p">(&lt;/span>&lt;span class="n">Intercept&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="m">100.74363&lt;/span> &lt;span class="m">0.37325&lt;/span> &lt;span class="m">269.91&lt;/span> &lt;span class="o">&amp;lt;&lt;/span> &lt;span class="m">2e-16&lt;/span> &lt;span class="o">***&lt;/span>
&lt;span class="n">AccountTypePremium&lt;/span> &lt;span class="m">1.23146&lt;/span> &lt;span class="m">0.31415&lt;/span> &lt;span class="m">3.92&lt;/span> &lt;span class="m">0.000101&lt;/span> &lt;span class="o">***&lt;/span>
&lt;span class="n">Age&lt;/span> &lt;span class="m">-1.05867&lt;/span> &lt;span class="m">0.01736&lt;/span> &lt;span class="m">-60.97&lt;/span> &lt;span class="o">&amp;lt;&lt;/span> &lt;span class="m">2e-16&lt;/span> &lt;span class="o">***&lt;/span>
&lt;span class="o">---&lt;/span>
&lt;span class="n">Signif.&lt;/span> &lt;span class="n">codes&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="m">0&lt;/span> ‘&lt;span class="o">***&lt;/span>’ &lt;span class="m">0.001&lt;/span> ‘&lt;span class="o">**&lt;/span>’ &lt;span class="m">0.01&lt;/span> ‘&lt;span class="o">*&lt;/span>’ &lt;span class="m">0.05&lt;/span> ‘&lt;span class="n">.’&lt;/span> &lt;span class="m">0.1&lt;/span> ‘ ’ &lt;span class="m">1&lt;/span>
&lt;span class="n">Residual&lt;/span> &lt;span class="n">standard&lt;/span> &lt;span class="n">error&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="m">2.93&lt;/span> &lt;span class="n">on&lt;/span> &lt;span class="m">497&lt;/span> &lt;span class="n">degrees&lt;/span> &lt;span class="n">of&lt;/span> &lt;span class="n">freedom&lt;/span>
&lt;span class="n">Multiple&lt;/span> &lt;span class="n">R&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">squared&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="m">0.9086&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Adjusted&lt;/span> &lt;span class="n">R&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">squared&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="m">0.9082&lt;/span>
&lt;span class="bp">F&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">statistic&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="m">2470&lt;/span> &lt;span class="n">on&lt;/span> &lt;span class="m">2&lt;/span> &lt;span class="n">and&lt;/span> &lt;span class="m">497&lt;/span> &lt;span class="n">DF&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">p&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">value&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="o">&amp;lt;&lt;/span> &lt;span class="m">2.2e-16&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/ResidualsStreamingMinutesByAccountType.png" />
&lt;/div>
&lt;a href="/image/ResidualsStreamingMinutesByAccountType.png" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>To see the effect of AccountType after adjusting for Age, we can plot the residuals from the regression of Age on Streaming Minutes. &lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;p>From the above, we can see that the effect of account type on total streaming minutes, controlling for age, is now positive!
However, even after controlling for age, can we be confident in interpreting this as a causal outcome of a hospital stay?
The answer is still most likely no. That is because there may exist more confounding variables that are not a part of our data set; these are known as unobserved confounders. Even if there were no unobserved confounders, there are much more robust methods for analyzing observational studies than linear regression. We will discuss these in more detail in future posts.&lt;/p>
&lt;h2 id="randomized-experiments">Randomized Experiments&lt;/h2>
&lt;p>Randomized experiments remove the selection problem and ensure that there are no confounding variables (observed or unobserved). They do this by removing the individual&amp;rsquo;s opportunity to select whether or not they receive the treatment. In the Musicfi example, if we randomly upgraded some free accounts to premium accounts, then we would no longer have to adjust for age as (on average) there will be no age difference between the treated and control subjects.&lt;/p>
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/RandExpAgeByAccountType.png" />
&lt;/div>
&lt;a href="/image/RandExpAgeByAccountType.png" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>There is no difference in the distribution of age across the two account types. &lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;p>So even though age is still correlated with the amount of music that Musicfi customers listen to:&lt;/p>
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/RandExpStreamingMinutesByAge.png" />
&lt;/div>
&lt;a href="/image/RandExpStreamingMinutesByAge.png" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>Relationship between age and streaming minutes.&lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;p>Age is not a confounding variables as it is indepedent of the treatment assignement. We can now directly attribute any differences in the outcome due to the intervention. Allowing us to conclude that giving people a premium account increases streaming minutes.&lt;/p>
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/RandExpStreamingMinutesByAccountType.png" />
&lt;/div>
&lt;a href="/image/RandExpStreamingMinutesByAccountType.png" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>Relationship between age and streaming minutes.&lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-R" data-lang="R">&lt;span class="nf">t.test&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">StreamingMinutes[AccountType&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s">&amp;#34;Premium&amp;#34;&lt;/span>&lt;span class="n">]&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">StreamingMinutes[AccountType&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s">&amp;#34;Free&amp;#34;&lt;/span>&lt;span class="n">]&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="n">Welch&lt;/span> &lt;span class="n">Two&lt;/span> &lt;span class="n">Sample&lt;/span> &lt;span class="n">t&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">test&lt;/span>
&lt;span class="n">data&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="n">StreamingMinutes[AccountType&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s">&amp;#34;Premium&amp;#34;&lt;/span>&lt;span class="n">]&lt;/span> &lt;span class="n">and&lt;/span> &lt;span class="n">StreamingMinutes[AccountType&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s">&amp;#34;Free&amp;#34;&lt;/span>&lt;span class="n">]&lt;/span>
&lt;span class="n">t&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="m">3.0805&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">df&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="m">491.55&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">p&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">value&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="m">0.002183&lt;/span>
&lt;span class="n">alternative&lt;/span> &lt;span class="n">hypothesis&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="n">true&lt;/span> &lt;span class="n">difference&lt;/span> &lt;span class="n">in&lt;/span> &lt;span class="n">means&lt;/span> &lt;span class="n">is&lt;/span> &lt;span class="n">not&lt;/span> &lt;span class="n">equal&lt;/span> &lt;span class="n">to&lt;/span> &lt;span class="m">0&lt;/span>
&lt;span class="m">95&lt;/span> &lt;span class="n">percent&lt;/span> &lt;span class="n">confidence&lt;/span> &lt;span class="n">interval&lt;/span>&lt;span class="o">:&lt;/span>
&lt;span class="m">0.5413153&lt;/span> &lt;span class="m">2.4479528&lt;/span>
&lt;span class="n">sample&lt;/span> &lt;span class="n">estimates&lt;/span>&lt;span class="o">:&lt;/span>
&lt;span class="n">mean&lt;/span> &lt;span class="n">of&lt;/span> &lt;span class="n">x&lt;/span> &lt;span class="n">mean&lt;/span> &lt;span class="n">of&lt;/span> &lt;span class="n">y&lt;/span>
&lt;span class="m">89.19549&lt;/span> &lt;span class="m">87.70085&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>In addition to ensuring that on average all covariates are balanced (i.e., the same) randomization also provides a basis for assumption light inference as we&amp;rsquo;ve discussed in our post on &lt;a href="/post/randomization-based-inference">Randomization Based Inference: The Neymanian approach&lt;/a> and &lt;a href="/post/frt">Randomization-based inference: the Fisherian Approach&lt;/a>.&lt;/p></description></item><item><title>Randomization-based inference: the Fisherian Approach</title><link>/post/frt/</link><pubDate>Mon, 05 Apr 2021 00:00:00 +0000</pubDate><guid>/post/frt/</guid><description>&lt;h2 id="why-another-approach-to-inference">Why another approach to inference?&lt;/h2>
&lt;h3 id="the-limits-of-the-neymanian-approach">The limits of the Neymanian approach&lt;/h3>
&lt;p>The Neymanian approach to inference allows us to construct asymptotic confidence
intervals for the average treatment effect under very mild assumptions. However,
it has three main downsides (we will discuss these in more details in a subsequent
post):&lt;/p>
&lt;ol>
&lt;li>It can only be used with &lt;em>certain&lt;/em> assignment mechanisms.&lt;/li>
&lt;li>It is valid only asymptotically.&lt;/li>
&lt;li>It still makes &lt;em>some&lt;/em> assumptions (however mild they are).&lt;/li>
&lt;/ol>
&lt;h3 id="how-far-can-we-get-with-no-assumptions-whatsoever">How far can we get with no assumptions whatsoever?&lt;/h3>
&lt;p>Here, we briefly introduce an alternative approach to inference named after the
famous Statistician R.A. Fisher. In contrast to the Neymanian approach to inference,
the Fisherian approach:&lt;/p>
&lt;ol>
&lt;li>Works with &lt;em>any&lt;/em> assignment mechanism.&lt;/li>
&lt;li>Is valid for any sample size \(n\).&lt;/li>
&lt;li>Makes absolutely no assumptions whatever.&lt;/li>
&lt;/ol>
&lt;p>Now this looks an aweful lot like a free lunch, and we all know that the universe
is never quite so cooperative &amp;mdash; so what&amp;rsquo;s the catch?&lt;/p>
&lt;p>Well, the downside is that in its simplest instantiation, this approach to
inference does not give us an estimator of the average treatment effect, let
alone a confidence interval. Instead, it allows us to answer the admittedly
simpler question: based on the data, would it be reasonable to conclude that
the treatment does not affect any of the units in the population. In statistical
language, the Fisherian approach to inference allows us to &lt;strong>test&lt;/strong> the following
null hypothesis:&lt;/p>
&lt;p>\[
H_0: \,Y_i(0) = Y_i(1) \quad \forall i=1,\ldots,n
\]&lt;/p>
&lt;p>At this point, it&amp;rsquo;s essential to understand what you need to assume with each
inferential approach and what you get in exchange. The Fisher Randomization Test,
as the Fisherian approach is often called, makes
fewer assumptions than the Neymanian approach (in fact, it makes no assumptions
whatsoever) &amp;mdash; but the question it answers is, in a sense, narrower than that
answered by the Neymanian approach.&lt;/p>
&lt;h2 id="hypothesis-testing-as-stochastic-proof-by-contradiction">Hypothesis testing as stochastic proof by contradiction&lt;/h2>
&lt;p>How can we test the null hypothesis \(H_0\) introduced above?
If you&amp;rsquo;ve taken an introductory statistics class,
you may have seen things like t-tests and chi-square tests, but it&amp;rsquo;s
unclear how to apply these to test \(H_0\).&lt;/p>
&lt;p>At this point, it is helpful to step back and consider
what a statistical &lt;em>hypothesis testing&lt;/em> is; a particular fruitful
analogy is with a mathematical device called a &lt;em>proof by contradiction&lt;/em>.&lt;/p>
&lt;p>Suppose you wish to prove that a statement \(P\) is true. The idea
of the proof by contradiction is to&lt;/p>
&lt;ol>
&lt;li>Suppose that the opposite of \(P\) is in fact true.&lt;/li>
&lt;li>Show that this leads to an internal contradiction, or an absurd statement.&lt;/li>
&lt;li>Concludes that since the opposite of \(P\) leads to an absurdity, \(P\) must be true.&lt;/li>
&lt;/ol>
&lt;blockquote>
&lt;p>&lt;strong>Example (from Wikipedia):&lt;/strong>&lt;/p>
&lt;p>A famous example is the proof of the fact that there exists no
smallest positive rational number. This is easy to show with a proof
by contradiction. Indeed, suppose that there exists smallest positive
rational number \(r = \frac{a}{b} &amp;gt; 0\). Then the number
\(r&amp;rsquo; = r/2 = \frac{a}{2b} &amp;gt; 0\) is also a positive rational number,
but we have \(r&amp;rsquo; &amp;lt; r\). This, however, contradicts the fact that
\(r\) is the smallest positive rational number! We conclude that
the initial supposition is wrong, and that there doesn&amp;rsquo;t exist a smallest
positive rational number.&lt;/p>
&lt;/blockquote>
&lt;p>We can think of statistical hypothesis testing as a stochastic version of proof by contradiction.
When we &amp;ldquo;test&amp;rdquo; the null hypothesis \(H_0\), our goal is to establish that it is false (or unlikely).
Indeed, we can never verify the null hypothesis; we can only reject it or fail to reject it.
By analogy with the proof by contradiction, the general strategy for hypothesis testing is as follows:&lt;/p>
&lt;ol>
&lt;li>Suppose that \(H_0\) is true.&lt;/li>
&lt;li>Show that this implies something very unlikely.&lt;/li>
&lt;li>Conclude that since \(H_0\) leads to something very unlikely, it
is unlikely to be true.&lt;/li>
&lt;/ol>
&lt;p>The key difference here is in step 2: showing that something is &lt;strong>impossible&lt;/strong> is generally two
stringent a criterion in statistics, so we settle for showing that it is unlikely.&lt;/p>
&lt;h2 id="the-fisher-randomization-test">The Fisher Randomization Test&lt;/h2>
&lt;p>The Fisher randomization test begins with the observed assignment vector \(W\),
the observed outcome vector \(Y\), and the sharp null hypothesis \(H_0\).
Following the stochastic proof by contradiction analogy, let&amp;rsquo;s suppose for a moment \(H_0\) is,
in fact, correct, and let&amp;rsquo;s follow the thread of implications.&lt;/p>
&lt;p>&lt;strong>Step 1: Hypothesized science table&lt;/strong>&lt;/p>
&lt;p>If \(H_0\) is true, then we know the entire science table! Indeed, for
illustration, suppose that \(W = (1, 1, 0, 1, 0, 0)\) and
\(Y = (3, 1, 2, 1, 3, 0)\) as in our post on the&lt;a href="/post/randomization-based-inference">Neymanian apprach&lt;/a>.
Again, we assume that the assignment was a &lt;a href="/post/po-introduction/#assignment-mechanism">completely randomized design&lt;/a>
with paramter \(n_1 = 3\).&lt;/p>
&lt;p>As we&amp;rsquo;ve discussed in earlier &lt;a href="post/po-introduction/#the-science">posts&lt;/a>, we typically only have a partial view of the science table since, as for each unit, we only observe one of the two potential outcomes. That is, we observe the following partial table:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>i&lt;/th>
&lt;th>\(y_i(0)\)&lt;/th>
&lt;th>\(y_i(1)\)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>?&lt;/td>
&lt;td>3&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>?&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>2&lt;/td>
&lt;td>?&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>?&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>3&lt;/td>
&lt;td>?&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>0&lt;/td>
&lt;td>?&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>But if \(H_0\) is true, then \(y_i(1) = y_i(0)\) for all
units \(i\)! So each question mark in the table can be filled replaced by the
number on the same row in the other column. That is, we have the following
table:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>i&lt;/th>
&lt;th>\(y_i(0)\)&lt;/th>
&lt;th>\(y_i(1)\)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>3&lt;/td>
&lt;td>3&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>1&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>2&lt;/td>
&lt;td>2&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>1&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>3&lt;/td>
&lt;td>3&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Now we must be very careful. The science table above is not the true
science table &amp;mdash; it is the what the true science table would be if \(H_0\)
where true! To make the distinction clear, we denote by
\(\underline{y}(H_0)\) this hypothesized science table.&lt;/p>
&lt;p>&lt;strong>Step 2: Null distribution&lt;/strong>&lt;/p>
&lt;p>Recall that our goal &amp;ndash; in a stochastic proof by contradiction &amp;ndash; is to
show that supposing that \(H_0\) is true implies something very unlikely. One
way to do so is to check whether &amp;ldquo;the outcome of the experiment we actually
observe would be considered unusually extreme if \(H_0\) really were true.&amp;rdquo;
Concretely, take any summary \(T\) of the observed data \(Y, W\) &amp;mdash; we
call this summary a &amp;ldquo;test statistic.&amp;rdquo; A simple
choice, for instance, could be the average outcome of the treated units,&lt;/p>
&lt;p>\[
T_a^{obs} = T_a(Y, W) = \frac{1}{n_1} \sum_{i=1}^n Y_i W_i,
\]&lt;/p>
&lt;p>or the difference in means,&lt;/p>
&lt;p>\[
T_b^{obs} = T_b(Y, W) = \frac{1}{n_1} \sum_{i=1}^n Y_i W_i - \frac{1}{1-n_1} \sum_{i=1}^n Y_i (1-W_i).
\]&lt;/p>
&lt;p>In our specific example, we have \(T_a^{obs} = 5/3\) and \(T_b^{obs} = 5/3 - 5/3 = 0\).
The choice of test statistic is important in practice &amp;mdash; but it doesn&amp;rsquo;t affect the
mechanics of the test so, for the sake of illustration, we will use \(T_b\) here.
Now say we observe a certain value \(T_b^{obs}\) corresponding to the observed
data \(Y, W\). Is this value surprising, if \(H_0\) is true? Well, we can check
that. Suppose that we had observed assignment \(W^{(1)} = (1,1,1,0,0,0)\) instead. If \(H_0\)
is true, then the science is \(\underline{y}(H_0)\), and so we would have observed
\(Y^{(1)} = (3,1,2,1,3,0) \) and the corresponding value of the test statistic&lt;/p>
&lt;p>\[
T_b^{(1)} = T_b(Y^{(1)}, W^{(1)}) = 4/2 - 6/2 = - 1
\]&lt;/p>
&lt;p>Likewise for any possible assignment \(W^{(k)}\), we can deduce from
\(\underline{y}(H_0)\) what \(Y^{(k)}\) and, therefore, \(T^{(k)}\)
would have been. The distribution of \(T(y(W&amp;rsquo;), W&amp;rsquo;)\) under \(H_0\)
is called the &lt;em>null distribution&lt;/em>.&lt;/p>
&lt;p>&lt;strong>Step 3: p-values quantify our surprise&lt;/strong>&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;p>We now compare the value \(T^{obs}_{b}\) that we actually
observe with the null distribution and ask: Is \(T^{obs}_b\) extreme compared
to the other values or not? Specifically, we can ask how likely would it have been
to observe a value as large as or larger than \(T^{obs}_b\) if \(H_0\) where
true. This is what we call (one-sided) a p-value; formally&lt;/p>
&lt;p>\[
pval(Y, W) = \sum_{W&amp;rsquo;} pr(W&amp;rsquo;) \cdot \mathbb{I}(T_b^{obs} \geq T(y(W&amp;rsquo;), W&amp;rsquo;)).
\]&lt;/p>
&lt;p>&lt;strong>Step 4: interpreting the p-value&lt;/strong>&lt;/p>
&lt;p>Now that we have obtained a p-value, let&amp;rsquo;s step back and see what it actually
means, and how it fits into our general perspective of the Fisher Randomization
Test as a stochastic proof by contradiction. To &amp;ldquo;disprove&amp;rdquo; \(H_0\),
we assumed it to be true, and computed the probability of observing a value \(T_b\) more extreme than the one we actually observed;
this was given by \(pval(Y, W)\). If \(pval(Y, W)\) is small&amp;mdash;typically smaller than 0.05 or 0.01&amp;mdash; we can reject the null hypothesis; otherwise, we fail to reject the null.&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;h3 id="summary-of-the-fisher-randomization-test">Summary of the Fisher Randomization Test&lt;/h3>
&lt;p>There is lot more that could be said about the Fisher Randomization Test &amp;mdash; and
indeed, we will say more about it in another post &amp;mdash; but these are the very
basics. The figure below summarizes the whole process&lt;/p>
&lt;link rel="stylesheet" href="/css/hugo-easy-gallery.css" />
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/FRT-overview.jpg" />
&lt;/div>
&lt;a href="/image/FRT-overview.jpg" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>The big picture idea of the Fisher randomization test.&lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;h2 id="convince-yourself">Convince yourself!&lt;/h2>
&lt;p>Once you really understand it, the Fisher Randomization Test is a
profoundly beautiful &amp;mdash; and useful &amp;mdash; inferential tool. But even
more so than the Neymanian approach to inference, it takes some getting
used to. And here again, playing with simulations and implementing your
own tests will really make a difference.&lt;/p>
&lt;h3 id="a-simple-implementation">A simple implementation&lt;/h3>
&lt;p>The code below implements a simple &amp;ndash; exact Fisher Randomization Test.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;span class="lnt">48
&lt;/span>&lt;span class="lnt">49
&lt;/span>&lt;span class="lnt">50
&lt;/span>&lt;span class="lnt">51
&lt;/span>&lt;span class="lnt">52
&lt;/span>&lt;span class="lnt">53
&lt;/span>&lt;span class="lnt">54
&lt;/span>&lt;span class="lnt">55
&lt;/span>&lt;span class="lnt">56
&lt;/span>&lt;span class="lnt">57
&lt;/span>&lt;span class="lnt">58
&lt;/span>&lt;span class="lnt">59
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-R" data-lang="R">
&lt;span class="nf">library&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">magrittr&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="nf">library&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">purrr&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="nf">library&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">gtools&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1">## Test Statitsic&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1">## Two examples of test statistics:&lt;/span>
&lt;span class="c1">## Any function of w and y will do, so feel free to experiment!&lt;/span>
&lt;span class="bp">T&lt;/span>&lt;span class="m">.1&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">function&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">w&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">y&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nf">mean&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">y[w&lt;/span>&lt;span class="o">==&lt;/span>&lt;span class="m">1&lt;/span>&lt;span class="n">]&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">-&lt;/span> &lt;span class="nf">mean&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">y[w&lt;/span>&lt;span class="o">==&lt;/span>&lt;span class="m">0&lt;/span>&lt;span class="n">]&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="bp">T&lt;/span>&lt;span class="m">.2&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">function&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">w&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">y&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nf">sum&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">y[w&lt;/span>&lt;span class="o">==&lt;/span>&lt;span class="m">1&lt;/span>&lt;span class="n">]&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1">## Observed data&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="n">W.obs&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">c&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="m">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">0&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">0&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">0&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="n">Y.obs&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">c&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="m">3&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">2&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">3&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">0&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="bp">T&lt;/span>&lt;span class="m">.1&lt;/span>&lt;span class="n">.obs&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">T.1&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.obs&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Y.obs&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="bp">T&lt;/span>&lt;span class="m">.2&lt;/span>&lt;span class="n">.obs&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">T.2&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.obs&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Y.obs&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1">## Constructing the null science&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="n">science.0&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">data.frame&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">y1&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">Y.obs&lt;/span>&lt;span class="p">,&lt;/span>
&lt;span class="n">y0&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">Y.obs&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1">## Computing the p-value -- the exact version&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="n">W.ls&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">permutations&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="m">6&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">6&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="m">6&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;span class="nf">array_tree&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="m">1&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;span class="nf">map&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="o">~&lt;/span> &lt;span class="n">W.obs[.]&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;span class="n">unique&lt;/span>
&lt;span class="bp">T&lt;/span>&lt;span class="m">.1&lt;/span>&lt;span class="n">.ls&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">vector&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#39;numeric&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">length&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="nf">length&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.ls&lt;/span>&lt;span class="p">))&lt;/span>
&lt;span class="bp">T&lt;/span>&lt;span class="m">.2&lt;/span>&lt;span class="n">.ls&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">vector&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#39;numeric&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">length&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="nf">length&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.ls&lt;/span>&lt;span class="p">))&lt;/span>
&lt;span class="nf">for&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">i&lt;/span> &lt;span class="n">in&lt;/span> &lt;span class="nf">seq_along&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.ls&lt;/span>&lt;span class="p">))&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="n">W&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="n">W.ls[[i]]&lt;/span>
&lt;span class="n">Y&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="n">science.0&lt;/span>&lt;span class="o">$&lt;/span>&lt;span class="n">y1&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="n">W&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="n">science.0&lt;/span>&lt;span class="o">$&lt;/span>&lt;span class="n">y0&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="m">1&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">W&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="bp">T&lt;/span>&lt;span class="m">.1&lt;/span>&lt;span class="n">.ls[i]&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">T.1&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Y&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="bp">T&lt;/span>&lt;span class="m">.2&lt;/span>&lt;span class="n">.ls[i]&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">T.2&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Y&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="n">pval.1&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">mean&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="bp">T&lt;/span>&lt;span class="m">.1&lt;/span>&lt;span class="n">.ls&lt;/span> &lt;span class="o">&amp;gt;=&lt;/span> &lt;span class="bp">T&lt;/span>&lt;span class="m">.1&lt;/span>&lt;span class="n">.obs&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="n">pval.2&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">mean&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="bp">T&lt;/span>&lt;span class="m">.2&lt;/span>&lt;span class="n">.ls&lt;/span> &lt;span class="o">&amp;gt;=&lt;/span> &lt;span class="bp">T&lt;/span>&lt;span class="m">.2&lt;/span>&lt;span class="n">.obs&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>One thing that may be surprising, when looking at the code, is that
the true science table appears nowhere! That&amp;rsquo;s right, the pvalues we
obtain at the end do depend on the true science only through the observed
outcomes! Another insight &amp;mdash; which see if you try the code with different values
of &lt;code>Y.obs&lt;/code> and &lt;code>W.obs&lt;/code> is that &lt;code>pval.1&lt;/code> and &lt;code>pval.2&lt;/code> are
always equal! That is a special property of the test statistics &lt;code>T.1&lt;/code>
and &lt;code>T.2&lt;/code>, but is not true in general.&lt;/p>
&lt;p>You should play around with the code above, changing the values of W.obs and
Y.obs (make sure that they remain vectors of lengths 6). Here are two useful
exercises:&lt;/p>
&lt;ol>
&lt;li>Come up with values of &lt;code>W.obs&lt;/code> and &lt;code>Y.obs&lt;/code> that yield high p-values.&lt;/li>
&lt;li>Come up with values of &lt;code>W.obs&lt;/code> and &lt;code>Y.obs&lt;/code> that yield low p-values.&lt;/li>
&lt;/ol>
&lt;h3 id="a-fancier-implementation">A fancier implementation&lt;/h3>
&lt;p>As mentioned earlier, one can think of the FRT as simply an algorithm that takes
four inputs: the observed assignments, the observed outcomes, a test statistic,
and the design of the experiment. We will show how to implement such an algorithm
in the simple case where the design is completely randomized.&lt;/p>
&lt;p>Before we do that, however, we point out another insight you can get from playing
with the code above. You will notice that the value of &lt;code>Y&lt;/code> in the loop on
line 50 of the code is constant, and always equal to &lt;code>Y.obs&lt;/code>. You can verify
easily that this is true mathematically. This simple observation will allow us to
simplify the code slightly. Below, an implementtion of the Fisher Randomization Test
function:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-R" data-lang="R">&lt;span class="n">FRT&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">function&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">Y.obs&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">W.obs&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="bp">T&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="c1">## Implementation of the FRT&lt;/span>
&lt;span class="c1">## Y.obs: the vector of observed outcomes&lt;/span>
&lt;span class="c1">## W.obs: the vector of observed assignments&lt;/span>
&lt;span class="c1">## T: the test statistic. Must be a function T(., .)&lt;/span>
&lt;span class="c1">##&lt;/span>
&lt;span class="c1">## This function assumes that W was completely randomized,&lt;/span>
&lt;span class="c1">## and returns a one sided p-value.&lt;/span>
&lt;span class="n">W.ls&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">permutations&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nf">length&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.obs&lt;/span>&lt;span class="p">),&lt;/span> &lt;span class="nf">length&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.obs&lt;/span>&lt;span class="p">),&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="nf">length&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.obs&lt;/span>&lt;span class="p">))&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;span class="nf">array_tree&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="m">1&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;span class="nf">map&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="o">~&lt;/span> &lt;span class="n">W.obs[.]&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;span class="n">unique&lt;/span>
&lt;span class="bp">T&lt;/span>&lt;span class="n">.obs&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">T&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.obs&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Y.obs&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="bp">T&lt;/span>&lt;span class="n">.ls&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">map_dbl&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.ls&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="o">~&lt;/span>&lt;span class="nf">T&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">.,&lt;/span> &lt;span class="n">Y.obs&lt;/span>&lt;span class="p">))&lt;/span>
&lt;span class="nf">return&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nf">mean&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="bp">T&lt;/span>&lt;span class="n">.ls&lt;/span> &lt;span class="o">&amp;gt;=&lt;/span> &lt;span class="bp">T&lt;/span>&lt;span class="n">.obs&lt;/span>&lt;span class="p">))&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>This implementation uses &lt;code>map_dbl&lt;/code> and the &lt;code>~&lt;/code> from the &lt;code>purrr&lt;/code> package
to avoid having to wrap a loop, and uses the aforementioned fact that &lt;code>Y&lt;/code> and &lt;code>Y.obs&lt;/code>
are always equal.&lt;/p>
&lt;p>You will notice that although conceptually profound, the FRT can ultimately be implemented with
just a few lines of code!&lt;/p>
&lt;h2 id="the-frt-in-practice-a-monte-carlo-approximation">The FRT in practice: a Monte-Carlo approximation&lt;/h2>
&lt;h3 id="two-practical-problems-with-our-implementation">Two practical problems with our implementation&lt;/h3>
&lt;p>If you&amp;rsquo;ve tried to modify the code above to run the FRT test in a setting with more
that a dozen units, you will have noticed that the execution time rapidly becomes
alarmingly long. The culprit is the line:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-R" data-lang="R">&lt;span class="n">W.ls&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">permutations&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nf">length&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.obs&lt;/span>&lt;span class="p">),&lt;/span> &lt;span class="nf">length&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.obs&lt;/span>&lt;span class="p">),&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="nf">length&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.obs&lt;/span>&lt;span class="p">))&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;span class="nf">array_tree&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="m">1&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;span class="nf">map&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="o">~&lt;/span> &lt;span class="n">W.obs[.]&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;span class="n">unique&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>That generates all the assignments. Think about it for a moment: the support of a
completely randomized design with \(n\) units, of which \(n_1\) are treated,
has size \(n \choose n_1\).&lt;/p>
&lt;ul>
&lt;li>For \(n=10\) and \(n_1=5\), that&amp;rsquo;s 252 assignments:
totally doable.&lt;/li>
&lt;li>For \(n=20\) and \(n_1 = 10\), that&amp;rsquo;s \(184,756\) assignments:
still doable, but much slower.&lt;/li>
&lt;li>For \(n=30\) and \(n_1 = 15\), the support has
more than \(10^8\) assignments: you should probably not try that on your laptop.&lt;/li>
&lt;/ul>
&lt;p>Another problem with our implementation is that it only allows us to run FRTs for
completely randomized experiment &amp;mdash; but the theory has no such requirements!&lt;/p>
&lt;h3 id="one-solution">One solution&lt;/h3>
&lt;p>We can solve the first computational problem by approximate the null dsitribution by using only a subset of the possible assignments.&lt;/p>
&lt;p>For the second problem, we can replace the permutations by any generic assignment mechanims. The sudo code is below.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-R" data-lang="R">&lt;span class="n">FRT.generic&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">function&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">Y.obs&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">W.obs&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="bp">T&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Mechanism&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">iterations&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="c1">## Implementation of the FRT&lt;/span>
&lt;span class="c1">## Y.obs: the vector of observed outcomes&lt;/span>
&lt;span class="c1">## W.obs: the vector of observed assignments&lt;/span>
&lt;span class="c1">## T: the test statistic. Must be a function T(Y, W)&lt;/span>
&lt;span class="c1">## Mechanism: a function that returns a new assignment W from the same&lt;/span>
&lt;span class="c1">## distribution as W.obs &lt;/span>
&lt;span class="c1">## iterations: the number of samples to obtain from the assignment&lt;/span>
&lt;span class="c1">## mechanism&lt;/span>
&lt;span class="c1">##&lt;/span>
&lt;span class="c1">## This function returns a one sided p-value.&lt;/span>
&lt;span class="n">W.ls&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">apply&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">Mechanism&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">iterations&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="bp">T&lt;/span>&lt;span class="n">.obs&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">T&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.obs&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Y.obs&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="bp">T&lt;/span>&lt;span class="n">.ls&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">map_dbl&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.ls&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="o">~&lt;/span>&lt;span class="nf">T&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">.,&lt;/span> &lt;span class="n">Y.obs&lt;/span>&lt;span class="p">))&lt;/span>
&lt;span class="nf">return&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nf">mean&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="bp">T&lt;/span>&lt;span class="n">.ls&lt;/span> &lt;span class="o">&amp;gt;=&lt;/span> &lt;span class="bp">T&lt;/span>&lt;span class="n">.obs&lt;/span>&lt;span class="p">))&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div></description></item><item><title>Randomization-based inference: the Neymanian approach</title><link>/post/randomization-based-inference/</link><pubDate>Fri, 12 Mar 2021 00:00:00 +0000</pubDate><guid>/post/randomization-based-inference/</guid><description>&lt;h2 id="prereqs-and-notational-matters">Prereqs and notational matters&lt;/h2>
&lt;p>This post requires a basic understanding of the potential outcomes framework
and familiarity with the standard notation; see our earlier &lt;a href="/post/po-introduction">post&lt;/a>
for the necessary background and notation.&lt;/p>
&lt;p>Appropriate notation is critical in causal inference, as it can give a visual reminder of some of the subtlety involved. The key challenge is to strike an appropriate balance between mathematical rigor, which would make the notation precise but heavy and sometimes hard to parse, and simplicity, which would make it readable at the cost of the occasional ambiguity. Another complication is that some unfortunate notational habits have become de facto standard in the literature, making their use almost unavoidable. We do our best to use clear and sensible notation while hewing close to the generally accepted standard.&lt;/p>
&lt;p>In our first &lt;a href="/post/po-introduction">post&lt;/a> on the subject, we used a number
of notational crutches that were appropriate for an introduction to the subject,
but will quickly become cumbersome. For instance, we denoted vectors with the
arrow symbol (&lt;em>e.g.,&lt;/em> \(\vec{W}\) and \(\vec{Y}\)): these are now omitted. We
also drop the superscript &amp;lsquo;&amp;lsquo;DiM&amp;rsquo;&amp;rsquo; from the difference-in-means estimator \(\hat{\tau}\)
and the superscript &amp;lsquo;&amp;lsquo;ATE&amp;rsquo;&amp;rsquo; from the average treatment effect estimand \(\tau\).&lt;/p>
&lt;h2 id="the-question-of-inference">The question of inference&lt;/h2>
&lt;h3 id="how-good-is-my-guess">How good is my guess?&lt;/h3>
&lt;p>Consider a randomized experiment run on a population of \(n\) units
to assess the effect of a binary intervention; assume throughout that
there is no &lt;a href="/post/interference">interference&lt;/a>.&lt;/p>
&lt;p>To make things very concrete, suppose that
\(n=6\) and that we observe the assignment
\(W = (1, 1, 0, 1, 0, 0)\) and the outcome vector
\(Y = (3, 1, 2, 1, 3, 0)\). Suppose our goal is to estimate the
Average Treatment Effect (ATE),&lt;/p>
&lt;p>\[
\tau = \frac{1}{6} \sum_{i=1}^6 \bigg(y_i(1) - y_i(0)\bigg),
\]&lt;/p>
&lt;p>using the observed data. One possible solution is to use
the difference-in-means estimator,&lt;/p>
&lt;p>\[
\hat{\tau} = \frac{1}{3}( 3, 1, 1) - \frac{1}{3}(2, 3, 0),
\]&lt;/p>
&lt;p>which gives us an estimate of \(\hat{\tau} = 0\) for \(\tau\). As we&amp;rsquo;ve
seen in our &lt;a href="/post/po-introduction">introduction to the potential outcomes framework&lt;/a>,
an estimator is a data-driven &amp;lsquo;&amp;lsquo;guess&amp;rsquo;&amp;rsquo; of the value of an estimand. The
difference-in-means estimator is one procedure for obtaining such a guess and,
presently, it gives us a guess of \(0\) for the ATE.&lt;/p>
&lt;p>But, how good a guess is this? We could have guessed 42, -5, or 1380.
Why should \(0\) be preferred, given the data we observed?
The answer to this question is complex, and it is at the heart of what statistical inference is.&lt;/p>
&lt;h3 id="a-parametric-answer">A parametric answer&lt;/h3>
&lt;p>If you have taken an introduction to statistical inference, then your answer
might start with the assumption that:&lt;/p>
&lt;p>\[
\begin{aligned}
Y_i \mid W_i = 1 \,\, &amp;amp;\overset{iid}{\sim} \,\, N(\mu_1, \sigma_1^2) \\\&lt;br>
Y_i \mid W_i = 0 \,\, &amp;amp;\overset{iid}{\sim} \,\, N(\mu_0, \sigma_0^2) \\\&lt;br>
\end{aligned}
\]&lt;/p>
&lt;p>It is easy to show that the difference-in-means estimator \(\hat{\tau}\) is the
Maximum Likelihood Estimator (MLE) for the parameter \(\theta \equiv \mu_1 - \mu_0\).
But that is an awkward answer for a number of reasons:&lt;/p>
&lt;ol>
&lt;li>Since by definition, \(Y_i = W_i \, y_i(1) + (1-W_i) \, y_i(0)\),
assuming that \(Y_i \mid W_i = 1\) and \(Y_i \mid W_i = 0\) follow some
distributions implies that \(y_i(1)\) and \(y_i(0)\) must be random. This
in turns implies that the science table \(\underline{y} = (y(1), y(0))\)
is random, and therefore our estimand \(\tau\) is itself a random
variable! So it&amp;rsquo;s all nice and good to say that \(\hat{\tau}\) is the MLE
for the parameter \(\theta\), but what does the parameter \(\theta\)
have to do with the random variable \(\tau\)?&lt;/li>
&lt;li>The parameter \(\theta \) is also a population parameter; that is, to interpret it, we implicitly require the assumption that there exists some larger population from which we sample our experimental units. This sampling allows us to model the outcomes as random; however, the price we pay is that our inference makes claims about the larger population, NOT our actual sample!&lt;/li>
&lt;li>Our key building blocks, in the potential frameworks, are&amp;hellip; well, &lt;em>the
potential outcomes&lt;/em> &amp;mdash; not the observed outcomes! The distributions on
\(Y_i \mid W_i = 1\) and \(Y_i \mid W_i = 0\) imply assumptions on the
distributions \(y(1)\) and \(y(0)\), but these are not transparent.&lt;/li>
&lt;/ol>
&lt;p>Both points can be partially addressed by modifying the assumption as follows:&lt;/p>
&lt;p>\[
\begin{aligned}
Y_i(1) \, \, &amp;amp;\overset{iid}{\sim} N(\mu_1, \sigma_1^2), \\\&lt;br>
Y_i(0) \, \, &amp;amp;\overset{iid}{\sim} N(\mu_0, \sigma_0^2), \\\&lt;br>
W_i \,\, &amp;amp;\perp \,\, (Y_i(1), Y_i(0)),
\end{aligned}
\]
where \( \perp \) is used to indicate that \(W_i\) and \((Y_i(1), Y_i(0))\) are independent.
Under these specifications, \(\hat{\tau}\) is still
the MLE for \(\theta = \mu_1 - \mu_0\), but now we can also establish a
connection between \(\theta\) and \(\tau\):&lt;/p>
&lt;p>\[
E[\tau] = \theta,
\]
where the expectation is taken with respect to the distribution of the potential outcomes.&lt;/p>
&lt;p>With some work, we can state analogous results without assuming normality, but we still
require that the potential outcomes be independent and identically distributed.
This may seem like a mild assumption, but it is still an assumption &amp;mdash; and in some scenarios
(e.g.,in the presence of &lt;a href="/post/interference">interference&lt;/a>), it is anything but mild.
In addition, we started with \(\tau\) as our estimand, but we had to settle for \(\theta\) which,
even if it is connected to \(\tau\), is not what we were originally after.&lt;/p>
&lt;p>It turns out that we don&amp;rsquo;t need to assume anything about the potential outcomes to say something meaningful about \(\tau\). Unlike traditional statistical inference problems, experiments have an additional source of variability: the random assignment. To use this for inference requires thinking about the problem in a somewhat unique way, as we see below.&lt;/p>
&lt;h3 id="randomization-as-the-basis-for-inference">Randomization as the basis for inference&lt;/h3>
&lt;p>Our goal is to limit the number of necessary assumptions so that our conclusions can be as objective as possible. To begin with, let&amp;rsquo;s focus on the one element that we control: the assignment mechanism. Let&amp;rsquo;s say that the assignment mechanism is a &lt;em>completely randomized design&lt;/em> with parameter \(n_1 = 3\), as defined in our &lt;a href="/post/po-introduction">previous post&lt;/a>. Then, all the assignments with exactly \(3\) treated units and, therefore, \(3\) control units have equal probability, while all other assignments have probability \(0\).&lt;/p>
&lt;p>Let&amp;rsquo;s see how far we can go with just this simple assumption. As before, we consider the science table to be a constant \(\underline{y} = (y(0), y(1))\). For illustration purposes, let&amp;rsquo;s take \(\underline{y}\) to be as follows:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>i&lt;/th>
&lt;th>\(y_i(0)\)&lt;/th>
&lt;th>\(y_i(1)\)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>2&lt;/td>
&lt;td>3&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>1&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>2&lt;/td>
&lt;td>4&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>0&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>3&lt;/td>
&lt;td>3&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>0&lt;/td>
&lt;td>2&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>In practice, the science is unknown (if we knew it, why would we be running an experiment?) &amp;mdash; here, we give it a concrete value just to illustrate our point.&lt;/p>
&lt;p>Now, say we observe the assignment \(W^{(1)} = (1, 1, 1, 0, 0, 0)\). Recall that
we defined the observed outcome of unit \(i\) to be
\(Y_i = W_i \, y_i(1) + (1-W_i) \, y_i(0)\), so the vector
of observed outcomes becomes \(Y = (3, 1, 4, 0, 3, 0)\), and the
difference-in-means estimator is:&lt;/p>
&lt;p>\[
\hat{\tau}^{(1)} = \hat{\tau}(W^{(1)}) = \frac{1}{3} (3 + 1 + 4) - \frac{1}{3} (0 + 3 + 0) = \frac{5}{3}.
\]&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;hr>
&lt;p>&lt;strong>Note:&lt;/strong>
&lt;em>Mathematically, the estimator \(\hat{\tau}\) is a function of both the assignment
\(W\) and the outcome vector \(Y\). Since \(Y\) is itself a function of
\(W\) and the science \(\underline{y}\), we could write
\(\hat{\tau} = \hat{\tau}(W, \underline{y})\), with the understanding that it is
a function that can be computed from observed data since the dependence on \(\underline{y}\)
is only through the observed \(Y\). Ultimately though, since we consider the
science table \(\underline{y}\) as fixed and unknown, we keep it implicit in our
notation for the estimator and simply write \(\hat{\tau}(W)\).&lt;/em>&lt;/p>
&lt;hr>
&lt;p>What happens if we had observed a different assignment? For instance, say we observed the assignment \(W^{(2)} = (1, 0, 1, 0, 1, 0)\),
then we would have observed the outcome vector \(Y = (3, 1, 4, 0, 3, 0)\), and
the difference-in-means estimator would have had the value:&lt;/p>
&lt;p>\[
\hat{\tau}^{(2)} = \hat{\tau}(W^{(2)}) = \frac{1}{3} (3 + 4 + 3) - \frac{1}{3} (1+0+0) = 3.
\]&lt;/p>
&lt;p>Now since we consider a completely randomized design with parameter
\(n_1 = 3\), both assignments \(W^{(1)}\) and \(W^{(2)}\) have equal probability of being observed&lt;/p>
&lt;p>\[
pr(W^{(1)}) = pr(W^{(2)}) = \frac{1}{6 \choose 3}.
\]&lt;/p>
&lt;p>The random variable \(\hat{\tau}\), therefore, takes the value \(\frac{5}{3}\)
with probability \({6 \choose 3}^{-1}\) and the value \(3\) with probability
\({6 \choose 3}^{-1}\). If we repeat this with all \(6 \choose 3\) possible
values of the assignment vector, we obtain the distribution of \(\hat{\tau}\)
induced by the assignment mechanism \(pr(W)\). Formally, for
\(t \in \mathbb{R}\), we define&lt;/p>
&lt;p>\[
pr(\hat{\tau} = t) \equiv \sum_{w} \mathbb{I}[\hat{\tau}(w)=t]\,\, pr(W = w)
\]&lt;/p>
&lt;p>where the function \(\mathbb{I}[\cdot]\) is an indicator that takes value
\(1\) if whatever is inside it is true, and value \(0\) otherwise.&lt;/p>
&lt;p>In summary, if we knew the entire science table \(\underline{y}\), we could
build the following table, which summarizes the distribution \(pr(\hat{\tau})\).&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>k&lt;/th>
&lt;th>\(W^{(k)}\)&lt;/th>
&lt;th>\(\hat{\tau}(W^{(k)})\)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>\((1,1,1,0,0,0)\)&lt;/td>
&lt;td>\(\frac{5}{3}\)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>\((1,0,1,0,1,0)\)&lt;/td>
&lt;td>\(3\)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&amp;hellip;&lt;/td>
&lt;td>&amp;hellip;&lt;/td>
&lt;td>&amp;hellip;&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(6 \choose 3\)&lt;/td>
&lt;td>\((0,0,0,1,1,1)\)&lt;/td>
&lt;td>\(\frac{1}{3}\)&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>If you think about it, this table provides a lot of information! For example, it lets us compute our estimator&amp;rsquo;s expectation and variance&amp;mdash;two rather valuable quantities. Of course, we don&amp;rsquo;t know the entire science table. Therefore we never see the previous table &amp;mdash; or to be more specific, &lt;strong>we only ever observe a single row&lt;/strong> from that table: this is yet another manifestation of the fundamental problem of causal inference.&lt;/p>
&lt;link rel="stylesheet" href="/css/hugo-easy-gallery.css" />
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/rbi-source-of-randomness.jpg" />
&lt;/div>
&lt;a href="/image/rbi-source-of-randomness.jpg" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>The figure illustrates pr(W) as the source of randomness and provides another visual of the above table.&lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;h2 id="neymanian-inference">Neymanian inference&lt;/h2>
&lt;p>The general inferential strategy we discuss in this post is named after the famous
statistician Jerzy Neyman. It leverages the ideas directly from the previous section
by focusing on the properties of the estimator. Indeed, we have
seen that \(\hat{\tau}\) is a random variable whose
distribution is induced by the assignment distribution \(W \sim pr(W)\). It
therefore makes sense to consider quantities like the expectation
\(E[\hat{\tau}]\) of \(\hat{\tau}\) as well as the bias of \(\hat{\tau}\)
for estimating \(\tau\).&lt;/p>
&lt;p>Let&amp;rsquo;s start with the expectation, because it is helpful in reinforcing how
randomization inference works. For an assignment mechanism \(pr(W)\),
define \(\mathbb{W} = \{W: pr(W) &amp;gt; 0\}\) the support of the design, and
denote by \(\mathbb{T} = \{\hat{\tau}(w), w \in \mathbb{W}\}\) the set of
all distinct values the estimator can take. By definition we have,&lt;/p>
&lt;p>\[
E[\hat{\tau}] = \sum_{t \in \mathbb{T}} t \, \cdot \, pr(\hat{\tau} = t),
\]&lt;/p>
&lt;p>The following equivalent formulation is often more convenient&lt;/p>
&lt;p>\[
E[\hat{\tau}] = \sum_{t \in \mathbb{T}} t \, \cdot \, pr(\hat{\tau} = t) = \sum_{w \in \mathbb{W}} \hat{\tau}(w) \, \cdot \, pr(W = w).
\]&lt;/p>
&lt;p>As we discussed, since we don&amp;rsquo;t know the science table, we only observe a single
realization from the random variable \(\hat{\tau}\), corresponding to a single draw
from the distribution \(pr(\hat{\tau})\). It turns out, however, that we can
say a lot about \(pr(\hat{\tau})\) even if we only observe the estimate
\(\hat{\tau}(W)\) corresponding to the observed assignment \(W\), as
long as we know the assignment mechanism \(pr(W)\).&lt;/p>
&lt;p>For instance, in the previous post, we stated the following proposition:&lt;/p>
&lt;p>&lt;strong>Proposition:&lt;/strong>
&lt;em>If \(W\) is assigned according to a completely
randomized design, then the difference in means estimator
\(\hat{\tau}\) is unbiased for the average
treatment effect \(\tau\).&lt;/em>&lt;/p>
&lt;p>Below we provide a formal proof of this result to give a sense of how the math works. Even if you&amp;rsquo;re not super interested in the maths, we strongly recommend that you take a close look, as it will help you understand randomization-based inference better.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Proof:&lt;/strong> The goal,
stated in mathematical terms, is to show that:&lt;/p>
&lt;p>\[
E[\hat{\tau}] = \tau.
\]&lt;/p>
&lt;p>We&amp;rsquo;ll do that in four steps.&lt;/p>
&lt;p>(1) Recall from basic probability that the expectation is linear,&lt;/p>
&lt;p>\[
\begin{aligned}
E[\hat{\tau}] &amp;amp;= E\bigg[\frac{1}{N_1} \sum_{i=1}^N W_i Y_i - \frac{1}{N_0}\sum_{i=1}^N (1-W_i) Y_i \bigg] \\\&lt;br>
&amp;amp;= \frac{1}{N_1} \sum_{i=1}^N E[W_i Y_i] - \frac{1}{N_0} \sum_{i=1}^N E[(1-W_i) Y_i].
\end{aligned}
\]&lt;/p>
&lt;p>(2) Now the tricky part is that both \(W_i\) and \(Y_i\) are random variables,
so we &lt;strong>cannot&lt;/strong> write \(E[W_i Y_i] = E[W_i] E[Y_i]\) &lt;em>a priori&lt;/em>. The key is to notice that since by definition
\(Y_i = W_i y_i(1) + (1-W_i) y_i(0)\), we have:&lt;/p>
&lt;p>\[
W_i Y_i = W_i^2 y_i(1) + W_i (1-W_i) y_i(0) = W_i y_i(1).
\]&lt;/p>
&lt;p>This helps because \(y_i(1)\) is a constant, so&lt;/p>
&lt;p>\[
E[W_i Y_i] = E[W_i y_i(1)] = E[W_i] y_i(1).
\]&lt;/p>
&lt;p>(3) Finally, recall from basic probability that if \(W_i\) is a binary
random variable,
\[
E[W_i] = P(W_i = 1) = \frac{N_1}{N}
\]
where the second equality follows from the fact that the design is completely
randomized. So, all together, we have:
\[
E[W_iY_i] = \frac{N_1}{N} y_i(1)
\]
An exactly parallel derivation shows that:
\[
E[(1-W_i)Y_i] = \frac{N_0}{N} y_i(0)
\]&lt;/p>
&lt;p>(4) Putting it all together, we have:
\[
\begin{aligned}
E[\hat{\tau}] &amp;amp;= \frac{1}{N_1} \sum_{i=1}^N \frac{N_1}{N} y_i(1) - \frac{1}{N_0} \sum_{i=1}^N \frac{N_0}{N} y_i(0) \\\&lt;br>
&amp;amp;= \frac{1}{N} \sum_{i=1}^N y_i(1) - \frac{1}{N} \sum_{i=1}^N y_i(0) \\\&lt;br>
&amp;amp;= \tau
\end{aligned}
\]
which completes the proof.&lt;/p>
&lt;hr>
&lt;p>If you think about it, this result is admirable. We have indeed made no assumption whatsoever on the potential outcomes \(\underline{y}\)
&amp;mdash; these could be anything. The only assumption made in this proposition is
that the treatment was assigned in a particular random way. But since the
assignment mechanism \(pr(W)\) is presumably under our control, this is not
much of an assumption: the proposition tells us that if we run our experiment
a certain way, the difference-in-means estimator \(\hat{\tau}\) will be
unbiased.&lt;/p>
&lt;p>Now unbiased estimators are good, but knowing that an estimator is unbiased gives us only a partial picture of its performance. What we really want is a measure of our uncertainty, as provided by confidence intervals (or credible intervals, for Bayesians). Incredibly, it turns out that we can construct such intervals with the difference-in-means estimator and prove that they are valid for the ATE while making only a few very mild assumptions. In particular, we still don&amp;rsquo;t need to assume that the potential outcomes are independent or identically distributed (or, indeed, even random). The pseudo-theorem below gives you a high-level picture of the kind of result that can be derived:&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Pseudo-theorem:&lt;/strong> Suppose that \(pr(W)\) is a completely randomized design.
Then we can
construct an interval \(\widehat{CI} = \widehat{CI}(Y, W)\) that depends only
on observed quantities, such that under mild conditions,
\[
pr(\tau \in \widehat{CI}) \geq 0.95
\]
for large \(n\). The interval \(\widehat{CI}\) is therefore a valid
\(95\%\) confidence interval for the average treatment effect \(\tau\).&lt;/p>
&lt;/blockquote>
&lt;p>Although stated rather informally, this is a beautiful result. It essentially says that one can construct valid confidence intervals for the ATE without assuming much about \(\underline{y}\) if one controls the assignment mechanism. Stating this result formally requires some more technical tools and concepts that are beyond the scope of this introductory post: we will tackle them in a subsequent article in this series.&lt;/p>
&lt;h2 id="convince-yourself">Convince yourself!&lt;/h2>
&lt;p>The ideas presented in this post are not difficult, but they may feel unfamiliar to many &amp;mdash; because they are! We have seen two main sources of confusion in students seeing this material for the first time:&lt;/p>
&lt;ol>
&lt;li>Understanding what is random and what is not.&lt;/li>
&lt;li>Understanding what is observed and what is not.&lt;/li>
&lt;/ol>
&lt;p>The best way to become comfortable with randomization-based inference &amp;mdash; and
convince yourself that there is no magic involved &amp;mdash; is to play around with small
simulations.&lt;/p>
&lt;p>The &lt;code>R&lt;/code> code below illustrates the example we considered throughout this post. You
can also find on &lt;a href="https://gist.github.com/gwb/913ba53542e24e63f27291f9f655fb03">github&lt;/a>. Go ahead and modify the values of the potential outcomes in the
science table on lines 23 and 24 (making sure to keep them of length 6, so the rest
of the code works unchanged). You will see that if you modify the science, the
value of the variable &lt;code>tau&lt;/code> will change, but the value of &lt;code>bias&lt;/code> will
remain equal to 0, up to numerical precision!&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;span class="lnt">48
&lt;/span>&lt;span class="lnt">49
&lt;/span>&lt;span class="lnt">50
&lt;/span>&lt;span class="lnt">51
&lt;/span>&lt;span class="lnt">52
&lt;/span>&lt;span class="lnt">53
&lt;/span>&lt;span class="lnt">54
&lt;/span>&lt;span class="lnt">55
&lt;/span>&lt;span class="lnt">56
&lt;/span>&lt;span class="lnt">57
&lt;/span>&lt;span class="lnt">58
&lt;/span>&lt;span class="lnt">59
&lt;/span>&lt;span class="lnt">60
&lt;/span>&lt;span class="lnt">61
&lt;/span>&lt;span class="lnt">62
&lt;/span>&lt;span class="lnt">63
&lt;/span>&lt;span class="lnt">64
&lt;/span>&lt;span class="lnt">65
&lt;/span>&lt;span class="lnt">66
&lt;/span>&lt;span class="lnt">67
&lt;/span>&lt;span class="lnt">68
&lt;/span>&lt;span class="lnt">69
&lt;/span>&lt;span class="lnt">70
&lt;/span>&lt;span class="lnt">71
&lt;/span>&lt;span class="lnt">72
&lt;/span>&lt;span class="lnt">73
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-R" data-lang="R">&lt;span class="nf">library&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">magrittr&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="c1"># provides `%&amp;gt;%`&lt;/span>
&lt;span class="nf">library&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">purrr&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="c1"># provides `array_tree` and `map`&lt;/span>
&lt;span class="nf">library&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">gtools&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="c1"># provides `permutations`&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1">## Estimand function and estimator function&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1"># average treatment effect function&lt;/span>
&lt;span class="n">tau.fn&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">function&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">science&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nf">mean&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">science&lt;/span>&lt;span class="o">$&lt;/span>&lt;span class="n">y1&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">-&lt;/span> &lt;span class="nf">mean&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">science&lt;/span>&lt;span class="o">$&lt;/span>&lt;span class="n">y0&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="c1"># Difference in means function&lt;/span>
&lt;span class="n">hat.tau.fn&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">function&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">w&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">y&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nf">mean&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">y[w&lt;/span>&lt;span class="o">==&lt;/span>&lt;span class="m">1&lt;/span>&lt;span class="n">]&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">-&lt;/span> &lt;span class="nf">mean&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">y[w&lt;/span>&lt;span class="o">==&lt;/span>&lt;span class="m">0&lt;/span>&lt;span class="n">]&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1">## The science table + estimand&lt;/span>
&lt;span class="c1">## (unobserved quantities)&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1"># The science :: try changing it and see what happens!&lt;/span>
&lt;span class="n">science&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">data.frame&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">y0&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nf">c&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="m">2&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">2&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">0&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">3&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">0&lt;/span>&lt;span class="p">),&lt;/span>
&lt;span class="n">y1&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nf">c&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="m">3&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">4&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">3&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">2&lt;/span>&lt;span class="p">))&lt;/span>
&lt;span class="c1"># The (unobserved) ATE corresponding to the (unobserved) science&lt;/span>
&lt;span class="n">tau&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">tau.fn&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">science&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1">## observed data + estimate&lt;/span>
&lt;span class="c1">## (observed quantitites)&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1"># Observed assignment vector&lt;/span>
&lt;span class="n">W.obs&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">c&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="m">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">0&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">0&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">0&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="c1"># Observed outcome vector&lt;/span>
&lt;span class="n">Y.obs&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="n">science&lt;/span>&lt;span class="o">$&lt;/span>&lt;span class="n">y1&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="n">W.obs&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="n">science&lt;/span>&lt;span class="o">$&lt;/span>&lt;span class="n">y0&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="m">1&lt;/span> &lt;span class="o">-&lt;/span> &lt;span class="n">W.obs&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="c1"># Observed estimate of the ATE&lt;/span>
&lt;span class="n">hat.tau.obs&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">hat.tau.fn&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.obs&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Y.obs&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1">## bias of estimator&lt;/span>
&lt;span class="c1">## ----------------------------&lt;/span>
&lt;span class="c1"># The list of all possible assignments in a completely randomized design &lt;/span>
&lt;span class="c1"># with 3 treated units and 3 control units. You can check that the &lt;/span>
&lt;span class="c1"># list has 20 elements, which is exactly 6 choose 3.&lt;/span>
&lt;span class="n">W.ls&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="n">gtools&lt;/span>&lt;span class="o">::&lt;/span>&lt;span class="nf">permutations&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="m">6&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">6&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="m">6&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;span class="n">purrr&lt;/span>&lt;span class="o">::&lt;/span>&lt;span class="nf">array_tree&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="m">1&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;span class="n">purrr&lt;/span>&lt;span class="o">::&lt;/span>&lt;span class="nf">map&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="o">~&lt;/span> &lt;span class="n">W.obs[.]&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;span class="n">unique&lt;/span>
&lt;span class="c1"># For each possible assignment W, compute the outcome Y that would be &lt;/span>
&lt;span class="c1"># observed, and the corresponding estimate&lt;/span>
&lt;span class="c1">#&lt;/span>
&lt;span class="c1"># Note: in practice, we only observe a single element of hat.tau.ls, &lt;/span>
&lt;span class="c1"># namely hat.tau.obs&lt;/span>
&lt;span class="n">hat.tau.ls&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">vector&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#39;numeric&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">length&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nf">length&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.ls&lt;/span>&lt;span class="p">))&lt;/span>
&lt;span class="nf">for&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">i&lt;/span> &lt;span class="n">in&lt;/span> &lt;span class="nf">seq_along&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W.ls&lt;/span>&lt;span class="p">))&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="n">W&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="n">W.ls[[i]]&lt;/span>
&lt;span class="n">Y&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="n">science&lt;/span>&lt;span class="o">$&lt;/span>&lt;span class="n">y1&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="n">W&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="n">science&lt;/span>&lt;span class="o">$&lt;/span>&lt;span class="n">y0&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="m">1&lt;/span> &lt;span class="o">-&lt;/span> &lt;span class="n">W&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="n">hat.tau.ls[i]&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">hat.tau.fn&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">W&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Y&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="c1"># The bias of the difference in means estimator (under complete randomization)&lt;/span>
&lt;span class="n">bias&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">mean&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">hat.tau.ls&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">-&lt;/span> &lt;span class="n">tau&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div></description></item><item><title>Introduction to Identification</title><link>/post/identification/</link><pubDate>Fri, 12 Feb 2021 00:00:00 +0000</pubDate><guid>/post/identification/</guid><description>&lt;h2 id="identification-what-is-it">Identification: What is it?&lt;/h2>
&lt;p>Identification and identifiable are two commonly used words in Statistics and
Economics. But, have you ever wondered, what does it really mean to say that a
quantity is identifiable from the data? Statisticians seem to agree on a
definition in the context of parametric models &amp;mdash; calling a parameter
identifiable if distinct values of the parameter correspond to distinct members
of a parametric family. Intuitively, this means that if we had an infinite
amount of data, we could learn the actual model parameters used to generate the
data &amp;mdash; it&amp;rsquo;s kinda neat!&lt;/p>
&lt;p>So this definition makes sense for a parametric model, but what about
nonparametric models? And what if you don&amp;rsquo;t have an explicit model that you want
to use? For instance, in the context of an experiment or an observational study,
we might want to ask whether the average treatment effect of an intervention is
identifiable from the data. Unfortunately, the simple definition of parametric
identifiability does not apply if we take a nonparametric or randomization-based
approach.&lt;/p>
&lt;p>This post will build on the parametric intuition to describe a more general
notion of identifiability that works for all types of settings. Our goal is to
explain the definition and provide examples of how to apply it in a range of
different contexts. The next few posts in the series will dive deeper into
the role of identification in the causal context.&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;h2 id="a-general-notion-of-identifiability">A general notion of identifiability&lt;/h2>
&lt;h3 id="basic-framework">Basic framework&lt;/h3>
&lt;p>The identification framework we will consider consists of three elements:&lt;/p>
&lt;ol>
&lt;li>A &lt;em>statistical universe&lt;/em> that contains all of the objects relevant to a given
problem \(S\).&lt;/li>
&lt;li>An &lt;em>estimand mapping&lt;/em> that describes what aspect of the
statistical universe we are trying to learn about \(\theta : S \to \Theta \).&lt;/li>
&lt;li>An &lt;em>observation mapping&lt;/em> that tells us what parts of our statistical universe
we observe \( \lambda: S \to \Lambda \).&lt;/li>
&lt;/ol>
&lt;link rel="stylesheet" href="/css/hugo-easy-gallery.css" />
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/identification-diagram.png" />
&lt;/div>
&lt;a href="/image/identification-diagram.png" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>Diagram of the main objects.&lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;p>We then define identification by studying the inherent relationship between the
estimand mapping and the observation mapping using the &lt;em>induced binary relation&lt;/em>
\(R\). Intuitively, the induced binary relation connects &amp;ldquo;what we know&amp;rdquo; to
&amp;ldquo;what we are trying to learn&amp;rdquo; through the &amp;ldquo;statistical universe&amp;rdquo; in which we
operate.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Binary relation interlude:&lt;/strong> If you are not familiar with &lt;a href="https://en.wikipedia.org/wiki/Binary_relation">binary
relations&lt;/a>, or it&amp;rsquo;s been a while
since you&amp;rsquo;ve seen them, they are basically a generalization of a
function. Mathematically, a binary relation \(R\) from a set \(\Theta\) to
\(\Lambda\) is a subset of the cartesian product \(\Theta \times
\Lambda\). For \(\vartheta \in \Theta\) and \(\ell \in \Lambda\), we say
that \(\vartheta\) is \(R\)-related to \(\ell\) if \((\vartheta, \ell)
\in R\) and write \(\vartheta R \ell\).&lt;/p>
&lt;p>For example, let \(\Theta\) be the set of prime numbers, \(\Lambda\) be the
set of integers, and \(R\) the &amp;ldquo;divides&amp;rdquo; relation such that \(\vartheta R
\ell \) if \(\vartheta\) divides \(\ell\) (&lt;em>e.g.&lt;/em>, \(3 R 3\), \(3 R
6\), but 3 is not in relation with 2).&lt;/p>
&lt;hr>
&lt;h3 id="definition-of-identification">Definition of Identification&lt;/h3>
&lt;p>Specifying the three elements of the framework for a given problem gives rise
a special binary relation.&lt;/p>
&lt;dl>
&lt;dt>&lt;strong>Definition (Induced binary relation)&lt;/strong>&lt;/dt>
&lt;dd>Consider \(\mathcal{S} \) and \(\theta, \lambda \in G(\mathcal{S} )\),
where \(G(\mathcal{S} )\) is the set of all function with domain
\(\mathcal{S}\) and let \(\Theta = Img(\theta)\) and \(\Lambda =
Img(\lambda)\). We define the binary relation \(R_{\theta, \lambda}\)
induced by \(\mathcal{S}, \theta, \lambda\) as the subset
\(R_{\theta,\lambda} = \{(\theta(S), \lambda(S)), S \in \mathcal{S}\}
\subseteq \Theta \times \Lambda\).&lt;/dd>
&lt;/dl>
&lt;p>With this in place, we say that \(\theta\), the estimand mapping, is
identifiable from \(\lambda\) if the induced binary relation \(R\) is
injective. In words, if there is a 1-1 relationship between what we are trying
to &lt;em>estimate&lt;/em> and &lt;em>what we observe&lt;/em>, then the estimand mapping is identifiable
from the observation mapping. This can be formalized mathematically as follows: &lt;!-- raw HTML omitted -->&lt;/p>
&lt;dl>
&lt;dt>&lt;strong>Definition (Identifiability)&lt;/strong>&lt;/dt>
&lt;dd>Consider \(\mathcal{S}, \lambda, \theta\) and \(\Theta, \Lambda\) as in
the previous definition. For a given \(\ell_0 \in \Lambda\), let
\(\mathcal(S)(\ell_0) = \{S \in \mathcal{S}: \lambda(S) = \ell_0\}\). The
function \(\theta\) is said to be \(R_{\theta,\lambda}\)-identifiable at
\(\ell_0 \in \Lambda\) if there exists \(\vartheta_0 \in \Theta\), such
that, for all \(S \in \mathcal{S}(\ell_0)\), we have that
\(\theta(S)=\vartheta_{0}\).
&lt;p>The function \(\theta\) is said to be \(R_{\theta,\lambda}\)-identifiable
everywhere from \(\lambda\) if it is
\(R_{\theta,\lambda}\)-identifiable at \(\ell\) for all \(\ell \in
\Lambda\). We will usually simply say that \(\theta\) is identifiable.&lt;/p>
&lt;/dd>
&lt;/dl>
&lt;p>This definition might seem really abstract, but it&amp;rsquo;s exactly the intuitive
definition we gave in the introduction. It says that if the part
\(\mathcal{S}(\ell_0)\) of the statistical universe \(\mathcal{S}\) that is
coherent with the observed data \(\ell_0\) uniquely corresponds to a single
estimand of interest &amp;mdash; i.e. \(\theta(S) = \vartheta_0, \forall S \in
\mathcal{S}(\ell_0)\) &amp;mdash; then that estimand is identifiable!&lt;/p>
&lt;h2 id="examples">Examples&lt;/h2>
&lt;p>Below we describe how the above definition applies to parametric and nonparametric models as well as finite population settings.&lt;/p>
&lt;h3 id="parametric-models">Parametric models&lt;/h3>
&lt;p>Consider a parametric model where \(P(\vartheta)\) is a distribution indexed
by \(\vartheta \in \Theta\).&lt;/p>
&lt;p>The &lt;em>statistical universe&lt;/em> is then \(S = {(P(\vartheta),\vartheta): \vartheta\in \Theta })\). Notice that it contains both the model and the parameters that determine the model.&lt;/p>
&lt;p>The &lt;em>estimand mapping&lt;/em> is \(\theta(S) = \vartheta\). This defines the quantity of interest: in the simplest case, it is just the parameters of the model but it can also be any function or subset of the parameters &amp;mdash; i.e. \(\theta(S) = \phi(\vartheta)\).&lt;/p>
&lt;p>The &lt;em>observation mapping&lt;/em> is \( \lambda(S) = P(\vartheta) \). This is simply the model for a given parameter.&lt;/p>
&lt;p>Remember, identification is about understanding the limits of our estimation
with an infinite amount of data, and so the observations correspond exactly to
the full distribution. If \(\phi(\vartheta) = \vartheta\), the induced binary
relation \(R_{\theta,\lambda}\) reduces to a simple function
\(R_{\theta,\lambda}: \vartheta \rightarrow P(\vartheta)\) and the abstract
definition we gave above is exactly equivalent to the textbook definition of
identification for parametric statistical models.&lt;/p>
&lt;dl>
&lt;dt>&lt;strong>Linear Regression Example&lt;/strong>&lt;/dt>
&lt;dd>Consider a \(p\)-dimensional random vector \(X \sim P(X)\) for some
distribution \(P_X\). &lt;!-- raw HTML omitted -->
Let \(P(Y \mid X; \beta,\sigma^2) = \mathcal{N}(X^t\beta, \sigma^2)\), where
\(\mathcal{N}(\mu,\sigma^2)\) is the normal distribution with mean \(\mu\)
and variance \(\sigma^2\), and let \(P_{\beta,\sigma^2}(X,Y) = P(Y \mid X;
\beta, \sigma^2) P(X)\).
&lt;p>&lt;em>Example question:&lt;/em> Are the regression parameters \((\beta\) and \(\sigma^2)\)
identifiable?&lt;/p>
&lt;p>&lt;em>Identification setup:&lt;/em> We can study the identifiability of the parameter
\(\vartheta = (\beta, \sigma^2)\) from the joint distribution
\(P_{\vartheta}(X,Y)\) using our framework, by letting \(\mathcal{S} =
\{(P_{\vartheta}, \vartheta), \vartheta \in \Theta\}\), where \(\Theta =
\mathbb{R} \times \mathbb{R}^{+}\), \(\lambda(S) = P_{\vartheta}\), and
\(\theta(S) = \vartheta\). In this case, the induced binary relation
\(R_{\theta,\lambda}\) is reduces to a function and so \(\vartheta\)
is identifiable iff the function \(R_{\theta,\lambda}\) is injective. It
is easy to verify that this is the case if and only if the matrix
\(E[X^tX]\) has full rank. If in contrast, we take \(\theta&amp;rsquo;(S) = \beta\),
then the induced binary relation \(R_{\theta&amp;rsquo;, \lambda}\) is no longer
a function, but our general definition of identifiability still applies.&lt;/p>
&lt;/dd>
&lt;/dl>
&lt;h3 id="nonparametric-identification">Nonparametric identification&lt;/h3>
&lt;p>Applying the mathematical definition of identification to nonparametric models is relatively straight forward.&lt;/p>
&lt;dl>
&lt;dt>&lt;strong>Missing Data Example&lt;/strong>&lt;/dt>
&lt;dd>If \(Y\) is a random variable representing a response of interest, let
\(Z\) be a missing data indicator that is equal to \(1\) if the response
\(Y\) is observed, and \(0\) otherwise; that is, the data we actually observe
is drawn from \(P(Y \mid Z=1)\).
&lt;p>&lt;em>Example question:&lt;/em> Is the distribution of the missing outcomes \(P(Y \mid Z=0)\)
identifiable from that of the observed outcomes \(P(Y \mid Z=1)\) combined with
that of the missing data indicator \(P(Z)\)?&lt;/p>
&lt;p>&lt;em>Identification setup:&lt;/em> Let \(\mathcal{S}\) be a family of joint distributions for \(Z\) and \(Y\),
and define \(\lambda(S) = (P(Y \mid Z=1), P(Z))\), and \(\theta(S) = P(Y \mid Z=0)\). The
question can be answered by studying the injectivity of the induced mapping \(R_{\theta, \lambda}\). We let that question unanswered for now, but will revisit it in a subsequent installment of this series.&lt;/p>
&lt;/dd>
&lt;/dl>
&lt;p>Notice that the same definition worked in both nonparametric and parametric models &lt;em>without&lt;/em> having to be adjusted or tweaked.&lt;/p>
&lt;h3 id="finite-population-identification">Finite population identification&lt;/h3>
&lt;p>In the previous two sections, we assumed an infinite amount of data—that is the usual starting point for identification. But what do you do if you plan to take a finite population perspective? Clearly, the assumption that you have an infinite amount of data doesn&amp;rsquo;t make sense! It turns out that we can again use the mathematical definition of identification by defining the appropriate statistical universe, estimand mapping, and observation mapping.&lt;/p>
&lt;dl>
&lt;dt>&lt;strong>Causal Inference Example&lt;/strong>&lt;/dt>
&lt;dd>With \(N\) units, let each unit be assigned to one of two treatment interventions, \(Z_i =1\) for treatment and \(Z_i=0\) for control. Under the stable unit treatment value assumption each unit \(i\) has two potential outcomes \(Y_i(1)\) and \(Y_i(0)\), corresponding to the outcome of unit \(i\) under treatment and control, respectively. For each unit \(i\), the observed outcome is \(Y^{\ast}_i = Y_i(Z) = Y_i(1) Z_i + Y_i(0) (1-Z_i)\). Let \(Y(1) = {Y_1(1), \ldots, Y_N(1)}\) and \(Y(0) = {Y_1(0), \ldots, Y_N(0)}\) be the vectors of potential outcomes and \(Y = (Y(1), Y(0))\).
&lt;p>&lt;em>Example question:&lt;/em> Is \(\tau(Y) = \overline{Y(1)} - \overline{Y(0)}\) identifiable from the observed data \((Y^\ast, Z)\).&lt;/p>
&lt;p>Identification setup: Let \(\mathcal{S}_Y = \mathbb{R}^N \times \mathbb{R}^N\) be the set of all possible values for \(Y\), \(\mathcal{S}_Z = \{0,1\}^N\) be the set of all possible values for \(Z\), and \(\mathcal{S} = \mathcal{S}_Y \times \mathcal{S}_Z\).&lt;/p>
&lt;p>Take \(\theta(S) = \tau(Y)\) and \(\lambda(S) = (Y^\ast, Z)\) as the estimand and observation mapping, respectively. The question is then answerable by studying the injectivity of the induced binary relation \(R_{\theta, \lambda}\).&lt;/p>
&lt;/dd>
&lt;/dl>
&lt;p>Once again, we will revisit this example in more details in a future post &amp;mdash; our goal here
is simply to show how identification questions can be formulated in a unified fashion within a simple framework.&lt;/p>
&lt;h2 id="further-reading">Further reading&lt;/h2>
&lt;p>We dive deeper into some of the formalism behind identification in a &lt;a href="https://arxiv.org/abs/2002.06041">recent
paper&lt;/a>. A lot of the pioneering work on
identifiability was done by the economist Charles Manski: see for instance his
2009 monograph &lt;em>&amp;lsquo;Identification for prediction and decisions&amp;rsquo;&lt;/em> for a very
accessible introduction. For a recent in-depth survey of the area, see Lewbel
2019: &lt;em>&amp;lsquo;The identification Zoo&amp;rsquo;&lt;/em>. Finally, as mentioned in the introduction, this
is the first installment in a series dedicated to identifiability &amp;mdash; stay tuned
for the next installments!&lt;!-- raw HTML omitted -->&lt;/p>
&lt;h2 id="references">References&lt;/h2>
&lt;p>&lt;a href="https://arxiv.org/abs/2002.06041">Basse, G., &amp;amp; Bojinov, I. (2020). &lt;em>A general theory of identification.&lt;/em> arXiv preprint arXiv:2002.06041.&lt;/a>&lt;/p>
&lt;p>Lewbel, A. (2019). &lt;em>The identification zoo: Meanings of identification in econometrics&lt;/em> Journal of Economic Literature.&lt;/p>
&lt;p>Manski, C. (2009) &lt;em>Identification for prediction and decisions.&lt;/em> Harvard University Press.&lt;/p></description></item><item><title>A Leader's Guide to Heterogeneous Treatment Effects</title><link>/post/heterogenous/</link><pubDate>Mon, 25 Jan 2021 00:00:00 +0000</pubDate><guid>/post/heterogenous/</guid><description>&lt;p>People don&amp;rsquo;t always agree; that is a fact of life. Similarly, when running an experiment, not everyone has the same reaction to the intervention! It&amp;rsquo;s critical that data scientists, academics, and the general public understand that the global average may not always be the most important or meaningful measure. Instead, it is often more informative to study how the effect of an intervention varies across different population subgroups. This post explains, at a high level, what &lt;em>heterogeneous treatment effects&lt;/em> are, why they are essential, and how to think about them.&lt;/p>
&lt;h2 id="what-are-heterogeneous-treatment-effects">What are heterogeneous treatment effects?&lt;/h2>
&lt;h3 id="intuitive-definition">Intuitive definition&lt;/h3>
&lt;p>When analyzing a randomized experiment or observational study, analysts often report the population &lt;em>average treatment effect&lt;/em> (ATE) as the main &amp;mdash;and often only&amp;mdash; summary for the causal effect of the intervention. But what does it really mean? And who does it apply to? Just because we see that an intervention has a +1 (statistically significant) effect on average, can we conclude that the treatment would have an effect of +1 on every untreated unit, if we were to treat them? In short, the answer is no. The average is an important summary, but it often fails to provide the full picture. For example, an ATE of +1 may correspond to a scenario in which the intervention affects every unit equally; but it may also correspond to a case in which it has a +2 effect for half the units and -1 for the other half (see the figure below).&lt;/p>
&lt;link rel="stylesheet" href="/css/hugo-easy-gallery.css" />
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/heterogeneous_causal.jpg" />
&lt;/div>
&lt;a href="/image/heterogeneous_causal.jpg" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>The figure illustrates how two different interventions can produce the same average causal effect. The left shows everyone having the same reaction to the intervention, whereas the right shows that some units have very positive responses and others have an adverse reaction.&lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;p>Hetoregenous literally means &amp;ldquo;diverse in character or content,&amp;rdquo; so when we talk about &amp;ldquo;heterogeneous treatment effects,&amp;rdquo; we acknowledge the fact that every experimental unit may have a different response to the intervention. In practice, however, it is extremely difficult to reliably assess the effect of the intervention on each individual unit, and we must instead settle on assessing the effect of the intervention on subgroups of units that share similar characteristics. For example, it is common in clinical trials to report separate estimates for how a drug impacts children and for how it impacts adults, to reflect the biological differences. Technology companies similarly track responses across different platforms and countries.&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;h3 id="which-heterogeneous-effects-to-look-at">Which heterogeneous effects to look at?&lt;/h3>
&lt;p>Any collection of average effects on subgroups of the population can be considered heterogeneous effects. Typically, the subgroups are defined by looking at each unit&amp;rsquo;s covariates (or characteristics). The extreme case is the individual treatment effects that try to ascertain each experimental unit&amp;rsquo;s causal effect separately; these, however, are virtually impossible to estimate without making strong assumptions. So what is the right middle ground between the average treatment effect (which is easy to estimate but not very informative) and the individual treatment effects (which are very informative but hard to estimate)? There is no unique answer to this question as it depends on the context. One crucial tradeoff to remember is that the smaller the subgroups we consider, the more difficult it is to estimate that subgroup&amp;rsquo;s effect.&lt;/p>
&lt;p>Broadly speaking, there are two approaches to looking for heterogeneous treatment effects. The first requires knowledge of which groups to look at, and the second attempts to learn them from the data.&lt;/p>
&lt;h2 id="estimating-heterogeneous-effects-within-pre-specified-groups">Estimating heterogeneous effects within pre-specified groups&lt;/h2>
&lt;h3 id="design-considerations">Design Considerations&lt;/h3>
&lt;p>If we expect that some groups will react differently to our intervention, we can separate them before starting the experiment. In other words, we can run smaller-scale experiments within the pre-defined groups. That way, we can obtain separate estimates of the causal effects within the groups. For example, suppose you work at a technology company that has a presence in many countries. In that case, it is relatively common to separately run experiments within each country to ensure that we can estimate how the innovations are perceived differently across different geographies.&lt;/p>
&lt;h3 id="post-experiment-analysis">Post experiment analysis&lt;/h3>
&lt;p>We can estimate heterogeneous effects even when experiments where not run separately in each
subgroup. Imagine we have a single binary covariate (for example, whether or not someone likes pie or whether or not someone is under the age of 18) that was recorded before the treatment assignment. Then, it is easy to measure the effect within the different values of this covariate. We simply group the units that like pie and the units that dislike pie and separately compute each group&amp;rsquo;s effect. We can carry out inference in the standard way, as discussed in our post on the &lt;a href="/post/po-introduction/">potential outcomes framework&lt;/a>. But, since we are testing multiple hypotheses, we need to perform a multiple comparison test adjustment to ensure that we control the overall type I error at the appropriate level. The simplest way to do this is via the &lt;a href="https://en.wikipedia.org/wiki/Bonferroni_correction">Bonferroni correction&lt;/a> that divides the nominal type I error by the number of tests.&lt;/p>
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/heterogeneous_causal_known_groups.jpg" />
&lt;/div>
&lt;a href="/image/heterogeneous_causal_known_groups.jpg" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>The figure shows the potential outcomes for two distinct groups of units. The left shows the control outcomes, and the right shows the treatment outcomes. Group 1 loved the intervention, whereas group 2 isn&amp;#39;t as keen. &lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;p>The post-experiment analysis approach works well with large experiments. However, depending on the adopted design, it might be the case that some groups are disproportionately assigned to certain treatments, making it hard to assess the heterogeneous effect accurately. That is why it is generally better to account for the subgroups of interest directly in the design, as suggested above.&lt;/p>
&lt;h2 id="group-discovery">Group discovery&lt;/h2>
&lt;p>The pre-specified strategy works well when there is only a handful of known groups. However, it starts to break down when the number of possible groups becomes large, which is often the case if we are interested in understanding how the effects differ across interactions of multiple covariates (&lt;em>i.e.&lt;/em>, children that like pie and adults that don’t like pie). When there are many possible groupings, and we don’t know which to look at, there is rarely enough data to perform an exhaustive search, so we have to be more strategic about finding these groups.&lt;/p>
&lt;p>There are two intuitive approaches to accomplish. The first begins with the whole population and sequentially tries to split the sample into subgroups that reacted similarly to the intervention but differently from everyone else. The second starts with everyone in small groups and carefully combines the groups that reacted similarly to intervention until we have a manageable number of distinct groups such that, within the groups, the units responded similarly, but across groups, there are significant differences in the effect. See the two examples below for more details.&lt;/p>
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/heterogeneous_causal_unknown_groups.jpg" />
&lt;/div>
&lt;a href="/image/heterogeneous_causal_unknown_groups.jpg" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>The figure shows the potential outcomes for a set of ungrouped units. The left shows the control outcomes, and the right shows the treatment outcomes. Based on the treatment effect, we can identify two distinct groups: Group 1 loved the intervention, and group 2 didn&amp;#39;t. &lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;h3 id="example-1-split-the-data-wager--athey-2018">Example 1: Split the data (Wager &amp;amp; Athey, 2018):&lt;/h3>
&lt;p>The machine learning community has widely used tree-based methods for both classification and regression tasks. Typically, these methods aim to partition covariate space into a set of homogeneous rectangles and then fit a simple model on each. The partitioning is done by finding a point that minimizes the within-group variability of the outcome. In causal inference, we focus on the causal effect; thus, applying this idea requires simply augmenting the objective function to find subgroups with estimated causal effects different from the overall group. This approach works well on small to moderate size data sets; however, the computation time increases rapidly as the data&amp;rsquo;s dimensions grow. This method is described in detail in Wager &amp;amp; Athey (2018) and is implemented in the grf R package (Athey et al. 2019).&lt;/p>
&lt;h3 id="example-2-regroup-the-data-sepehri--diciccio-2020">Example 2: Regroup the data (Sepehri &amp;amp; DiCiccio, 2020):&lt;/h3>
&lt;p>An alternative to the above approach that tries to group the data by sequentially splitting the larger group into smaller groups is to reverse this. In particular, we can begin by grouping everyone into a fixed number of predefined subgroups based on their covariates. We then iteratively merge the two &amp;ldquo;most similar&amp;rdquo; clusters at each step until a stopping criterion is met. The notion of similarity and the stopping criteria can be defined using a formal hypothesis test; the resulting algorithm easily scalable to massive data sets and provide inferential guarantees about the output. This method is described in detail in Sepehri and DiCiccio (2020).&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;h1 id="references">References&lt;/h1>
&lt;p>Athey, S., Tibshirani, J., &amp;amp; Wager, S. (2019). Generalized random forests. The Annals of Statistics, 47(2), 1148-1178.&lt;/p>
&lt;p>Sepehri, A., &amp;amp; DiCiccio, C. (2020). Interpretable Assessment of Fairness During Model Evaluation. arXiv preprint arXiv:2010.13782.&lt;/p>
&lt;p>Wager, S., &amp;amp; Athey, S. (2018). Estimation and inference of heterogeneous treatment effects using random forests. Journal of the American Statistical Association, 113(523), 1228-1242.&lt;/p></description></item><item><title>A Leader's Guide to Interference</title><link>/post/interference/</link><pubDate>Mon, 18 Jan 2021 00:00:00 +0000</pubDate><guid>/post/interference/</guid><description>&lt;h2 id="what-is-interference">What is interference?&lt;/h2>
&lt;h3 id="basics">Basics&lt;/h3>
&lt;p>Suppose you wish to test whether a drug is effective at reducing a person&amp;rsquo;s
blood pressure. Typically, you would assign some units to take the drug
(treatment) and others to take a placebo (control). You would then contrast
the outcome (blood pressure) of the units in the treatment group, to that of
the units in the control group.&lt;/p>
&lt;link rel="stylesheet" href="/css/hugo-easy-gallery.css" />
&lt;div class="box">
&lt;figure itemprop="associatedMedia"
itemscope itemtype="http://schema.org/ImageObject" >
&lt;div class="img">
&lt;img itemprop="thumbnail" src="/image/interference_sutva.jpg" />
&lt;/div>
&lt;a href="/image/interference_sutva.jpg" itemprop="contentUrl">&lt;/a>
&lt;figcaption>&lt;h4>Example of treatment comparison where the experimental units belong to different households, but where that structure is ignored.&lt;/h4>
&lt;/figcaption>
&lt;/figure>
&lt;/div>
&lt;h3 id="examples-of-interference-scenarios">Examples of interference scenarios&lt;/h3>
&lt;p>Notice that in this particular example, it seems reasonable to assume that a
drug pill (treatment) affects only the blood pressure (outcome) of the
particular unit who takes that pill. In more general terms, an individual
unit&amp;rsquo;s treatment assignment affects only its own outcome: we say that there
is no interference between units. In contrast, if a unit&amp;rsquo;s treatment assignment
may affect another unit&amp;rsquo;s outcome, we say that there is interference between
units.&lt;/p>
&lt;p>The best way to get familiar with the idea is to consider a few examples:&lt;/p>
&lt;p>&lt;strong>Example 1: SDP example (Rogers and Feller 2016)&lt;/strong>&lt;/p>
&lt;blockquote>
&lt;p>An important challenge that the school districts across the US face is a high
student-absence rate: 10% of students in K-12 schools are chronically absent,
meaning that they miss more than 18 days of school in the year. In a recent
paper, Rogers and Feller studied the effectiveness of a mail-based intervention,
with the following design: they randomly selected households with children
attending K-12 in the School District of Philadelphia. Within these selected
households (let’s call them “treated” household), they selected at random one
of the children attending K-12 (if more than one) and sent information to the
parents about that child’s current absence rate. While the intervention was
ostensibly aimed at reducing the absence rate of the child targeted by the
intervention, Basse and Feller (2018) showed that the intervention also affects the
siblings of targeted children.&lt;/p>
&lt;/blockquote>
&lt;p>&lt;strong>Example 2: Get out the vote experiment (Bond et al. 2012)&lt;/strong>&lt;/p>
&lt;blockquote>
&lt;p>In a study designed to assess the effectiveness of a get-out-the-vote intervention
on facebook, Bond and colleagues sent messages to 60 million facebook users encouraging
them to go out and vote. They found that not only the intervention increased the
probability of the treated individuals (i.e. those who received the intervention) to
vote: the intervention also increased the probability that their close friends would
vote!&lt;/p>
&lt;/blockquote>
&lt;p>&lt;strong>Example 3: 401k investment example (Duflo and Saez 2003)&lt;/strong>&lt;/p>
&lt;blockquote>
&lt;p>Duflo and Saez designed an experiment to study the determinants of an employee’s
choice to sign-up for a tax deferred retirement account at a large university. As
part of this study, they randomly selected a number of departments, and within
those departments, they randomly selected a number of employees to whom they sent
an encouragement to participate in a “benefits information fair” (the encouragement
included some money). They note that the intervention “multiplied by more than five
the attendance rate of these treated individuals (relative to controls), and
tripled that of untreated individuals within departments where some individuals
were treated.”&lt;/p>
&lt;/blockquote>
&lt;h2 id="what-can-go-wrong-if-i-ignore-interference">What can go wrong if I ignore interference?&lt;/h2>
&lt;h3 id="comparing-apples-and-oranges">Comparing apples and oranges&lt;/h3>
&lt;p>The strategy illustrated in Figure 1 works well if there is no interference
between units, but things can go very wrong if units interfere with each other.
To understand what the problem is consider the household example from Rogers
and Feller 2016, described above. Although the treatment status is binary (a
unit is treated or control), there are, in fact, three effective treatment
statuses: a unit can be treated (pure treated), it can be untreated but have
a sibling treated (exposed), or it can be untreated and have no sibling treated
(pure control).&lt;/p>
&lt;p>Notice, in particular, how untreated units may either be pure control or exposed.
The comparison of Figure 1 between treated and untreated units now looks as follows:&lt;/p>
&lt;p>&lt;img src="/image/interference_partial.jpg" alt="Partial interference">&lt;/p>
&lt;p>The &amp;ldquo;control group&amp;rdquo; now contains a mix of pure control units, and exposed units:
the treatment has spilled over to the control group!&lt;/p>
&lt;h3 id="so-what">So what?&lt;/h3>
&lt;p>Well, suppose that the effect of receiving the treatment directly is almost the
same as receiving spillovers from treatment (this is not so unlikely &amp;mdash; Basse
and Feller (2018) found spillovers roughly half as large as the direct effect).
Then the average response in the &amp;ldquo;control group&amp;rdquo; is inflated by the presence of
spillover units: this may lead to severe bias (in this case, you would
underestimate the effect of your intervention).&lt;/p>
&lt;p>How much bias? It depends on what you are willing to assume about the interference
structure, but if you believe that the treatment assignment of any unit may affect
any other unit&amp;rsquo;s response arbitrarily, then the bias may be arbitrarily bad.&lt;/p>
&lt;h3 id="what-is-the-direction-of-the-bias">What is the direction of the bias?&lt;/h3>
&lt;p>In the examples we’ve presented so far, it seems—at least intuitively—that the
bias is gently pulling us towards 0. So is this always true? Does interference
just slightly dilute the effect? The simple answer is no. There are many other
examples where interference can arbitrarily change the sign and magnitude of an
effect. This is particularly prominent when experimental units are competing for
a limited resource; for example, in marketplaces.&lt;/p>
&lt;p>Consider a ridesharing firm that has developed a new pricing algorithm. Their
hope is that this innovation will reduce both wait time for passengers and
increase revenue for drivers (and in turn the firm) by introducing a temporary
price increase in areas where demand exceeds supply. Now, let’s imagine running
an experiment in Boston, where for every driver we flip an unbiased coin: if lands
heads the driver is assigned to the algorithm; if it lands tails they stick with
the current approach. Focusing on revenue, suppose the experiment has a negative
effect, that is, if everyone were assigned to the new version (or treatment) then
the company would generate less revenue as fewer riders would be willing to pay
the higher prices. But in the experiment, the drivers in the treatment group are
sent to the busier areas and so they pick up more drivers at a higher price. The
results say that the treatment is generating a lot more revenue than the control.
But there are two things happening. The first is that there is a redistribution
where the revenue is shifting from being evenly spread amongst all the drivers to
being more concentrated in the treatment group. The second is that the overall
revenue is actually going down! When all the drivers start to receive treatment
this redistribution will no longer occur and so the perceived positive effect will
disappear.&lt;/p>
&lt;p>&lt;img src="/image/Interference_effect_impact.jpg" alt="The effect of interference">&lt;/p>
&lt;p>When the experimental units are competing for a limited resource more
experiments perform a redistribution between treatment and control—making it seem
like there is a positive or negative effect when really it’s just 0.&lt;/p>
&lt;h2 id="what-can-i-do-about-it">What can I do about it?&lt;/h2>
&lt;h3 id="design">Design&lt;/h3>
&lt;p>Many authors have proposed different experimental designs to either alleviate
the interference or to directly measure it. At the heart of most of these
designs is a simple idea of creating groups such that most of the interference
is contained within the group and there is little (or usually none) across the
groups. Once these groups have been defined, we can vary treatment across the
groups as well as within the groups. Typically the cross-group variation allows
us to measure average treatment effect whereas the within-group variations
allows for the estimation of the spillovers.&lt;/p>
&lt;p>An alternative approach that has also gained a lot of popularity in technology
companies is to use switchback (or time series experiments). This class of experiments
treats the city as a single unit and alternates the treatment over time, thereby
translating the problem of interference across drivers into a problem of
interference over time. This approach will be the object of another post.&lt;/p>
&lt;h3 id="analysis">Analysis&lt;/h3>
&lt;p>Analyzing a well-designed study that is subject to interference is—although trickier
than a study with no interference—relatively straightforward. The main idea is to
continue respecting the isolation generated in the design phase and only focus on
well-specified contrasts, as illustrated below. One thing to keep in mind is that
we still need to normalize each observation by the appropriate treatment exposure probabilities.
Without proper normalization, even isolated contrasts can lead to biased results.&lt;/p>
&lt;p>&lt;img src="/image/interference_partial_est.jpg" alt="Estimation under partial interference">&lt;/p>
&lt;h2 id="mind-the-gap-from-intuition-to-formalization">Mind the gap: from intuition to formalization&lt;/h2>
&lt;p>In trying to provide helpful intuition, we have brushed a number of important
details under the proverbial rug. We conclude this note by pointing out the
holes and over-simplifications in our treatment of the subject and provide
some starting points for a fuller understanding of the subject.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Assumption on the interference structure.&lt;/strong> In Figure 1, we noted that the
siblings of treated units received “some spillover,” but how do we know that
these spillovers don’t also affect units in untreated households? We don’t ––
this is an assumption we have implicitly made on the interference mechanism.
Such assumptions are generally formulated via the concept of
&lt;em>exposure mapping&lt;/em>.&lt;/li>
&lt;li>&lt;strong>Defining the effects of interest.&lt;/strong> Throughout this note, we have thrown
around the words direct effect and spillover effect without defining them
formally. While it is easy to get an “intuitive” understanding of these,
this intuition can be misleading in more complex situations. Rigorously
defining these effects requires quite a bit of formalism.&lt;/li>
&lt;li>&lt;strong>Spillover or spillovers?&lt;/strong> An important idea that gets lost in our
oversimplification is the fact that there is, in general, no single
unambiguous definition of “spillover effect”. Instead, there are many
possible “spillover effects”, and one must be clear about which one they are
interested in.&lt;/li>
&lt;li>&lt;strong>Analysis.&lt;/strong> A popular approach is to rely on inverse probability weighted
estimators (e.g. Horvitz-Thompson and Hajek). There is an ongoing research
effort to provide a satisfactory asymptotic theory for a large class of designs
and interference structures.&lt;/li>
&lt;/ul>
&lt;p>For an accessible introduction to the main formalism, we suggest starting out with
Basse and Feller 2018, and then Aronow and Samii 2017: the former focuses on a special
case of the latter, which might make it more accessible as a starting point. For an
example of marketplace interference, see Basse et al. 2016. For recent advances in the
asymptotic theory, see Leung 2020 and Chin 2019. For different designs, see Ugander
et al. 2013, Rogers and Feller 2016, Baird et al. 2018., and Saint-Jacque et al. 2019.&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;h2 id="references">References&lt;/h2>
&lt;p>Aronow, P. M., &amp;amp; Samii, C. (2017). Estimating average causal effects under general interference, with application to a social network experiment. The Annals of Applied Statistics, 11(4), 1912-1947.&lt;/p>
&lt;p>Baird, S., Bohren, J. A., McIntosh, C., &amp;amp; Özler, B. (2018). Optimal design of experiments in the presence of interference. Review of Economics and Statistics, 100(5), 844-860.&lt;/p>
&lt;p>Basse, G., &amp;amp; Feller, A. (2018). Analyzing two-stage experiments in the presence of interference. Journal of the American Statistical Association, 113(521), 41-55.&lt;/p>
&lt;p>Basse, G. W., Soufiani, H. A., &amp;amp; Lambert, D. (2016, May). Randomization and the pernicious effects of limited budgets on auction experiments. In Artificial Intelligence and Statistics (pp. 1412-1420).&lt;/p>
&lt;p>Bond, R. M., Fariss, C. J., Jones, J. J., Kramer, A. D., Marlow, C., Settle, J. E., &amp;amp; Fowler, J. H. (2012). A 61-million-person experiment in social influence and political mobilization. Nature, 489(7415), 295-298.&lt;/p>
&lt;p>Chin, A. (2018). Central limit theorems via Stein&amp;rsquo;s method for randomized experiments under interference. arXiv preprint arXiv:1804.03105.&lt;/p>
&lt;p>Duflo, E., &amp;amp; Saez, E. (2003). The role of information and social interactions in retirement plan decisions: Evidence from a randomized experiment. The Quarterly journal of economics, 118(3), 815-842.&lt;/p>
&lt;p>Leung, M. P. (2020). Treatment and spillover effects under network interference. Review of Economics and Statistics, 102(2), 368-380.&lt;/p>
&lt;p>Saint-Jacques, G., Varshney, M., Simpson, J., &amp;amp; Xu, Y. (2019). Using Ego-Clusters to Measure Network Effects at LinkedIn. arXiv preprint arXiv:1903.08755.&lt;/p>
&lt;p>Rogers, T., &amp;amp; Feller, A. (2016). Discouraged by peer excellence: Exposure to exemplary peer performance causes quitting. Psychological science, 27(3), 365-374.&lt;/p>
&lt;p>Ugander, J., Karrer, B., Backstrom, L., &amp;amp; Kleinberg, J. (2013). Graph cluster randomization: Network exposure to multiple universes. In Proceedings of the 19th ACM SIGKDD international conference on Knowledge discovery and data mining (pp. 329-337).&lt;/p></description></item><item><title>Introduction to the Potential Outcomes Framework</title><link>/post/po-introduction/</link><pubDate>Mon, 18 Jan 2021 00:00:00 +0000</pubDate><guid>/post/po-introduction/</guid><description>&lt;p>The Potential Outcomes Framework (aka the Neyman-Rubin Causal Model) is arguably the most widely used framework for causal inference in the social sciences. This post gives an accessible introduction to the framework&amp;rsquo;s key elements — interventions, potential outcomes, estimands, assignment mechanisms, and estimators.&lt;/p>
&lt;h2 id="an-informal-first-look-a-game-and-a-story">An informal first look: a game and a story&lt;/h2>
&lt;h3 id="a-game-with-boxes">A game with boxes&lt;/h3>
&lt;p>Suppose we play the following game. I put two boxes in front of you, one
labelled \(0\) and the other labelled \(1\). Each box contains a slip
of paper on which I&amp;rsquo;ve written some number. Denote by \(y(0)\) the number
in the box labelled \(0\) and \(y(1)\) the number in the box labelled
\(1\), both of which are unknown to you. Your goal is to guess the
difference between the number in box \(1\) and the number in box \(0\),
denoted:&lt;/p>
&lt;p>\[
\tau = y(1) - y(0).
\]&lt;/p>
&lt;p>The game is played as follows: you must choose a box and open it to read the
number it contains. The trick, however, is that the boxes are rigged so that
the moment you open one of the boxes, the other box self-destructs so you
can never know the number it contained.&lt;/p>
&lt;p>In general, a variant of the game is played in which \(N\) pairs of boxes
are aranged in \(N\) rows indexed \(i = 1, \ldots, N \). Each box is
sealed and contains a slip of paper with a number. Denote by \(y_i(0)\)
the number in the box labelled \(0\) in the \(i^{th}\) row, and
\(y_i(1)\) the number in the box labelled \(1\) in the same row. This
time, the goal is to guess the average difference:&lt;/p>
&lt;p>\[
\tau = \frac{1}{n} \sum_{i=1}^n {y_i(1) - y_i(0)},
\]&lt;/p>
&lt;p>You get to open a single box in each row &amp;mdash; the rule being, as above,
that the moment you open one of the boxes in row \(i\) the other box
in the same row self-destructs. The name of this game, as you&amp;rsquo;ve probably guessed, is causal inference. Now let&amp;rsquo;s look at another way of motivating this framework.&lt;/p>
&lt;h3 id="a-story-with-a-genie">A story with a genie&lt;/h3>
&lt;p>Guillaume is in a bit of a bind at the moment: he must give a talk in one hour but is currently having a throbbing headache. He contemplates taking an aspirin pill, but he is unsure of the effect that it would have on his headache. Fortunately, he met a genie a long time ago who promised to grant him a wish, and this seems like a good time to use it. He conjures the genie and asks what the effect of taking the pill would be on his headache. After pointing out that he could have asked him to cure his headache, the genie tells Guillaume that although he is all-powerful, he cannot answer his question because he doesn’t know what “the effect of the pill” even means! Guillaume scratches his head and starts to babble stuff about causal effects, but the genie interrupts him:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>Genie: Look, here&amp;rsquo;s what we&amp;rsquo;re going to do. If you were all-powerful like me,
describe precisely the quantity that you would like to know.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Guillaume: Ok, if I were all powerful, here is what I would do. First I would take the
aspirin, wait an hour, and then assess the state of my headache.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Genie: Wait, how would you &amp;ldquo;assess&amp;rdquo; the state of your headache?&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Guillaume: I have a special scale for rating headaches, from 1 (feeling great) to
10 (feeling aweful). You&amp;rsquo;re all-powerful, so you should know my scale..&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Genie: Ah, right. Ok, sure, so you&amp;rsquo;d get a number between 1 and 10. Then what
would you do?&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Guillaume: Well, after that I would go back in time to the exact moment I took the
aspirin pill, but this time I would not take it. I would then wait an hour
and rate the state of my headache: this would give me an other number. What
I call a causal effect is the difference between these two numbers.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Genie: I see. Wait a sec. Done &amp;mdash; the answer is -4, which means the Aspirin would
help&amp;hellip;&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Guillaume: Got it, thank you for your help!&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h3 id="potential-outcomes-in-a-nutshell">Potential outcomes in a nutshell&lt;/h3>
&lt;p>Hopefully, the connection between the (first version) of the game and the
story is clear. The numbers written in the box labelled \(1\) corresponds
to the strength of the headache should Guillaume take the pill, and the
number written in the box labelled \(0\) corresponds to the strength
of the headache should he not take the pill. So
we can write \(y(1)\) the strength of Guillaume&amp;rsquo;s headache (an hour from
now) should he take the pill, and \(y(0)\) the strength of his headache
should he not take the pill. The causal effect of the pill is then defined
as \(\tau = y(1) - y(0)\).&lt;/p>
&lt;p>The boxes metaphore crystalizes the key intuition behind the potential
outcomes framework. Before he decides which action to take (pill or no pill),
\(y(1)\) and \(y(0)\) exists as potentialities: they are the potential
state of the headache (one hour from now) if Guillaume takes the pill (resp.
doesn&amp;rsquo;t take the pill). Like the numbers in the boxes, they are well-defined,
and exist prior to Guillaume&amp;rsquo;s action: they are the &amp;ldquo;potential outcomes&amp;rdquo; of
Guillaume&amp;rsquo;s action. Like the numbers in the boxes, they are both unknown prior
to Guillaume&amp;rsquo;s action. Like the numbers in the boxes, one of the two will be
revealed depending on which action is taken, while the other will never be
knowable.&lt;/p>
&lt;p>The quantities \(y(1)\) and \(y(0)\) are known as the &lt;strong>potential outcomes&lt;/strong>.
If Guillaume takes the pill, then he observes \(y(1)\), and \(y(0)\) becomes
counterfactual; if he does not take the pill, he observes \(y(0)\) and
\(y(1)\) becomes counterfactual. The fundamental problem of causal inference
is that in either case, the counterfactual outcome forever remains unknown.&lt;/p>
&lt;p>This, in a nutshell, summarizes the intuition behind potential outcomes. The
next section formalizes this intuition, and introduces the remaining components
of the framework.&lt;/p>
&lt;h2 id="the-rubin-causal-model">The Rubin Causal Model&lt;/h2>
&lt;h3 id="assignments-and-potential-outcomes">Assignments and potential outcomes&lt;/h3>
&lt;p>Consider a population of \(n\) units indexed \(i = 1, \ldots n\). Suppose
that each unit may receive one of two interventions &amp;mdash; for concreteness, let&amp;rsquo;s
call one of them &lt;em>treatment&lt;/em> and the other &lt;em>control&lt;/em>. For each unit \(i\)
denote by \(W_i\) the treatment indicator for unit i, where \(W_i = 1\) if
unit \(i\) is assigned to treatment and \(W_i = 0\) if unit \(i\) is
assigned to control. The vector of treatment indicators is denoted
\(\vec{W} = (W_1, \ldots, W_n)\). Since the treatment will be assigned at
random, \(\vec{W}\) will be a random vector. We will denote by an uppercase
\(\vec{W}\) the random variable, and by lower case
\(\vec{w} = (w_1, \ldots, w_n)\) a specific realizations of the assignment. Then we use the notation \(Pr(\vec{W} = \vec{w})\) to denote the probability that the
random assignment vector \(\vec{W}\) will take the value \(\vec{w}\). The
distribution of \(\vec{W}\), called &lt;em>assignment mechanism&lt;/em>, will be discussed
in more detailed below.&lt;/p>
&lt;p>&lt;em>Note: Throughout, we will still to the convention that uppercase letters denote
random variables, while lowercase letters denote constants or specific realizations
of random variables.&lt;/em>&lt;/p>
&lt;p>In the examples above, we introduced the potential outcomes intuitively, as
describing the response of a unit if it were assigned a specific treatment.
More formally, for each unit \(i\) consider a function
\(y_i: \{0,1\}^n \rightarrow \mathbb{R}\), so that for any assignment
\(\vec{w} \in \{0,1\}^n\), \(y_i(\vec{w})\) is the potential outcome of
unit \(i\) if unit 1 were assigned to treatment \(w_1\), unit 2 to \(w_2\), etc&amp;hellip;&lt;/p>
&lt;p>In our aspirin example, there is a single unit \((n=1)\), therefore
the assignment vector \(\vec{w}\) reduces to a scalar
\(w_1 \in \{0,1\}\), and the potential outcomes for the single unit
\(i=1\) are \(y_1(w_1)\) for \(w_1 \in \{0,1\}\); in this case, the
outcomes of unit \(i=1\) depend only the unit&amp;rsquo;s own treatment assignment \(w_1\),
so there are only two potential outcomes: \(y_1(1)\) and \(y_1(0)\).
When there are more than one units, the outcome of any unit may, a priori,
depend on the treatment assigned to any other unit: this is captured by the
notation \(y_i(\vec{w})\). In particular, each unit has not two but
\(|\{0,1\}^n| = 2^n\) potential outcomes.&lt;/p>
&lt;h3 id="the-no-interference-assumption">The no-interference assumption&lt;/h3>
&lt;p>Let&amp;rsquo;s go back, once again, to our aspirin example, but suppose that we
have not just a single individual, but \(n\) units participating in
the drug trial. Following the framework so far, we can write the potential
outcomes for unit \(i\) as \(y_i(\vec{w})\) for \({\vec{w} \in \{0,1\}^N}\).
As stated above, this allows for unit \(i\)&amp;rsquo;s outcome to depend on another
unit, say unit \(j\)&amp;rsquo;s treatment assignment. In the context of the drug
trial though, this seems a bit overkill. Barring very special circumstances
(e.g. the units enrolled in the trial know each other), it seems reasonable
to assume that the outcome of the trial for unit \(i\) depends only
on the treatment assigned to unit \(i\) itself &amp;mdash; that is, it should
depend on \(\vec{w}\) only through \(w_i\). This assumption is
known as the no-interference assumption, and can be formally stated as
follows:&lt;/p>
&lt;p>&lt;strong>Assumption (No Interference):&lt;/strong> For all \(i=1, \ldots, n\), it holds that:
\[
\forall \vec{w}, \vec{w}&amp;rsquo; \in \{0,1\}^n, \quad
w_i = w_i&amp;rsquo; \quad \Rightarrow \quad y_i(\vec{w}) = y_i(\vec{w}')
\]
With a slight abuse of notation, we can write \(y_i(\vec{w}) = y_i(w_i)\).&lt;/p>
&lt;p>In words, the assumption says that if you are a trial participant,
the status of your headache depends only on whether you took the aspirin &amp;mdash;
not on whether the other trial participants took the aspirin. This assumption is
reasonable in a broad range of settings, and simplifies matters considerably.
Indeed, under then no-interference assumption, each units \(i\) has only two
potential outcomes: its outcome under treatment, \(y_i(1)\) and its outcome under
control \(y_i(0)\).&lt;/p>
&lt;h3 id="the-science">The Science&lt;/h3>
&lt;p>If there is no interference, then all the information of a causal problem is
contained in the treatment and control potential outcomes vectors. Taken together,
they form what is sometimes called &lt;strong>the Science Table&lt;/strong> or just &lt;strong>the Science&lt;/strong>,
denoted \(\underline{y} = (\vec{y}(1), \vec{y}(0))\). An example of the Science for
6 units is given below.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>i&lt;/th>
&lt;th>\(y_i(0)\)&lt;/th>
&lt;th>\(y_i(1)\)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>2&lt;/td>
&lt;td>3&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>1&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>2&lt;/td>
&lt;td>4&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>0&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>3&lt;/td>
&lt;td>3&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>0&lt;/td>
&lt;td>2&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>This table gives, for each unit \(i\), it&amp;rsquo;s potential outcome under treatment,
\(y_i(1)\) and its potential outcome under control, \(y_i(0)\). For instance,
for unit \(i = 4\), we read \(y_4(0) = 0\) and \(y_4(1)=1\).&lt;/p>
&lt;p>An important fact about the Science is that we can never observe it fully. Indeed,
if a unit \(i\) is assigned to treatment (\(w_i=1\)), then we only observe
its potential outcome \(y_i(1)\). If, however, it is assigned to control
(\(w_i=0\)), then we only observe its control potential outcome, \(y_i(0)\).&lt;/p>
&lt;p>So, suppose for instance that \(\vec{W} = (1, 1, 0, 1, 0 ,0)\), then we would only
observe a partial version of the table, with missing elements:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>i&lt;/th>
&lt;th>W_i&lt;/th>
&lt;th>\(y_i(0)\)&lt;/th>
&lt;th>\(y_i(1)\)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>1&lt;/td>
&lt;td>?&lt;/td>
&lt;td>3&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>1&lt;/td>
&lt;td>?&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>0&lt;/td>
&lt;td>2&lt;/td>
&lt;td>?&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>1&lt;/td>
&lt;td>?&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>0&lt;/td>
&lt;td>3&lt;/td>
&lt;td>?&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>?&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>This is what makes causal inference a challenging problem — we will get back to this point below. Still, it is useful to consider the full Science table conceptually because it allows us to rigorously define causal effects.&lt;/p>
&lt;h3 id="causal-estimands">Causal Estimands&lt;/h3>
&lt;p>An estimand can be defined as a &amp;ldquo;quantity we would compute if we were omniscient.&amp;rdquo;
In the current context, being omniscient would mean knowing the entire Science Table
\(\underline{y}\), so we can think of an estimand as a function of the Science, say
\(\tau(\underline{y})\). The simplest quantity that satisfies this definition is the
so-called individual treatment effect (ITE) for unit \(i\), defined as:&lt;/p>
&lt;p>\[
\tau_i = y_i(1) - y_i(0), \quad i = 1, \ldots n.
\]&lt;/p>
&lt;p>As its name indicates, the ITE \(\tau_i\) is the causal effect
of the treatment on unit \(i\): it compares the response of unit \(i\) if it
were assigned to receive the treatment to the response of unit \(i\) if it
were assigned to receive the control. Since it depends on both the treatment &lt;strong>and&lt;/strong>
the control potential outcome of the same unit \(i\), the ITE can never be computed
in practice &amp;ndash; this is what makes it an estimand, a quantity that we could only compute
if we were omniscient.&lt;/p>
&lt;p>If we have more than a single unit, we are generally interested in some sort of
average effect of the treatment. The Average Treatment Effect (ATE) is defined
as:&lt;/p>
&lt;p>\[
\tau^{ATE} = \frac{1}{n} \sum_{i=1}^n \{ y_i(1) - y_i(0)\} = \frac{1}{n} \sum_{i=1}^n \tau_i
\]&lt;/p>
&lt;p>What makes these estimands causal is that they are based on contrasts between
potential outcomes.&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;h2 id="estimating-causal-effects">Estimating causal effects&lt;/h2>
&lt;p>In the previous section, we have introduced the key pieces of the Rubin Causal Model:&lt;/p>
&lt;ol>
&lt;li>an experimental population,&lt;/li>
&lt;li>an intervention,&lt;/li>
&lt;li>the potential outcomes, and&lt;/li>
&lt;li>the causal estimands &amp;mdash; that is, the quantity that we would like to
learn.&lt;/li>
&lt;/ol>
&lt;p>So far, we have remained in the realm of the &lt;em>potential&lt;/em> &amp;mdash; all the quantities introduced
exist prior to the experiment being actually conducted. We have defined our
objective &amp;mdash; our causal estimand &amp;mdash; but have said nothing about how one would actually
go about estimating that quantity. To do so, we need to move to the realm of the
&lt;em>observed&lt;/em>.&lt;/p>
&lt;h3 id="observed-outcomes">Observed Outcomes&lt;/h3>
&lt;p>An important fact about the Science, which we have alluded to repeatedly, is that
we can never observe it fully. Indeed, for each unit \(i\), we only observe the
unique potential outcome associated with the treatment to which the unit is assigned.
The observed outcome, denoted \(Y_i\), can therefore be written:&lt;/p>
&lt;p>\[
Y_i = y_i(W_i) = W_i \,y_i(1) + (1-W_i) \,y_i(0)
\]&lt;/p>
&lt;p>Since \(W_i\) is a random variable, the observed outcome \(Y_i\) will also be
a random quantity &amp;mdash; hence, we write it in uppercase. We will denote by
\(\vec{Y} = y(\vec{W}) = (Y_1, \ldots, Y_N)\) the vector of observed outcomes.
Once the experiment has been run, the analyst observed only two quantities: the observed
assignment \(\vec{W}\) and the observed outcomes \(\vec{Y}\). For the science table
we displayed in the previous section, and assignment vector \(\vec{W}\), the observed
outcome vector is \(\vec{Y} = (3, 1, 2, 1, 3, 0)\)&lt;/p>
&lt;h3 id="assignment-mechanism">Assignment Mechanism&lt;/h3>
&lt;p>When we introduced the assignment vector \(\vec{W}\), we said that it was a
random quantity, but we didn&amp;rsquo;t say much about its distribution \(Pr(\vec{W})\)
other than it was called the &lt;em>assignment mechanism&lt;/em> (or the &lt;em>design&lt;/em>).&lt;/p>
&lt;p>There are, of course, many possible assignment mechanisms for an experiment on
a population of \(n\) individuals &amp;mdash; as many, in fact, as there are distributions
with support \(\{0,1\}^n\). To keep things simple, we introduce just two of the
simplest and most popular such distributions.&lt;/p>
&lt;p>&lt;strong>Definition (Bernoulli Design):&lt;/strong> We say that \(\vec{W}\) is
assigned according to a Bernoulli design (or Bernoulli assignment mechanism) with
parameter \(\pi\) if each unit \(i\) is assigned to treatment independently
with probability \(\pi\). That is,&lt;/p>
&lt;p>\[
W_i \overset{i.i.d}{\sim} Bernoulli(\pi).
\]&lt;/p>
&lt;p>&lt;strong>Definition (Completely Randomized Design):&lt;/strong> We say that \(\vec{W}\) is
assigned according to a Completely Randomized Design with parameter \(n_1\)
if all assignments with exactly \(n_1\) treated units are equally likely.&lt;/p>
&lt;h3 id="estimators">Estimators&lt;/h3>
&lt;p>A causal estimand, such as the \(\tau^{ATE}\), depends on the entire science
table, meaning we can never compute it directly. In practice, we
estimate it using data that we observe: the observed assignment
\(\vec{W}\) and the observed outcomes \(\vec{Y}\).&lt;/p>
&lt;p>An estimator is a function \(\hat{\tau}\) of the observed data, say
\(\hat{\tau}(\vec{W}, \vec{Y}))\). It can be thought of as a &amp;ldquo;data-driven&amp;rdquo;
guess for the estimand of interest; indeed, since it depends only on observed data,
an estimator can always be computed. It is only a guess, though, because it uses
only the observed portion \(\vec{Y}\) of the science table \(\underline{y}\) to
estimate the estimand of interest. Specifically, since it depends on the random
assignment vector \(\vec{W}\), the estimator \(\hat{\tau}(\vec{W}, \vec{Y})\)
is itself a random variable.&lt;/p>
&lt;p>Choosing an appropriate estimator of a given estimand is an interesting topic but is beyond this post&amp;rsquo;s scope. If the causal estimand of interest
\(\tau^{ATE}(\underline{y})\) as defined above, then a natural estimator for it
is the difference in means:&lt;/p>
&lt;p>\[
\hat{\tau}^{DiM}(\vec{W},\vec{Y}) = \frac{1}{n_1(\vec{W})} \sum_{i=1}^n W_i Y_i - \frac{1}{n_0(\vec{W})} \sum_{i=1}^n (1-W_i) Y_i
\]&lt;/p>
&lt;p>where \(n_1(\vec{W}) = \sum_{i=1}^n W_i\) and \(n_0(\vec{W}) = n - n_1(\vec{W})\).
For the science table we displayed in the previous section and assignment
\(\vec{W} = (1, 1, 0, 1, 0, 0)\), we saw that the observed outcome vector
was \(\vec{Y} = (3, 1, 2, 1, 3, 0)\) and therefore the estimate is:&lt;/p>
&lt;p>\[
\hat{\tau}^{DiM} = \frac{1}{3} (3 + 1 + 1) - \frac{1}{3}(2 + 3 + 0) = 0
\]&lt;/p>
&lt;p>If the treatment was assigned according to a Completely Randomized Design as defined
above, then \(\hat{\tau}^{DiM}\) is, in the precise sense described below, a good
estimator.&lt;/p>
&lt;h2 id="randomization-based-inference-a-primer">Randomization-based inference: a primer&lt;/h2>
&lt;p>So far, we haven&amp;rsquo;t talked about models &amp;mdash; or about randomness, really. That&amp;rsquo;s
because the Rubin Causal Model is largely agnostic about these considerations.
The RCM helps us define clearly what is the causal quantity we are after, and
separate this from what we actually observe.&lt;/p>
&lt;p>Once this has been established, we can take a number of paths to estimate causal effects and assess the uncertainty of those estimates. Here we will give a primer on one such approach that is particularly natural and helpful in randomized experiments. Specifically, suppose that the treatment \(\vec{W}\) is assigned according to a completely randomized design. As mentioned above, apart from \(P(\vec{W})\), which we have just specified, we have not assumed any model. In particular, we have not assumed that the potential outcomes follow any distribution, nor that they are independent draws from some distribution, nor are they random. At the same time, we have also not precluded the potential outcomes from having been randomly drawn from some distributions. That is the wonderful nature of the potential outcomes framework: it requires no assumptions on the outcomes!&lt;/p>
&lt;p>Let&amp;rsquo;s see how far we can push this idea, and let&amp;rsquo;s consider \(\underline{y}\) to
be fixed (and, prior to the experiment, unknown). Notice that the observed outcomes
\(\vec{Y}\) are still random, since they depend on \(\vec{W}\) which is itself
random. We can then state the following result.&lt;/p>
&lt;p>&lt;strong>Proposition:&lt;/strong> If \(\vec{W}\) is assigned according to a completely
randomized design, then the difference in means estimator
\(\hat{\tau}^{DiM}\) is unbiased for the average
treatment effect \(\tau^{ATE}\).&lt;/p>
&lt;p>Much more can be said about the properties of \(\hat{\tau}^{DiM}\) in completely
randomized experiments &amp;mdash; future posts will explore these properties in greater
details.&lt;/p>
&lt;h2 id="references">References&lt;/h2>
&lt;p>There are many fantastic books on the topic of causal inference, but we have found the following to be useful:&lt;/p>
&lt;p>Imbens, G. W., &amp;amp; Rubin, D. B. (2015). &lt;em>Causal inference in statistics, social, and biomedical sciences.&lt;/em> Cambridge University Press.&lt;/p></description></item><item><title>About the authors</title><link>/about/</link><pubDate>Fri, 15 Jan 2021 00:00:00 +0000</pubDate><guid>/about/</guid><description>&lt;p>This (growing) collection of essays about causal inference and experimental
design is being written by Guillaume Basse and Iav Bojinov. It is our attempt at
explaining some ideas from our work &amp;mdash; and more broadly, from our field &amp;mdash; in
an accessible way.&lt;/p>
&lt;h2 id="guillaume-basse">Guillaume Basse&lt;/h2>
&lt;p>I am an Assistant Professor in the &lt;a href="https://msande.stanford.edu/">MS&amp;amp;E&lt;/a> and &lt;a href="https://statistics.stanford.edu/">Statistics departments at Stanford&lt;/a>.
My research focuses on Causal Inference and Design of Experiments in the presence
of interference. I got my PhD in Statistics at Harvard in 2018, under the supervision
of Edo Airoldi, then spent a year as a postdoctoral fellow in the Statistics
Department at UC Berkeley where I was advised by Peng Ding. Before coming to the US
I attended the Ecole Centrale Paris, where I studied Applied Mathematics and
Engineering. I have lived in France, Israel, the US and Senegal, where I was born.
My personal website is &lt;a href="https://web.stanford.edu/~gbasse/">here&lt;/a>.&lt;/p>
&lt;h2 id="iav-bojinov">Iav Bojinov&lt;/h2>
&lt;p>I am an assistant professor of business administration in the &lt;a href="https://www.hbs.edu/faculty/units/tom/Pages/default.aspx">Technology and Operations Management&lt;/a> unit at Harvard Business School and a faculty affiliate in the &lt;a href="https://statistics.fas.harvard.edu/">Department of Statistics at Harvard University&lt;/a>. My research interest is at the interface of causal inference, experimental design, and large-scale computing with the overall goal of democratizing statistical methods in order to help firms innovate and grow. Currently, I am actively pursuing three related research areas: design and analysis of experiments in complex settings, demystifying the value and limitation of experimentation, and understanding the role of data science in the modern AI organization. My personal website is &lt;a href="https://ibojinov.com/">here&lt;/a>.&lt;/p></description></item></channel></rss>