<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>conformal inference | Chen Xing</title>
    <link>https://chenxing.space/tag/conformal-inference/</link>
      <atom:link href="https://chenxing.space/tag/conformal-inference/index.xml" rel="self" type="application/rss+xml" />
    <description>conformal inference</description>
    <generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Mon, 14 Sep 2026 00:00:00 +0000</lastBuildDate>
    <image>
      <url>https://chenxing.space/media/icon_hu1047bfb8eb914f6094f6385efb9c7d12_5902_512x512_fill_lanczos_center_3.png</url>
      <title>conformal inference</title>
      <link>https://chenxing.space/tag/conformal-inference/</link>
    </image>
    
    <item>
      <title>Conformal Inference for Counterfactual and Synthetic Controls</title>
      <link>https://chenxing.space/blog/conformal-inference-for-counterfactual-and-synthetic-controls/</link>
      <pubDate>Mon, 14 Sep 2026 00:00:00 +0000</pubDate>
      <guid>https://chenxing.space/blog/conformal-inference-for-counterfactual-and-synthetic-controls/</guid>
      <description>&lt;p&gt;I’ve been reading Chernozhukov, Wüthrich, and Zhu (2021) on conformal inference for synthetic control. The basic idea is quite intuitive once viewed as a residual-based test.&lt;/p&gt;
&lt;h2 id=&#34;1-the-core-problem-measuring-the-counterfactual&#34;&gt;1. The Core Problem: Measuring the Counterfactual&lt;/h2&gt;
&lt;p&gt;What was the causal impact of a treatment on a single treated unit (e.g., a state, city, or firm)? To measure this impact, we compare what actually happened after the treatment ($Y^I_{1t}$) against what &lt;strong&gt;would have happened&lt;/strong&gt; if the treatment had never been implemented ($Y^N_{1t}$). This unobserved hypothetical scenario is called the &lt;strong&gt;counterfactual&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Researchers usually construct a &lt;strong&gt;proxy model&lt;/strong&gt; ($\hat{P}^N_t$) for this counterfactual using untreated control groups or past historical trends—such as &lt;strong&gt;Synthetic Control (SC)&lt;/strong&gt; or &lt;strong&gt;Difference-in-Differences (DID)&lt;/strong&gt;. However, calculating whether the observed treatment effect is statistically significant (i.e., not just random noise) is notoriously difficult when working with a single treated unit or a small number of pre-policy time periods ($T_0$).&lt;/p&gt;
&lt;h2 id=&#34;2-what-is-conformal-inference&#34;&gt;2. What is Conformal Inference?&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Conformal inference&lt;/strong&gt; is a statistical framework that reframes causal policy evaluation as a &lt;strong&gt;counterfactual prediction and structural breaks testing problem&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Instead of relying on rigid parametric statistical assumptions or assuming the counterfactual model is perfectly specified, conformal inference asks an intuitive question:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Does the prediction error pattern after the treatment look abnormally large compared to the typical prediction errors before the treatment?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If the treatment had &lt;strong&gt;no effect&lt;/strong&gt;, the prediction errors (residuals) in the post-treatment period should look like just another set of errors from the pre-treatment period. If the post-treatment errors are systematically larger or different, we can conclude that a &lt;strong&gt;structural break&lt;/strong&gt; occurred—meaning the treatment likely had a true causal effect.&lt;/p&gt;
&lt;h2 id=&#34;3-how-conformal-inference-works-step-by-step&#34;&gt;3. How Conformal Inference Works: Step-by-Step&lt;/h2&gt;
&lt;p&gt;Here is how the procedure operates in practice:&lt;/p&gt;
&lt;p&gt;Step 1. &lt;strong&gt;Formulate a Sharp Null Hypothesis ($H_0$)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We postulate a specific trajectory for the treatment effect $\theta_0$ across the post-treatment period (for instance, the &amp;ldquo;zero-effect&amp;rdquo; null hypothesis: $H_0: \theta_t = 0$, for $t &amp;gt; T_0$).&lt;/p&gt;
&lt;p&gt;Step 2. &lt;strong&gt;Impute the Counterfactual and Estimate Under the Null&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;By subtracting our hypothesized effect $\theta_0$ from the observed outcomes during the post-treatment period ($Y^N_{1t} = Y_{1t}^I - \theta_t^0$), we create an &amp;ldquo;as-if untreated&amp;rdquo; outcome series across all periods.&lt;/p&gt;
&lt;p&gt;For example, under the &amp;ldquo;zero-effect&amp;rdquo; $H_0$, we have  $$Y^N_{1t} = Y_{1t}^I - \theta_t^0 = Y_{1t} - 0 = Y_{1t}$$  In other words, if there was no treatment effect, the observed treated outcome is also the counterfactual untreated outcome.&lt;/p&gt;
&lt;p&gt;We then estimate our counterfactual model across the &lt;strong&gt;entire dataset&lt;/strong&gt; ($T_0$ pre-treatment + $T^*$ post-treatment periods) under this null assumption.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Why this matters:&lt;/em&gt; Estimating the model under the null guarantees &lt;strong&gt;exact finite-sample validity&lt;/strong&gt; and prevents severe size distortions, especially when sample sizes ($T_0$) are small.&lt;/p&gt;
&lt;p&gt;Step 3. &lt;strong&gt;Compute Prediction Residuals&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We compute the prediction errors (residuals) across all periods:  $$\hat{u}_t = Y^N_{1t} - \hat{P}^N_t,$$  where $Y^N_{1t}$ is the imputed counterfactual outcome and $\hat{P}^N_t$ is the model&amp;rsquo;s estimated proxy.&lt;/p&gt;
&lt;p&gt;Step 4. &lt;strong&gt;Permute Residuals Across Time&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Under the null hypothesis, the post-treatment error should follow the same underlying error distribution as the pre-treatment errors. We construct a reference distribution by &lt;strong&gt;permuting&lt;/strong&gt; blocks of residuals across time—either using all possible permutations (if data points are independent/exchangeable) or &lt;strong&gt;moving block permutations&lt;/strong&gt; (if data exhibits serial dependence). In practice, we often use &lt;strong&gt;moving block permutations&lt;/strong&gt; in the panel data setting.&lt;/p&gt;
&lt;p&gt;Step 5. &lt;strong&gt;Calculate a Test Statistic and $p$-Value&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We calculate a test statistic $S(\hat{u})$ that measures the magnitude of post-treatment residuals.&lt;/p&gt;
&lt;p&gt; $$
S(\hat{u})=S_q(\hat{u})=\left(\frac{1}{\sqrt{T_*}} \sum_{t=T_0+1}^T\left|\hat{u}_t\right|^q\right)^{1 / q} .
$$  We often set $q = 1$.&lt;/p&gt;
&lt;p&gt;The $p$-value is simply the proportion of permuted residual sets that generate a test statistic as large or larger than the observed test statistic.&lt;/p&gt;
&lt;p&gt;Formally, the $p$-value is $\hat{p}=1-\hat{F}(S(\hat{u}))$, where&lt;/p&gt;
&lt;p&gt;
$$\hat{F}(x)=\frac{1}{|\Pi|} \sum_{\pi \in \Pi} 1\left\{S\left(\hat{u}_\pi\right) \lt x\right\}.$$
 $\Pi$ denotes the set of permutations.&lt;/p&gt;
