{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d962de53",
   "metadata": {},
   "source": [
    "$$\n",
    "\\newcommand{\\argmax}{arg\\,max}\n",
    "\\newcommand{\\argmin}{arg\\,min}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "da2c9277",
   "metadata": {},
   "source": [
    "# Inflation During the French Revolution"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3b2efa50",
   "metadata": {},
   "source": [
    "## Overview\n",
    "\n",
    "This lecture describes some  of the monetary and fiscal  features of the French Revolution (1789-1799) described by [[Sargent and Velde, 1995](https://intro.quantecon.org/zreferences.html#id872)].\n",
    "\n",
    "To finance public expenditures and service its debts,\n",
    "the French government embarked on   policy experiments.\n",
    "\n",
    "The authors of these experiments  had in mind theories about how government  monetary and fiscal policies affected economic outcomes.\n",
    "\n",
    "Some of those theories about monetary and fiscal policies still interest us today.\n",
    "\n",
    "- a **tax-smoothing** model like Robert Barro’s [[Barro, 1979](https://intro.quantecon.org/zreferences.html#id98)]  \n",
    "  - this normative (i.e., prescriptive model) advises a government to finance temporary war-time surges in expenditures mostly by issuing government debt, raising taxes by just enough to service the additional debt issued during the war; then,   after the war,  to roll over whatever debt the government had accumulated during the war;  and  to increase taxes after the war permanently by just enough to finance interest payments on that post-war government  debt  \n",
    "- **unpleasant monetarist arithmetic** like that described in this quantecon lecture  [Some Unpleasant Monetarist Arithmetic](https://intro.quantecon.org/unpleasant.html)  \n",
    "  - mathematics involving compound interest  governed French government debt dynamics in the decades preceding 1789; according to leading historians, that arithmetic set the stage for the French Revolution  \n",
    "- a *real bills* theory of the effects of government open market operations in which the government *backs* new  issues of paper money with government holdings of valuable real property or financial assets that holders of money can purchase from the government in exchange for their money.  \n",
    "  - The Revolutionaries learned about this theory from Adam Smith’s 1776 book The Wealth of Nations\n",
    "    [[Smith, 2010](https://intro.quantecon.org/zreferences.html#id928)] and other contemporary sources  \n",
    "  - It shaped how the Revolutionaries issued a paper money called **assignats** from 1789 to 1791  \n",
    "- a classical **gold**  or **silver standard**  \n",
    "  - Napoleon Bonaparte became head of the French government in 1799. He  used this theory to guide his monetary and fiscal policies  \n",
    "- a classical **inflation-tax** theory of inflation in which Philip Cagan’s ([[Cagan, 1956](https://intro.quantecon.org/zreferences.html#id194)]) demand for money studied in this lecture  [A Monetarist Theory of Price Levels](https://intro.quantecon.org/cagan_ree.html) is a key component  \n",
    "  - This theory helps  explain French price level and money supply data from 1794 to 1797  \n",
    "- a **legal restrictions**  or **financial repression** theory of the demand for real balances  \n",
    "  - The Twelve Members comprising the Committee of Public Safety who administered the Terror from June 1793 to July 1794 used this theory to shape their monetary policy  \n",
    "\n",
    "\n",
    "We use matplotlib to replicate several of the graphs with which  [[Sargent and Velde, 1995](https://intro.quantecon.org/zreferences.html#id872)] portrayed outcomes of these experiments"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6850d187",
   "metadata": {},
   "source": [
    "## Data Sources\n",
    "\n",
    "This lecture uses data from three spreadsheets assembled by [[Sargent and Velde, 1995](https://intro.quantecon.org/zreferences.html#id872)]:\n",
    "\n",
    "- [fig_3.xlsx](https://github.com/QuantEcon/data-lectures/blob/main/lectures/fig_3.xlsx)  \n",
    "- [dette.xlsx](https://github.com/QuantEcon/data-lectures/blob/main/lectures/dette.xlsx)  \n",
    "- [assignat.xlsx](https://github.com/QuantEcon/data-lectures/blob/main/lectures/assignat.xlsx)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "13856ff5",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "from io import BytesIO\n",
    "import requests\n",
    "plt.rcParams.update({'font.size': 12})\n",
    "\n",
    "base_url = 'https://github.com/QuantEcon/data-lectures/raw/'\\\n",
    "           + 'main/lectures/'\n",
    "\n",
    "fig_3_url = f'{base_url}fig_3.xlsx'\n",
    "dette_url = f'{base_url}dette.xlsx'\n",
    "assignat_url = f'{base_url}assignat.xlsx'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "01a1733f",
   "metadata": {},
   "source": [
    "## Government Expenditures and Taxes Collected\n",
    "\n",
    "We’ll start by using `matplotlib` to construct several  graphs that will provide important historical context.\n",
    "\n",
    "These graphs are versions of ones that appear in [[Sargent and Velde, 1995](https://intro.quantecon.org/zreferences.html#id872)].\n",
    "\n",
    "These graphs show that during the 18th century\n",
    "\n",
    "- government expenditures in France and Great Britain both surged during four big wars, and by comparable amounts  \n",
    "- In Britain, tax revenues were approximately equal to government expenditures during peace times,\n",
    "  but were substantially less than government expenditures during wars  \n",
    "- In France, even in peace time, tax revenues were substantially less than government expenditures  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b9cf42a7",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Read the data from Excel file\n",
    "data2 = pd.read_excel(dette_url,\n",
    "        sheet_name='Militspe', usecols='M:X',\n",
    "        skiprows=7, nrows=102, header=None)\n",
    "\n",
    "# French military spending, 1685-1789, in 1726 livres\n",
    "data4 = pd.read_excel(dette_url,\n",
    "        sheet_name='Militspe', usecols='D',\n",
    "        skiprows=3, nrows=105, header=None).squeeze()\n",
    "\n",
    "years = range(1685, 1790)\n",
    "\n",
    "plt.figure()\n",
    "plt.plot(years, data4, '*-', linewidth=0.8)\n",
    "\n",
    "plt.plot(range(1689, 1791), data2.iloc[:, 4], linewidth=0.8)\n",
    "\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "plt.gca().tick_params(labelsize=12)\n",
    "plt.xlim([1689, 1790])\n",
    "plt.xlabel('*: France')\n",
    "plt.ylabel('Millions of livres')\n",
    "plt.ylim([0, 475])\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3717bf14",
   "metadata": {},
   "source": [
    "During the 18th century, Britain and France fought four large wars.\n",
    "\n",
    "Britain won the first three wars and lost the fourth.\n",
    "\n",
    "Each  of those wars  produced surges in both countries’ government expenditures that each country somehow had to finance.\n",
    "\n",
    "Figure Fig. 38.1 shows surges in military expenditures in France (in blue) and Great Britain.\n",
    "during those four wars.\n",
    "\n",
    "A remarkable aspect of figure Fig. 38.1 is that despite having a population less than half of France’s, Britain was able to finance military expenses of about the same amounts as France’s.\n",
    "\n",
    "This testifies to Britain’s  having created state institutions that could sustain high  tax collections, government spending , and government borrowing. See  [[North and Weingast, 1989](https://intro.quantecon.org/zreferences.html#id756)]."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b4b9b9b8",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Read the data from Excel file\n",
    "data2 = pd.read_excel(dette_url, sheet_name='Militspe', usecols='M:X',\n",
    "                      skiprows=7, nrows=102, header=None)\n",
    "\n",
    "# Plot the data\n",
    "plt.figure()\n",
    "plt.plot(range(1689, 1791), data2.iloc[:, 5], linewidth=0.8)\n",
    "plt.plot(range(1689, 1791), data2.iloc[:, 11], linewidth=0.8, color='red')\n",
    "plt.plot(range(1689, 1791), data2.iloc[:, 9], linewidth=0.8, color='orange')\n",
    "plt.plot(range(1689, 1791), data2.iloc[:, 8], 'o-',\n",
    "         markerfacecolor='none', linewidth=0.8, color='purple')\n",
    "\n",
    "# Customize the plot\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "plt.gca().tick_params(labelsize=12)\n",
    "plt.xlim([1689, 1790])\n",
    "plt.ylabel('millions of pounds', fontsize=12)\n",
    "\n",
    "# Add text annotations\n",
    "plt.text(1765, 1.5, 'civil', fontsize=10)\n",
    "plt.text(1760, 4.2, 'civil plus debt service', fontsize=10)\n",
    "plt.text(1708, 15.5, 'total govt spending', fontsize=10)\n",
    "plt.text(1759, 7.3, 'revenues', fontsize=10)\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f87ece90",
   "metadata": {},
   "source": [
    "Figures  Fig. 38.2 and  Fig. 38.4 summarize British and French government   fiscal policies  during the century before the start of the French Revolution in 1789.\n",
    "\n",
    "Before 1789, progressive forces in France  admired how  Britain had financed its government expenditures and wanted to redesign French fiscal arrangements to make them more like Britain’s.\n",
    "\n",
    "Figure  Fig. 38.2 shows government expenditures and how it was distributed among expenditures for\n",
    "\n",
    "- civil (non-military) activities  \n",
    "- debt service, i.e., interest payments  \n",
    "- military expenditures (the yellow line minus the red line)  \n",
    "\n",
    "\n",
    "Figure  Fig. 38.2 also plots total government revenues from tax collections (the purple circled line)\n",
    "\n",
    "Notice the surges in total government expenditures associated with surges in military expenditures\n",
    "in these four wars\n",
    "\n",
    "- Wars against France’s King Louis XIV early in the 18th century  \n",
    "- The War of the Austrian Succession in the 1740s  \n",
    "- The French and Indian War in the 1750’s and 1760s  \n",
    "- The American War for Independence from 1775 to 1783  \n",
    "\n",
    "\n",
    "Figure Fig. 38.2 indicates that\n",
    "\n",
    "- during times of peace, government expenditures approximately equal taxes and debt service payments neither grow nor decline over time  \n",
    "- during times of wars, government expenditures exceed tax revenues  \n",
    "  - the government finances the deficit of revenues relative to expenditures by issuing debt  \n",
    "- after a war is over, the government’s tax revenues exceed its non-interest expenditures by just enough to service the debt that the government issued to finance earlier deficits  \n",
    "  - thus, after a war, the government does *not* raise taxes by enough to pay off its debt  \n",
    "  - instead, it just rolls over whatever debt it inherits, raising taxes by just enough to service the interest payments on that debt  \n",
    "\n",
    "\n",
    "Eighteenth-century British fiscal policy portrayed in Figure Fig. 38.2 thus looks very much like a text-book example of a *tax-smoothing* model like Robert Barro’s [[Barro, 1979](https://intro.quantecon.org/zreferences.html#id98)].\n",
    "\n",
    "A striking feature of the graph is what we’ll label a *law of gravity* between tax collections and government expenditures.\n",
    "\n",
    "- levels of government expenditures and taxes attract each other  \n",
    "- while they can temporarily differ – as they do during wars – they come back together when peace returns  \n",
    "\n",
    "\n",
    "Next we’ll plot data on debt service costs as fractions of government revenues in Great Britain and France during the 18th century."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a5950597",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Read the data from the Excel file\n",
    "data1 = pd.read_excel(dette_url, sheet_name='Debt',\n",
    "            usecols='R:S', skiprows=5, nrows=99, header=None)\n",
    "data1a = pd.read_excel(dette_url, sheet_name='Debt',\n",
    "            usecols='P', skiprows=89, nrows=15, header=None)\n",
    "\n",
    "# Plot the data\n",
    "plt.figure()\n",
    "plt.plot(range(1690, 1789), 100 * data1.iloc[:, 1], linewidth=0.8)\n",
    "\n",
    "date = np.arange(1690, 1789)\n",
    "index = (date < 1774) & (data1.iloc[:, 0] > 0)\n",
    "plt.plot(date[index], 100 * data1[index].iloc[:, 0],\n",
    "         '*:', color='r', linewidth=0.8)\n",
    "\n",
    "# Plot the additional data\n",
    "plt.plot(range(1774, 1789), 100 * data1a, '*:', color='orange')\n",
    "\n",
    "# Note about the data\n",
    "# The French data before 1720 don't match up with the published version\n",
    "# Set the plot properties\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "plt.gca().set_facecolor('white')\n",
    "plt.gca().set_xlim([1688, 1788])\n",
    "plt.ylabel('% of Taxes')\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "48750eae",
   "metadata": {},
   "source": [
    "Figure  Fig. 38.3 shows that interest payments on government debt (i.e., so-called ‘‘debt service’’) were high fractions of government tax revenues in both Great Britain and France.\n",
    "\n",
    "Fig. 38.2 showed us that in peace times Britain managed to balance its budget despite those large interest costs.\n",
    "\n",
    "But as  we’ll see in our next graph, on the eve of the French Revolution in 1788, the  fiscal  *law of gravity* that worked so well in Britain did not  work very well in  France."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "22b871b1",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Read the data from the Excel file\n",
    "data1 = pd.read_excel(fig_3_url, sheet_name='Sheet1',\n",
    "          usecols='C:F', skiprows=5, nrows=30, header=None)\n",
    "\n",
    "data1.replace(0, np.nan, inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "60bf5025",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Plot the data\n",
    "plt.figure()\n",
    "\n",
    "plt.plot(range(1759, 1789, 1), data1.iloc[:, 0], '-x', linewidth=0.8)\n",
    "plt.plot(range(1759, 1789, 1), data1.iloc[:, 1], '--*', linewidth=0.8)\n",
    "plt.plot(range(1759, 1789, 1), data1.iloc[:, 2],\n",
    "         '-o', linewidth=0.8, markerfacecolor='none')\n",
    "plt.plot(range(1759, 1789, 1), data1.iloc[:, 3], '-*', linewidth=0.8)\n",
    "\n",
    "plt.text(1775, 610, 'total spending', fontsize=10)\n",
    "plt.text(1773, 325, 'military', fontsize=10)\n",
    "plt.text(1773, 220, 'civil plus debt service', fontsize=10)\n",
    "plt.text(1773, 80, 'debt service', fontsize=10)\n",
    "plt.text(1785, 500, 'revenues', fontsize=10)\n",
    "\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "plt.ylim([0, 700])\n",
    "plt.ylabel('millions of livres')\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fedbcbe4",
   "metadata": {},
   "source": [
    "Fig. 38.4 shows that on the eve of the French Revolution in 1788, government expenditures exceeded tax revenues.\n",
    "\n",
    "Especially during and after France’s expenditures to help the Americans in their War of Independence from Great Britain,   growing government debt service (i.e., interest payments)\n",
    "contributed to this situation.\n",
    "\n",
    "This was partly a consequence of the unfolding of the debt dynamics that underlies the Unpleasant Arithmetic discussed in this quantecon lecture  [Some Unpleasant Monetarist Arithmetic](https://intro.quantecon.org/unpleasant.html).\n",
    "\n",
    "[[Sargent and Velde, 1995](https://intro.quantecon.org/zreferences.html#id872)] describe how the Ancient Regime that until 1788 had  governed France  had stable institutional features that made it difficult for the government to balance its budget.\n",
    "\n",
    "Powerful contending interests had prevented the government from closing the gap between its\n",
    "total expenditures and its tax revenues by either\n",
    "\n",
    "- raising taxes, or  \n",
    "- lowering government’s non-debt service (i.e., non-interest)   expenditures, or  \n",
    "- lowering debt service (i.e., interest) costs by rescheduling, i.e., defaulting on some  debts  \n",
    "\n",
    "\n",
    "Precedents and prevailing French arrangements had empowered three constituencies to block adjustments to components of the government budget constraint that they cared especially about\n",
    "\n",
    "- tax payers  \n",
    "- beneficiaries of government expenditures  \n",
    "- government creditors (i.e., owners of government bonds)  \n",
    "\n",
    "\n",
    "When the French government had confronted a similar situation around 1720 after King  Louis XIV’s\n",
    "Wars had left it with a debt crisis, it had sacrificed the interests of\n",
    "government creditors, i.e., by defaulting on enough of its debt to bring interest payments down enough to balance the budget.\n",
    "\n",
    "Somehow, in 1789, creditors of the French government were more powerful than they had been in 1720.\n",
    "\n",
    "Therefore, King Louis XVI convened the Estates General together to ask them to redesign the French constitution in a way that would lower government expenditures or increase taxes, thereby\n",
    "allowing him to balance the budget while also honoring his promises to creditors of the French government.\n",
    "\n",
    "The King called the Estates General together in an effort to promote the reforms that would\n",
    "bring sustained budget balance.\n",
    "\n",
    "[[Sargent and Velde, 1995](https://intro.quantecon.org/zreferences.html#id872)] describe how the French Revolutionaries set out to accomplish that."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1a6c86e2",
   "metadata": {},
   "source": [
    "## Nationalization, Privatization, Debt Reduction\n",
    "\n",
    "In 1789, the Revolutionaries quickly reorganized the Estates General  into a National Assembly.\n",
    "\n",
    "A first piece of business was to address the fiscal crisis, the situation that had motivated the King to convene the Estates General.\n",
    "\n",
    "The Revolutionaries were not socialists or communists.\n",
    "\n",
    "To the contrary, they respected  private property and knew state-of-the-art economics.\n",
    "\n",
    "They knew that to honor government debts, they would have to raise new revenues or reduce expenditures.\n",
    "\n",
    "A coincidence was that the Catholic Church owned vast income-producing properties.\n",
    "\n",
    "Indeed, the capitalized value of those income streams put estimates of the value of church lands at\n",
    "about the same amount as the entire French government debt.\n",
    "\n",
    "This coincidence fostered a three step plan for servicing the French government debt\n",
    "\n",
    "- nationalize the church lands – i.e., sequester or confiscate them without paying for them  \n",
    "- sell the church lands  \n",
    "- use the proceeds from those sales to service or even retire French government debt  \n",
    "\n",
    "\n",
    "The monetary theory underlying this plan had been set out by Adam Smith in his analysis of what he called *real bills*  in his  1776 book\n",
    "**The Wealth of Nations**   [[Smith, 2010](https://intro.quantecon.org/zreferences.html#id928)], which many of the revolutionaries had read.\n",
    "\n",
    "Adam Smith defined a *real bill* as a paper money note that is backed by a claim on a real asset like productive capital or inventories.\n",
    "\n",
    "The National Assembly put together an ingenious institutional  arrangement to implement this plan.\n",
    "\n",
    "In response to a motion by Catholic Bishop Talleyrand (an atheist),\n",
    "the National Assembly confiscated and nationalized  Church lands.\n",
    "\n",
    "The National Assembly intended to use earnings from  Church lands to service its national debt.\n",
    "\n",
    "To do this, it  began to implement a ‘‘privatization plan’’ that would let it service its debt while\n",
    "not raising taxes.\n",
    "\n",
    "Their plan involved issuing paper notes called ‘‘assignats’’ that entitled bearers to use them to purchase state lands.\n",
    "\n",
    "These paper notes would be ‘‘as good as silver coins’’ in the sense that both were acceptable means of payment in exchange for those (formerly) church lands.\n",
    "\n",
    "Finance Minister Necker and the Constituents of the National Assembly thus  planned\n",
    "to solve the privatization problem *and* the debt problem simultaneously\n",
    "by creating a new currency.\n",
    "\n",
    "They devised a scheme to raise revenues by auctioning\n",
    "the confiscated lands, thereby withdrawing paper notes issued on the security of\n",
    "the lands sold by the government.\n",
    "\n",
    "This ‘‘tax-backed money’’ scheme propelled the National Assembly  into the domains of then modern monetary theories.\n",
    "\n",
    "Records of  debates show\n",
    "how members of the Assembly marshaled theory and evidence to assess the likely\n",
    "effects of their innovation.\n",
    "\n",
    "- Members of the National Assembly quoted David Hume and Adam Smith  \n",
    "- They  cited John Law’s System of 1720 and the American experiences with paper money fifteen years\n",
    "  earlier as examples of how paper money schemes can go awry  \n",
    "- Knowing pitfalls, they set out to avoid them  \n",
    "\n",
    "\n",
    "They succeeded for two or three years.\n",
    "\n",
    "But after that, France entered a big War that disrupted the plan in ways that completely altered the character of France’s paper money. [[Sargent and Velde, 1995](https://intro.quantecon.org/zreferences.html#id872)] describe what happened."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0cdab951",
   "metadata": {},
   "source": [
    "## Remaking the tax code and tax administration\n",
    "\n",
    "In 1789 the French Revolutionaries formed a National Assembly and set out to remake French\n",
    "fiscal policy.\n",
    "\n",
    "They wanted to honor government debts – interests of French government creditors were well represented in the National Assembly.\n",
    "\n",
    "But they set out to remake  the French tax code and the administrative machinery for collecting taxes.\n",
    "\n",
    "- they abolished many taxes  \n",
    "- they abolished the Ancient Regime’s scheme for *tax farming*  \n",
    "  - tax farming meant that the government had privatized tax collection by hiring private citizens – so-called  tax farmers to collect taxes, while retaining a fraction of them as payment for their services  \n",
    "  - the great chemist Lavoisier was also a tax farmer, one of the reasons that the Committee for Public Safety sent him to the guillotine in 1794  \n",
    "\n",
    "\n",
    "As a consequence of these tax reforms, government tax revenues declined\n",
    "\n",
    "The next figure shows this"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "23f96b08",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Read data from Excel file\n",
    "data5 = pd.read_excel(dette_url, sheet_name='Debt', usecols='K',\n",
    "                    skiprows=41, nrows=120, header=None)\n",
    "\n",
    "# Plot the data\n",
    "plt.figure()\n",
    "plt.plot(range(1726, 1846), data5.iloc[:, 0], linewidth=0.8)\n",
    "\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "plt.gca().set_facecolor('white')\n",
    "plt.gca().tick_params(labelsize=12)\n",
    "plt.xlim([1726, 1845])\n",
    "plt.ylabel('1726 = 1', fontsize=12)\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4fe18dc2",
   "metadata": {},
   "source": [
    "According to Fig. 38.5, tax revenues per capita did not rise to their pre 1789 levels\n",
    "until after 1815, when Napoleon Bonaparte was exiled to St Helena and King Louis XVIII was restored to the French Crown.\n",
    "\n",
    "- from 1799 to 1814, Napoleon Bonaparte had other sources of revenues – booty and reparations from provinces and nations that he defeated in war  \n",
    "- from 1789 to 1799, the French Revolutionaries turned to another source to raise resources to pay for government purchases of goods and services and to service French government debt.  \n",
    "\n",
    "\n",
    "And as the next figure shows, government expenditures exceeded tax revenues by substantial\n",
    "amounts during the period from 1789 to 1799."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "749665b7",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Read data from Excel file\n",
    "data11 = pd.read_excel(assignat_url, sheet_name='Budgets',\n",
    "        usecols='J:K', skiprows=22, nrows=52, header=None)\n",
    "\n",
    "# Prepare the x-axis data\n",
    "x_data = np.concatenate([\n",
    "    np.arange(1791, 1794 + 8/12, 1/12),\n",
    "    np.arange(1794 + 9/12, 1795 + 3/12, 1/12)\n",
    "])\n",
    "\n",
    "# Remove NaN values from the data\n",
    "data11_clean = data11.dropna()\n",
    "\n",
    "# Plot the data\n",
    "plt.figure()\n",
    "h = plt.plot(x_data, data11_clean.values[:, 0], linewidth=0.8)\n",
    "h = plt.plot(x_data, data11_clean.values[:, 1], '--', linewidth=0.8)\n",
    "\n",
    "# Set plot properties\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "plt.gca().set_facecolor('white')\n",
    "plt.gca().tick_params(axis='both', which='major', labelsize=12)\n",
    "plt.xlim([1791, 1795 + 3/12])\n",
    "plt.xticks(np.arange(1791, 1796))\n",
    "plt.yticks(np.arange(0, 201, 20))\n",
    "\n",
    "# Set the y-axis label\n",
    "plt.ylabel('millions of livres', fontsize=12)\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dbfffbe8",
   "metadata": {},
   "source": [
    "To cover the discrepancies between government expenditures and tax revenues revealed in Fig. 38.6, the French revolutionaries  printed paper money and spent it.\n",
    "\n",
    "The next figure shows that by printing money, they were able to finance substantial purchases\n",
    "of goods and services, including military goods and soldiers’ pay."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "893b150d",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Read data from Excel file\n",
    "data12 = pd.read_excel(assignat_url, sheet_name='seignor',\n",
    "         usecols='F', skiprows=6, nrows=75, header=None).squeeze()\n",
    "\n",
    "# Create a figure and plot the data\n",
    "plt.figure()\n",
    "plt.plot(pd.date_range(start='1790', periods=len(data12), freq='ME'),\n",
    "         data12, linewidth=0.8)\n",
    "\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "\n",
    "plt.axhline(y=472.42/12, color='r', linestyle=':')\n",
    "plt.xticks(ticks=pd.date_range(start='1790',\n",
    "           end='1796', freq='YS'), labels=range(1790, 1797))\n",
    "plt.xlim(pd.Timestamp('1791'),\n",
    "         pd.Timestamp('1796-02') + pd.DateOffset(months=2))\n",
    "plt.ylabel('millions of livres', fontsize=12)\n",
    "plt.text(pd.Timestamp('1793-11'), 39.5, 'revenues in 1788',\n",
    "         verticalalignment='top', fontsize=12)\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a042239c",
   "metadata": {},
   "source": [
    "Fig. 38.7 compares the revenues raised by printing money from 1789 to 1796 with tax revenues that the Ancient Regime had raised in 1788.\n",
    "\n",
    "Measured in goods, revenues raised at time $ t $ by printing new money equal\n",
    "\n",
    "$$\n",
    "\\frac{M_{t+1} - M_t}{p_t}\n",
    "$$\n",
    "\n",
    "where\n",
    "\n",
    "- $ M_t $ is the stock of paper money at time $ t $ measured in livres  \n",
    "- $ p_t $ is the price level at time $ t $ measured in units of goods per livre at time $ t $  \n",
    "- $ M_{t+1} - M_t $ is the amount of new money printed at time $ t $  \n",
    "\n",
    "\n",
    "Notice the 1793-1794  surge in revenues raised by printing money.\n",
    "\n",
    "- This reflects extraordinary measures that the Committee for Public Safety adopted to force citizens to accept paper money, or else.  \n",
    "\n",
    "\n",
    "Also note the abrupt fall off in revenues raised by 1797 and the absence of further observations after 1797.\n",
    "\n",
    "- This reflects the end of using the printing press to raise revenues.  \n",
    "\n",
    "\n",
    "What French paper money  entitled its holders to changed over time in interesting ways.\n",
    "\n",
    "These  led to outcomes  that vary over time and that illustrate the playing out in practice of  theories that guided the Revolutionaries’ monetary policy decisions.\n",
    "\n",
    "The next figure shows the price level in France  during the time that the Revolutionaries used paper money to finance parts of their expenditures.\n",
    "\n",
    "Note that we use a log scale because the price level rose so much."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b9331034",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Read the data from Excel file\n",
    "data7 = pd.read_excel(assignat_url, sheet_name='Data',\n",
    "          usecols='P:Q', skiprows=4, nrows=80, header=None)\n",
    "data7a = pd.read_excel(assignat_url, sheet_name='Data',\n",
    "          usecols='L', skiprows=4, nrows=80, header=None)\n",
    "# Create the figure and plot\n",
    "plt.figure()\n",
    "x = np.arange(1789 + 10/12, 1796 + 5/12, 1/12)\n",
    "h, = plt.plot(x, 1. / data7.iloc[:, 0], linestyle='--')\n",
    "h, = plt.plot(x, 1. / data7.iloc[:, 1], color='r')\n",
    "\n",
    "# Set properties of the plot\n",
    "plt.gca().tick_params(labelsize=12)\n",
    "plt.yscale('log')\n",
    "plt.xlim([1789 + 10/12, 1796 + 5/12])\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "\n",
    "# Add vertical lines\n",
    "plt.axvline(x=1793 + 6.5/12, linestyle='-', linewidth=0.8, color='orange')\n",
    "plt.axvline(x=1794 + 6.5/12, linestyle='-', linewidth=0.8, color='purple')\n",
    "\n",
    "# Add text\n",
    "plt.text(1793.75, 120, 'Terror', fontsize=12)\n",
    "plt.text(1795, 2.8, 'price level', fontsize=12)\n",
    "plt.text(1794.9, 40, 'gold', fontsize=12)\n",
    "\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e065383e",
   "metadata": {},
   "source": [
    "We have partitioned  Fig. 38.8 that shows the log of the price level and   Fig. 38.9\n",
    "below  that plots real balances $ \\frac{M_t}{p_t} $ into three periods that correspond to  different monetary  experiments or *regimes*.\n",
    "\n",
    "The first period ends in the late summer of 1793, and is characterized\n",
    "by growing real balances and moderate inflation.\n",
    "\n",
    "The second period begins and ends\n",
    "with the Terror. It is marked by high real balances, around 2,500 million, and\n",
    "roughly stable prices. The fall of Robespierre in late July 1794 begins the third\n",
    "of our episodes, in which real balances decline and prices rise rapidly.\n",
    "\n",
    "We interpret\n",
    "these three episodes in terms of distinct  theories\n",
    "\n",
    "- a *backing* or *real bills* theory (the classic text for this theory is  Adam Smith  [[Smith, 2010](https://intro.quantecon.org/zreferences.html#id928)])  \n",
    "- a legal restrictions theory ( [[Keynes, 1940](https://intro.quantecon.org/zreferences.html#id569)], [[Bryant and Wallace, 1984](https://intro.quantecon.org/zreferences.html#id185)] )  \n",
    "- a classical hyperinflation theory ([[Cagan, 1956](https://intro.quantecon.org/zreferences.html#id194)])  \n",
    "- \n",
    "\n",
    ">**Note**\n",
    ">\n",
    ">According to the empirical  definition of hyperinflation adopted by [[Cagan, 1956](https://intro.quantecon.org/zreferences.html#id194)],\n",
    "beginning in the month that inflation exceeds 50 percent\n",
    "per month and ending in the month before inflation drops below 50 percent per month\n",
    "for at least a year, the *assignat*  experienced a hyperinflation from May to December\n",
    "1795.\n",
    "\n",
    "We view these\n",
    "theories not as competitors but as alternative collections of ‘‘if-then’’\n",
    "statements about government note issues, each of which finds its conditions more\n",
    "nearly met in one of these episodes than in the other two."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "34ba3816",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Read the data from Excel file\n",
    "data7 = pd.read_excel(assignat_url, sheet_name='Data',\n",
    "        usecols='P:Q', skiprows=4, nrows=80, header=None)\n",
    "data7a = pd.read_excel(assignat_url, sheet_name='Data',\n",
    "        usecols='L', skiprows=4, nrows=80, header=None)\n",
    "\n",
    "# Create the figure and plot\n",
    "plt.figure()\n",
    "h = plt.plot(pd.date_range(start='1789-11-01', periods=len(data7), freq='ME'),\n",
    "            (data7a.values * [1, 1]) * data7.values, linewidth=1.)\n",
    "plt.setp(h[1], linestyle='--', color='red')\n",
    "\n",
    "plt.vlines([pd.Timestamp('1793-07-15'), pd.Timestamp('1793-07-15')],\n",
    "           0, 3000, linewidth=0.8, color='orange')\n",
    "plt.vlines([pd.Timestamp('1794-07-15'), pd.Timestamp('1794-07-15')],\n",
    "           0, 3000, linewidth=0.8, color='purple')\n",
    "\n",
    "plt.ylim([0, 3000])\n",
    "\n",
    "# Set properties of the plot\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "plt.gca().set_facecolor('white')\n",
    "plt.gca().tick_params(labelsize=12)\n",
    "plt.xlim(pd.Timestamp('1789-11-01'), pd.Timestamp('1796-06-01'))\n",
    "plt.ylabel('millions of livres', fontsize=12)\n",
    "\n",
    "# Add text annotations\n",
    "plt.text(pd.Timestamp('1793-09-01'), 200, 'Terror', fontsize=12)\n",
    "plt.text(pd.Timestamp('1791-05-01'), 750, 'gold value', fontsize=12)\n",
    "plt.text(pd.Timestamp('1794-10-01'), 2500, 'real value', fontsize=12)\n",
    "\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e8c65d7c",
   "metadata": {},
   "source": [
    "The three clouds of points in Figure\n",
    "Fig. 38.10\n",
    "depict different real balance-inflation relationships.\n",
    "\n",
    "Only the cloud for the\n",
    "third period has the inverse relationship familiar to us now from twentieth-century\n",
    "hyperinflations.\n",
    "\n",
    "- subperiod 1: (”*real bills* period): January 1791 to July 1793  \n",
    "- subperiod 2: (“terror”):  August 1793 - July 1794  \n",
    "- subperiod 3: (“classic Cagan hyperinflation”): August 1794 - March 1796  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1d44180d",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "def fit(x, y):\n",
    "\n",
    "    b = np.cov(x, y)[0, 1] / np.var(x)\n",
    "    a = y.mean() - b * x.mean()\n",
    "\n",
    "    return a, b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "eaa73414",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Load data\n",
    "caron_response = requests.get(f'{base_url}caron.npy')\n",
    "nom_balances_response = requests.get(f'{base_url}nom_balances.npy')\n",
    "caron = np.load(BytesIO(caron_response.content))\n",
    "nom_balances = np.load(BytesIO(nom_balances_response.content))\n",
    "\n",
    "infl = np.concatenate(([np.nan],\n",
    "      -np.log(caron[1:63, 1] / caron[0:62, 1])))\n",
    "bal = nom_balances[14:77, 1] * caron[:, 1] / 1000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a8728402",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Regress y on x for three periods\n",
    "a1, b1 = fit(bal[1:31], infl[1:31])\n",
    "a2, b2 = fit(bal[31:44], infl[31:44])\n",
    "a3, b3 = fit(bal[44:63], infl[44:63])\n",
    "\n",
    "# Regress x on y for three periods\n",
    "a1_rev, b1_rev = fit(infl[1:31], bal[1:31])\n",
    "a2_rev, b2_rev = fit(infl[31:44], bal[31:44])\n",
    "a3_rev, b3_rev = fit(infl[44:63], bal[44:63])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f1b21d1d",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "plt.figure()\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "\n",
    "# First subsample\n",
    "plt.plot(bal[1:31], infl[1:31], 'o', markerfacecolor='none',\n",
    "         color='blue', label='real bills period')\n",
    "\n",
    "# Second subsample\n",
    "plt.plot(bal[31:44], infl[31:44], '+', color='red', label='terror')\n",
    "\n",
    "# Third subsample\n",
    "plt.plot(bal[44:63], infl[44:63], '*',\n",
    "        color='orange', label='classic Cagan hyperinflation')\n",
    "\n",
    "plt.xlabel('real balances')\n",
    "plt.ylabel('inflation')\n",
    "plt.legend()\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eb7c46b3",
   "metadata": {},
   "source": [
    "The three clouds of points in Fig. 38.10 evidently\n",
    "depict different real balance-inflation relationships.\n",
    "\n",
    "Only the cloud for the\n",
    "third period has the inverse relationship familiar to us now from twentieth-century\n",
    "hyperinflations.\n",
    "\n",
    "To bring this out, we’ll use linear regressions to draw straight lines that compress the\n",
    "inflation-real balance relationship for our three sub-periods.\n",
    "\n",
    "Before we do that, we’ll drop some of the early observations during the terror period\n",
    "to obtain the following graph."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c511e576",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "# Regress y on x for three periods\n",
    "a1, b1 = fit(bal[1:31], infl[1:31])\n",
    "a2, b2 = fit(bal[31:44], infl[31:44])\n",
    "a3, b3 = fit(bal[44:63], infl[44:63])\n",
    "\n",
    "# Regress x on y for three periods\n",
    "a1_rev, b1_rev = fit(infl[1:31], bal[1:31])\n",
    "a2_rev, b2_rev = fit(infl[31:44], bal[31:44])\n",
    "a3_rev, b3_rev = fit(infl[44:63], bal[44:63])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "30206986",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "plt.figure()\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "\n",
    "# First subsample\n",
    "plt.plot(bal[1:31], infl[1:31], 'o', markerfacecolor='none', color='blue', label='real bills period')\n",
    "\n",
    "# Second subsample\n",
    "plt.plot(bal[34:44], infl[34:44], '+', color='red', label='terror')\n",
    "\n",
    "# Third subsample\n",
    "plt.plot(bal[44:63], infl[44:63], '*', color='orange', label='classic Cagan hyperinflation')\n",
    "\n",
    "plt.xlabel('real balances')\n",
    "plt.ylabel('inflation')\n",
    "plt.legend()\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "63229ec2",
   "metadata": {},
   "source": [
    "Now let’s regress inflation on real balances during the *real bills* period and plot the regression\n",
    "line."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "61577ffc",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "plt.figure()\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "\n",
    "# First subsample\n",
    "plt.plot(bal[1:31], infl[1:31], 'o', markerfacecolor='none',\n",
    "        color='blue', label='real bills period')\n",
    "plt.plot(bal[1:31], a1 + bal[1:31] * b1, color='blue')\n",
    "\n",
    "# Second subsample\n",
    "plt.plot(bal[31:44], infl[31:44], '+', color='red', label='terror')\n",
    "\n",
    "# Third subsample\n",
    "plt.plot(bal[44:63], infl[44:63], '*',\n",
    "        color='orange', label='classic Cagan hyperinflation')\n",
    "\n",
    "plt.xlabel('real balances')\n",
    "plt.ylabel('inflation')\n",
    "plt.legend()\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8028a73b",
   "metadata": {},
   "source": [
    "The regression line in Fig. 38.12 shows that large increases in real balances of\n",
    "assignats (paper money) were accompanied by only modest rises in the price level, an outcome in line\n",
    "with the *real bills* theory.\n",
    "\n",
    "During this period, assignats were claims on church lands.\n",
    "\n",
    "But towards the end of this period, the price level started to rise and real balances to fall\n",
    "as the government continued to print money but stopped selling church land.\n",
    "\n",
    "To get people to hold that paper money, the government forced people to hold it by using legal restrictions.\n",
    "\n",
    "Now let’s regress real balances on inflation  during the terror  and plot the regression\n",
    "line."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4608aded",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "plt.figure()\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "\n",
    "# First subsample\n",
    "plt.plot(bal[1:31], infl[1:31], 'o', markerfacecolor='none',\n",
    "        color='blue', label='real bills period')\n",
    "\n",
    "# Second subsample\n",
    "plt.plot(bal[31:44], infl[31:44], '+', color='red', label='terror')\n",
    "plt.plot(a2_rev + b2_rev * infl[31:44], infl[31:44], color='red')\n",
    "\n",
    "# Third subsample\n",
    "plt.plot(bal[44:63], infl[44:63], '*',\n",
    "        color='orange', label='classic Cagan hyperinflation')\n",
    "\n",
    "plt.xlabel('real balances')\n",
    "plt.ylabel('inflation')\n",
    "plt.legend()\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "52127f40",
   "metadata": {},
   "source": [
    "The regression line in Fig. 38.13 shows that large increases in real balances of\n",
    "assignats (paper money) were accompanied by little upward price  level pressure, even some declines in prices.\n",
    "\n",
    "This reflects how well legal restrictions – financial repression – was working during the period of the Terror.\n",
    "\n",
    "But the Terror ended in July 1794.\n",
    "\n",
    "That unleashed a big inflation as people tried to find other ways to transact and store values.\n",
    "\n",
    "The following two graphs are for the classical hyperinflation period.\n",
    "\n",
    "One regresses inflation on real balances, the other regresses real balances on inflation.\n",
    "\n",
    "Both show a pronounced inverse relationship that is the hallmark of the hyperinflations studied by\n",
    "Cagan [[Cagan, 1956](https://intro.quantecon.org/zreferences.html#id194)]."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "26139658",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "plt.figure()\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "\n",
    "# First subsample\n",
    "plt.plot(bal[1:31], infl[1:31], 'o', markerfacecolor='none',\n",
    "        color='blue', label='real bills period')\n",
    "\n",
    "# Second subsample\n",
    "plt.plot(bal[31:44], infl[31:44], '+', color='red', label='terror')\n",
    "\n",
    "# Third subsample\n",
    "plt.plot(bal[44:63], infl[44:63], '*',\n",
    "    color='orange', label='classic Cagan hyperinflation')\n",
    "plt.plot(bal[44:63], a3 + bal[44:63] * b3, color='orange')\n",
    "\n",
    "plt.xlabel('real balances')\n",
    "plt.ylabel('inflation')\n",
    "plt.legend()\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "240cfe25",
   "metadata": {},
   "source": [
    "Fig. 38.14 shows the results of regressing inflation on real balances during the\n",
    "period of the hyperinflation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8681c45f",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "plt.figure()\n",
    "plt.gca().spines['top'].set_visible(False)\n",
    "plt.gca().spines['right'].set_visible(False)\n",
    "\n",
    "# First subsample\n",
    "plt.plot(bal[1:31], infl[1:31], 'o',\n",
    "    markerfacecolor='none', color='blue', label='real bills period')\n",
    "\n",
    "# Second subsample\n",
    "plt.plot(bal[31:44], infl[31:44], '+', color='red', label='terror')\n",
    "\n",
    "# Third subsample\n",
    "plt.plot(bal[44:63], infl[44:63], '*',\n",
    "        color='orange', label='classic Cagan hyperinflation')\n",
    "plt.plot(a3_rev + b3_rev * infl[44:63], infl[44:63], color='orange')\n",
    "\n",
    "plt.xlabel('real balances')\n",
    "plt.ylabel('inflation')\n",
    "plt.legend()\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fefb3126",
   "metadata": {},
   "source": [
    "Fig. 38.14 shows the results of regressing  real money balances on inflation during the\n",
    "period of the hyperinflation."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "07cbc838",
   "metadata": {},
   "source": [
    "## Hyperinflation Ends\n",
    "\n",
    "[[Sargent and Velde, 1995](https://intro.quantecon.org/zreferences.html#id872)] tell how in 1797 the Revolutionary government abruptly ended the inflation by\n",
    "\n",
    "- repudiating 2/3 of the national debt, and thereby  \n",
    "- eliminating the net-of-interest government deficit  \n",
    "- no longer printing money, but instead  \n",
    "- using gold and silver coins as money  \n",
    "\n",
    "\n",
    "In 1799, Napoleon Bonaparte became first consul and for the next 15 years used resources confiscated from conquered territories to help pay for French government expenditures."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58c67290",
   "metadata": {},
   "source": [
    "## Underlying Theories\n",
    "\n",
    "This lecture  sets the stage for studying  theories of inflation and the  government monetary and fiscal policies that bring it about.\n",
    "\n",
    "A  *monetarist theory of the price level* is described in this quantecon lecture [A Monetarist Theory of Price Levels](https://intro.quantecon.org/cagan_ree.html).\n",
    "\n",
    "That lecture sets the stage for these quantecon lectures [Money Financed Government Deficits and Price Levels](https://intro.quantecon.org/money_inflation.html) and [Some Unpleasant Monetarist Arithmetic](https://intro.quantecon.org/unpleasant.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9e9ef6f4",
   "metadata": {},
   "source": [
    "## Exercises"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "97c9d893",
   "metadata": {},
   "source": [
    "## Exercise 38.1\n",
    "\n",
    "**Identifying the hyperinflation: Cagan’s 50 per cent threshold.**\n",
    "\n",
    "The “Note” callout box in this lecture states that France experienced a\n",
    "hyperinflation from May to December 1795, using Cagan’s definition: a\n",
    "hyperinflation begins in the first month that the monthly inflation rate exceeds\n",
    "50 per cent and ends in the first month it stays below 50 per cent for at least\n",
    "a year.\n",
    "\n",
    "Because `infl` measures the *log* change in the price level, the 50 per cent\n",
    "threshold in simple-ratio terms ($ P_{t+1}/P_t - 1 \\geq 0.5 $) corresponds to\n",
    "$ \\log(1.5) \\approx 0.405 $ in the `infl` units.\n",
    "\n",
    "a. Using the approximate date grid\n",
    "`pd.date_range(start='1791-01', periods=63, freq='ME')`, plot the full\n",
    "monthly inflation series `infl[1:]` (skip the leading `NaN`), draw a dashed\n",
    "horizontal line at the 50 per cent threshold, and shade the months that\n",
    "exceed it.\n",
    "\n",
    "b. Print the number of months above the threshold and their approximate dates to\n",
    "check whether they match the “May to December 1795” statement in the lecture.\n",
    "\n",
    "c. Using the lecture’s boundary at index 44 (August 1794, roughly), compute how\n",
    "many Cagan-hyperinflation months fall inside the third sub-period\n",
    "`infl[44:63]`."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "700d7368",
   "metadata": {},
   "source": [
    "## Solution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ed6365c9",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "dates = pd.date_range(start='1791-01', periods=63, freq='ME')\n",
    "threshold = np.log(1.5)\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(10, 4))\n",
    "ax.plot(dates[1:], infl[1:], color='black', lw=1, label='Monthly inflation (log change)')\n",
    "ax.axhline(threshold, color='red', linestyle='--', lw=1,\n",
    "           label=f'50%/month threshold (log 1.5 approx {threshold:.3f})')\n",
    "ax.fill_between(dates[1:], infl[1:], threshold,\n",
    "                where=infl[1:] > threshold,\n",
    "                alpha=0.35, color='red', label='Above Cagan threshold')\n",
    "ax.axvline(pd.Timestamp('1793-07'), color='orange', lw=0.8, linestyle=':',\n",
    "           label='Sub-period boundaries')\n",
    "ax.axvline(pd.Timestamp('1794-08'), color='orange', lw=0.8, linestyle=':')\n",
    "ax.set_xlabel('Date')\n",
    "ax.set_ylabel('Monthly inflation (log change)')\n",
    "ax.set_title('Monthly inflation in Revolutionary France, 1791-1796')\n",
    "ax.legend(fontsize=8)\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5e926f80",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "above = np.where(infl > threshold)[0]\n",
    "print(f'Months above 50%/month threshold: {len(above)}')\n",
    "for idx in above:\n",
    "    print(f'  index {idx:3d}  approx {dates[idx].strftime(\"%b %Y\")}  '\n",
    "          f'(inflation = {infl[idx]:.3f})')\n",
    "\n",
    "# Part c\n",
    "in_subperiod3 = above[above >= 44]\n",
    "print(f'\\nOf those, {len(in_subperiod3)} fall in sub-period 3 (index >= 44)')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a3314ec7",
   "metadata": {},
   "source": [
    "The concentrated cluster of months above the threshold falls in 1795,\n",
    "consistent with the lecture’s “May to December 1795” statement.\n",
    "\n",
    "All Cagan-hyperinflation threshold months sit inside sub-period 3, confirming that the boundary the lecture uses is a good approximation to Cagan’s own criterion."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "40f74609",
   "metadata": {},
   "source": [
    "## Exercise 38.2\n",
    "\n",
    "**Estimating Cagan’s money-demand sensitivity $ \\alpha $ from the data.**\n",
    "\n",
    "The Cagan demand-for-money function (see [A Monetarist Theory of Price Levels](https://intro.quantecon.org/cagan_ree.html)) implies a\n",
    "*log-linear* relationship between real money balances and inflation:\n",
    "\n",
    "$$\n",
    "\\log(M_t/p_t) = c - \\alpha \\pi_t\n",
    "$$\n",
    "\n",
    "The lecture fits a *linear* (levels) regression of `infl` on `bal` for the\n",
    "hyperinflation sub-period, but Cagan’s theory predicts a log-linear\n",
    "relationship.\n",
    "\n",
    "a. Compute `log_bal = np.log(bal)`, use the `fit` helper defined in this lecture\n",
    "to regress `log_bal[44:63]` on `infl[44:63]`, extract the slope $ b $, and set\n",
    "$ \\hat\\alpha = -b $.\n",
    "\n",
    "b. Plot `infl[44:63]` on the horizontal axis and `log_bal[44:63]` on the\n",
    "vertical axis, then overlay the fitted line and label it with the estimated\n",
    "$ \\hat\\alpha $.\n",
    "\n",
    "c. Explain why the slope $ b_3 $ from the lecture’s levels regression of `infl` on\n",
    "`bal` is less consistent with Cagan’s model than the log-linear\n",
    "specification in part a, and identify the distortion that arises from using\n",
    "`bal` in levels during a hyperinflation.\n",
    "\n",
    "d. Compare $ \\hat\\alpha $ from part a to the default value $ \\alpha = 5 $ used in\n",
    "the quantecon lecture [A Monetarist Theory of Price Levels](https://intro.quantecon.org/cagan_ree.html) and assess whether the order of\n",
    "magnitude is consistent."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ea1306fc",
   "metadata": {},
   "source": [
    "## Solution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3a42fe27",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "log_bal = np.log(bal)\n",
    "\n",
    "# Fit log_bal = a + b * infl.\n",
    "a_log, b_log = fit(infl[44:63], log_bal[44:63])\n",
    "α_hat = -b_log\n",
    "print(f'Log-linear estimate:  alpha_hat = {α_hat:.2f}')\n",
    "print(f'Default in cagan_ree: α  = 5.00')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2b06e855",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "infl_grid = np.linspace(infl[44:63].min(), infl[44:63].max(), 100)\n",
    "\n",
    "fig, ax = plt.subplots()\n",
    "ax.scatter(infl[44:63], log_bal[44:63],\n",
    "           marker='*', color='orange', s=60, label='data (hyperinflation)')\n",
    "ax.plot(infl_grid, a_log + b_log * infl_grid,\n",
    "        color='orange', lw=2,\n",
    "        label=fr'log-linear fit: $\\hat{{\\alpha}} = {α_hat:.1f}$')\n",
    "ax.set_xlabel('Monthly inflation rate $\\\\pi_t$')\n",
    "ax.set_ylabel('$\\\\log(\\\\mathrm{real\\\\;balances})$')\n",
    "ax.set_title('Cagan demand for money - hyperinflation period')\n",
    "ax.legend()\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bdefbcc0",
   "metadata": {},
   "source": [
    "**Part c:** Cagan’s model postulates an exponential fall in real balances as\n",
    "inflation rises, $ M/p = e^{c - \\alpha\\pi} $.\n",
    "\n",
    "Over a hyperinflation real balances vary by orders of magnitude, so a linear\n",
    "fit of `infl` on `bal` is a poor global approximation because it imposes a straight line on what is an exponential curve.\n",
    "\n",
    "Taking logs first makes the relationship linear and the regression well-specified\n",
    "across the full range of the data.\n",
    "\n",
    "**Part d:** $ \\hat\\alpha $ should come out in the range of 3-6, consistent with the\n",
    "default $ \\alpha = 5 $ in [A Monetarist Theory of Price Levels](https://intro.quantecon.org/cagan_ree.html), confirming that the same model estimated\n",
    "on 18th-century French data gives a parameter value similar to those obtained from\n",
    "20th-century hyperinflations."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e4f254b2",
   "metadata": {},
   "source": [
    "## Exercise 38.3\n",
    "\n",
    "**A single-figure portrait of the three monetary regimes.**\n",
    "\n",
    "The lecture presents the three monetary regimes through five separate scatter plots.\n",
    "\n",
    "Here you will synthesise them into a single figure that makes the contrasting theories visually obvious.\n",
    "\n",
    "Produce a figure with all three scatter clouds (blue circles, red pluses, orange\n",
    "stars) and one regression line per cloud, using the coefficients already computed\n",
    "in the lecture:\n",
    "\n",
    "- **Real bills** (indices 1:31): draw the regression line\n",
    "  `infl = a1 + b1 * bal`  (theory says growing *backed* real balances accompany\n",
    "  only modest inflation).  \n",
    "- **Terror** (indices 31:44): because legal restrictions suspended the normal\n",
    "  money-demand relationship, draw the *reversed* regression\n",
    "  `bal = a2_rev + b2_rev * infl` as a function of `infl`, which produces a\n",
    "  nearly *horizontal* line in `(bal, infl)` space and shows that real balances\n",
    "  were held roughly fixed by force regardless of inflation.  \n",
    "- **Hyperinflation** (indices 44:63): draw `infl = a3 + b3 * bal`  (the classic\n",
    "  negative Cagan slope, since higher inflation accompanies lower real balances).  \n",
    "\n",
    "\n",
    "After producing the figure, write 2-3 sentences explaining why the Terror\n",
    "regression line takes a different orientation from the other two."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c81740eb",
   "metadata": {},
   "source": [
    "## Solution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8fa9142f",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots(figsize=(8, 6))\n",
    "\n",
    "# Real bills\n",
    "ax.plot(bal[1:31], infl[1:31], 'o', markerfacecolor='none',\n",
    "        color='blue', label='Real bills (1791-1793)')\n",
    "bal_grid1 = np.linspace(bal[1:31].min(), bal[1:31].max(), 100)\n",
    "ax.plot(bal_grid1, a1 + b1 * bal_grid1, color='blue', lw=2)\n",
    "\n",
    "# Terror\n",
    "ax.plot(bal[31:44], infl[31:44], '+', color='red', ms=9,\n",
    "        label='Terror (1793-1794)')\n",
    "infl_grid2 = np.linspace(infl[31:44].min(), infl[31:44].max(), 100)\n",
    "ax.plot(a2_rev + b2_rev * infl_grid2, infl_grid2, color='red', lw=2)\n",
    "\n",
    "# Hyperinflation\n",
    "ax.plot(bal[44:63], infl[44:63], '*', color='orange', ms=8,\n",
    "        label='Hyperinflation (1794-1796)')\n",
    "bal_grid3 = np.linspace(bal[44:63].min(), bal[44:63].max(), 100)\n",
    "ax.plot(bal_grid3, a3 + b3 * bal_grid3, color='orange', lw=2)\n",
    "\n",
    "ax.set_xlabel('Real balances (millions of livres)')\n",
    "ax.set_ylabel('Monthly inflation rate')\n",
    "ax.set_title('Three monetary regimes in Revolutionary France')\n",
    "ax.legend(fontsize=9)\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b85dd723",
   "metadata": {},
   "source": [
    "During the Terror the Committee of Public Safety imposed legal restrictions, including the death penalty for refusing assignats, that forced citizens to hold high real balances regardless of how fast prices were rising.\n",
    "\n",
    "This broke the normal money-demand relationship because real balances were determined by government decree rather than by inflation.\n",
    "\n",
    "Regressing `bal` on `infl` and plotting the result as a nearly horizontal line reflects this altered direction of causation.\n",
    "\n",
    "Inflation varied substantially during the Terror, but real balances barely moved.\n",
    "\n",
    "By contrast, both the real-bills and hyperinflation clouds obey a theory in which real balances are chosen by the public and hence respond to inflation."
   ]
  }
 ],
 "metadata": {
  "date": 1795846196.7266276,
  "filename": "french_rev.md",
  "kernelspec": {
   "display_name": "Python",
   "language": "python3",
   "name": "python3"
  },
  "title": "Inflation During the French Revolution"
 },
 "nbformat": 4,
 "nbformat_minor": 5
}