<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Nicolas Franz-Pattillo</title>
<link>https://www.nicolasfranzpattillo.com/marginalia.html</link>
<atom:link href="https://www.nicolasfranzpattillo.com/marginalia.xml" rel="self" type="application/rss+xml"/>
<description>Economist at the Central Bank of Chile. Ph.D., Vancouver School of Economics, UBC.</description>
<generator>quarto-1.8.26</generator>
<lastBuildDate>Sat, 26 Sep 2026 00:00:00 GMT</lastBuildDate>
<item>
  <title>The Power of an Apology</title>
  <dc:creator>Nicolas Franz-Pattillo</dc:creator>
  <link>https://www.nicolasfranzpattillo.com/posts/published/power-of-an-apology/</link>
  <description><![CDATA[ 






<div class="page-hero column-screen"><img src="https://www.nicolasfranzpattillo.com/posts/published/power-of-an-apology/src/cover.webp" alt="Black-and-white photo of two small children seen from behind, sitting side by side at the water’s edge, one with an arm around the other. Photo: Joshua Clay, Unsplash via Wikimedia Commons — CC0 (public domain)."><div class="page-hero__credit">Photo: Joshua Clay, Unsplash via Wikimedia Commons — CC0 (public domain).</div></div>
<p>Most of us learned to apologize as children, and most of us learned it badly. An adult pointed at the person we had hurt, and we said “sorry” as fast as possible so the moment would end. The word was a toll we paid to get out of trouble.</p>
<p>A real apology is something else. It is one of the few tools we have for repairing harm after it has already happened. It is also hard to do well, and the difficulty is exactly what makes it work.</p>
<section id="an-apology-starts-with-agreeing-that-something-was-wrong" class="level2">
<h2 class="anchored" data-anchor-id="an-apology-starts-with-agreeing-that-something-was-wrong">An apology starts with agreeing that something was wrong</h2>
<p>An apology begins with a shared recognition that a wrong act occurred. Without it, every later step rests on two conflicting stories about what happened. The person apologizing thinks they are making amends, and the person receiving it hears a negotiation. So the first job is simply to agree, clearly and without qualification, that what happened was not okay.</p>
</section>
<section id="the-work-is-in-the-details" class="level2">
<h2 class="anchored" data-anchor-id="the-work-is-in-the-details">The work is in the details</h2>
<p><strong>Say exactly what you did.</strong> A vague “I’m sorry for everything” costs nothing, and the other person knows it. Naming the specific act shows that you know what you did and aren’t hoping it gets forgotten.</p>
<p><strong>Explain why, without passing the blame.</strong> This is the hardest part. The instinct is to explain our behavior by pointing at the other person: <em>“I reacted that way because you yelled at me.”</em> That sentence looks like an apology but works as an accusation. It moves responsibility outward. Compare <em>“I reacted that way because I couldn’t control my anger.”</em> The event is the same, but now the cause is yours, which it was all along.</p>
<p>The “why” matters to the person you hurt. It shows you’ve looked past what happened to what drove it. It is often slow and uncomfortable to find, because the honest answer is rarely flattering: fear, insecurity, pride, a habit we picked up long ago.</p>
<p><strong>Sit with the suffering you caused.</strong> After you’ve explained yourself, stay present while the other person tells you what it was like for them, without defending, minimizing, or rushing to the resolution. It hurts. It is also the only way to actually understand the harm, and you can’t take responsibility for something you haven’t understood.</p>
<p><strong>Take responsibility and make amends.</strong> If you’ve done the previous steps honestly, this one mostly follows. Taking responsibility means committing to do better and then showing it with concrete actions over time.</p>
</section>
<section id="why-go-through-all-this" class="level2">
<h2 class="anchored" data-anchor-id="why-go-through-all-this">Why go through all this?</h2>
<p>A sincere apology is a gift to the person harmed. It is also, less obviously, a way out for the person who caused the harm.</p>
<p>People who hurt others often carry a burden of their own: they refuse to be vulnerable, they fear looking weak, and they live with guilt they never deal with. That armor is heavy. Punishment hardens us, but it doesn’t teach us, and humiliation doesn’t bring insight. Being punished or shamed rarely changes anyone. Understanding what you did can.</p>
<p><span class="inline-tip" data-tip="traditions-tip">Many religious traditions</span> have a ritual built on this idea: naming your wrong out loud is what releases its weight.</p>
<div id="traditions-tip" class="inline-tip-content">
<div class="inline-tip-body">
<ul>
<li><strong>Catholicism:</strong> the sacrament of reconciliation, once called confession. You name your sins to a priest, feel real sorrow for them, and take on a penance, a concrete act of repair.</li>
<li><strong>Judaism:</strong> <em>teshuvah</em> means recognizing the wrong, regretting it, confessing it aloud, and resolving not to repeat it. Yom Kippur atones only for wrongs against God. For a wrong against another person, you must first ask that person’s forgiveness.</li>
<li><strong>Islam:</strong> <em>tawbah</em> is made directly to God. It asks you to stop the wrong, regret it, and resolve not to return to it. If someone was harmed, you must also make it right with them.</li>
<li><strong>Buddhism:</strong> monks confess their offenses to a fellow monk before the twice-monthly recitation of the monastic rules.</li>
<li><strong>Other Christian churches:</strong> the Orthodox Church keeps private confession, and Anglicans and Lutherans say a general confession during the service. The Letter of James asks believers to “confess your sins to one another… that you may be healed.”</li>
<li><strong>Hinduism:</strong> <em>prāyaścitta</em> are rites of penance meant to cleanse the consequences of a wrong act.</li>
</ul>
</div>
</div>
<p>An apology makes both people human again. It shows the person you hurt that you can see them, and that you are more than the worst thing you did to them.</p>
</section>
<section id="learning-to-apologize" class="level2">
<h2 class="anchored" data-anchor-id="learning-to-apologize">Learning to apologize</h2>
<p>If apologizing is this hard for adults, it is worth being patient with children who are learning it. When a child struggles to apologize, the difficulty is rarely a lack of empathy or goodwill. The steps above demand skills that are still growing in them: regulating emotions, identifying their own feelings and other people’s, thinking flexibly, and tolerating vulnerability. It can be very hard to:</p>
<ul>
<li>find words for what they felt in the moment,</li>
<li>tell an explanation apart from an excuse,</li>
<li>tolerate intense feelings of shame or guilt,</li>
<li>work out how the other person felt,</li>
<li>or stay in an emotionally demanding conversation without being overwhelmed.</li>
</ul>
<p>That’s why learning to apologize usually needs support, time, modeling, and emotional containment more than punishment or on-the-spot demands. The patience we ask of them when they apologize is the patience we owe them while they learn.</p>
</section>
<section id="conclusion" class="level2">
<h2 class="anchored" data-anchor-id="conclusion">Conclusion</h2>
<p>Apologizing is hard because it requires exposure, self-examination, and humility. That’s also why it works. By taking responsibility, acknowledging the harm, and letting ourselves feel what the other person felt, we make it possible to rebuild trust. We also take a step, not only toward repairing a relationship, but toward becoming better people.</p>


</section>

 ]]></description>
  <category>Essays</category>
  <category>Life Lessons (Allegedly)</category>
  <guid>https://www.nicolasfranzpattillo.com/posts/published/power-of-an-apology/</guid>
  <pubDate>Sat, 26 Sep 2026 00:00:00 GMT</pubDate>
  <media:content url="https://www.nicolasfranzpattillo.com/posts/published/power-of-an-apology/src/cover.webp" medium="image" type="image/webp"/>