&lt;p&gt;Here is a simple illustration for the step 4 and 5.&lt;/p&gt;
&lt;div class=&#34;eg&#34;&gt;
  &lt;figure class=&#34;blog-figure&#34;&gt;
   &lt;img src=&#34;https://cdn.jsdelivr.net/gh/chenx2018/cloudimg@main/uPic/image-20260914073245596.png&#34; alt=&#34;image-20260914073245596&#34; style=&#34;zoom:50%;&#34; /&gt; 
  &lt;figcaption&gt;
&lt;pre&gt;&lt;code&gt;  Figure 1: How to get the permutation distribution
&lt;/code&gt;&lt;/pre&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;h3 id=&#34;conceptual-picture&#34;&gt;Conceptual picture&lt;/h3&gt;
&lt;div class=&#34;eg&#34;&gt;
  &lt;figure class=&#34;blog-figure&#34;&gt;
  &lt;img src=&#34;https://cdn.jsdelivr.net/gh/chenx2018/cloudimg@main/uPic/image-20260914073921810.png&#34; alt=&#34;image-20260914073921810&#34; style=&#34;zoom:50%;&#34; /&gt;  
  &lt;figcaption&gt;
&lt;pre&gt;&lt;code&gt;  Figure 2: The conceptual picture to keep in mind
&lt;/code&gt;&lt;/pre&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;hr&gt;
&lt;h2 id=&#34;4-why-is-this-method-a-major-advancement&#34;&gt;4. Why Is This Method a Major Advancement?&lt;/h2&gt;
&lt;p&gt;Conformal inference offers several key theoretical and practical benefits:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Exact Finite-Sample Validity:&lt;/strong&gt; It delivers reliable $p$-values even when the pre-treatment sample size ($T_0$) is small, avoiding the large-sample approximations that frequently break down in empirical case studies.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Robustness Against Model Misspecification:&lt;/strong&gt; Even if your underlying proxy model is misspecified or inconsistent, conformal inference remains valid as long as the estimator satisfies a basic &lt;strong&gt;stability condition&lt;/strong&gt; (meaning small changes in individual data points do not cause drastic changes in predictions).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Universal Compatibility:&lt;/strong&gt; It works with almost any counterfactual estimator, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Difference-in-Differences&lt;/strong&gt; and &lt;strong&gt;Synthetic Control&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Constrained Lasso&lt;/strong&gt; (a tuning-free method that unifies DID and SC)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Interactive Fixed Effects &amp;amp; Factor Models&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Matrix Completion&lt;/strong&gt; via nuclear norm regularization&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pure Time Series Models&lt;/strong&gt; (such as AR or neural network models) and &lt;strong&gt;Fused Panel/Time Series Models&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&#34;5-a-real-world-example-rhode-island-prostitution-decriminalization&#34;&gt;5. A Real-World Example: Rhode Island Prostitution Decriminalization&lt;/h2&gt;
&lt;p&gt;To demonstrate the methodology, the paper re-analyzed an unexpected legal event in Rhode Island, where indoor prostitution was unexpectedly decriminalized between 2003 and 2009.&lt;/p&gt;
&lt;p&gt;Using $T_0 = 19$ pre-treatment years (1985–2003) and $J = 50$ donor states as controls, the authors applied conformal inference across Difference-in-Differences, Synthetic Control, and Constrained Lasso. The test rejected the zero-effect null hypothesis ($p &amp;lt; 0.10$ across all estimators), providing rigorous evidence that indoor sex work decriminalization led to a statistically significant reduction in female gonorrhea incidence.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;reference&#34;&gt;Reference&lt;/h2&gt;
&lt;p&gt;Chernozhukov, V., Wüthrich, K., &amp;amp; Zhu, Y. (2021). An Exact and Robust Conformal Inference Method for Counterfactual and Synthetic Controls. Journal of the American Statistical Association, 116(536), 1849–1864. &lt;a href=&#34;https://doi.org/10.1080/01621459.2021.1920957&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;https://doi.org/10.1080/01621459.2021.1920957&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;YouTube short intro: &lt;a href=&#34;https://www.youtube.com/watch?v=mrok29unYpk&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Conformal Prediction without Big Words&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