</item>
<item>
  <title>What is loose commitment?</title>
  <dc:creator>Nicolas Franz-Pattillo</dc:creator>
  <link>https://www.nicolasfranzpattillo.com/posts/published/loose-commitment-math/</link>
  <description><![CDATA[ 






<div class="page-hero column-screen"><img src="https://www.nicolasfranzpattillo.com/posts/published/loose-commitment-math/src/cover.webp" alt="Ulysses tied to the mast of his ship as the Sirens swoop around it, so he cannot act on their song. John William Waterhouse, Ulysses and the Sirens, 1891. National Gallery of Victoria, Melbourne — public domain." style="object-position: 50% 42%"><div class="page-hero__credit">John William Waterhouse, Ulysses and the Sirens, 1891. National Gallery of Victoria, Melbourne — public domain.</div></div>
<p>Textbook monetary policy comes in two flavors. Either the central bank follows a rule, such as a Taylor rule, or it chooses policy optimally, in which case one has to say whether it can <strong>commit</strong> to its promises or acts under <strong>discretion</strong> (<span class="citation" data-cites="KydlandPrescott1977">Kydland and Prescott (1977)</span>). Outside of the textbook, we may find something in between.</p>
<p>This note explains the machinery behind a model of that middle ground, <strong>loose commitment</strong>, as used in my paper <em>Optimal Monetary Policy under Loose Commitment and the Zero Lower Bound</em>. Here the goal is to show how the math works: the model, the three policy problems, and why solving them requires a global (non-linear) method.</p>
<section id="the-economy" class="level2">
<h2 class="anchored" data-anchor-id="the-economy">The economy</h2>
<p>The model is a small New Keynesian economy with three ingredients: sticky prices <span class="citation" data-cites="Rotemberg1982">Rotemberg (1982)</span>, monopolistic competition and a lower bound on the nominal interest rate. It is deliberately small; the point is to isolate how commitment interacts with those three frictions, not to fit the data.</p>
<section id="households" class="level3">
<h3 class="anchored" data-anchor-id="households">Households</h3>
<p>A representative household chooses consumption <img src="https://latex.codecogs.com/png.latex?c_t">, hours <img src="https://latex.codecogs.com/png.latex?n_t"> and nominal bonds to maximize</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathbb%7BE%7D_0%20%5Csum_%7Bt=0%7D%5E%7B%5Cinfty%7D%20%5Cbeta%5Et%20%5CDelta_t%20%5Cleft%5B%20%5Cfrac%7Bc_t%5E%7B1-%5Csigma%7D-1%7D%7B1-%5Csigma%7D%20-%20%5Cchi%20%5Cfrac%7Bn_t%5E%7B1+%5Ceta%7D%7D%7B1+%5Ceta%7D%20%5Cright%5D,%0A%5Cqquad%20%5CDelta_%7Bt+1%7D%20=%20%5Cdelta_t%20%5CDelta_t%20,%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?%5Cdelta_t"> is a preference shock: when <img src="https://latex.codecogs.com/png.latex?%5Cdelta_t"> is high the household becomes more patient and wants to save. It follows <img src="https://latex.codecogs.com/png.latex?%5Clog%20%5Cdelta_t%20=%20%5Crho_%5Cdelta%20%5Clog%20%5Cdelta_%7Bt-1%7D%20+%20%5Csigma_%5Cdelta%20%5Cepsilon_t">. This is the shock that pushes the economy to the zero lower bound, because a sudden desire to save lowers the interest rate the economy needs.</p>
<p>The household’s choices give two familiar conditions, the Euler equation and the labor supply condition:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cfrac%7Bc_t%5E%7B-%5Csigma%7D%7D%7BR_t%7D%20=%20%5Cdelta_t%20%5Cbeta%20%5C,%20%5Cmathbb%7BE%7D_t%5C!%5Cleft%5B%20%5Cfrac%7Bc_%7Bt+1%7D%5E%7B-%5Csigma%7D%7D%7B%5Cpi_%7Bt+1%7D%7D%20%5Cright%5D,%0A%5Cqquad%0A%5Cchi%20n_t%5E%7B%5Ceta%7D%20=%20c_t%5E%7B-%5Csigma%7D%20w_t%20(1+%5Ctau),%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?R_t"> is the gross nominal interest rate, <img src="https://latex.codecogs.com/png.latex?%5Cpi_t%20=%20p_t/p_%7Bt-1%7D"> gross inflation, <img src="https://latex.codecogs.com/png.latex?w_t"> the real wage and <img src="https://latex.codecogs.com/png.latex?%5Ctau"> a labor subsidy.</p>
</section>
<section id="firms-and-the-non-linear-phillips-curve" class="level3">
<h3 class="anchored" data-anchor-id="firms-and-the-non-linear-phillips-curve">Firms and the non-linear Phillips curve</h3>
<p>A competitive final-goods firm combines a continuum of intermediate goods with a constant elasticity of substitution <img src="https://latex.codecogs.com/png.latex?1/%5Cnu">. Intermediate firm <img src="https://latex.codecogs.com/png.latex?j"> therefore faces the demand <img src="https://latex.codecogs.com/png.latex?y_t(j)%20=%20%5Cleft%5Bp_t(j)/p_t%5Cright%5D%5E%7B-1/%5Cnu%7D%20y_t">, produces with <img src="https://latex.codecogs.com/png.latex?y_t(j)%20=%20z_t%20n_t(j)"> and, following Rotemberg, pays a quadratic cost to change its price.<sup>1</sup></p>
<p><img src="https://latex.codecogs.com/png.latex?%0AAC_t(j)%20=%20%5Cfrac%7B%5Cphi%7D%7B2%7D%20%5Cleft%5B%20%5Cfrac%7Bp_t(j)%7D%7Bp_%7Bt-1%7D(j)%7D%20-%20%5Cpi_f%20%5Cright%5D%5E2%20y_t%20.%0A"></p>
<p>Two parameters matter here. <img src="https://latex.codecogs.com/png.latex?%5Cphi"> governs how sticky prices are. <img src="https://latex.codecogs.com/png.latex?%5Cpi_f"> is the inflation rate that is free of cost; the literature usually sets <img src="https://latex.codecogs.com/png.latex?%5Cpi_f%20=%201"> (zero net inflation), and so does the benchmark calibration.</p>
<p>Each firm chooses its price path to maximize the discounted value of profits, using the household’s stochastic discount factor (<span class="citation" data-cites="Yun2005">Yun (2005)</span>). In a symmetric equilibrium this yields the <strong>non-linear Phillips curve</strong>:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A&amp;%201%20-%20%5Cnu%20-%20%5Cfrac%7Bw_t%7D%7Bz_t%7D%20+%20%5Cphi%20%5Cnu%20%5C,%20%5Cpi_t%20(%5Cpi_t%20-%20%5Cpi_f)%20%5C%5C%0A&amp;%20%5Cqquad%20=%20%5Cphi%20%5Cnu%20%5C,%20%5Cdelta_t%20%5Cbeta%20%5C,%20%5Cmathbb%7BE%7D_t%5C!%5Cleft%5B%20%5Cleft(%5Cfrac%7Bc_%7Bt+1%7D%7D%7Bc_t%7D%5Cright)%5E%7B-%5Csigma%7D%20%5Cfrac%7By_%7Bt+1%7D%7D%7By_t%7D%20%5C,%20(%5Cpi_%7Bt+1%7D%20-%20%5Cpi_f)%20%5C,%20%5Cpi_%7Bt+1%7D%20%5Cright%5D.%0A%5Cend%7Baligned%7D%0A"></p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-1-contents" aria-controls="callout-1" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Derivation: from the firm’s problem to the Phillips curve
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-1" class="callout-1-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>Firm <img src="https://latex.codecogs.com/png.latex?j"> solves</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A%5Cmax_%7B%5C%7Bp_%7Bt+s%7D(j)%5C%7D%7D%20%5C;%20%5Cmathbb%7BE%7D_t%20%5Csum_%7Bs%20%5Cge%200%7D%20Q_%7Bt+s%7Ct%7D%20%5CBig%5B%20%5C,%20&amp;%20p_%7Bt+s%7D(j)%20%5C,%20y_%7Bt+s%7D(j)%20-%20p_%7Bt+s%7D%20%5Cfrac%7Bw_%7Bt+s%7D%7D%7Bz_%7Bt+s%7D%7D%20y_%7Bt+s%7D(j)%20%5C%5C%0A&amp;%20-%20p_%7Bt+s%7D%20AC_%7Bt+s%7D(j)%20%5CBig%5D,%0A%5Cend%7Baligned%7D%0A"></p>
<p>with <img src="https://latex.codecogs.com/png.latex?y_t(j)%20=%20%5Cleft%5Bp_t(j)/p_t%5Cright%5D%5E%7B-1/%5Cnu%7D%20y_t"> and the nominal discount factor <img src="https://latex.codecogs.com/png.latex?Q_%7Bt+1%7Ct%7D%20=%20%5Cdelta_t%20%5Cbeta%20(c_%7Bt+1%7D/c_t)%5E%7B-%5Csigma%7D%20/%20%5Cpi_%7Bt+1%7D">.</p>
<p>The price <img src="https://latex.codecogs.com/png.latex?p_t(j)"> appears in period <img src="https://latex.codecogs.com/png.latex?t"> (revenue, labor cost and today’s adjustment cost) and in period <img src="https://latex.codecogs.com/png.latex?t+1"> (tomorrow’s adjustment cost, through <img src="https://latex.codecogs.com/png.latex?p_%7Bt+1%7D(j)/p_t(j)">). Differentiating and imposing symmetry, <img src="https://latex.codecogs.com/png.latex?p_t(j)%20=%20p_t">:</p>
<ul>
<li>revenue: <img src="https://latex.codecogs.com/png.latex?%5Cleft(1%20-%20%5Cfrac%7B1%7D%7B%5Cnu%7D%5Cright)%20y_t">;</li>
<li>labor cost: <img src="https://latex.codecogs.com/png.latex?+%5Cfrac%7B1%7D%7B%5Cnu%7D%20%5Cfrac%7Bw_t%7D%7Bz_t%7D%20y_t">;</li>
<li>today’s adjustment cost: <img src="https://latex.codecogs.com/png.latex?-%5Cphi%20(%5Cpi_t%20-%20%5Cpi_f)%20%5Cpi_t%20y_t">;</li>
<li>tomorrow’s adjustment cost: <img src="https://latex.codecogs.com/png.latex?+%5Cmathbb%7BE%7D_t%5C!%5Cleft%5B%20Q_%7Bt+1%7Ct%7D%20%5Cfrac%7Bp_%7Bt+1%7D%7D%7Bp_t%7D%20%5Cphi%20(%5Cpi_%7Bt+1%7D%20-%20%5Cpi_f)%20%5Cpi_%7Bt+1%7D%20y_%7Bt+1%7D%20%5Cright%5D">.</li>
</ul>
<p>Setting the sum to zero, using <img src="https://latex.codecogs.com/png.latex?Q_%7Bt+1%7Ct%7D%20%5C,%20p_%7Bt+1%7D/p_t%20=%20%5Cdelta_t%20%5Cbeta%20(c_%7Bt+1%7D/c_t)%5E%7B-%5Csigma%7D"> and multiplying by <img src="https://latex.codecogs.com/png.latex?-%5Cnu/y_t"> gives the equation above. With flexible prices (<img src="https://latex.codecogs.com/png.latex?%5Cphi%20=%200">) it reduces to <img src="https://latex.codecogs.com/png.latex?w_t/z_t%20=%201%20-%20%5Cnu">: firms charge a constant markup <img src="https://latex.codecogs.com/png.latex?1/(1-%5Cnu)"> over marginal cost.</p>
</div>
</div>
</div>
</section>
<section id="the-private-sector-equilibrium" class="level3">
<h3 class="anchored" data-anchor-id="the-private-sector-equilibrium">The private-sector equilibrium</h3>
<p>Using market clearing and the resource constraint, which subtracts the resources used up in changing prices, the economy is summarized by</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A&amp;%5Ctext%7BEuler:%7D%20&amp;&amp;%0A%20%20%5Cfrac%7Bc_t%5E%7B-%5Csigma%7D%7D%7BR_t%7D%20=%20%5Cdelta_t%20%5Cbeta%20%5C,%20%5Cmathbb%7BE%7D_t%5C!%5Cleft%5B%20%5Cfrac%7Bc_%7Bt+1%7D%5E%7B-%5Csigma%7D%7D%7B%5Cpi_%7Bt+1%7D%7D%20%5Cright%5D%20%5C%5C%0A&amp;%5Ctext%7BPhillips:%7D%20&amp;&amp;%0A%20%20c_t%5E%7B-%5Csigma%7D%20y_t%20%5Cleft%5B%201%20-%20%5Cnu%20-%20%5Cfrac%7Bw_t%7D%7Bz_t%7D%20+%20%5Cphi%20%5Cnu%20%5Cpi_t(%5Cpi_t%20-%20%5Cpi_f)%20%5Cright%5D%20%5C%5C%0A&amp;%20&amp;&amp;%20%5Cqquad%20=%20%5Cphi%20%5Cnu%20%5C,%20%5Cdelta_t%20%5Cbeta%20%5C,%20%5Cmathbb%7BE%7D_t%5C!%5Cleft%5B%20c_%7Bt+1%7D%5E%7B-%5Csigma%7D%20y_%7Bt+1%7D%20(%5Cpi_%7Bt+1%7D%20-%20%5Cpi_f)%20%5Cpi_%7Bt+1%7D%20%5Cright%5D%20%5C%5C%0A&amp;%5Ctext%7BLabor:%7D%20&amp;&amp;%0A%20%20%5Cchi%20n_t%5E%7B%5Ceta%7D%20=%20c_t%5E%7B-%5Csigma%7D%20w_t%20(1+%5Ctau)%20%5C%5C%0A&amp;%5Ctext%7BResources:%7D%20&amp;&amp;%0A%20%20c_t%20=%20y_t%20%5Cleft%5B%201%20-%20%5Ctfrac%7B%5Cphi%7D%7B2%7D%20(%5Cpi_t%20-%20%5Cpi_f)%5E2%20%5Cright%5D,%20%5Cquad%20y_t%20=%20z_t%20n_t%20%5C%5C%0A&amp;%5Ctext%7BZLB:%7D%20&amp;&amp;%0A%20%20R_t%20%5Cge%201%0A%5Cend%7Baligned%7D%0A"></p>
<p>Only the Euler equation and the Phillips curve involve expectations. That will turn out to be the whole story: the only reason policy is hard is that today’s outcomes depend on what people expect policy to do tomorrow.</p>
</section>
</section>
<section id="the-benchmark-flexible-prices-and-an-efficient-subsidy" class="level2">
<h2 class="anchored" data-anchor-id="the-benchmark-flexible-prices-and-an-efficient-subsidy">The benchmark: flexible prices and an efficient subsidy</h2>
<p>Before asking what a central bank can achieve, it helps to know what the best possible outcome is, and which frictions stand in the way.</p>
<section id="the-efficient-allocation" class="level3">
<h3 class="anchored" data-anchor-id="the-efficient-allocation">The efficient allocation</h3>
<p>A planner who could simply assign consumption and hours, with no prices involved, would maximize <img src="https://latex.codecogs.com/png.latex?u(c_t,%20n_t)"> subject to <img src="https://latex.codecogs.com/png.latex?c_t%20=%20z_t%20n_t">. At the optimum, the marginal disutility of an hour of work equals the consumption it produces:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cchi%20n_t%5E%7B%5Ceta%7D%20=%20c_t%5E%7B-%5Csigma%7D%20z_t%20.%0A"></p>
<p>Combined with <img src="https://latex.codecogs.com/png.latex?c_t%20=%20z_t%20n_t">, this gives the efficient allocation:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0An%5E%7B*%7D_t%20=%20%5Cleft%5B%20%5Cfrac%7Bz_t%5E%7B1-%5Csigma%7D%7D%7B%5Cchi%7D%20%5Cright%5D%5E%7B%5Cfrac%7B1%7D%7B%5Ceta+%5Csigma%7D%7D,%0A%5Cqquad%0Ac%5E%7B*%7D_t%20=%20%5Cleft%5B%20%5Cfrac%7Bz_t%5E%7B1+%5Ceta%7D%7D%7B%5Cchi%7D%20%5Cright%5D%5E%7B%5Cfrac%7B1%7D%7B%5Ceta+%5Csigma%7D%7D%20.%0A"></p>
<p>The market economy reaches this point only if prices are flexible (<img src="https://latex.codecogs.com/png.latex?%5Cphi%20=%200">) and markets are competitive (<img src="https://latex.codecogs.com/png.latex?%5Cnu%20=%200">). Monetary policy is then irrelevant.</p>
</section>
<section id="flexible-prices-with-market-power" class="level3">
<h3 class="anchored" data-anchor-id="flexible-prices-with-market-power">Flexible prices with market power</h3>
<p>Now keep prices flexible but let firms have market power (<img src="https://latex.codecogs.com/png.latex?%5Cnu%20%3E%200">). With <img src="https://latex.codecogs.com/png.latex?%5Cphi%20=%200"> the Phillips curve says that firms set a constant markup, so the real wage is below the marginal product of labor:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cfrac%7Bw_t%7D%7Bz_t%7D%20=%201%20-%20%5Cnu%20.%0A"></p>
<p>Substituting into the household’s labor supply condition, <img src="https://latex.codecogs.com/png.latex?%5Cchi%20n_t%5E%7B%5Ceta%7D%20=%20c_t%5E%7B-%5Csigma%7D%20w_t%20(1+%5Ctau)">, gives</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cchi%20n_t%5E%7B%5Ceta%7D%20=%20(1-%5Cnu)(1+%5Ctau)%20%5C,%20c_t%5E%7B-%5Csigma%7D%20z_t%20,%0A"></p>
<p>which differs from the efficient condition by the factor <img src="https://latex.codecogs.com/png.latex?(1-%5Cnu)(1+%5Ctau)">. The flexible-price allocation is therefore</p>
<p><img src="https://latex.codecogs.com/png.latex?%0An%5E%7B%5Ctext%7Bflex%7D%7D_t%20=%20%5Cleft%5B%20%5Cfrac%7B(1-%5Cnu)(1+%5Ctau)%5C,%20z_t%5E%7B1-%5Csigma%7D%7D%7B%5Cchi%7D%20%5Cright%5D%5E%7B%5Cfrac%7B1%7D%7B%5Ceta+%5Csigma%7D%7D,%0A%5Cqquad%0Ac%5E%7B%5Ctext%7Bflex%7D%7D_t%20=%20%5Cleft%5B%20%5Cfrac%7B(1-%5Cnu)(1+%5Ctau)%5C,%20z_t%5E%7B1+%5Ceta%7D%7D%7B%5Cchi%7D%20%5Cright%5D%5E%7B%5Cfrac%7B1%7D%7B%5Ceta+%5Csigma%7D%7D%20.%0A"></p>
<p>Without a subsidy (<img src="https://latex.codecogs.com/png.latex?%5Ctau%20=%200">), the markup acts like a tax on work: people work too little and the economy produces too little. With the benchmark calibration (<img src="https://latex.codecogs.com/png.latex?%5Cnu%20%5Capprox%200.087">, <img src="https://latex.codecogs.com/png.latex?%5Csigma%20=%201">, <img src="https://latex.codecogs.com/png.latex?%5Ceta%20=%200.5">), output is about 6% below its efficient level even with perfectly flexible prices.</p>
</section>
<section id="the-subsidy-that-undoes-the-markup" class="level3">
<h3 class="anchored" data-anchor-id="the-subsidy-that-undoes-the-markup">The subsidy that undoes the markup</h3>
<p>A labor subsidy can close this gap exactly. Setting</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Ctau%5E%7B*%7D%20=%20%5Cfrac%7B%5Cnu%7D%7B1-%5Cnu%7D%0A%5Cquad%20%5CLongrightarrow%20%5Cquad%0A(1-%5Cnu)(1+%5Ctau%5E%7B*%7D)%20=%201%0A"></p>
<p>makes the flexible-price allocation efficient. The government pays the subsidy on wages and finances it with a lump-sum tax of the same size, so its budget balances and the tax itself distorts nothing. This is the scheme that much of the optimal-policy literature assumes, for example Siu (2004) and Yun (2005).</p>
</section>
<section id="what-this-means-for-monetary-policy" class="level3">
<h3 class="anchored" data-anchor-id="what-this-means-for-monetary-policy">What this means for monetary policy</h3>
<p>With the subsidy in place and sticky prices (<img src="https://latex.codecogs.com/png.latex?%5Cphi%20%3E%200">), the central bank can reproduce the efficient allocation by keeping inflation at its free-of-cost level every period, <img src="https://latex.codecogs.com/png.latex?%5Cpi_t%20=%20%5Cpi_f">. Adjustment costs are then zero, both sides of the Phillips curve collapse to <img src="https://latex.codecogs.com/png.latex?w_t%20/%20z_t%20=%201%20-%20%5Cnu">, and the economy behaves as if prices were flexible. The interest rate that delivers this follows from the Euler equation:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AR_t%20=%20%5Cfrac%7B%5Cpi_f%20%5C,%20c_t%5E%7B-%5Csigma%7D%7D%7B%5Cdelta_t%20%5Cbeta%20%5C,%20%5Cmathbb%7BE%7D_t%5C!%5Cleft%5B%20c%5E%7B-%5Csigma%7D_%7Bt+1%7D%20%5Cright%5D%7D%20.%0A"></p>
<p>Two things can break this. First, a large enough preference shock makes the required <img src="https://latex.codecogs.com/png.latex?R_t"> fall below one, which the lower bound rules out. Second, without the subsidy, keeping <img src="https://latex.codecogs.com/png.latex?%5Cpi_t%20=%20%5Cpi_f"> delivers the flexible-price allocation, not the efficient one, and the central bank is tempted to push output up with inflation.</p>
<p>The paper keeps <img src="https://latex.codecogs.com/png.latex?%5Ctau%20=%200"> on purpose. The subsidy would remove the second problem, and with it the inflation bias. Leaving the markup in place is what lets the model study how the two biases, inflationary in normal times and deflationary at the lower bound, trade off as commitment changes.</p>
</section>
</section>
<section id="why-optimal-policy-is-time-inconsistent" class="level2">
<h2 class="anchored" data-anchor-id="why-optimal-policy-is-time-inconsistent">Why optimal policy is time-inconsistent</h2>
<p>The central bank sets <img src="https://latex.codecogs.com/png.latex?R_t"> to maximize the household’s welfare, taking this equilibrium as a constraint. It would like to close three gaps, or <strong>wedges</strong>, but it cannot close all of them at once:</p>
<ol type="1">
<li><strong>Price adjustment.</strong> Any inflation different from <img src="https://latex.codecogs.com/png.latex?%5Cpi_f"> wastes resources. This wedge says: keep <img src="https://latex.codecogs.com/png.latex?%5Cpi_t%20=%20%5Cpi_f">.</li>
<li><strong>Monopolistic competition.</strong> Markups keep output below its efficient level. In the benchmark there is no subsidy (<img src="https://latex.codecogs.com/png.latex?%5Ctau%20=%200">; see the previous section), so this wedge is open. Surprise inflation raises output, so this wedge says: inflate.</li>
<li><strong>The zero lower bound.</strong> When the economy needs a negative nominal rate, the bound keeps real rates too high. This wedge says: promise higher inflation later, so that real rates fall today.</li>
</ol>
<p>The second and third wedges create opposite temptations, and both are temptations to break a promise.</p>
<ul>
<li><strong>Inflation bias.</strong> Suppose the central bank promises <img src="https://latex.codecogs.com/png.latex?%5Cpi_%7Bt+1%7D%20=%20%5Cpi_f"> and firms believe it. Once expectations are set, a bit of surprise inflation raises output at no cost in credibility for today. Firms anticipate this, so in equilibrium inflation ends up above <img src="https://latex.codecogs.com/png.latex?%5Cpi_f"> with no gain in output.</li>
<li><strong>Deflation bias.</strong> At the lower bound, the central bank would like to promise higher future inflation to lower real rates now. But when the future arrives, the crisis is over and it would rather deliver <img src="https://latex.codecogs.com/png.latex?%5Cpi_f">. If people anticipate that, the promise is worthless, and the economy spends longer at the bound with lower inflation.</li>
</ul>
<p>This is Kydland and Prescott’s time inconsistency in its cleanest form. What the central bank can do therefore depends on what it can promise, which is what the three policy problems below differ in.</p>
</section>
<section id="three-policy-problems" class="level2">
<h2 class="anchored" data-anchor-id="three-policy-problems">Three policy problems</h2>
<p>For all three, write <img src="https://latex.codecogs.com/png.latex?u(x_t)%20=%20%5Cfrac%7Bc_t%5E%7B1-%5Csigma%7D-1%7D%7B1-%5Csigma%7D%20-%20%5Cchi%5Cfrac%7Bn_t%5E%7B1+%5Ceta%7D%7D%7B1+%5Ceta%7D"> and split each forward-looking equation into the part that depends on today’s variables and the part that depends on tomorrow’s:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0AA(x_t)%20&amp;=%20%5Cfrac%7Bc_t%5E%7B-%5Csigma%7D%7D%7BR_t%7D,%20%5C%5C%0AB(x_%7Bt+1%7D)%20&amp;=%20%5Cfrac%7Bc_%7Bt+1%7D%5E%7B-%5Csigma%7D%7D%7B%5Cpi_%7Bt+1%7D%7D,%20%5C%5C%0AC(x_t)%20&amp;=%20c_t%5E%7B-%5Csigma%7D%20y_t%20%5Cleft%5B%201%20-%20%5Cnu%20-%20%5Cfrac%7Bw_t%7D%7Bz_t%7D%20+%20%5Cphi%5Cnu%5Cpi_t(%5Cpi_t%20-%20%5Cpi_f)%20%5Cright%5D,%20%5C%5C%0AD(x_%7Bt+1%7D)%20&amp;=%20%5Cphi%5Cnu%20%5C,%20c_%7Bt+1%7D%5E%7B-%5Csigma%7D%20y_%7Bt+1%7D%20(%5Cpi_%7Bt+1%7D%20-%20%5Cpi_f)%5Cpi_%7Bt+1%7D.%0A%5Cend%7Baligned%7D%0A"></p>
<p>The Euler equation is then <img src="https://latex.codecogs.com/png.latex?A(x_t)%20=%20%5Cdelta_t%20%5Cbeta%20%5C,%20%5Cmathbb%7BE%7D_t%20B(x_%7Bt+1%7D)"> and the Phillips curve is <img src="https://latex.codecogs.com/png.latex?C(x_t)%20=%20%5Cdelta_t%20%5Cbeta%20%5C,%20%5Cmathbb%7BE%7D_t%20D(x_%7Bt+1%7D)">.</p>
<section id="discretion" class="level3">
<h3 class="anchored" data-anchor-id="discretion">Discretion</h3>
<p>Under discretion no promise binds: each period the central bank re-optimizes, taking how it will behave in the future as given. Because it has no incentive to preserve a promise when the next period arrives, promises have no independent force; it is as if they did not exist. The state therefore carries no burden from previous promises: policy depends only on the current exogenous shock, not on an inherited policy plan. The right-hand sides <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BE%7D_t%20B"> and <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BE%7D_t%20D"> are then outside its control, and the problem is static:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmax_%7Bx_t%7D%20%5C;%20u(x_t)%0A"></p>
<p>subject to the equilibrium conditions, with <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BE%7D_t%20B"> and <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BE%7D_t%20D"> taken as given.</p>
<p>Discretionary models have more than one equilibrium. I focus on the Markov-perfect equilibrium in which policy depends only on the current shock and the lower bound binds occasionally; there is also a “deflation trap” equilibrium in which low expectations keep the economy at the bound, which I rule out.</p>
<p>The first-order condition for <img src="https://latex.codecogs.com/png.latex?R_t"> gives the most useful insight in the whole problem. With multipliers <img src="https://latex.codecogs.com/png.latex?%5Clambda%5EE_t"> on the Euler equation and <img src="https://latex.codecogs.com/png.latex?%5Clambda%5ER_t%20%5Cge%200"> on the lower bound,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Clambda%5EE_t%20%5C,%20%5Cfrac%7Bc_t%5E%7B-%5Csigma%7D%7D%7BR_t%5E2%7D%20=%20%5Clambda%5ER_t%20.%0A"></p>
<p>Away from the bound, <img src="https://latex.codecogs.com/png.latex?%5Clambda%5ER_t%20=%200">, so <img src="https://latex.codecogs.com/png.latex?%5Clambda%5EE_t%20=%200">: <strong>the Euler equation is not a constraint in normal times</strong>. The central bank can always set the rate the Euler equation requires. Aggregate demand only becomes a binding problem at the lower bound. Keep this in mind for the next section.</p>
</section>
<section id="commitment" class="level3">
<h3 class="anchored" data-anchor-id="commitment">Commitment</h3>
<p>Under full commitment the central bank chooses, once and for all, a plan for every possible history of shocks. Attach multipliers <img src="https://latex.codecogs.com/png.latex?%5Clambda%5EE_t"> and <img src="https://latex.codecogs.com/png.latex?%5Clambda%5EP_t"> to the Euler equation and the Phillips curve, and <img src="https://latex.codecogs.com/png.latex?%5Clambda%5ER_t"> to the lower bound. The Lagrangian is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A%5Cmathbb%7BE%7D_0%20%5Csum_%7Bt=0%7D%5E%7B%5Cinfty%7D%20%5Cbeta%5Et%20%5CDelta_t%20%5CBig%5C%7B%20%5C,%20&amp;%20u(x_t)%20+%20%5Clambda%5EE_t%20%5Cbig%5B%20A(x_t)%20-%20%5Cdelta_t%5Cbeta%5C,%5Cmathbb%7BE%7D_t%20B(x_%7Bt+1%7D)%20%5Cbig%5D%20%5C%5C%0A&amp;%20+%20%5Clambda%5EP_t%20%5Cbig%5B%20C(x_t)%20-%20%5Cdelta_t%5Cbeta%5C,%5Cmathbb%7BE%7D_t%20D(x_%7Bt+1%7D)%20%5Cbig%5D%20%5C%5C%0A&amp;%20+%20%5Clambda%5ER_t%20(R_t%20-%201)%20%5CBig%5C%7D.%0A%5Cend%7Baligned%7D%0A"></p>
<p>The difficulty is that <img src="https://latex.codecogs.com/png.latex?x_%7Bt+1%7D"> appears in the constraints of period <img src="https://latex.codecogs.com/png.latex?t">. Marcet and Marimon’s trick is to move those terms into period <img src="https://latex.codecogs.com/png.latex?t+1">, where they belong. Because the discount weight of period <img src="https://latex.codecogs.com/png.latex?t+1"> is <img src="https://latex.codecogs.com/png.latex?%5Cbeta%5E%7Bt+1%7D%5CDelta_%7Bt+1%7D%20=%20%5Cbeta%5Et%5CDelta_t%20%5Ccdot%20%5Cdelta_t%5Cbeta">, the term <img src="https://latex.codecogs.com/png.latex?-%5Cbeta%5Et%5CDelta_t%20%5C,%20%5Clambda%5EE_t%20%5C,%20%5Cdelta_t%5Cbeta%20%5C,%20B(x_%7Bt+1%7D)"> is exactly <img src="https://latex.codecogs.com/png.latex?-%5Cbeta%5E%7Bt+1%7D%5CDelta_%7Bt+1%7D%20%5C,%20%5Clambda%5EE_t%20%5C,%20B(x_%7Bt+1%7D)">. So in period <img src="https://latex.codecogs.com/png.latex?t+1"> the problem contains yesterday’s multiplier. Define</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmu_%7Bt+1%7D%20%5Cequiv%20%5Clambda_t%20,%20%5Cqquad%20%5Cmu_0%20=%200%20.%0A"></p>
<p>The problem becomes recursive, a <strong>saddle-point functional equation</strong> with the lagged multipliers as a new state:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0AW(%5Cdelta,%20%5Cmu)%20=%20%5Cmin_%7B%5Clambda%7D%20%5Cmax_%7Bx%7D%20%5CBig%5C%7B%20%5C,%20&amp;%20u(x)%20+%20%5Clambda%5EE%20A(x)%20-%20%5Cmu%5EE%20B(x)%20%5C%5C%0A&amp;%20+%20%5Clambda%5EP%20C(x)%20-%20%5Cmu%5EP%20D(x)%20+%20%5Clambda%5ER%20(R%20-%201)%20%5CBig%5C%7D%20%5C%5C%0A&amp;%20+%20%5Cdelta%5Cbeta%20%5C,%20%5Cmathbb%7BE%7D%5C,%20W(%5Cdelta',%20%5Clambda).%0A%5Cend%7Baligned%7D%0A"></p>
<p>This is where the word <em>promise</em> becomes literal. <img src="https://latex.codecogs.com/png.latex?%5Cmu%5EE"> and <img src="https://latex.codecogs.com/png.latex?%5Cmu%5EP"> are yesterday’s promises about today; they enter today’s problem as costs of deviating from what was announced. Today’s multipliers become tomorrow’s promises. The state now has two endogenous dimensions on top of the shock.</p>
<p>Two consequences follow from the first-order conditions.</p>
<p><strong>No inflation bias in the long run.</strong> In a steady state without the bound, promises are constant, so <img src="https://latex.codecogs.com/png.latex?%5Cmu%20=%20%5Clambda">. The terms <img src="https://latex.codecogs.com/png.latex?%5Clambda%5EP%20C(x)%20-%20%5Cmu%5EP%20D(x)"> then pull in opposite directions with equal weight, and the first-order condition for inflation reduces to</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Clambda%5E%7B%5Ctext%7Bres%7D%7D%20%5C,%20n%20%5C,%20%5Cphi%20%5C,%20(%5Cpi%20-%20%5Cpi_f)%20=%200%20,%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?%5Clambda%5E%7B%5Ctext%7Bres%7D%7D%20%3E%200"> is the multiplier on the resource constraint. Hence <img src="https://latex.codecogs.com/png.latex?%5Cpi%20=%20%5Cpi_f">. Under discretion there is no <img src="https://latex.codecogs.com/png.latex?%5Cmu%5EP"> term to offset <img src="https://latex.codecogs.com/png.latex?%5Clambda%5EP">, and inflation settles above <img src="https://latex.codecogs.com/png.latex?%5Cpi_f">: the inflation bias.</p>
<p><strong>Forward guidance lives in <img src="https://latex.codecogs.com/png.latex?%5Cmu%5EE">.</strong> As under discretion, <img src="https://latex.codecogs.com/png.latex?%5Clambda%5EE_t%20=%200"> whenever the bound does not bind. So the Euler promise <img src="https://latex.codecogs.com/png.latex?%5Cmu%5EE"> is positive only after the economy has been at the bound. When it is, the first-order condition for inflation acquires an extra term,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cldots%20=%20%5Cmu%5EE_t%20%5C,%20c_t%5E%7B-%5Csigma%7D%20%5Cpi_t%5E%7B-2%7D%20+%20%5Cldots%20,%0A"></p>
<p>which raises inflation after the episode ends. This is the credible promise of higher future inflation that makes commitment so effective at the bound.</p>
</section>
<section id="loose-commitment" class="level3">
<h3 class="anchored" data-anchor-id="loose-commitment">Loose commitment</h3>
<p>Loose commitment, from Debortoli and Nunes (2010), sits between the two. Each period an i.i.d. coin is tossed:</p>
<ul>
<li>with probability <img src="https://latex.codecogs.com/png.latex?%5Cxi"> the plan continues (<em>commit</em>);</li>
<li>with probability <img src="https://latex.codecogs.com/png.latex?1-%5Cxi"> the central bank reneges and a new plan is drawn up from scratch (<em>renege</em>).</li>
</ul>
<p>A promise made today therefore survives until tomorrow with probability <img src="https://latex.codecogs.com/png.latex?%5Cxi">. When the central bank reneges, it starts again with no inherited promises, so the state jumps back to <img src="https://latex.codecogs.com/png.latex?%5Cmu%20=%200">. The parameter <img src="https://latex.codecogs.com/png.latex?%5Cxi"> moves the economy continuously from discretion (<img src="https://latex.codecogs.com/png.latex?%5Cxi%20=%200">) to commitment (<img src="https://latex.codecogs.com/png.latex?%5Cxi%20%5Cto%201">). Promises last <img src="https://latex.codecogs.com/png.latex?1/(1-%5Cxi)"> periods on average.</p>
<p>Private agents know this, so their expectations average over the two branches. The Euler equation of the committed plan becomes</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AA(x%5Ec_t)%20=%20%5Cdelta_t%5Cbeta%20%5C,%20%5Cmathbb%7BE%7D_t%20%5CBig%5B%20%5Cxi%20%5C,%20B(x%5Ec_%7Bt+1%7D)%20+%20(1-%5Cxi)%20%5C,%20B(x%5Er_%7Bt+1%7D)%20%5CBig%5D,%0A"></p>
<p>and similarly for the Phillips curve, where <img src="https://latex.codecogs.com/png.latex?x%5Er"> is what a re-optimizing central bank will do. The same regrouping trick as before moves the <img src="https://latex.codecogs.com/png.latex?%5Cxi"> part to the next period of the committed branch. The <img src="https://latex.codecogs.com/png.latex?(1-%5Cxi)"> part stays where it is, because the central bank cannot promise anything about a plan that will have been replaced. The result is the loose-commitment saddle-point problem:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0AV%5Ec(%5Cdelta,%20%5Cmu)%20=%20%5Cmin_%7B%5Clambda%7D%5Cmax_%7Bx%7D%20%5CBig%5C%7B%20%5C,%20&amp;%20u(x)%20+%20%5Clambda%5ER(R-1)%20%5C%5C%0A&amp;%20+%20%5Clambda%5EE%20%5Cbig%5B%20A(x)%20-%20(1-%5Cxi)%5C,%5Cdelta%5Cbeta%5C,%5Cmathbb%7BE%7D%5C,B(x%5Er)%20%5Cbig%5D%20-%20%5Cmu%5EE%20B(x)%20%5C%5C%0A&amp;%20+%20%5Clambda%5EP%20%5Cbig%5B%20C(x)%20-%20(1-%5Cxi)%5C,%5Cdelta%5Cbeta%5C,%5Cmathbb%7BE%7D%5C,D(x%5Er)%20%5Cbig%5D%20-%20%5Cmu%5EP%20D(x)%20%5CBig%5C%7D%20%5C%5C%0A&amp;%20+%20%5Cdelta%5Cbeta%20%5C,%20%5Cmathbb%7BE%7D%5CBig%5B%20%5Cxi%20%5C,%20V%5Ec(%5Cdelta',%20%5Clambda)%20+%20(1-%5Cxi)%20%5C,%20V%5Er(%5Cdelta')%20%5CBig%5D.%0A%5Cend%7Baligned%7D%0A"></p>
<p>The reneging branch is not free to choose. Whoever re-optimizes tomorrow faces exactly the same problem with a clean slate, so equilibrium requires a fixed point:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AV%5Er(%5Cdelta)%20=%20V%5Ec(%5Cdelta,%200),%20%5Cqquad%20x%5Er(%5Cdelta)%20=%20x%5Ec(%5Cdelta,%200).%0A"></p>
<p>A loose-commitment equilibrium is a set of functions <img src="https://latex.codecogs.com/png.latex?V%5Ec">, <img src="https://latex.codecogs.com/png.latex?V%5Er">, <img src="https://latex.codecogs.com/png.latex?x%5Ec"> and <img src="https://latex.codecogs.com/png.latex?x%5Er"> that solve the problem above and satisfy this fixed point. Setting <img src="https://latex.codecogs.com/png.latex?%5Cxi%20=%201"> recovers full commitment; setting <img src="https://latex.codecogs.com/png.latex?%5Cxi%20=%200"> removes every promise and recovers the discretionary problem.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-2-contents" aria-controls="callout-2" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Why there is no steady state
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-2" class="callout-2-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>Under full commitment the promise state starts at zero and drifts to its long-run level. Under loose commitment it is reset to zero every time the coin comes up <em>renege</em>, so the economy keeps falling back to the origin and climbing away from it. Even without shocks it never settles. Its long-run distribution is a mixture of commitment spells of different lengths, with spell length geometric in <img src="https://latex.codecogs.com/png.latex?%5Cxi">, and it changes with <img src="https://latex.codecogs.com/png.latex?%5Cxi"> itself.</p>
</div>
</div>
</div>
</section>
</section>
<section id="measuring-welfare" class="level2">
<h2 class="anchored" data-anchor-id="measuring-welfare">Measuring welfare</h2>
<p>Welfare is reported as a consumption equivalent: the percentage <img src="https://latex.codecogs.com/png.latex?%5CLambda"> of consumption that would make the household indifferent between the economy with the lower bound and the efficient allocation <img src="https://latex.codecogs.com/png.latex?(c%5E%7B*%7D,%20n%5E%7B*%7D)"> derived above,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Au%5Cbig(c_%7B%5Ctext%7Bzlb%7D%7D(1+%5CLambda),%20%5C,%20n_%7B%5Ctext%7Bzlb%7D%7D%5Cbig)%20=%20u%5Cbig(c%5E%7B*%7D,%20%5C,%20n%5E%7B*%7D%5Cbig),%0A"></p>
<p>and its unconditional version <img src="https://latex.codecogs.com/png.latex?%5CLambda%5Eu">, which takes expectations over the model’s long-run distribution on both sides.</p>
</section>
<section id="solving-it-without-linearizing" class="level2">
<h2 class="anchored" data-anchor-id="solving-it-without-linearizing">Solving it without linearizing</h2>
<p>The usual shortcut, a linear-quadratic approximation around a steady state, fails here for three reasons:</p>
<ul>
<li><strong>The lower bound is a kink.</strong> Policy functions bend sharply where the bound starts to bind.</li>
<li><strong>There is no single point to approximate around.</strong> Average inflation moves from <img src="https://latex.codecogs.com/png.latex?%5Cpi_f"> under commitment to <img src="https://latex.codecogs.com/png.latex?%5Cpi_f"> plus the inflation bias under discretion, so any approximation point is wrong for most values of <img src="https://latex.codecogs.com/png.latex?%5Cxi">. And under loose commitment there is no steady state at all.</li>
<li><strong>The results are about the shape of things.</strong> The main result is that the probability of reaching the bound is hump-shaped in <img src="https://latex.codecogs.com/png.latex?%5Cxi">. That depends on how the mean <em>and</em> the volatility of inflation shift along the commitment line, which is exactly what a linearization around one point throws away.</li>
</ul>
<p>So the model is solved globally, with <strong>time iteration</strong> (<span class="citation" data-cites="Coleman1991">Coleman (1991)</span>): guess policy functions on a grid of states, solve the first-order conditions at each grid point given the guess for tomorrow, update, and repeat until nothing changes.</p>
<ol type="1">
<li>At each grid point, compute the expectations in the Euler equation and the Phillips curve. Tomorrow’s promise state is <img src="https://latex.codecogs.com/png.latex?%5Clambda"> with probability <img src="https://latex.codecogs.com/png.latex?%5Cxi"> and <img src="https://latex.codecogs.com/png.latex?0"> with probability <img src="https://latex.codecogs.com/png.latex?1-%5Cxi">; the shock is integrated with Gauss–Hermite quadrature.</li>
<li>Solve the first-order conditions assuming the bound does not bind.</li>
<li>If the implied <img src="https://latex.codecogs.com/png.latex?R"> is below one, re-solve with <img src="https://latex.codecogs.com/png.latex?R%20=%201">.</li>
<li>Update the policy guess with some dampening, and stop when successive guesses agree to within a tolerance.</li>
</ol>
<p>Discretion is the easy case: the only state is the exogenous shock, whose distribution is known, so the grid is simple. The only refinement is to find the point where the bound starts to bind by bisection and place extra nodes around it.</p>
<p>Loose commitment is the hard case. The state has three dimensions (the shock and two promises), and the relevant part of the promise space is unknown before solving the model, and different for every <img src="https://latex.codecogs.com/png.latex?%5Cxi">. A dense rectangular grid is both slow and unstable, because it includes promise levels the economy never reaches. The solution follows <span class="citation" data-cites="MaliarMaliar2015">Maliar and Maliar (2015)</span>: let the model tell you where it lives.</p>
<ol type="1">
<li>Solve on a coarse grid.</li>
<li>Use that solution to approximate the long-run distribution of the promise state. Every spell starts at <img src="https://latex.codecogs.com/png.latex?%5Cmu%20=%200">; mass is pushed forward along the policy functions, and spells survive each period with probability <img src="https://latex.codecogs.com/png.latex?%5Cxi">.</li>
<li>Keep only the grid nodes with non-negligible probability, which gives an irregular grid concentrated where the economy actually spends its time.</li>
<li>Re-solve on the new grid, interpolating between the scattered nodes with a Delaunay triangulation, and repeat until the grid stops changing.</li>
</ol>
</section>
<section id="where-this-leaves-us" class="level2">
<h2 class="anchored" data-anchor-id="where-this-leaves-us">Where this leaves us</h2>
<p>The machinery comes down to one idea: <strong>a promise is a state variable</strong>. Under discretion there are no promises, and the central bank suffers from an inflation bias in normal times and a deflation bias at the lower bound. Under commitment, promises are permanent and both biases disappear. Under loose commitment, promises decay at rate <img src="https://latex.codecogs.com/png.latex?1-%5Cxi">, and with them the value of making them.</p>
<p>Because the model is solved globally, one can move <img src="https://latex.codecogs.com/png.latex?%5Cxi"> smoothly from zero to one, holding everything else fixed, and examine how inflation, welfare and the lower bound change along the way.</p>
<p>The recursive formulation of the policy problem follows the loose-commitment and recursive-contracts literature (<span class="citation" data-cites="DebortoliNunes2010">Debortoli and Nunes (2010)</span>; <span class="citation" data-cites="MarcetMarimon2019">Marcet and Marimon (2019)</span>), while the treatment of the lower bound and the welfare comparison is related to <span class="citation" data-cites="Siu2004">Siu (2004)</span>.</p>


<div class="site-disclaimer">
<p>This is my personal website. The views and opinions expressed here are my own and do not necessarily represent those of the Central Bank of Chile or its Board. Any errors, unfinished thoughts, questionable code, and overly complicated solutions found here are, of course, my own.</p>
</div>

</section>


<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent">
<div id="ref-Calvo1983JME" class="csl-entry">
<span class="smallcaps">Calvo, G. A.</span> (1983): <span>“Staggered prices in a utility-maximizing framework,”</span> <em>Journal of Monetary Economics</em>, 12, 383–98.
</div>
<div id="ref-Coleman1991" class="csl-entry">
<span class="smallcaps">Coleman, W. J.</span> (1991): <span>“Equilibrium in a production economy with an income tax,”</span> <em>Econometrica</em>, 59, 1091–1104.
</div>
<div id="ref-DebortoliNunes2010" class="csl-entry">
<span class="smallcaps">Debortoli, D., and R. Nunes</span>. (2010): <span>“Fiscal policy under loose commitment,”</span> <em>Journal of Economic Theory</em>, 145, 1005–32.
</div>
<div id="ref-DotseyKingEtal1999QJE" class="csl-entry">
<span class="smallcaps">Dotsey, M., R. G. King, and A. L. Wolman</span>. (1999): <span>“State-dependent pricing and the general equilibrium dynamics of money and output,”</span> <em>The Quarterly Journal of Economics</em>, 114, 655–90.
</div>
<div id="ref-KydlandPrescott1977" class="csl-entry">
<span class="smallcaps">Kydland, F. E., and E. C. Prescott</span>. (1977): <span>“Rules rather than discretion: The inconsistency of optimal plans,”</span> <em>Journal of Political Economy</em>, 85, 473–91.
</div>
<div id="ref-MaliarMaliar2015" class="csl-entry">
<span class="smallcaps">Maliar, L., and S. Maliar</span>. (2015): <span>“Merging simulation and projection approaches to solve high-dimensional problems with an application to a new keynesian model,”</span> <em>Quantitative Economics</em>, 6, 1–47.
</div>
<div id="ref-MarcetMarimon2019" class="csl-entry">
<span class="smallcaps">Marcet, A., and R. Marimon</span>. (2019): <span>“Recursive contracts,”</span> <em>Econometrica</em>, 87, 1589–1631.
</div>
<div id="ref-Rotemberg1982" class="csl-entry">
<span class="smallcaps">Rotemberg, J. J.</span> (1982): <span>“Sticky prices in the united states,”</span> <em>Journal of Political Economy</em>, 90, 1187–1211.
</div>
<div id="ref-Siu2004" class="csl-entry">
<span class="smallcaps">Siu, H. E.</span> (2004): <span>“Optimal fiscal and monetary policy with sticky prices,”</span> <em>Journal of Monetary Economics</em>, 51, 575–607.
</div>
<div id="ref-Yun2005" class="csl-entry">
<span class="smallcaps">Yun, T.</span> (2005): <span>“Optimal monetary policy with relative price distortions,”</span> <em>American Economic Review</em>, 95, 89–109.
</div>
</div></section><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>I use Rotemberg pricing because it gives a smooth, fully nonlinear price-adjustment problem that is convenient for global solution and for studying an occasionally binding lower bound (<span class="citation" data-cites="Rotemberg1982">Rotemberg (1982)</span>). It also avoids introducing an additional endogenous distribution of firms’ prices as a state variable in this formulation. The familiar Calvo model instead gives each firm a fixed probability of being able to reoptimize its price in each period (<span class="citation" data-cites="Calvo1983JME">Calvo (1983)</span>), which generally requires tracking price dispersion. The two formulations generate the same New Keynesian Phillips curve only locally, after a first-order linearization around a steady state and with an appropriate mapping between parameters; they are not the same model away from that approximation. In particular, their nonlinear welfare costs, price dispersion, and responses near the ZLB can differ. A third possibility is state-dependent pricing, in which firms adjust when their individual state makes it worthwhile rather than according to a fixed probability (<span class="citation" data-cites="DotseyKingEtal1999QJE">Dotsey et al. (1999)</span>), adding a distribution of pricing states to the aggregate state.↩︎</p></li>
</ol>
</section></div> ]]></description>
  <category>Monetary Policy</category>
  <category>Economics</category>
  <category>Methodology</category>
  <guid>https://www.nicolasfranzpattillo.com/posts/published/loose-commitment-math/</guid>
  <pubDate>Wed, 01 May 2024 00:00:00 GMT</pubDate>
  <media:content url="https://www.nicolasfranzpattillo.com/posts/published/loose-commitment-math/src/cover.webp" medium="image" type="image/webp"/>
</item>
<item>
  <title>COVID-19 Pandexit and the effects on economic activity</title>
  <dc:creator>Nicolas Franz-Pattillo</dc:creator>
  <link>https://www.nicolasfranzpattillo.com/posts/published/covid19-vaccines/</link>
  <description><![CDATA[ 






<div class="page-hero column-screen"><img src="https://www.nicolasfranzpattillo.com/posts/published/covid19-vaccines/src/cover.webp" alt="A vial of the Pfizer-BioNTech COVID-19 vaccine. Photo: Lisa Ferdinando, U.S. Department of Defense — public domain."><div class="page-hero__credit">Photo: Lisa Ferdinando, U.S. Department of Defense — public domain.</div></div>
<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>Chile’s vaccination campaign is progressing rapidly, raising a natural question: <strong>when can we expect mobility—and economic activity—to return to normal?</strong> The answer depends not only on how quickly the population is vaccinated, but also on how effective the vaccines are at preventing contagion.</p>
<p>Using the methodology proposed by <span class="citation" data-cites="Rungcharoenkitkul2021">Rungcharoenkitkul (2021)</span>, we project the evolution of the pandemic and the associated optimal mobility response under a vaccination process similar to Chile’s. We consider three scenarios in which vaccines prevent contagion 95%, 60%, and 5% of the time. The exercise allows us to ask how vaccine efficacy affects the expected timing of the return to normality—and what a slower <em>pandexit</em> could cost in terms of economic activity.</p>
<p> shows a sizable difference across scenarios. <strong>With 95% efficacy, mobility returns to normal roughly a month and a half earlier than with 60% efficacy.</strong> Over the following six months, the average mobility gap between the two scenarios is approximately 4.7%.</p>
<p>That delay has an economic cost. We estimate that a 10% reduction in mobility is associated with GDP growth that is roughly 1.7 to 3 percentage points lower. Combining this estimate with the projected mobility paths suggests that <strong>a slower return to normality could subtract around 0.4 to 0.6 percentage points from annual GDP growth</strong>. For an economy expected to grow 8.5% under the 60%-efficacy scenario, this implies growth could instead reach roughly 8.9% to 9.1% if vaccines prevented contagion 95% of the time.</p>
<p>The effectiveness of vaccination therefore matters for more than the evolution of the pandemic. <strong>It also determines how quickly we can return to normal—and how much economic activity we lose while we wait.</strong></p>
</section>
<section id="epidemiological-model-mobility-and-activity" class="level2">
<h2 class="anchored" data-anchor-id="epidemiological-model-mobility-and-activity">Epidemiological model, mobility, and activity</h2>
<p>The mechanism is a feedback loop: <strong>mobility supports economic activity, but also creates opportunities for infection</strong>. Rising health risks make restrictions more attractive. Effective vaccination reduces the susceptible population, allowing mobility to recover with a smaller health cost.</p>
<p>The framework follows the 12-compartment model of <span class="citation" data-cites="Rungcharoenkitkul2021">Rungcharoenkitkul (2021)</span>. People move from susceptible to exposed and then infectious. They subsequently isolate at home, enter quarantine, or go to hospital, before recovering or dying. The six isolated groups distinguish these three settings and the two eventual outcomes; only the infectious group transmits in the model. Vaccination provides a route from susceptibility to immunity without passing through infection.</p>
<div class="wide">
<div class="paper-figure model-diagram">
<div class="paper-plot__header">
<p><span class="paper-plot__title">Population flows in the model</span></p>
</div>
<!-- Generated by src/diagrams/draw_model.py. -->
<div class="model-diagram-responsive">
<svg xmlns="http://www.w3.org/2000/svg" class="model-flow model-flow-wide" viewbox="0 0 960 340" aria-labelledby="wide-title wide-desc">
<title id="wide-title">Population flows: infection, isolation and immunity</title>
<desc id="wide-desc">Twelve population compartments. Susceptible people become exposed, then infectious. Infectious people enter one of six isolated groups: undetected, quarantined or hospitalised, with either recovery or death as the eventual outcome. Vaccination moves susceptible people directly to immunity. Dashed return paths allow vaccinated and recovered people to lose immunity.</desc>
<style>
.model-flow { font-family: var(--site-font-body, "Roboto", "Helvetica Neue", sans-serif); }
.model-flow text { fill: var(--site-text, #434648); font-family: inherit; font-size: 15px; }
.model-flow .state { fill: var(--site-bg, #fff); stroke: var(--site-text, #434648); stroke-opacity: .45; }
.model-flow .group { fill: var(--site-code-bg, #f6f6f6); stroke: var(--site-border, #ececec); }
.model-flow .symbol { fill: var(--site-heading, #0d122b); font-size: 22px; font-weight: 700; }
.model-flow .group-label { fill: var(--site-heading, #0d122b); font-size: 14px; font-weight: 700; letter-spacing: .5px; }
.model-flow .edge { fill: none; stroke: var(--site-text, #434648); stroke-width: 1.5; stroke-linejoin: round; }
.model-flow .waning { stroke-dasharray: 5 5; opacity: .8; }
.model-flow .accent { stroke: var(--site-link, #003fff); }
.model-flow .accent-label { fill: var(--site-link, #003fff); }
.model-flow .small { font-size: 14px; }
</style>
<defs><marker id="wide-arrow" viewbox="0 0 10 10" refx="9" refy="5" markerwidth="6" markerheight="6" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="var(--site-text, #434648)"></path></marker>
<marker id="wide-accent" viewbox="0 0 10 10" refx="9" refy="5" markerwidth="6" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" fill="var(--site-link, #003fff)"></path></marker></defs>
<path class="edge waning" d="M 882 75 V 18 H 34 V 143" marker-end="url(#wide-arrow)"></path>
<text x="450" y="12" class="small" text-anchor="middle">Loss of immunity (optional)</text>
<path class="edge " d="M 120 170 H 164" marker-end="url(#wide-arrow)"></path>
<text x="142" y="134" class="small" text-anchor="middle">Infection</text>
<path class="edge " d="M 280 170 H 324" marker-end="url(#wide-arrow)"></path>
<text x="302" y="134" class="small" text-anchor="middle">Incubation</text>
<path class="edge " d="M 440 170 H 455 V 102 H 470" marker-end="url(#wide-arrow)"></path>
<path class="edge " d="M 455 170 V 262 H 470" marker-end="url(#wide-arrow)"></path>
<path class="edge " d="M 802 102 H 832" marker-end="url(#wide-arrow)"></path>
<path class="edge " d="M 802 262 H 832" marker-end="url(#wide-arrow)"></path>
<path class="edge accent" d="M 62 197 V 273" marker-end="url(#wide-accent)"></path>
<text x="74" y="228" class="accent-label small" text-anchor="start">Effective</text>
<text x="74" y="246" class="accent-label small" text-anchor="start">vaccination</text>
<path class="edge waning" d="M 120 300 H 175 V 214 H 92 V 197" marker-end="url(#wide-arrow)"></path>
<rect class="state" x="4.0" y="143" width="116" height="54" rx="5"></rect>
<text x="62" y="163" class="symbol" text-anchor="middle">S</text>
<text x="62" y="186" class="" text-anchor="middle">Susceptible</text>
<rect class="state" x="164.0" y="143" width="116" height="54" rx="5"></rect>
<text x="222" y="163" class="symbol" text-anchor="middle">E</text>
<text x="222" y="186" class="" text-anchor="middle">Exposed</text>
<rect class="state" x="324.0" y="143" width="116" height="54" rx="5"></rect>
<text x="382" y="163" class="symbol" text-anchor="middle">I</text>
<text x="382" y="186" class="" text-anchor="middle">Infectious</text>
<rect class="state" x="4.0" y="273" width="116" height="54" rx="5"></rect>
<text x="62" y="293" class="symbol" text-anchor="middle">V</text>
<text x="62" y="316" class="" text-anchor="middle">Vaccinated</text>
<rect class="group" x="470" y="48" width="332" height="98" rx="7"></rect>
<text x="636.0" y="70" class="group-label" text-anchor="middle">WILL RECOVER</text>
<rect class="state" x="478.0" y="84.0" width="100" height="54" rx="5"></rect>
<text x="528.0" y="104.0" class="symbol" text-anchor="middle">Uᴿ</text>
<text x="528.0" y="127.0" class="" text-anchor="middle">Undetected</text>
<rect class="state" x="586.0" y="84.0" width="100" height="54" rx="5"></rect>
<text x="636.0" y="104.0" class="symbol" text-anchor="middle">Qᴿ</text>
<text x="636.0" y="127.0" class="" text-anchor="middle">Quarantined</text>
<rect class="state" x="694.0" y="84.0" width="100" height="54" rx="5"></rect>
<text x="744.0" y="104.0" class="symbol" text-anchor="middle">Hᴿ</text>
<text x="744.0" y="127.0" class="" text-anchor="middle">Hospitalised</text>
<rect class="group" x="470" y="208" width="332" height="98" rx="7"></rect>
<text x="636.0" y="230" class="group-label" text-anchor="middle">WILL DIE</text>
<rect class="state" x="478.0" y="244.0" width="100" height="54" rx="5"></rect>
<text x="528.0" y="264.0" class="symbol" text-anchor="middle">Uᴰ</text>
<text x="528.0" y="287.0" class="" text-anchor="middle">Undetected</text>
<rect class="state" x="586.0" y="244.0" width="100" height="54" rx="5"></rect>
<text x="636.0" y="264.0" class="symbol" text-anchor="middle">Qᴰ</text>
<text x="636.0" y="287.0" class="" text-anchor="middle">Quarantined</text>
<rect class="state" x="694.0" y="244.0" width="100" height="54" rx="5"></rect>
<text x="744.0" y="264.0" class="symbol" text-anchor="middle">Hᴰ</text>
<text x="744.0" y="287.0" class="" text-anchor="middle">Hospitalised</text>
<rect class="state" x="832.0" y="75" width="100" height="54" rx="5"></rect>
<text x="882" y="95" class="symbol" text-anchor="middle">R</text>
<text x="882" y="118" class="" text-anchor="middle">Recovered</text>
<rect class="state" x="832.0" y="235" width="100" height="54" rx="5"></rect>
<text x="882" y="255" class="symbol" text-anchor="middle">D</text>
<text x="882" y="278" class="" text-anchor="middle">Deaths</text>
<text x="636" y="190" class="small" text-anchor="middle">ISOLATED · NO TRANSMISSION</text>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" class="model-flow model-flow-narrow" viewbox="0 0 360 696" aria-labelledby="narrow-title narrow-desc">
<title id="narrow-title">Population flows: infection, isolation and immunity</title>
<desc id="narrow-desc">Twelve population compartments. Susceptible people become exposed, then infectious. Infectious people enter one of six isolated groups: undetected, quarantined or hospitalised, with either recovery or death as the eventual outcome. Vaccination moves susceptible people directly to immunity. Dashed return paths allow vaccinated and recovered people to lose immunity.</desc>
<style>
.model-flow { font-family: var(--site-font-body, "Roboto", "Helvetica Neue", sans-serif); }
.model-flow text { fill: var(--site-text, #434648); font-family: inherit; font-size: 15px; }
.model-flow .state { fill: var(--site-bg, #fff); stroke: var(--site-text, #434648); stroke-opacity: .45; }
.model-flow .group { fill: var(--site-code-bg, #f6f6f6); stroke: var(--site-border, #ececec); }
.model-flow .symbol { fill: var(--site-heading, #0d122b); font-size: 22px; font-weight: 700; }
.model-flow .group-label { fill: var(--site-heading, #0d122b); font-size: 14px; font-weight: 700; letter-spacing: .5px; }
.model-flow .edge { fill: none; stroke: var(--site-text, #434648); stroke-width: 1.5; stroke-linejoin: round; }
.model-flow .waning { stroke-dasharray: 5 5; opacity: .8; }
.model-flow .accent { stroke: var(--site-link, #003fff); }
.model-flow .accent-label { fill: var(--site-link, #003fff); }
.model-flow .small { font-size: 14px; }
</style>
<defs><marker id="narrow-arrow" viewbox="0 0 10 10" refx="9" refy="5" markerwidth="6" markerheight="6" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="var(--site-text, #434648)"></path></marker>
<marker id="narrow-accent" viewbox="0 0 10 10" refx="9" refy="5" markerwidth="6" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" fill="var(--site-link, #003fff)"></path></marker></defs>
<path class="edge waning" d="M 88 664 V 684 H 7 V 62 H 23" marker-end="url(#narrow-arrow)"></path>
<path class="edge accent" d="M 157 62 H 203" marker-end="url(#narrow-accent)"></path>
<text x="180" y="21" class="accent-label small" text-anchor="middle">Effective vaccination</text>
<path class="edge waning" d="M 270 89 V 111 H 90 V 89" marker-end="url(#narrow-arrow)"></path>
<path class="edge " d="M 90 111 V 151" marker-end="url(#narrow-arrow)"></path>
<text x="107" y="136" class="small" text-anchor="start">Infection</text>
<path class="edge " d="M 90 205 V 261" marker-end="url(#narrow-arrow)"></path>
<text x="107" y="238" class="small" text-anchor="start">Incubation</text>
<path class="edge " d="M 90 315 V 348" marker-end="url(#narrow-arrow)"></path>
<path class="edge " d="M 90 337 H 270 V 348" marker-end="url(#narrow-arrow)"></path>
<text x="102" y="327" class="small" text-anchor="start">ISOLATED · NO TRANSMISSION</text>
<path class="edge " d="M 88 570 V 610" marker-end="url(#narrow-arrow)"></path>
<path class="edge " d="M 272 570 V 610" marker-end="url(#narrow-arrow)"></path>
<text x="180" y="594" class="small" text-anchor="middle">Eventual outcomes</text>
<rect class="state" x="24.0" y="35" width="132" height="54" rx="5"></rect>
<text x="90" y="55" class="symbol" text-anchor="middle">S</text>
<text x="90" y="78" class="" text-anchor="middle">Susceptible</text>
<rect class="state" x="204.0" y="35" width="132" height="54" rx="5"></rect>
<text x="270" y="55" class="symbol" text-anchor="middle">V</text>
<text x="270" y="78" class="" text-anchor="middle">Vaccinated</text>
<rect class="state" x="24.0" y="151" width="132" height="54" rx="5"></rect>
<text x="90" y="171" class="symbol" text-anchor="middle">E</text>
<text x="90" y="194" class="" text-anchor="middle">Exposed</text>
<rect class="state" x="24.0" y="261" width="132" height="54" rx="5"></rect>
<text x="90" y="281" class="symbol" text-anchor="middle">I</text>
<text x="90" y="304" class="" text-anchor="middle">Infectious</text>
<rect class="group" x="18" y="348" width="140" height="222" rx="7"></rect>
<text x="88.0" y="370" class="group-label" text-anchor="middle">WILL RECOVER</text>
<rect class="state" x="26.0" y="384" width="124" height="54" rx="5"></rect>
<text x="88.0" y="404" class="symbol" text-anchor="middle">Uᴿ</text>
<text x="88.0" y="427" class="" text-anchor="middle">Undetected</text>
<rect class="state" x="26.0" y="446" width="124" height="54" rx="5"></rect>
<text x="88.0" y="466" class="symbol" text-anchor="middle">Qᴿ</text>
<text x="88.0" y="489" class="" text-anchor="middle">Quarantined</text>
<rect class="state" x="26.0" y="508" width="124" height="54" rx="5"></rect>
<text x="88.0" y="528" class="symbol" text-anchor="middle">Hᴿ</text>
<text x="88.0" y="551" class="" text-anchor="middle">Hospitalised</text>
<rect class="group" x="202" y="348" width="140" height="222" rx="7"></rect>
<text x="272.0" y="370" class="group-label" text-anchor="middle">WILL DIE</text>
<rect class="state" x="210.0" y="384" width="124" height="54" rx="5"></rect>
<text x="272.0" y="404" class="symbol" text-anchor="middle">Uᴰ</text>
<text x="272.0" y="427" class="" text-anchor="middle">Undetected</text>
<rect class="state" x="210.0" y="446" width="124" height="54" rx="5"></rect>
<text x="272.0" y="466" class="symbol" text-anchor="middle">Qᴰ</text>
<text x="272.0" y="489" class="" text-anchor="middle">Quarantined</text>
<rect class="state" x="210.0" y="508" width="124" height="54" rx="5"></rect>
<text x="272.0" y="528" class="symbol" text-anchor="middle">Hᴰ</text>
<text x="272.0" y="551" class="" text-anchor="middle">Hospitalised</text>
<rect class="state" x="22.0" y="610" width="132" height="54" rx="5"></rect>
<text x="88" y="630" class="symbol" text-anchor="middle">R</text>
<text x="88" y="653" class="" text-anchor="middle">Recovered</text>
<rect class="state" x="206.0" y="610" width="132" height="54" rx="5"></rect>
<text x="272" y="630" class="symbol" text-anchor="middle">D</text>
<text x="272" y="653" class="" text-anchor="middle">Deaths</text>
</svg>
</div>
<div class="paper-plot__footer">
<p>Note: solid arrows are flows of people between states; dashed arrows are losses of immunity, which the model allows after vaccination or recovery.</p>
</div>
</div>
</div>
<p>The economic block chooses mobility by balancing a quadratic cost of restrictions against a mortality-loss measure. A separate empirical relationship translates mobility into activity. The vaccine percentages below are <strong>scenario assumptions about protection against infection</strong>, rather than estimates of protection against hospitalisation or death.</p>
<p><a href="../pandexit-model/index.html" class="post-modal-link" data-post-modal="true">Explore the model: states, equations, and mobility choice</a></p>
</section>
<section id="vaccine-effectiveness-and-alternative-scenarios" class="level2">
<h2 class="anchored" data-anchor-id="vaccine-effectiveness-and-alternative-scenarios">Vaccine effectiveness and alternative scenarios</h2>
<p>In this model, effective vaccination removes people from the susceptible group without them having to get sick. Protection does not arrive immediately. For this 2021 exercise, the vaccination chart assumes two doses 30 days apart, with full effectiveness reached 14 days after the second dose.  shows first and second doses alongside the population effectively protected under 100%, 75%, and 50% effectiveness assumptions. The first dose contributes half of eventual effectiveness by day 30, building linearly. These illustrative percentages differ from the 95%, 60%, and 5% assumptions used in the mobility scenarios.</p>
<figure class="paper-plot figure" style="width: 100%; margin: 0 auto;"><div class="paper-plot__header"><div class="paper-plot__title">Vaccination process</div><div class="paper-plot__units">(people)</div></div><div class="paper-plot__body"><div class="paper-plotly" id="vaccines" data-paper-plotly-spec="src/graphs/vaccines.json" style="width: 100%; height: 360px;"></div></div><div class="paper-plot__footer"><div class="paper-plot__notes">Note: this figure assumes that the first dose delivers half of its effectiveness by the end of day 30, and that the effectiveness gain from the day of injection is linear. The second dose delivers full effectiveness once 14 days have passed.</div></div></figure><script type="application/json" id="vaccines__spec">{"data":[{"x":[1608786000000,1609390800000,1609995600000,1610600400000,1611205200000,1611810000000,1612414800000,1613019600000,1613624400000,1614229200000,1614834000000,1615438800000,1616043600000,1616648400000,1617253200000,1617858000000,1618462800000,1619067600000,1619672400000,1620277200000,1620882000000,1621486800000,1622091600000,1622696400000,1623301200000,1623906000000,1624510800000,1625115600000,1625720400000,1626325200000,1626930000000,1627534800000,1627707600000],"y":[420,8651,10704,12824,56581,57032,414607,1607577,2700019,3227290,3914660,4644511,5447352,6221919,6949522,7298643,7676574,7914366,8116754,8489704,9004685,9624141,10376229,11032384,11378499,11849862,12160559,12386919,12692967,13021205,13191013,13314261,13322944],"type":"scatter","visible":true,"name":"1 dose","mode":"lines"},{"x":[1608786000000,1609390800000,1609995600000,1610600400000,1611205200000,1611810000000,1612414800000,1613019600000,1613624400000,1614229200000,1614834000000,1615438800000,1616043600000,1616648400000,1617253200000,1617858000000,1618462800000,1619067600000,1619672400000,1620277200000,1620882000000,1621486800000,1622091600000,1622696400000,1623301200000,1623906000000,1624510800000,1625115600000,1625720400000,1626325200000,1626930000000,1627534800000,1627707600000],"y":[0,0,0,5828,8370,10402,12521,55596,55851,56232,389075,1544415,2715746,3215344,3851579,4511250,5289700,6033535,6726194,7099639,7466997,7723035,7933803,8252901,8733985,9299718,9866945,10393957,10769822,11228521,11504492,11749235,11820321],"type":"scatter","visible":true,"name":"2 doses","mode":"lines","showlegend":true},{"x":[1608786000000,1609390800000,1609995600000,1610600400000,1611205200000,1611810000000,1612414800000,1613019600000,1613624400000,1614229200000,1614834000000,1615438800000,1616043600000,1616648400000,1617253200000,1617858000000,1618462800000,1619067600000,1619672400000,1620277200000,1620882000000,1621486800000,1622091600000,1622696400000,1623301200000,1623906000000,1624510800000,1625115600000,1625720400000,1626325200000,1626930000000,1627534800000,1627707600000],"y":[7,953.5333333,2068.8,3597.95,9363.980952,17464.32143,32897.48571,148769.5,413020.9571,761528.8381,1184548.355,1822254.69,2696476.4,3571893.529,4283313.324,4907059.85,5577066.352,6221237.252,6783832.59,7244900.986,7626684.369,7985779.65,8346799.445,8767373.75,9236499.021,9759482.493,10287329.97,10769176.59,11202882.35,11578062.67,11908047.92,12192766.21,12266874.85],"type":"scatter","visible":true,"name":"100% effectiveness","mode":"lines","showlegend":true},{"x":[1608786000000,1609390800000,1609995600000,1610600400000,1611205200000,1611810000000,1612414800000,1613019600000,1613624400000,1614229200000,1614834000000,1615438800000,1616043600000,1616648400000,1617253200000,1617858000000,1618462800000,1619067600000,1619672400000,1620277200000,1620882000000,1621486800000,1622091600000,1622696400000,1623301200000,1623906000000,1624510800000,1625115600000,1625720400000,1626325200000,1626930000000,1627534800000,1627707600000],"y":[5.25,715.15,1551.6,2698.4625,7022.985714,13098.24107,24673.11429,111577.125,309765.7179,571146.6286,888411.2661,1366691.018,2022357.3,2678920.146,3212484.993,3680294.888,4182799.764,4665927.939,5087874.443,5433675.739,5720013.277,5989334.738,6260099.584,6575530.313,6927374.266,7319611.87,7715497.48,8076882.439,8402161.761,8683547.005,8931035.943,9144574.657,9200156.141],"type":"scatter","visible":true,"name":"75% effectiveness","mode":"lines","showlegend":true},{"x":[1608786000000,1609390800000,1609995600000,1610600400000,1611205200000,1611810000000,1612414800000,1613019600000,1613624400000,1614229200000,1614834000000,1615438800000,1616043600000,1616648400000,1617253200000,1617858000000,1618462800000,1619067600000,1619672400000,1620277200000,1620882000000,1621486800000,1622091600000,1622696400000,1623301200000,1623906000000,1624510800000,1625115600000,1625720400000,1626325200000,1626930000000,1627534800000,1627707600000],"y":[3.5,476.7666667,1034.4,1798.975,4681.990476,8732.160714,16448.74286,74384.75,206510.4786,380764.419,592274.1774,911127.3452,1348238.2,1785946.764,2141656.662,2453529.925,2788533.176,3110618.626,3391916.295,3622450.493,3813342.185,3992889.825,4173399.723,4383686.875,4618249.511,4879741.246,5143664.987,5384588.293,5601441.174,5789031.337,5954023.962,6096383.105,6133437.427],"type":"scatter","visible":true,"name":"50% effectiveness","mode":"lines","showlegend":true}],"layout":{"xaxis":{"type":"date"},"legend":{"orientation":"h"},"showlegend":true,"font":{},"margin":{"l":30,"r":30,"b":20,"t":10}},"config":{"modeBarButtonsToRemove":["zoomIn2d","zoomOut2d","autoScale2d","toggleSpikelines"],"showEditInChartStudio":false,"displaylogo":false,"responsive":true}}</script>
<p>The effects of mobility restrictions on economic activity have not been homogeneous over time.</p>
<div class="paper-plot-row" title="Mobility: economic activity and uncertainty">
<figure class="paper-plot figure" style="width: 100%; margin: 0 auto;"><div class="paper-plot__header"><div class="paper-plot__title">Mobility versus economic activity</div><div class="paper-plot__units">(percentages)</div></div><div class="paper-plot__body"><div class="paper-plotly" id="mobility-activity" data-paper-plotly-spec="src/graphs/mobility2gdp.json" style="width: 100%; height: 360px;"></div></div><div class="paper-plot__footer"><div class="paper-plot__notes">Note: observed mobility corresponds to the monthly average of the index compiled by Google. IMACEC is the percentage change, relative to the same month of the previous year, of the monthly economic activity index reported by the Central Bank of Chile.</div></div></figure><script type="application/json" id="mobility-activity__spec">{"data":[{"x":[1580533200000,1583038800000,1585717200000,1588309200000,1590987600000,1593579600000,1596258000000,1598936400000,1601528400000,1604206800000,1606798800000,1609477200000,1612155600000,1614574800000,1617253200000,1619845200000,1622523600000],"y":[3.231753939,-3.536601888,-13.81832972,-15.31430779,-13.58431153,-11.24989645,-10.90081486,-4.756740823,-0.915587313,0.978117505,-0.071983268,-2.931076689,-2.080373852,5.770488109,14.05228717,18.10372645,20.13970297],"type":"scatter","visible":true,"name":"IMACEC","mode":"lines","line":{"color":"rgb(0,113.985,188.955)","width":1.5,"dash":"solid"},"marker":{"size":6,"line":{"width":1.5},"color":"rgb(0,113.985,188.955)"},"showlegend":true},{"x":[1580533200000,1583038800000,1585717200000,1588309200000,1590987600000,1593579600000,1596258000000,1598936400000,1601528400000,1604206800000,1606798800000,1609477200000,1612155600000,1614574800000,1617253200000,1619845200000,1622523600000],"y":[-1,-22.2,-56.7,-56.2,-58,-56.3,-47.2,-43.4,-35.1,-29.5,-26.5,-35.6,-29.1,-32.8,-43.3,-27.9,-26.4],"type":"scatter","visible":true,"name":"Mobility","mode":"lines","showlegend":true}],"layout":{"xaxis":{"type":"date"},"legend":{"orientation":"h"},"showlegend":true,"font":{},"margin":{"l":30,"r":30,"b":20,"t":10}},"config":{"modeBarButtonsToRemove":["zoomIn2d","zoomOut2d","autoScale2d","toggleSpikelines"],"showEditInChartStudio":false,"displaylogo":false,"responsive":true}}</script>
<figure class="paper-plot figure" style="width: 100%; margin: 0 auto;"><div class="paper-plot__header"><div class="paper-plot__title">Mobility versus uncertainty</div><div class="paper-plot__units">(percentages, index)</div></div><div class="paper-plot__body"><div class="paper-plotly" id="mobility-depuc" data-paper-plotly-spec="src/graphs/mobility2uncertainty.json" style="width: 100%; height: 360px;"></div></div><div class="paper-plot__footer"><div class="paper-plot__notes">Note: observed mobility corresponds to the monthly moving average of the index compiled by Google. DEPUC from Becerra &amp; Sagner (2020).</div></div></figure><script type="application/json" id="mobility-depuc__spec">{"data":[{"x":[1584334800000,1584939600000,1585544400000,1586149200000,1586754000000,1587358800000,1587963600000,1588568400000,1589173200000,1589778000000,1590382800000,1590987600000,1591592400000,1592197200000,1592802000000,1593406800000,1594011600000,1594616400000,1595221200000,1595826000000,1596430800000,1597035600000,1597640400000,1598245200000,1598850000000,1599454800000,1600059600000,1600664400000,1601269200000,1601874000000,1602478800000,1603083600000,1603688400000,1604293200000,1604898000000,1605502800000,1606107600000,1606712400000,1607317200000,1607922000000,1608526800000,1609131600000,1609736400000,1610341200000,1610946000000,1611550800000,1612155600000,1612760400000,1613365200000,1613970000000,1614574800000,1615179600000,1615784400000,1616389200000,1616994000000,1617598800000,1618203600000,1618808400000,1619413200000,1620018000000,1620622800000,1621227600000,1621832400000,1622437200000,1623042000000,1623646800000,1624251600000,1624856400000,1625461200000,1626066000000,1626670800000,1626930000000],"y":[241.2197876,298.6937256,356.6352234,399.000824,426.2863159,413.079895,387.4128113,360.6925354,349.6687927,340.6147461,338.2168884,337.9399109,336.5505066,340.2736206,343.3519592,350.8057861,349.0764771,351.598175,358.6645813,360.9927063,366.3900146,344.7409668,324.6522827,296.7737732,286.4624939,277.0204468,267.4411621,262.7030029,271.8695984,265.8284302,284.7135315,294.6546936,299.3390808,313.3572998,306.1043091,330.1104431,348.7792969,337.8291016,354.0351257,335.000946,347.9959412,330.9408569,327.2897339,327.725769,309.4490356,297.3968811,284.9848328,249.6224823,222.7664642,207.4272766,185.9187927,205.7169495,215.8719025,228.5828552,247.7012634,261.2617493,268.9935303,264.7944946,260.9469604,266.8250732,255.7726593,261.3600159,244.187149,218.8134613,214.8224945,209.3043671,204.3713074,208.1658325,227.7584991,231.5237427,237.9663391,237.4284058],"type":"scatter","visible":true,"name":"DEPUC","mode":"lines","line":{"color":"rgb(0,113.985,188.955)","width":1.5,"dash":"solid"},"marker":{"size":6,"line":{"width":1.5},"color":"rgb(0,113.985,188.955)"},"showlegend":true},{"x":[1584334800000,1584939600000,1585544400000,1586149200000,1586754000000,1587358800000,1587963600000,1588568400000,1589173200000,1589778000000,1590382800000,1590987600000,1591592400000,1592197200000,1592802000000,1593406800000,1594011600000,1594616400000,1595221200000,1595826000000,1596430800000,1597035600000,1597640400000,1598245200000,1598850000000,1599454800000,1600059600000,1600664400000,1601269200000,1601874000000,1602478800000,1603083600000,1603688400000,1604293200000,1604898000000,1605502800000,1606107600000,1606712400000,1607317200000,1607922000000,1608526800000,1609131600000,1609736400000,1610341200000,1610946000000,1611550800000,1612155600000,1612760400000,1613365200000,1613970000000,1614574800000,1615179600000,1615784400000,1616389200000,1616994000000,1617598800000,1618203600000,1618808400000,1619413200000,1620018000000,1620622800000,1621227600000,1621832400000,1622437200000,1623042000000,1623646800000,1624251600000,1624856400000,1625461200000,1626066000000,1626670800000,1626930000000],"y":[1.462365591,-7.451612903,-20.22580645,-34.53763441,-49.78494624,-57.43010753,-57.40860215,-56.5483871,-54.58064516,-54.09677419,-55.40860215,-55.49462366,-56.90322581,-57.60215054,-56.70967742,-57.64516129,-57.95698925,-57.94623656,-58.13978495,-57.3655914,-55.52688172,-54.07526882,-51.5483871,-49.30107527,-47.23655914,-45.27956989,-43.59139785,-44.61290323,-43.56989247,-42.33333333,-42.08602151,-40.07526882,-36.30107527,-34.80645161,-33.30107527,-31.11827957,-29.98924731,-29.66666667,-27.82795699,-28.20430108,-26.08602151,-26.96774194,-29.50537634,-29.96774194,-32.09677419,-34.03225806,-34,-34.59139785,-34.10752688,-32.3655914,-29.84946237,-27.86021505,-27.1827957,-28.05376344,-32.1827957,-37.92473118,-41.92473118,-44.70967742,-45.75268817,-42.51612903,-38.5483871,-34.98924731,-31.97849462,-27.92473118,-24.75268817,-24.19354839,-24.25806452,-26.67741935,-26.48387097,-24.78494624,-22.69892473,-19.69892473],"type":"scatter","visible":true,"name":"Mobility","mode":"lines","showlegend":true,"yaxis":"y2"}],"layout":{"yaxis2":{"overlaying":"y","side":"right"},"xaxis":{"type":"date"},"legend":{"orientation":"h"},"showlegend":true,"font":{},"margin":{"l":30,"r":30,"b":20,"t":10}},"config":{"modeBarButtonsToRemove":["zoomIn2d","zoomOut2d","autoScale2d","toggleSpikelines"],"showEditInChartStudio":false,"displaylogo":false,"responsive":true}}</script>
</div>
<figure class="paper-plot figure" style="width: 100%; margin: 0 auto;"><div class="paper-plot__header"><div class="paper-plot__title">Relationship between activity and mobility</div><div class="paper-plot__units">(percentages)</div></div><div class="paper-plot__body"><div class="paper-plotly" id="mobility-activity-coefficient" data-paper-plotly-spec="src/graphs/mobility2gdpCoefficient.json" style="width: 100%; height: 360px;"></div></div><div class="paper-plot__footer"><div class="paper-plot__notes">Note: the chart shows the coefficient from a regression of activity on mobility plus a constant. This regression was estimated using 8-observation rolling windows.</div></div></figure><script type="application/json" id="mobility-activity-coefficient__spec">{"data":[{"x":[1598936400000,1601528400000,1604206800000,1606798800000,1609477200000,1612155600000,1614574800000,1617253200000,1619845200000,1622523600000],"y":[0.2958986,0.366654,0.5518182,0.4996178,0.4644271,0.4238129,0.5015372,-0.2705503,-0.304273,-0.0124584],"type":"scatter","visible":true,"name":"Mobility","mode":"lines","line":{"width":1.5,"dash":"solid"},"showlegend":true},{"x":[1598936400000,1601528400000,1604206800000,1606798800000,1609477200000,1612155600000,1614574800000,1617253200000,1619845200000,1622523600000],"y":[0.3765468,0.5366064,0.673113,0.6207578,0.5738527,0.5615763,0.862387,0.4786189,0.8459476,1.3176376],"type":"scatter","visible":true,"name":"CI1","mode":"lines","line":{"color":"rgb(50,50,50)","width":0,"dash":"solid"},"showlegend":false},{"x":[1598936400000,1601528400000,1604206800000,1606798800000,1609477200000,1612155600000,1614574800000,1617253200000,1619845200000,1622523600000],"y":[0.2152504,0.1967016,0.4305234,0.3784778,0.3550015,0.2860495,0.1406874,-1.0197195,-1.4544936,-1.3425544],"type":"scatter","visible":true,"name":"Confidence interval","fill":"tonexty","mode":"lines","line":{"color":"rgb(50,50,50)","width":0,"dash":"solid"}}],"layout":{"xaxis":{"type":"date"},"legend":{"orientation":"h"},"showlegend":true,"margin":{"l":20,"r":0,"b":20,"t":30,"pad":0},"font":{}},"config":{"modeBarButtonsToRemove":["zoomIn2d","zoomOut2d","autoScale2d","toggleSpikelines"],"showEditInChartStudio":false,"displaylogo":false,"responsive":true}}</script>
<figure class="paper-plot figure" style="width: 100%; margin: 0 auto;"><div class="paper-plot__header"><div class="paper-plot__title">Return to pre-pandemic mobility</div><div class="paper-plot__units">(percentage deviations from normal)</div></div><div class="paper-plot__body"><div class="paper-plotly" id="mobility" data-paper-plotly-spec="src/graphs/efficacy.json" style="width: 100%; height: 360px;"></div></div><div class="paper-plot__footer"><div class="paper-plot__notes">Note: observed mobility corresponds to the moving average of the index compiled by Google. The 95% line corresponds to the mobility projection using information through December 20, 2020 and assuming vaccine effectiveness of around 95%. The 60% and 5% calculations are analogous to the 95% one.</div></div></figure><script type="application/json" id="mobility__spec">{"data":[{"x":[1584248400000,1584853200000,1585458000000,1586062800000,1586667600000,1587272400000,1587877200000,1588482000000,1589086800000,1589691600000,1590296400000,1590901200000,1591506000000,1592110800000,1592715600000,1593320400000,1593925200000,1594530000000,1595134800000,1595739600000,1596344400000,1596949200000,1597554000000,1598158800000,1598763600000,1599368400000,1599973200000,1600578000000,1601182800000,1601787600000,1602392400000,1602997200000,1603602000000,1604206800000,1604811600000,1605416400000,1606021200000,1606626000000,1607230800000,1607835600000,1608440400000,1609045200000,1609650000000,1610254800000,1610859600000,1611464400000,1612069200000,1612674000000,1613278800000,1613883600000,1614488400000,1615093200000,1615698000000,1616302800000,1616907600000,1617512400000,1618117200000,1618722000000,1619326800000,1619931600000,1620536400000,1621141200000,1621746000000,1622350800000,1622955600000,1623560400000,1624165200000,1624770000000,1625374800000,1625979600000,1626584400000,1627189200000,1627794000000,1628398800000,1629003600000,1629608400000,1630213200000,1630818000000,1631422800000,1632027600000,1632632400000,1633237200000,1633842000000,1634446800000,1635051600000,1635656400000,1636261200000,1636866000000,1637470800000,1638075600000,1638680400000,1639285200000,1639890000000,1640494800000,1640926800000],"y":[3.42857142857143,-36.0952380952381,-56.2380952380952,-57.2380952380952,-62.2380952380952,-55.8095238095238,-54.5714285714286,-54.9047619047619,-50,-55.952380952381,-61.2380952380952,-56.3333333333333,-55.8095238095238,-56.7142857142857,-57.3809523809524,-59.1428571428571,-60.2380952380952,-56.3333333333333,-58.3809523809524,-55.3333333333333,-52.4761904761905,-50.8095238095238,-47.5238095238095,-46.1428571428571,-44.7619047619048,-42.8571428571428,-41.4285714285714,-49.6190476190476,-41.3809523809524,-38.3809523809524,-36.2857142857143,-39.5238095238095,-30.2857142857143,-32.6190476190476,-30.047619047619,-29.8095238095238,-29.1904761904762,-28.6190476190476,-23.9047619047619,-32,-22.047619047619,-31.1904761904762,-36.0952380952381,-28.7619047619047,-33.3333333333333,-35.6666666666666,-35.7619047619047,-32.8571428571428,-29.8571428571428,-28.6666666666666,-24.8571428571428,-25.6190476190476,-28.8095238095238,-31.1428571428571,-43.3333333333333,-47.8095238095238,-44.4761904761905,-43.3333333333333,-41.047619047619,-39.047619047619,-29.2380952380952,-29.6190476190476,-28.9047619047619,-20.6666666666666,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"type":"scatter","visible":true,"name":"Observed"},{"x":[1584248400000,1584853200000,1585458000000,1586062800000,1586667600000,1587272400000,1587877200000,1588482000000,1589086800000,1589691600000,1590296400000,1590901200000,1591506000000,1592110800000,1592715600000,1593320400000,1593925200000,1594530000000,1595134800000,1595739600000,1596344400000,1596949200000,1597554000000,1598158800000,1598763600000,1599368400000,1599973200000,1600578000000,1601182800000,1601787600000,1602392400000,1602997200000,1603602000000,1604206800000,1604811600000,1605416400000,1606021200000,1606626000000,1607230800000,1607835600000,1608440400000,1609045200000,1609650000000,1610254800000,1610859600000,1611464400000,1612069200000,1612674000000,1613278800000,1613883600000,1614488400000,1615093200000,1615698000000,1616302800000,1616907600000,1617512400000,1618117200000,1618722000000,1619326800000,1619931600000,1620536400000,1621141200000,1621746000000,1622350800000,1622955600000,1623560400000,1624165200000,1624770000000,1625374800000,1625979600000,1626584400000,1627189200000,1627794000000,1628398800000,1629003600000,1629608400000,1630213200000,1630818000000,1631422800000,1632027600000,1632632400000,1633237200000,1633842000000,1634446800000,1635051600000,1635656400000,1636261200000,1636866000000,1637470800000,1638075600000,1638680400000,1639285200000,1639890000000,1640494800000,1640926800000],"y":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,-22.047619047619,-19,-15,-15,-16,-16,-16,-16,-15,-14,-13,-11,-9,-7,-6,-4,-3,-2,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"scatter","visible":true,"name":"95%","mode":"lines"},{"x":[1584248400000,1584853200000,1585458000000,1586062800000,1586667600000,1587272400000,1587877200000,1588482000000,1589086800000,1589691600000,1590296400000,1590901200000,1591506000000,1592110800000,1592715600000,1593320400000,1593925200000,1594530000000,1595134800000,1595739600000,1596344400000,1596949200000,1597554000000,1598158800000,1598763600000,1599368400000,1599973200000,1600578000000,1601182800000,1601787600000,1602392400000,1602997200000,1603602000000,1604206800000,1604811600000,1605416400000,1606021200000,1606626000000,1607230800000,1607835600000,1608440400000,1609045200000,1609650000000,1610254800000,1610859600000,1611464400000,1612069200000,1612674000000,1613278800000,1613883600000,1614488400000,1615093200000,1615698000000,1616302800000,1616907600000,1617512400000,1618117200000,1618722000000,1619326800000,1619931600000,1620536400000,1621141200000,1621746000000,1622350800000,1622955600000,1623560400000,1624165200000,1624770000000,1625374800000,1625979600000,1626584400000,1627189200000,1627794000000,1628398800000,1629003600000,1629608400000,1630213200000,1630818000000,1631422800000,1632027600000,1632632400000,1633237200000,1633842000000,1634446800000,1635051600000,1635656400000,1636261200000,1636866000000,1637470800000,1638075600000,1638680400000,1639285200000,1639890000000,1640494800000,1640926800000],"y":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,-22.047619047619,-21,-19,-19,-19,-20,-21,-21,-21,-20,-19,-18,-16,-15,-13,-11,-9,-8,-5.99999999999999,-4.99999999999999,-3,-2,-2,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"scatter","visible":true,"name":"60%","mode":"lines"},{"x":[1584248400000,1584853200000,1585458000000,1586062800000,1586667600000,1587272400000,1587877200000,1588482000000,1589086800000,1589691600000,1590296400000,1590901200000,1591506000000,1592110800000,1592715600000,1593320400000,1593925200000,1594530000000,1595134800000,1595739600000,1596344400000,1596949200000,1597554000000,1598158800000,1598763600000,1599368400000,1599973200000,1600578000000,1601182800000,1601787600000,1602392400000,1602997200000,1603602000000,1604206800000,1604811600000,1605416400000,1606021200000,1606626000000,1607230800000,1607835600000,1608440400000,1609045200000,1609650000000,1610254800000,1610859600000,1611464400000,1612069200000,1612674000000,1613278800000,1613883600000,1614488400000,1615093200000,1615698000000,1616302800000,1616907600000,1617512400000,1618117200000,1618722000000,1619326800000,1619931600000,1620536400000,1621141200000,1621746000000,1622350800000,1622955600000,1623560400000,1624165200000,1624770000000,1625374800000,1625979600000,1626584400000,1627189200000,1627794000000,1628398800000,1629003600000,1629608400000,1630213200000,1630818000000,1631422800000,1632027600000,1632632400000,1633237200000,1633842000000,1634446800000,1635051600000,1635656400000,1636261200000,1636866000000,1637470800000,1638075600000,1638680400000,1639285200000,1639890000000,1640494800000,1640926800000],"y":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,-22.047619047619,-27,-29,-31,-33,-33,-34,-35,-35,-36,-36,-35,-35,-35,-35,-34,-34,-33,-33,-32,-31,-30,-29,-29,-28,-27,-26,-25,-24,-23,-23,-21,-21,-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-10,-9,-8,-6.99999999999999,-6.99999999999999,-5.99999999999999,-4.99999999999999,-4.99999999999999,-4,-4,-3],"type":"scatter","visible":true,"name":"5%","mode":"lines"}],"layout":{"xaxis":{"type":"date"},"legend":{"orientation":"h"},"showlegend":true,"font":{},"margin":{"l":30,"r":30,"b":20,"t":10}},"config":{"modeBarButtonsToRemove":["zoomIn2d","zoomOut2d","autoScale2d","toggleSpikelines"],"showEditInChartStudio":false,"displaylogo":false,"responsive":true}}</script>
<p>The observed mobility figures show that there are factors that have changed drastically relative to the base scenario.<sup>1</sup> These factors cannot be identified without assuming a vaccine efficacy and, therefore, are not estimated in our analysis. The contagion rate estimated when assuming 95% efficacy is 6 times higher than the maximum recorded before the vaccination process began. We interpret this as the model rejecting the 95%-efficacy hypothesis.</p>
<p>The vaccination chart illustrates a timing issue that the mobility counterfactuals do not separately model: the delay between inoculation and effective protection. Under the two-dose schedule assumed here, full protection takes about a month and a half from the first injection. The vaccination illustration should therefore not be read as a separate dose-by-dose model underlying the mobility projections.</p>
</section>
<section id="conclusion" class="level2">
<h2 class="anchored" data-anchor-id="conclusion">Conclusion</h2>
<p>Chile’s rapid vaccination campaign means that a return to normality may finally be getting close. But <strong>how close depends critically on how effective vaccines are at preventing contagion</strong>. If vaccination substantially weakens the link between mobility and infections, restrictions can be relaxed sooner and economic activity can recover faster. If it does not, the <em>pandexit</em> will take longer.</p>
<p>Our estimates suggest that the difference could be economically meaningful. Under the 95%-efficacy scenario, mobility returns to normal roughly a month and a half earlier than under the 60% scenario. Over the following six months, this translates into an average mobility gap of about 4.7 percentage points and, using our estimated relationship between mobility and activity, <strong>around 0.4–0.6 percentage points of annual GDP growth</strong>.</p>
<p>That last calculation should be taken with a grain of salt. The regressions relating mobility to economic activity are deliberately simple and leave out many factors that changed simultaneously during the pandemic—fiscal support, uncertainty, firms’ and households’ adaptation, external conditions, and the composition of restrictions, among others. These omitted variables may bias the estimated relationship between mobility and activity. <strong>The GDP figures should therefore be read as an illustration of the possible economic magnitude of a delayed <em>pandexit</em>, rather than as a causal estimate.</strong></p>
<p>The data arriving as the vaccination campaign progresses also give us reasons to be cautious about the most optimistic epidemiological scenario. Matching observed mobility under the assumption of 95% effectiveness against contagion requires a contagion rate around six times higher than anything estimated before vaccination began. Within the model, this makes the 95% scenario increasingly difficult to reconcile with what we are seeing.</p>
<p>The next few months will therefore be particularly informative. As vaccination advances and more data become available, we should learn much more about how strongly vaccines break the connection between mobility and contagion. <strong>That connection will help determine not only when Chile can return to normal, but also how much economic activity is lost on the way there.</strong></p>
<section id="our-world-in-data" class="level3">
<h3 class="anchored" data-anchor-id="our-world-in-data">Our World in Data</h3>
<div class="wide embed-row">
<iframe title="People vaccinated by dose, per 100 people" src="https://ourworldindata.org/explorers/coronavirus-data-explorer?zoomToSelection=true&amp;pickerSort=desc&amp;pickerMetric=population&amp;hideControls=true&amp;Metric=People+vaccinated+%28by+dose%29&amp;Interval=Cumulative&amp;Relative+to+Population=true&amp;Align+outbreaks=true&amp;country=BRA~CHL~FRA~DEU~ISR~GBR~USA~URY~ESP~ITA~ARE" loading="lazy" style="width: 100%; height: 440px; border: 0px none;">
</iframe>
<iframe title="Daily new confirmed COVID-19 deaths per million people" src="https://ourworldindata.org/explorers/coronavirus-data-explorer?zoomToSelection=true&amp;pickerSort=desc&amp;pickerMetric=total_deaths&amp;hideControls=true&amp;Metric=Confirmed+deaths&amp;Interval=7-day+rolling+average&amp;Relative+to+Population=true&amp;Align+outbreaks=false&amp;country=BRA~CHL~FRA~DEU~ISR~GBR~USA~URY~ESP~ITA~ARE" loading="lazy" style="width: 100%; height: 440px; border: 0px none;">
</iframe>
</div>
<div class="site-disclaimer">
<p>This is my personal website. The views and opinions expressed here are my own and do not necessarily represent those of the Central Bank of Chile or its Board. Any errors, unfinished thoughts, questionable code, and overly complicated solutions found here are, of course, my own.</p>
</div>
</section>
</section>
<section id="references" class="level2">
<h2 class="anchored" data-anchor-id="references">References</h2>
<div id="refs" class="references csl-bib-body hanging-indent">
<div id="ref-Rungcharoenkitkul2021" class="csl-entry">
<span class="smallcaps">Rungcharoenkitkul, P.</span> (2021): <a href="https://www.bis.org/publ/work932.htm">Macroeconomic Consequences of Pandexit</a>, BIS Working Papers, Bank for International Settlements.
</div>
</div>


</section>


<div id="quarto-appendix" class="default"><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>The base projection scenario uses estimates with data through December 20, 2020. After that, all shock innovations are assumed to disappear.↩︎</p></li>
</ol>
</section></div> ]]></description>
  <category>COVID-19</category>
  <category>Economics</category>
  <guid>https://www.nicolasfranzpattillo.com/posts/published/covid19-vaccines/</guid>
  <pubDate>Sun, 01 Aug 2021 00:00:00 GMT</pubDate>
  <media:content url="https://www.nicolasfranzpattillo.com/posts/published/covid19-vaccines/src/cover.webp" medium="image" type="image/webp"/>
</item>
<item>
  <title>The Pandexit model: states, equations, and mobility choice</title>
  <dc:creator>Nicolas Franz-Pattillo</dc:creator>
  <link>https://www.nicolasfranzpattillo.com/posts/published/pandexit-model/</link>
  <description><![CDATA[ 






<p>This is a companion piece to <a href="../covid19-vaccines/index.html">COVID-19 Pandexit and the effects on economic activity</a>, covering the underlying epidemiological model in full.</p>
<p>This is a restatement of the core framework in <span class="citation" data-cites="Rungcharoenkitkul2021">Rungcharoenkitkul (2021)</span>, sections 2.1–2.2, checked against the author’s <a href="https://github.com/phurichai/covid19macro/blob/b2f89d7d45e5cfffcfb08e11c983f1c67433b845/codes/seir_simple.py">public implementation</a>. The notation below groups the six isolation equations to make the population accounting easier to follow.</p>
<p><strong>States and notation</strong></p>
<p>Each state is a number of people; one period is one day. Write <img src="https://latex.codecogs.com/png.latex?%5CDelta%20X_%7Bt+1%7D=X_%7Bt+1%7D-X_t">.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">State</th>
<th style="text-align: left;">Interpretation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><img src="https://latex.codecogs.com/png.latex?S_t"></td>
<td style="text-align: left;">Susceptible</td>
</tr>
<tr class="even">
<td style="text-align: left;"><img src="https://latex.codecogs.com/png.latex?E_t"></td>
<td style="text-align: left;">Exposed, not yet infectious</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><img src="https://latex.codecogs.com/png.latex?I_t"></td>
<td style="text-align: left;">Infectious and able to transmit</td>
</tr>
<tr class="even">
<td style="text-align: left;"><img src="https://latex.codecogs.com/png.latex?U%5ER_t,%5C%20Q%5ER_t,%5C%20H%5ER_t"></td>
<td style="text-align: left;">Isolated and eventually recovering: undetected, quarantined, hospitalised</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><img src="https://latex.codecogs.com/png.latex?U%5ED_t,%5C%20Q%5ED_t,%5C%20H%5ED_t"></td>
<td style="text-align: left;">Isolated and eventually dying, in the same three settings</td>
</tr>
<tr class="even">
<td style="text-align: left;"><img src="https://latex.codecogs.com/png.latex?R_t"></td>
<td style="text-align: left;">Recovered and immune</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><img src="https://latex.codecogs.com/png.latex?D_t"></td>
<td style="text-align: left;">Cumulative deaths</td>
</tr>
<tr class="even">
<td style="text-align: left;"><img src="https://latex.codecogs.com/png.latex?V_t"></td>
<td style="text-align: left;">Effectively vaccinated and immune</td>
</tr>
</tbody>
</table>
<p>The twelve compartments sum to the initial population <img src="https://latex.codecogs.com/png.latex?N">, including deaths. The public code also tracks auxiliary series, such as cumulative detected cases; these are not additional mutually exclusive population compartments.</p>
<p><strong>Infection and vaccination</strong></p>
<p>Let <img src="https://latex.codecogs.com/png.latex?F_t"> be new exposures and <img src="https://latex.codecogs.com/png.latex?%5Cnu_t"> the daily flow of susceptible people gaining vaccine protection. With <img src="https://latex.codecogs.com/png.latex?%5Csigma"> the incubation-transition rate, <img src="https://latex.codecogs.com/png.latex?%5Cdelta"> the isolation-transition rate, and <img src="https://latex.codecogs.com/png.latex?%5Comega"> the immunity-loss rate:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AF_t=%5Cgamma_t%5Cfrac%7BS_tI_t%7D%7BN%7D,%5Cqquad%0A%5Cbegin%7Baligned%7D%0A%5CDelta%20S_%7Bt+1%7D&amp;=-F_t-%5Cnu_t+%5Comega(R_t+V_t),%5C%5C%0A%5CDelta%20E_%7Bt+1%7D&amp;=F_t-%5Csigma%20E_t,%5C%5C%0A%5CDelta%20I_%7Bt+1%7D&amp;=%5Csigma%20E_t-%5Cdelta%20I_t,%5C%5C%0A%5CDelta%20V_%7Bt+1%7D&amp;=%5Cnu_t-%5Comega%20V_t.%0A%5Cend%7Baligned%7D%0A"></p>
<p>Here <img src="https://latex.codecogs.com/png.latex?%5Cnu_t"> measures effective protection, not injections: an efficacy assumption scales the vaccination input. A delay can be represented in that input without adding compartments. The displayed core equations allocate vaccination to susceptible people; the upstream code also offers allocation across susceptible and recovered people. Setting <img src="https://latex.codecogs.com/png.latex?%5Comega=0"> rules out waning immunity. Flows must be bounded so no compartment becomes negative.</p>
<p><strong>Isolation, recovery, and deaths</strong></p>
<p>Let <img src="https://latex.codecogs.com/png.latex?q"> be detection probability, <img src="https://latex.codecogs.com/png.latex?h"> hospitalisation probability conditional on detection, and <img src="https://latex.codecogs.com/png.latex?p_t"> eventual death probability after infection. Define the allocation weights</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Aw_U=1-q,%5Cqquad%20w_Q=q(1-h),%5Cqquad%20w_H=qh.%0A"></p>
<p>For each <img src="https://latex.codecogs.com/png.latex?j%5Cin%5C%7BU,Q,H%5C%7D">, the two equations</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A%5CDelta%20j%5ER_%7Bt+1%7D&amp;=%5Cdelta(1-p_t)w_jI_t-%5Crho_j%20j%5ER_t,%5C%5C%0A%5CDelta%20j%5ED_%7Bt+1%7D&amp;=%5Cdelta%20p_tw_jI_t-%5Cmu%20j%5ED_t%0A%5Cend%7Baligned%7D%0A"></p>
<p>represent six state transitions. The recovery rates satisfy <img src="https://latex.codecogs.com/png.latex?%5Crho_U=%5Crho_Q=%5Crho">, while hospital recovery uses <img src="https://latex.codecogs.com/png.latex?%5Crho_H">; <img src="https://latex.codecogs.com/png.latex?%5Cmu"> is the death-transition rate. The remaining two equations are</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A%5CDelta%20R_%7Bt+1%7D&amp;=%5Crho(U%5ER_t+Q%5ER_t)+%5Crho_H%20H%5ER_t-%5Comega%20R_t,%5C%5C%0A%5CDelta%20D_%7Bt+1%7D&amp;=%5Cmu(U%5ED_t+Q%5ED_t+H%5ED_t).%0A%5Cend%7Baligned%7D%0A"></p>
<p>Summing all twelve changes gives zero. The outcome superscripts are accounting categories, not assumptions that an individual’s outcome is observed in advance.</p>
<p><strong>Mobility and the policy rule</strong></p>
<p>Mobility <img src="https://latex.codecogs.com/png.latex?m_t%5Cin%5B-1,0%5D"> is a fractional deviation from normal: <img src="https://latex.codecogs.com/png.latex?-0.1"> means 10% below normal. Its contribution to transmission is exponential:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cgamma_t(m_t)=%5Cbeta_0%20e%5E%7B%5Cbeta_1m_t%7D+z_t,%0A%5Cqquad%20%5Cbeta_0,%5Cbeta_1%3E0.%0A"></p>
<p>The residual <img src="https://latex.codecogs.com/png.latex?z_t"> captures transmission changes not explained by mobility. The paper’s baseline projection uses a mean-reverting residual, <img src="https://latex.codecogs.com/png.latex?z_t=%5Cvarrho%20z_%7Bt-1%7D+%5Cvarepsilon_t">, with future innovations set to zero. This still allows the inherited residual to decay gradually.</p>
<p>Writing <img src="https://latex.codecogs.com/png.latex?s_t=S_t/N"> and <img src="https://latex.codecogs.com/png.latex?i_t=I_t/N">, the reduced policy block uses the mortality-loss measure</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidetilde%20d_t(m)=p_t%5Cdelta%20i_t%0A%5Cleft%5B1-%5Cdelta+%5Cgamma_t(m)s_t%5Cright%5D.%0A"></p>
<p>This is the policy rule’s mortality measure, <strong>not</strong> observed daily deaths <img src="https://latex.codecogs.com/png.latex?%5CDelta%20D_%7Bt+1%7D/N">. The mobility decision balances it against the cost of restrictions:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Am_t%5E*%5Cin%5Cunderset%7B-1%5Cle%20m%5Cle0%7D%7B%5Coperatorname%7Bargmin%7D%7D%0A%5Cleft%5C%7B%5Cwidetilde%20d_t(m)%5E2+%5Cvarphi%20m%5E2%5Cright%5C%7D,%0A%5Cqquad%20%5Cvarphi%3E0.%0A"></p>
<p>An interior choice satisfies</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A-%5Cvarphi%20m_t=%0A%5Cwidetilde%20d_t(m_t)%5C,%0A%5Cunderbrace%7Bp_t%5Cdelta%20i_t%20s_t%5Cbeta_0%5Cbeta_1e%5E%7B%5Cbeta_1m_t%7D%7D_%7B%5Cpartial%5Cwidetilde%20d_t/%5Cpartial%20m_t%7D.%0A"></p>
<p>Boundary choices must also be considered. The upstream numerical routine searches a mobility grid for the smallest first-order-condition residual. This is the source’s reduced policy rule, rather than a newly solved full dynamic-planning problem.</p>
<p>A useful summary of epidemic pressure is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathcal%20R_t%5E%7B%5Cmathrm%7Beff%7D%7D=%0A%5Cfrac%7B%5Cgamma_t%7D%7B%5Cdelta%7D%5Cfrac%7BS_t%7D%7BN%7D.%0A"></p>
<p>Reducing mobility lowers <img src="https://latex.codecogs.com/png.latex?%5Cgamma_t">; effective vaccination lowers <img src="https://latex.codecogs.com/png.latex?S_t">. Both can push this quantity below one, when the combined exposed-and-infectious pool starts shrinking.</p>
<p><strong>From mobility to activity</strong></p>
<p>The activity calculation is a separate empirical step. The rolling regressions below estimate an intercept and a mobility coefficient using eight monthly observations. For a scenario comparison, the approximation is <img src="https://latex.codecogs.com/png.latex?%5CDelta%20y_t%5Csimeq%5Cwidehat%20b_t%5CDelta%20m_t">, with mobility and activity changes expressed in consistent percentage-point units. It is an estimated association, not an additional epidemiological equation or a causal identification result.</p>
<p>The 95%, 60%, and 5% mobility paths keep the vaccination scenario comparable while varying assumed protection against infection. This section documents their model framework; it does not supply a new calibration or re-estimate the historical charts.</p>
<div class="site-disclaimer">
<p>This is my personal website. The views and opinions expressed here are my own and do not necessarily represent those of the Central Bank of Chile or its Board. Any errors, unfinished thoughts, questionable code, and overly complicated solutions found here are, of course, my own.</p>
</div>
<section id="references" class="level2">
<h2 class="anchored" data-anchor-id="references">References</h2>
<div id="refs" class="references csl-bib-body hanging-indent">
<div id="ref-Rungcharoenkitkul2021" class="csl-entry">
<span class="smallcaps">Rungcharoenkitkul, P.</span> (2021): <a href="https://www.bis.org/publ/work932.htm">Macroeconomic Consequences of Pandexit</a>, BIS Working Papers, Bank for International Settlements.
</div>
</div>


</section>

 ]]></description>
  <category>COVID-19</category>
  <category>Economics</category>
  <category>Methodology</category>
  <guid>https://www.nicolasfranzpattillo.com/posts/published/pandexit-model/</guid>
  <pubDate>Sun, 01 Aug 2021 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Git for economists</title>
  <dc:creator>Nicolas Franz-Pattillo</dc:creator>
  <link>https://www.nicolasfranzpattillo.com/posts/published/git-for-economists/</link>
  <description><![CDATA[ 






<div class="page-hero column-screen"><img src="https://www.nicolasfranzpattillo.com/posts/published/git-for-economists/src/cover.webp" alt="A coloured railway diagram of the lines around Clapham Junction in London: tracks of five railway companies split apart, cross and rejoin at a dozen labelled junctions. Railway Clearing House, junction diagram of Clapham Junction, Stewarts Lane, Lavender Hill &amp; Longhedge, 1912 (detail) — public domain, via Wikimedia Commons." style="object-position: 50% 55%"><div class="page-hero__credit">Railway Clearing House, junction diagram of Clapham Junction, Stewarts Lane, Lavender Hill &amp; Longhedge, 1912 (detail) — public domain, via Wikimedia Commons.</div></div>
<p>Here is a folder I used to keep on my computer. I suspect you have one like it.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://www.nicolasfranzpattillo.com/posts/published/git-for-economists/src/projectBeforeGit.png" class="img-fluid figure-img" alt="A Finder window showing folders named 20200728Project, 20200815Project, 20200905Project and 20200925Project, and inside the current project the files Project.tex, Project final.tex, Project final V2.tex, main.m, main_alternative calibration.m and solution_chevicehv(not working).m."></p>
<figcaption>A research project before version control: one folder per date, and inside the latest one, “Project.tex”, “Project final.tex” and “Project final V2.tex”, next to “solution_chevicehv(not working).m”.</figcaption>
</figure>
</div>
<p>Every folder is a snapshot of the project on some date. Every file with “final” in its name was final until it wasn’t. One script is labelled “not working”, and I no longer remember why I kept it. Somewhere in there is the version of the code that produced the figures in the draft I sent to my advisor, and I couldn’t tell you which one.</p>
<p>This post is a short version of a talk I gave to economists about <strong>version control</strong>, and about Git in particular. The original <a href="https://nicofranzp.github.io/Git4Econ/">slides</a> are in Spanish.</p>
<section id="our-projects-are-software-projects-now" class="level2">
<h2 class="anchored" data-anchor-id="our-projects-are-software-projects-now">Our projects are software projects now</h2>
<p>Not long ago a research project was a paper and maybe a do-file. Today it is rarely one file. It has text, data, tables and figures, and programs in Stata, MATLAB, Python, R or EViews. It usually has more than one author. More and more, the output is not a static document but a web app or a dashboard.</p>
<p>That is the situation software developers have been in for decades: many files, many people, and a constant need to move forward without breaking what already works. They have spent those decades building tools for it. Economists mostly haven’t adopted them, and we pay for it in three ways:</p>
<ul>
<li><strong>Innovating is risky.</strong> Trying a new specification means editing code that works. If the experiment fails, getting back to where you were depends on memory and on how disciplined you were about copying folders.</li>
<li><strong>Collaboration and replication suffer.</strong> Emailing files, sharing a Dropbox folder, or using Word’s track changes all work up to a point. None of them tells you which version of the code produced which result.</li>
<li><strong>History gets lost.</strong> Usually in a folder called <code>old</code>. Or in the code itself, as hundreds of commented-out lines that “might be useful later”. I call this <em>computational Diogenes syndrome</em>: hoarding dead code because deleting it feels like losing it.</li>
</ul>
<p>Version control solves all three. One caveat before going further: version control is designed for <strong>code and text</strong>, not for data. Large or binary files belong somewhere else.</p>
</section>
<section id="a-little-vocabulary" class="level2">
<h2 class="anchored" data-anchor-id="a-little-vocabulary">A little vocabulary</h2>
<p>Version control systems share a common vocabulary, the same way most programming languages share <code>if</code>, <code>for</code> and <code>while</code>. Three words go a long way:</p>
<ul>
<li>A <strong>commit</strong> is a snapshot of the project at a moment in time, with a message saying what changed and why.</li>
<li>A <strong>repository</strong> (“repo”) is the whole project, including its full history of commits.</li>
<li>The <strong>working copy</strong> is the version of the project you are currently looking at and editing.</li>
</ul>
<p>The important word is <em>commit</em>. It is not an autosave. You decide when a change is ready and commit to it, the way you would sign off on a version. Your editor can keep saving temporary copies as it likes; version control works on top of that and doesn’t interfere.</p>
<p>Systems differ in where the repository lives:</p>
<ul>
<li><strong>Local</strong> systems keep the repository on your computer only. They track history but don’t help you collaborate.</li>
<li><strong>Centralized</strong> systems keep the repository on a server and give each person a working copy. Everyone commits to the server and updates from it. Collaboration is easy, but everything depends on that one server.</li>
<li><strong>Distributed</strong> systems give every person a complete copy of the repository, history included. You commit locally, then <strong>push</strong> your commits to a shared server; your coauthors <strong>pull</strong> them from there. There are a couple more steps, but nothing is lost if the server dies, and you can browse the whole history offline.</li>
</ul>
<p>The distributed model won. Git, the system almost everyone uses today, is distributed.</p>
</section>
<section id="git-is-not-github" class="level2">
<h2 class="anchored" data-anchor-id="git-is-not-github">Git is not GitHub</h2>
<p>Git is software that you install on your computer. It was written in 2005 by Linus Torvalds to manage the development of Linux, and it is now by far the most widely used version control system. You don’t need a server or an internet connection to use it. You may already have it: it ships with macOS’s command line tools, with Anaconda, and with recent versions of MATLAB. Type this in a terminal to check:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">$</span> git <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--version</span></span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> version 2.39.5 <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Apple</span> Git-154<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span></code></pre></div></div>
<p><strong>GitHub</strong> is a website built on top of Git. It hosts repositories so people can share them, and adds what a team needs around the code: access control, issue tracking, task boards, automated builds and wikis. Think of it as a social network for Git repositories. <a href="https://gitlab.com">GitLab</a> and <a href="https://bitbucket.org">Bitbucket</a> do the same job. You can use Git without any of them, but a shared server is what makes collaboration painless.</p>
</section>
<section id="a-worked-example" class="level2">
<h2 class="anchored" data-anchor-id="a-worked-example">A worked example</h2>
<p>You can use Git through the command line or through a graphical interface. The basic workflow needs only five to ten commands. Most documentation is written for the command line, so it is worth seeing what they are even if you end up clicking buttons.</p>
<p>Say we have a small MATLAB project in <code>~/Desktop/project</code>: a script <code>main.m</code> that runs a model, a function <code>solution.m</code> that solves it, and a report <code>Report.tex</code>.</p>
<p><strong>Start a repository</strong><span>(steps 1–2)</span>. Go to the folder and initialize it:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~</span> $ cd Desktop/project</span>
<span id="cb2-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/Desktop/project</span> $ git init</span>
<span id="cb2-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Initialized</span> empty Git repository in /Users/you/Desktop/project/.git/</span></code></pre></div></div>
<p>That creates a hidden <code>.git</code> folder, where Git keeps the entire history. Nothing else in your folder changes. If you ever want to stop using Git, delete that folder. If the project already exists somewhere else, such as on GitHub, you <strong>clone</strong> it instead, which downloads the files along with their full history: <code>git clone &lt;url&gt;</code>.</p>
<p><strong>Make the first commit</strong><span>(steps 3–4)</span>. Committing is a two-step process. First you choose which changes go into the snapshot by adding them to the <strong>staging area</strong>. Then you commit them with a message:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/Desktop/project</span> $ git add main.m solution.m Report.tex</span>
<span id="cb3-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/Desktop/project</span> $ git commit <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-m</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"First version of the model and report"</span></span>
<span id="cb3-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[main</span> <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">root-commit</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span> <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">f026d7e]</span> First version of the model and report</span>
<span id="cb3-4"> <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">3</span> files changed, 48 insertions<span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">+</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span></code></pre></div></div>
<p><strong>Experiment on a branch</strong><span>(steps 5–8)</span>. Now we want to see how alternative parameter values change the results. In the old world, this is the moment we would copy the folder or create <code>main_alternative calibration.m</code>. Instead, we create a <strong>branch</strong>, a parallel line of work that leaves <code>main</code> untouched:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/Desktop/project</span> $ git switch <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-c</span> alt-parameters</span>
<span id="cb4-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Switched</span> to a new branch <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'alt-parameters'</span></span>
<span id="cb4-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ...edit main.m...</span></span>
<span id="cb4-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/Desktop/project</span> $ git add main.m</span>
<span id="cb4-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/Desktop/project</span> $ git commit <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-m</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Try alternative parameter values"</span></span></code></pre></div></div>
<p><strong>Fix a bug in the right place</strong><span>(steps 9–12)</span>. While experimenting we find a bug in <code>solution.m</code>. The bug isn’t specific to the experiment: it is in the code everyone uses. So the fix belongs on <code>main</code>, especially if other people are working on the project. We fix the file, switch to <code>main</code> (the uncommitted change comes with us), and commit it there:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb5-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/Desktop/project</span> $ git switch main</span>
<span id="cb5-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">M</span>       solution.m</span>
<span id="cb5-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Switched</span> to branch <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'main'</span></span>
<span id="cb5-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/Desktop/project</span> $ git add solution.m</span>
<span id="cb5-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/Desktop/project</span> $ git commit <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-m</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fix sign error in solution.m"</span></span></code></pre></div></div>
<p><strong>Bring the fix into the experiment</strong><span>(steps 13–14)</span>. Finally we go back to our branch and <strong>merge</strong> <code>main</code> into it, so the experiment also runs on the corrected code:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb6-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/Desktop/project</span> $ git switch alt-parameters</span>
<span id="cb6-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/Desktop/project</span> $ git merge main <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-m</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Merge main: fix in solution.m"</span></span></code></pre></div></div>
<p>If the experiment works out, we merge <code>alt-parameters</code> into <code>main</code>. If it doesn’t, we delete the branch and <code>main</code> is exactly as we left it. Either way, there’s no <code>old</code> folder, no “final V2”, and every result can be traced back to the commit that produced it.</p>
<p>The animation in the figure below runs the whole example, from an empty folder to a merge. The right panel shows what Git sees at each step: the history, the files you have changed, and what is staged for the next commit. The step links in the paragraphs above jump it to the matching point.</p>
<div id="git-example" class="paper-figure">
<div class="paper-plot__header">
<p><span class="paper-plot__title">The worked example, step by step</span></p>
</div>
<div class="git-demo" data-scenario="example"></div>
<div class="paper-plot__footer">
<p>Note: each dot is a commit. The filled label marks HEAD, the branch you are on; the larger dot is the merge commit, which has two parents. Use the buttons to go through the commands at your own pace.</p>
</div>
</div>
</section>
<section id="habits-that-help" class="level2">
<h2 class="anchored" data-anchor-id="habits-that-help">Habits that help</h2>
<p>Version control doesn’t replace good organization. The bad habits we have in our digital lives tend to come along into Git, and they can get worse if we don’t notice them. There is no single right way to work: two coauthors need less structure than a team of fifty. A few practices help almost everywhere:</p>
<ol type="1">
<li><strong>Commit often, and write messages that mean something.</strong> “Final version” says nothing. “Add robustness check with quarterly data” tells your future self, and your coauthors, what changed and why.</li>
<li><strong>Use the staging area to keep commits tidy.</strong> You will often make progress on several things at once. Rather than committing everything together, stage and commit related changes separately, so each commit tells one story.</li>
<li><strong>Use branches for experiments.</strong> A new specification, a new estimator, a referee’s suggestion: each can live on its own branch until you know whether it stays.</li>
<li><strong>Fix shared problems on the shared branch.</strong> As in the example, fix bugs where everyone will get the fix, then merge it into your branches.</li>
<li><strong>Tell Git what to ignore.</strong> A <code>.gitignore</code> file lists what shouldn’t be versioned: raw data, compiled PDFs, LaTeX auxiliary files, MATLAB <code>.mat</code> outputs.</li>
</ol>
</section>
<section id="how-to-learn-it" class="level2">
<h2 class="anchored" data-anchor-id="how-to-learn-it">How to learn it</h2>
<p>The best way to learn Git is to use it. Start with your next project, even if you work alone.</p>
<p>You don’t have to live in the terminal. Graphical interfaces such as <a href="https://code.visualstudio.com">VS Code</a>, <a href="https://www.gitkraken.com">GitKraken</a> and GitHub Desktop show the history as a graph, highlight the differences between versions, and turn most commands into a button. Still, it is worth understanding the handful of commands above. Each interface implements Git in its own way, and learning one without understanding what it does underneath is like learning Excel without knowing arithmetic. The commands are what every interface has in common.</p>
</section>
<section id="conclusion" class="level2">
<h2 class="anchored" data-anchor-id="conclusion">Conclusion</h2>
<p>I started with three costs of working without version control: experimenting is risky, collaborating and replicating are hard, and history gets lost. Git deals with each of them. A branch lets you try something new without putting working code at risk. A shared repository means everyone works on the same history instead of emailing copies around. Every commit records what changed, when, and why, so you can trace any result back to the code that produced it.</p>
<p>None of this happens automatically. Git is a habit more than a tool, and it only pays off once committing becomes as routine as saving a file. The cost is a few commands and a few weeks of slight discomfort. The return grows with every project, coauthor and referee report, and with every time a journal asks for a replication package.</p>
<p>So start small: run <code>git init</code> in your next project, and commit when something works. After a few weeks the vocabulary stops feeling foreign, and the <code>20200925Project</code> folders start to look like a relic. If you’d rather go through it in Spanish, the <a href="https://nicofranzp.github.io/Git4Econ/">original slides</a> are still online.</p>
<!-- Animated terminal + commit graph for the worked example, rebuilt from the
     typed-terminal slides in the Git4Econ deck. Each `.git-demo` div in the
     post picks a scenario with data-scenario (see SCENARIOS below), and
     `.git-step` links in the text jump it to a step. HTML only: the PDF keeps the post's code blocks. -->
<style>
.git-demo {
  --gd-main: #2f6bff;
  --gd-alt: #ff5277;
  --gd-term-bg: #1b1e2b;
  --gd-term-text: #e8e8ec;
  --gd-term-muted: #8a93a6;
  --gd-term-out: #b9bfcc;
  font-family: var(--site-font-body, "Roboto", sans-serif);
  margin: 0.25rem 0 0.5rem;
}
body.quarto-dark .git-demo {
  --gd-main: #6d9bff;
  --gd-term-bg: #131418;
}
.git-demo__note {
  min-height: 1.85em;
  margin: 0 0 0.6rem;
  color: var(--site-heading, #0d122b);
  font-size: 0.95rem;
}
.git-demo__note b { color: var(--site-muted, #6b7886); font-weight: 500; margin-right: 0.4em; }
.git-demo__panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
}
.git-demo__term {
  background: var(--gd-term-bg);
  color: var(--gd-term-text);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 13rem;
}
.git-demo__bar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.git-demo__bar i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.git-demo__bar i:nth-child(1) { background: #ff605c; }
.git-demo__bar i:nth-child(2) { background: #ffbd44; }
.git-demo__bar i:nth-child(3) { background: #00ca4e; }
.git-demo__bar span { margin-left: 8px; font-size: 0.72rem; color: var(--gd-term-muted); }
.git-demo__screen {
  flex: 1;
  padding: 10px 12px 12px;
  font-family: var(--site-font-mono, monospace);
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: 13rem;
}
.git-demo__screen .p-path { color: #7fd1ff; }
.git-demo__screen .p-branch { color: var(--gd-alt); }
.git-demo__screen .p-dollar { color: var(--gd-term-muted); }
.git-demo__screen .out { color: var(--gd-term-out); }
.git-demo__screen .comment { color: var(--gd-term-muted); font-style: italic; }
.git-demo__cursor {
  display: inline-block; width: 0.55em; height: 1.05em;
  vertical-align: text-bottom; background: var(--gd-term-text);
  animation: gd-blink 1s steps(1) infinite;
}
@keyframes gd-blink { 50% { opacity: 0; } }
.git-demo__side {
  border: 1px solid var(--site-border, #ececec);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 8px 18px;
  align-items: start;
}
@media (max-width: 640px) {
  .git-demo__side { grid-template-columns: minmax(0, 1fr); }
}
.git-demo__label {
  font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--site-muted, #6b7886);
}
.git-demo__graph { width: 100%; height: auto; display: block; }
.git-demo__graph text { font-family: var(--site-font-mono, monospace); font-size: 14px; fill: var(--site-text, #434648); }
.git-demo__graph .gd-empty { font-family: var(--site-font-body, sans-serif); font-size: 15px; fill: var(--site-muted, #6b7886); }
.git-demo__graph .gd-edge { fill: none; stroke-width: 3; }
.git-demo__graph .gd-node { stroke: var(--site-bg, #fff); stroke-width: 3; }
.git-demo__graph .gd-new { animation: gd-pop 0.45s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes gd-pop { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.git-demo__graph .gd-tag rect { stroke-width: 1.5; }
.git-demo__graph .gd-tag.head text { fill: #fff; font-weight: 700; }
.git-demo__files { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; }
.git-demo__files .gd-chips { margin-bottom: 8px; }
.git-demo__files .gd-chips { display: flex; flex-wrap: wrap; gap: 4px; min-height: 1.6em; }
.git-demo__files .gd-chip {
  font-family: var(--site-font-mono, monospace); font-size: 0.72rem;
  padding: 1px 7px; border-radius: 999px;
  background: var(--site-code-bg, #f6f6f6); border: 1px solid var(--site-border, #ececec);
  color: var(--site-text, #434648);
}
.git-demo__files .gd-chip em { font-style: normal; color: var(--site-muted, #6b7886); margin-left: 4px; }
.git-demo__files .gd-chip.staged { border-color: var(--gd-main); }
.git-demo__files .gd-none { color: var(--site-muted, #6b7886); font-size: 0.75rem; }
.git-demo__controls {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 0.7rem;
}
.git-demo__controls button {
  font: inherit; font-size: 0.8rem; line-height: 1;
  padding: 7px 12px; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--site-text, #434648);
  border: 1px solid var(--site-border, #ececec);
}
.git-demo__controls button:hover:not(:disabled) { border-color: var(--site-accent, #ff5277); color: var(--site-heading, #0d122b); }
.git-demo__controls button:disabled { opacity: 0.4; cursor: default; }
.git-demo__controls button:focus-visible { outline: 2px solid var(--site-accent, #ff5277); outline-offset: 2px; }
.git-demo__count { margin-left: auto; font-size: 0.78rem; color: var(--site-muted, #6b7886); }
@media (prefers-reduced-motion: reduce) {
  .git-demo__cursor, .git-demo__graph .gd-new { animation: none; }
}
</style>
<script>
(function () {
  if (window.__gitDemoLoaded) return;
  window.__gitDemoLoaded = true;

  // Each step: the command typed (a "#" line is an edit made outside Git),
  // its output, a one-line explanation, and the change it makes to the
  // repository (see apply()).
  var SCENARIOS = {
    example: {
      start: "A project folder with three files and no history.",
      steps: [
        { cmd: "cd Desktop/project", note: "Go to the project folder.", ops: [["cd", "~/Desktop/project"]] },
        { cmd: "git init", out: ["Initialized empty Git repository in /Users/you/Desktop/project/.git/"],
          note: "Create the repository. The files are there, but Git isn't tracking them yet.", ops: [["init"]] },
        { cmd: "git add main.m solution.m Report.tex",
          note: "Stage the files: choose what goes into the next snapshot.", ops: [["stage", ["main.m", "solution.m", "Report.tex"]]] },
        { cmd: 'git commit -m "First version of the model and report"',
          out: ["[main (root-commit) f026d7e] First version of the model and report", " 3 files changed, 48 insertions(+)"],
          note: "Commit: the first snapshot is in the history, on branch main.", ops: [["commit", "f026d7e"]] },
        { cmd: "git switch -c alt-parameters", out: ["Switched to a new branch 'alt-parameters'"],
          note: "Create a branch for the experiment and move to it. main stays where it was.", ops: [["branch", "alt-parameters"]] },
        { cmd: "# edit main.m: try new parameter values", note: "Change the parameters in your editor.", ops: [["edit", "main.m"]] },
        { cmd: "git add main.m", note: "Stage the change.", ops: [["stage", ["main.m"]]] },
        { cmd: 'git commit -m "Try alternative parameter values"',
          out: ["[alt-parameters c787e04] Try alternative parameter values", " 1 file changed, 2 insertions(+), 2 deletions(-)"],
          note: "Commit on the branch. main doesn't know about it.", ops: [["commit", "c787e04"]] },
        { cmd: "# oh no, a bug in solution.m: fix it", note: "We find a bug in code everyone uses, and fix it.", ops: [["edit", "solution.m"]] },
        { cmd: "git switch main", out: ["M\tsolution.m", "Switched to branch 'main'"],
          note: "The fix belongs on main. The uncommitted change comes along.", ops: [["switch", "main"]] },
        { cmd: "git add solution.m", note: "Stage only the fix.", ops: [["stage", ["solution.m"]]] },
        { cmd: 'git commit -m "Fix sign error in solution.m"',
          out: ["[main f89dffb] Fix sign error in solution.m", " 1 file changed, 1 insertion(+), 1 deletion(-)"],
          note: "Commit the fix on main: the two lines of work have now diverged.", ops: [["commit", "f89dffb"]] },
        { cmd: "git switch alt-parameters", out: ["Switched to branch 'alt-parameters'"],
          note: "Back to the experiment.", ops: [["switch", "alt-parameters"]] },
        { cmd: 'git merge main -m "Merge main: fix in solution.m"',
          out: ["Merge made by the 'ort' strategy.", " solution.m | 2 +-", " 1 file changed, 1 insertion(+), 1 deletion(-)"],
          note: "Merge main into the branch: the experiment now runs on the fixed code.", ops: [["merge", "main", "4b1d2a9"]] }
      ]
    }
  };

  function freshState() {
    return { cwd: "~", repo: false, commits: [], branches: {}, lanes: [], head: null,
             working: { "main.m": "untracked", "solution.m": "untracked", "Report.tex": "untracked" },
             staged: [], last: null };
  }

  function laneOf(s, name) {
    var i = s.lanes.indexOf(name);
    if (i < 0) { s.lanes.push(name); i = s.lanes.length - 1; }
    return i;
  }

  function addCommit(s, hash, parents) {
    s.commits.push({ hash: hash, lane: laneOf(s, s.head), parents: parents.filter(Boolean) });
    s.branches[s.head] = hash;
    s.last = hash;
  }

  function apply(s, op) {
    var kind = op[0];
    s.last = null;
    if (kind === "cd") s.cwd = op[1];
    else if (kind === "init") { s.repo = true; s.head = "main"; s.branches.main = null; laneOf(s, "main"); }
    else if (kind === "stage") op[1].forEach(function (f) { delete s.working[f]; if (s.staged.indexOf(f) < 0) s.staged.push(f); });
    else if (kind === "commit") { addCommit(s, op[1], [s.branches[s.head]]); s.staged = []; }
    else if (kind === "branch") { s.branches[op[1]] = s.branches[s.head]; s.head = op[1]; laneOf(s, op[1]); }
    else if (kind === "switch") s.head = op[1];
    else if (kind === "edit") s.working[op[1]] = "modified";
    else if (kind === "merge") addCommit(s, op[2], [s.branches[s.head], s.branches[op[1]]]);
  }



  // ---- rendering ----------------------------------------------------------
  var SVGNS = "http://www.w3.org/2000/svg";
  function el(tag, attrs, text) {
    var e = document.createElementNS(SVGNS, tag);
    for (var k in attrs) e.setAttribute(k, attrs[k]);
    if (text != null) e.textContent = text;
    return e;
  }
  function span(cls, text) { var e = document.createElement("span"); e.className = cls; e.textContent = text; return e; }

  var W = 420, H = 220, LANE_Y = [72, 156];
  function cx(i) { return 46 + i * 104; }

  function renderGraph(svg, s) {
    while (svg.firstChild) svg.removeChild(svg.firstChild);
    if (!s.repo) {
      svg.appendChild(el("text", { x: W / 2, y: H / 2, "text-anchor": "middle", "class": "gd-empty" }, "No repository yet: just files in a folder"));
      return;
    }
    var colors = ["var(--gd-main)", "var(--gd-alt)"];
    var pos = {};
    s.commits.forEach(function (c, i) { pos[c.hash] = { x: cx(i), y: LANE_Y[c.lane], lane: c.lane }; });

    s.commits.forEach(function (c) {
      var b = pos[c.hash];
      c.parents.forEach(function (p) {
        var a = pos[p], d = a.y === b.y
          ? "M" + a.x + "," + a.y + " L" + b.x + "," + b.y
          : "M" + a.x + "," + a.y + " C" + (a.x + 50) + "," + a.y + " " + (b.x - 50) + "," + b.y + " " + b.x + "," + b.y;
        // An edge takes the color of the lane it leads into.
        svg.appendChild(el("path", { d: d, "class": "gd-edge" + (c.hash === s.last ? " gd-new" : ""), stroke: colors[b.lane] }));
      });
    });
    s.commits.forEach(function (c) {
      var p = pos[c.hash], g = el("g", { "class": c.hash === s.last ? "gd-new" : "" });
      g.appendChild(el("circle", { cx: p.x, cy: p.y, r: c.parents.length > 1 ? 13 : 11, fill: colors[c.lane], "class": "gd-node" }));
      g.appendChild(el("text", { x: p.x, y: p.lane === 0 ? p.y + 32 : p.y - 22, "text-anchor": "middle" }, c.hash));
      svg.appendChild(g);
    });

    // Branch labels: main above its commit, other branches below theirs.
    Object.keys(s.branches).forEach(function (name) {
      var target = s.branches[name], isHead = name === s.head;
      var label = (isHead ? "HEAD → " : "") + name;
      var w = label.length * 8.6 + 18, h = 24;
      var x, y, color = colors[s.lanes.indexOf(name)] || colors[0];
      if (target === null) { x = cx(0); y = LANE_Y[0]; }
      else { x = pos[target].x; y = pos[target].y; }
      var ty = name === "main" ? y - 48 : y + (pos[target] && pos[target].lane === 0 ? 46 : 22);
      if (target === null) ty = y - 12;
      var left = Math.max(4, Math.min(W - 4 - w, x - w / 2));
      var g = el("g", { "class": "gd-tag" + (isHead ? " head" : "") });
      g.appendChild(el("rect", { x: left, y: ty, width: w, height: h, rx: 12,
        fill: isHead ? color : "var(--site-bg, #fff)", stroke: color }));
      g.appendChild(el("text", { x: left + w / 2, y: ty + 17, "text-anchor": "middle" }, label));
      svg.appendChild(g);
    });
    if (!s.commits.length) {
      svg.appendChild(el("text", { x: W / 2, y: LANE_Y[1], "text-anchor": "middle", "class": "gd-empty" }, "No commits yet"));
    }
  }

  function renderFiles(box, s) {
    var rows = box.querySelectorAll(".gd-chips");
    [rows[0], rows[1]].forEach(function (r) { r.textContent = ""; });
    var names = Object.keys(s.working);
    if (!names.length) rows[0].appendChild(span("gd-none", "no changes"));
    names.forEach(function (f) {
      var c = span("gd-chip", f);
      var tag = document.createElement("em"); tag.textContent = s.working[f]; c.appendChild(tag);
      rows[0].appendChild(c);
    });
    if (!s.staged.length) rows[1].appendChild(span("gd-none", "nothing staged"));
    s.staged.forEach(function (f) { rows[1].appendChild(span("gd-chip staged", f)); });
  }

  function promptLine(s, cmd) {
    var line = document.createElement("div");
    line.appendChild(span("p-path", s.cwd));
    if (s.repo) line.appendChild(span("p-branch", " (" + s.head + ")"));
    line.appendChild(span("p-dollar", " $ "));
    var c = span(cmd && cmd.charAt(0) === "#" ? "comment" : "cmd", cmd || "");
    line.appendChild(c);
    return { line: line, cmd: c };
  }

  // ---- player -------------------------------------------------------------
  function Player(root) {
    var name = root.getAttribute("data-scenario");
    this.sc = SCENARIOS[name];
    this.reduce = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
    this.token = 0;
    this.playing = false;
    root.innerHTML =
      '<p class="git-demo__note" aria-live="polite"></p>' +
      '<div class="git-demo__panes">' +
        '<div class="git-demo__term" aria-hidden="true"><div class="git-demo__bar"><i></i><i></i><i></i><span>bash</span></div><div class="git-demo__screen"></div></div>' +
        '<div class="git-demo__side">' +
          '<div><div class="git-demo__label">History</div>' +
          '<svg class="git-demo__graph" viewBox="0 0 ' + W + ' ' + H + '" role="img" aria-label="Commit graph"></svg></div>' +
          '<div class="git-demo__files">' +
            '<span class="git-demo__label">Working copy</span><div class="gd-chips"></div>' +
            '<span class="git-demo__label">Staged</span><div class="gd-chips"></div>' +
          '</div>' +
        '</div>' +
      '</div>' +
      '<div class="git-demo__controls">' +
        '<button type="button" data-act="restart">↺ Restart</button>' +
        '<button type="button" data-act="back">‹ Back</button>' +
        '<button type="button" data-act="play">▶ Play</button>' +
        '<button type="button" data-act="next">Next ›</button>' +
        '<span class="git-demo__count"></span>' +
      '</div>';
    this.note = root.querySelector(".git-demo__note");
    this.screen = root.querySelector(".git-demo__screen");
    this.svg = root.querySelector(".git-demo__graph");
    this.files = root.querySelector(".git-demo__files");
    this.count = root.querySelector(".git-demo__count");
    this.btn = {};
    var self = this;
    root.querySelectorAll("button").forEach(function (b) {
      self.btn[b.getAttribute("data-act")] = b;
      b.addEventListener("click", function () { self[b.getAttribute("data-act")](); });
    });
    this.goTo(0);
  }

  // Draw step k (0 = before any command) instantly, without animation.
  Player.prototype.goTo = function (k) {
    this.token++;
    var s = freshState(), steps = this.sc.steps;
    this.screen.textContent = "";
    for (var i = 0; i < k; i++) {
      var p = promptLine(s, steps[i].cmd);
      this.screen.appendChild(p.line);
      steps[i].ops.forEach(function (op) { apply(s, op); });
      this.printOut(steps[i].out);
    }
    s.last = null;
    this.step = k;
    this.state = s;
    this.showPrompt();
    this.render();
  };

  Player.prototype.printOut = function (lines) {
    var screen = this.screen;
    (lines || []).forEach(function (t) {
      var d = document.createElement("div"); d.className = "out"; d.textContent = t; screen.appendChild(d);
    });
  };

  Player.prototype.showPrompt = function () {
    var p = promptLine(this.state, "");
    p.line.appendChild(span("git-demo__cursor", ""));
    p.line.className = "gd-live";
    this.screen.appendChild(p.line);
    this.screen.scrollTop = this.screen.scrollHeight;
  };

  Player.prototype.render = function () {
    var steps = this.sc.steps, k = this.step;
    this.note.innerHTML = "";
    var b = document.createElement("b");
    b.textContent = k === 0 ? "Start" : "Step " + k;
    this.note.appendChild(b);
    this.note.appendChild(document.createTextNode(k === 0 ? this.sc.start : steps[k - 1].note));
    renderGraph(this.svg, this.state);
    renderFiles(this.files, this.state);
    this.count.textContent = k + " / " + steps.length;
    this.btn.back.disabled = k === 0;
    this.btn.restart.disabled = k === 0 && !this.playing;
    this.btn.next.disabled = k === steps.length;
    this.btn.play.textContent = this.playing ? "❚❚ Pause" : (k === steps.length ? "▶ Replay" : "▶ Play");
  };

  // Type step k's command, print its output, then update the graph.
  Player.prototype.animateNext = function (done) {
    var self = this, k = this.step, st = this.sc.steps[k], tok = ++this.token;
    if (!st) return;
    var live = this.screen.querySelector(".gd-live");
    if (live) live.parentNode.removeChild(live);
    var p = promptLine(this.state, "");
    var cursor = span("git-demo__cursor", "");
    p.line.appendChild(cursor);
    this.screen.appendChild(p.line);
    if (st.cmd.charAt(0) === "#") p.cmd.className = "comment";
    var i = 0, delay = this.reduce ? 0 : 38;
    function finish() {
      if (tok !== self.token) return;
      p.cmd.textContent = st.cmd;
      p.line.removeChild(cursor);
      st.ops.forEach(function (op) { apply(self.state, op); });
      self.printOut(st.out);
      self.step = k + 1;
      self.showPrompt();
      self.render();
      if (done) done();
    }
    if (!delay) return finish();
    (function type() {
      if (tok !== self.token) return;
      if (i < st.cmd.length) { p.cmd.textContent += st.cmd.charAt(i++); self.screen.scrollTop = self.screen.scrollHeight; setTimeout(type, delay); }
      else setTimeout(finish, 250);
    })();
  };

  Player.prototype.next = function () {
    // Redraw first so a half-typed command from Play doesn't stay on screen.
    this.playing = false;
    this.goTo(this.step);
    if (this.step < this.sc.steps.length) this.animateNext();
  };
  Player.prototype.back = function () { this.playing = false; this.goTo(Math.max(0, this.step - 1)); };
  Player.prototype.restart = function () { this.playing = false; this.goTo(0); };
  Player.prototype.play = function () {
    var self = this;
    if (this.playing) { this.playing = false; this.goTo(this.step); return; }
    if (this.step === this.sc.steps.length) this.goTo(0);
    this.playing = true;
    this.render();
    (function loop() {
      if (!self.playing) return;
      if (self.step >= self.sc.steps.length) { self.playing = false; self.render(); return; }
      var tok;
      self.animateNext(function () {
        tok = self.token;
        setTimeout(function () { if (self.playing && tok === self.token) loop(); }, 1500);
      });
    })();
  };

  function init() {
    document.querySelectorAll(".git-demo[data-scenario]").forEach(function (root) {
      if (root.__gitDemo || !SCENARIOS[root.getAttribute("data-scenario")]) return;
      var player = root.__gitDemo = new Player(root);
      // Start playing the first time the player scrolls into view.
      if (!player.reduce && "IntersectionObserver" in window) {
        var io = new IntersectionObserver(function (entries) {
          if (entries[0].isIntersecting) { io.disconnect(); if (player.step === 0) player.play(); }
        }, { threshold: 0.6 });
        io.observe(root);
      }
    });
  }
  // Links in the text, `[steps 5–8](#id){.git-step data-step="8"}`, jump the
  // player inside #id to that step, typing out its last command.
  document.addEventListener("click", function (e) {
    var a = e.target.closest && e.target.closest("a.git-step[data-step]");
    if (!a || !a.hash) return;
    var target = document.getElementById(decodeURIComponent(a.hash.slice(1)));
    var root = target && (target.matches(".git-demo") ? target : target.querySelector(".git-demo"));
    if (!root || !root.__gitDemo) return;
    e.preventDefault();
    var player = root.__gitDemo, n = parseInt(a.getAttribute("data-step"), 10);
    player.playing = false;
    player.goTo(Math.max(0, Math.min(n, player.sc.steps.length) - 1));
    root.scrollIntoView({ behavior: player.reduce ? "auto" : "smooth", block: "center" });
    player.animateNext();
  });

  if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", init);
  else init();
})();
</script>


</section>

 ]]></description>
  <category>Tools</category>
  <guid>https://www.nicolasfranzpattillo.com/posts/published/git-for-economists/</guid>
  <pubDate>Wed, 27 Jan 2021 00:00:00 GMT</pubDate>
  <media:content url="https://www.nicolasfranzpattillo.com/posts/published/git-for-economists/src/cover.webp" medium="image" type="image/webp"/>
</item>
</channel>
</rss>
