Skip to content

Commit 9bb6036

Browse files
committed
Create two notebook versions: portable and MyST
- method-of-moderation.ipynb: Expanded LaTeX, displays correctly in any Jupyter/KaTeX environment (macros like \mNrm → m) - method-of-moderation-myst.ipynb: Original with MyST macros, for paper building where macros.yml is available This enables the notebook to display properly in standard Jupyter while preserving the MyST-compatible source for document builds.
1 parent 13a7649 commit 9bb6036

File tree

2 files changed

+1368
-31
lines changed

2 files changed

+1368
-31
lines changed

code/method-of-moderation-myst.ipynb

Lines changed: 1337 additions & 0 deletions
Large diffs are not rendered by default.

code/method-of-moderation.ipynb

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@
325325
"source": [
326326
"## Consumption Function Analysis\n",
327327
"\n",
328-
"The first set of figures will focus on the core of the consumption-saving problem: the consumption function $\\cFunc(\\mNrm)$, which maps market resources $\\mNrm$ to consumption. We will demonstrate the extrapolation problem inherent in the standard EGM and show how the Method of Moderation resolves it by respecting theoretical bounds.\n",
328+
"The first set of figures will focus on the core of the consumption-saving problem: the consumption function $\\mathbf{c}(m)$, which maps market resources $m$ to consumption. We will demonstrate the extrapolation problem inherent in the standard EGM and show how the Method of Moderation resolves it by respecting theoretical bounds.\n",
329329
"\n",
330330
"### Figure 1: The EGM Extrapolation Problem\n",
331331
"\n",
@@ -432,7 +432,7 @@
432432
"metadata": {},
433433
"source": [
434434
"```{important} Key Theoretical Insight\n",
435-
"The constraint $\\cFuncPes(\\mNrm) \\leq \\cFuncReal(\\mNrm) \\leq \\cFuncOpt(\\mNrm)$ is the foundation for MoM {cite:p}`CarrollShanker2024`. The lower bound arises from the natural borrowing constraint in incomplete markets models {cite:p}`Aiyagari1994,Huggett1993,Zeldes1989,Deaton1991`.\n",
435+
"The constraint $\\underline{\\mathbf{c}}(m) \\leq \\hat{\\mathbf{c}}(m) \\leq \\bar{\\mathbf{c}}(m)$ is the foundation for MoM {cite:p}`CarrollShanker2024`. The lower bound arises from the natural borrowing constraint in incomplete markets models {cite:p}`Aiyagari1994,Huggett1993,Zeldes1989,Deaton1991`.\n",
436436
"```\n",
437437
"\n",
438438
"### Figure 3: Method of Moderation Solution\n",
@@ -494,22 +494,22 @@
494494
"\n",
495495
"MoM steps (notation matches the paper):\n",
496496
"1. Solve standard EGM for realist consumption at gridpoints\n",
497-
"2. Transform to $\\logmNrmEx = \\log(\\mNrm - \\mNrmMin)$\n",
498-
"3. Compute $\\modRte(\\logmNrmEx) = (\\cFuncReal - \\cFuncPes)/(\\cFuncOpt - \\cFuncPes) \\in [0,1]$ (Eq. {eq}`eq:modRte`)\n",
499-
"4. Apply logit: $\\logitModRte = \\log(\\modRte/(1-\\modRte))$\n",
500-
"5. Interpolate $\\logitModRte(\\logmNrmEx)$ with derivatives\n",
501-
"6. Reconstruct: $\\cFuncReal = \\cFuncPes + \\modRte \\cdot (\\cFuncOpt - \\cFuncPes)$\n",
497+
"2. Transform to $\\boldsymbol{\\mu} = \\log(m - \\underline{m})$\n",
498+
"3. Compute $\\boldsymbol{\\omega}(\\boldsymbol{\\mu}) = (\\hat{\\mathbf{c}} - \\underline{\\mathbf{c}})/(\\bar{\\mathbf{c}} - \\underline{\\mathbf{c}}) \\in [0,1]$ (Eq. {eq}`eq:modRte`)\n",
499+
"4. Apply logit: $\\boldsymbol{\\chi} = \\log(\\boldsymbol{\\omega}/(1-\\boldsymbol{\\omega}))$\n",
500+
"5. Interpolate $\\boldsymbol{\\chi}(\\boldsymbol{\\mu})$ with derivatives\n",
501+
"6. Reconstruct: $\\hat{\\mathbf{c}} = \\underline{\\mathbf{c}} + \\boldsymbol{\\omega} \\cdot (\\bar{\\mathbf{c}} - \\underline{\\mathbf{c}})$\n",
502502
"\n",
503503
"This ensures bound compliance via asymptotically linear extrapolation, as derived in the paper. HARK uses **cubic Hermite interpolation** {cite:p}`Fritsch1980,FritschButland1984` for accuracy; see {cite:p}`Santos2000,JuddMaliarMaliar2017` on function approximation and error bounding.\n",
504504
"```\n",
505505
"\n",
506506
"```{note} The Transformation\n",
507-
"The logit maps $\\modRte \\in (0,1)$ to $\\logitModRte \\in (-\\infty, +\\infty)$ and becomes asymptotically linear with positive slope $\\logitModRteMu > 0$ as wealth increases.\n",
507+
"The logit maps $\\boldsymbol{\\omega} \\in (0,1)$ to $\\boldsymbol{\\chi} \\in (-\\infty, +\\infty)$ and becomes asymptotically linear with positive slope $\\partial \\boldsymbol{\\chi} / \\partial \\boldsymbol{\\mu} > 0$ as wealth increases.\n",
508508
"```\n",
509509
"\n",
510510
"### Figure 4: MoM Consumption Function\n",
511511
"\n",
512-
"[](#fig:mom-consumption-function) ({ref}`Figure 4 <fig:IntExpFOCInvPesReaOptNeed45>` in the paper) shows MoM consumption between optimist and pessimist bounds, plus a **tighter upper bound** derived from $\\MPCmax$ near the borrowing constraint {cite:p}`Carroll2001MPCBound,MaToda2021SavingRateRich,CarrollToche2009`. The cusp intersection is given by {eq}`eq:mNrmCusp`."
512+
"[](#fig:mom-consumption-function) ({ref}`Figure 4 <fig:IntExpFOCInvPesReaOptNeed45>` in the paper) shows MoM consumption between optimist and pessimist bounds, plus a **tighter upper bound** derived from $\\bar{\\boldsymbol{\\kappa}}$ near the borrowing constraint {cite:p}`Carroll2001MPCBound,MaToda2021SavingRateRich,CarrollToche2009`. The cusp intersection is given by {eq}`eq:mNrmCusp`."
513513
]
514514
},
515515
{
@@ -608,18 +608,18 @@
608608
"\n",
609609
"## Method of Moderation Framework\n",
610610
"\n",
611-
"### Figure 6: Moderation Ratio Function $\\modRte(\\mNrm)$\n",
611+
"### Figure 6: Moderation Ratio Function $\\boldsymbol{\\omega}(m)$\n",
612612
"\n",
613613
"::::{admonition} Definition: The Moderation Ratio\n",
614614
":class: note\n",
615615
"\n",
616616
"The **moderation ratio** (Eq. {eq}`eq:modRte`):\n",
617617
"\n",
618618
"$$\n",
619-
"\\modRte(\\mNrm) = \\frac{\\cFuncReal(\\mNrm) - \\cFuncPes(\\mNrm)}{\\cFuncOpt(\\mNrm) - \\cFuncPes(\\mNrm)} \\in (0,1)\n",
619+
"\\boldsymbol{\\omega}(m) = \\frac{\\hat{\\mathbf{c}}(m) - \\underline{\\mathbf{c}}(m)}{\\bar{\\mathbf{c}}(m) - \\underline{\\mathbf{c}}(m)} \\in (0,1)\n",
620620
"$$\n",
621621
"\n",
622-
"This ratio is strictly between 0 and 1 due to prudence {cite:p}`CarrollKimball1996`. At $\\modRte = 0$ the realist behaves like the pessimist (maximum precautionary saving); at $\\modRte = 1$ like the optimist (no precautionary saving). [](#fig:moderation-ratio) plots this ratio across wealth levels.\n",
622+
"This ratio is strictly between 0 and 1 due to prudence {cite:p}`CarrollKimball1996`. At $\\boldsymbol{\\omega} = 0$ the realist behaves like the pessimist (maximum precautionary saving); at $\\boldsymbol{\\omega} = 1$ like the optimist (no precautionary saving). [](#fig:moderation-ratio) plots this ratio across wealth levels.\n",
623623
"::::"
624624
]
625625
},
@@ -665,8 +665,8 @@
665665
"id": "587c8ea3",
666666
"metadata": {},
667667
"source": [
668-
"```{note} Economic Interpretation of $\\modRte(\\mNrm)$\n",
669-
"$\\modRte \\to 1$ at high wealth (approaches optimist), $\\modRte \\to 0$ at low wealth (approaches pessimist). This monotonic pattern ensures proper economic behavior across the wealth distribution.\n",
668+
"```{note} Economic Interpretation of $\\boldsymbol{\\omega}(m)$\n",
669+
"$\\boldsymbol{\\omega} \\to 1$ at high wealth (approaches optimist), $\\boldsymbol{\\omega} \\to 0$ at low wealth (approaches pessimist). This monotonic pattern ensures proper economic behavior across the wealth distribution.\n",
670670
"```\n",
671671
"\n",
672672
"### Figure 7: The Logit Transformation\n",
@@ -677,10 +677,10 @@
677677
"The **logit transformation** (Eq. {eq}`eq:chi`) maps the bounded ratio to an unbounded space:\n",
678678
"\n",
679679
"$$\n",
680-
"\\logitModRte(\\logmNrmEx) = \\log\\left(\\frac{\\modRte(\\logmNrmEx)}{1 - \\modRte(\\logmNrmEx)}\\right)\n",
680+
"\\boldsymbol{\\chi}(\\boldsymbol{\\mu}) = \\log\\left(\\frac{\\boldsymbol{\\omega}(\\boldsymbol{\\mu})}{1 - \\boldsymbol{\\omega}(\\boldsymbol{\\mu})}\\right)\n",
681681
"$$\n",
682682
"\n",
683-
"where $\\logmNrmEx = \\log(\\mNrm - \\mNrmMin)$. As [](#fig:logit-transformation) shows, $\\logitModRte$ is nearly linear, making it well-suited for interpolation.\n",
683+
"where $\\boldsymbol{\\mu} = \\log(m - \\underline{m})$. As [](#fig:logit-transformation) shows, $\\boldsymbol{\\chi}$ is nearly linear, making it well-suited for interpolation.\n",
684684
"::::"
685685
]
686686
},
@@ -726,18 +726,18 @@
726726
"metadata": {},
727727
"source": [
728728
"```{important} Why Asymptotic Linearity Matters\n",
729-
"As $\\logmNrmEx \\to \\infty$, $\\logitModRte$ becomes linear with slope $\\logitModRteMu > 0$. This prevents extrapolation errors, ensures smooth convergence to the optimist bound, and maintains numerical stability.\n",
729+
"As $\\boldsymbol{\\mu} \\to \\infty$, $\\boldsymbol{\\chi}$ becomes linear with slope $\\partial \\boldsymbol{\\chi} / \\partial \\boldsymbol{\\mu} > 0$. This prevents extrapolation errors, ensures smooth convergence to the optimist bound, and maintains numerical stability.\n",
730730
"```\n",
731731
"\n",
732-
"```{note} Properties of $\\logitModRte(\\logmNrmEx)$\n",
733-
"Unbounded domain $(-\\infty, \\infty)$, monotonically increasing, asymptotically linear. $\\logitModRte > 0$ indicates behavior closer to optimist; $\\logitModRte < 0$ closer to pessimist.\n",
732+
"```{note} Properties of $\\boldsymbol{\\chi}(\\boldsymbol{\\mu})$\n",
733+
"Unbounded domain $(-\\infty, \\infty)$, monotonically increasing, asymptotically linear. $\\boldsymbol{\\chi} > 0$ indicates behavior closer to optimist; $\\boldsymbol{\\chi} < 0$ closer to pessimist.\n",
734734
"```\n",
735735
"\n",
736736
"## Function Properties and Bounds\n",
737737
"\n",
738738
"### Figure 8: MoM MPC Bounded by Theory\n",
739739
"\n",
740-
"The **MPC** ($\\partial \\cNrm / \\partial \\mNrm$) is bounded between $\\MPCmin$ (optimist) and $\\MPCmax$ (at the borrowing constraint), as detailed in {ref}`the paper <a-tighter-upper-bound>` and Eq. {eq}`eq:MPCModeration` {cite:p}`Carroll2001MPCBound`. [](#fig:mpc-bounds) confirms MoM respects these bounds.\n",
740+
"The **MPC** ($\\partial c / \\partial m$) is bounded between $\\underline{\\boldsymbol{\\kappa}}$ (optimist) and $\\bar{\\boldsymbol{\\kappa}}$ (at the borrowing constraint), as detailed in {ref}`the paper <a-tighter-upper-bound>` and Eq. {eq}`eq:MPCModeration` {cite:p}`Carroll2001MPCBound`. [](#fig:mpc-bounds) confirms MoM respects these bounds.\n",
741741
"\n",
742742
"```{tip} Policy Applications\n",
743743
"Bounded MPC estimates prevent nonsensical policy multipliers in DSGE models. MoM ensures economically meaningful MPCs for policy analysis.\n",
@@ -785,12 +785,12 @@
785785
"metadata": {},
786786
"source": [
787787
"```{hint} MPC Economic Interpretation\n",
788-
"MoM MPC declines with $\\mNrm$: poor consumers spend windfalls immediately (MPC $\\to \\MPCmax$), wealthy consumers save them (MPC $\\to \\MPCmin$), reflecting diminishing marginal utility.\n",
788+
"MoM MPC declines with $m$: poor consumers spend windfalls immediately (MPC $\\to \\bar{\\boldsymbol{\\kappa}}$), wealthy consumers save them (MPC $\\to \\underline{\\boldsymbol{\\kappa}}$), reflecting diminishing marginal utility.\n",
789789
"```\n",
790790
"\n",
791791
"### Figure 9: Value Functions Bounded by Theory\n",
792792
"\n",
793-
"The **value function** $\\vFunc(\\mNrm)$ is also bounded by optimist and pessimist solutions {cite:p}`Aiyagari1994,Huggett1993`. [](#fig:value-functions) compares truth, EGM, and MoM value functions."
793+
"The **value function** $\\mathbf{v}(m)$ is also bounded by optimist and pessimist solutions {cite:p}`Aiyagari1994,Huggett1993`. [](#fig:value-functions) compares truth, EGM, and MoM value functions."
794794
]
795795
},
796796
{
@@ -843,9 +843,9 @@
843843
"Uncertainty matters most at low wealth where buffers are small; the optimist-pessimist gap narrows with wealth as assets provide natural insurance.\n",
844844
"```\n",
845845
"\n",
846-
"### Figure 10: Inverse Value Functions $\\vInv(\\mNrm)$\n",
846+
"### Figure 10: Inverse Value Functions ${\\scriptsize \\boldsymbol{\\Lambda}}(m)$\n",
847847
"\n",
848-
"The **inverse value function** $\\vInv(\\mNrm) = \\uFunc^{-1}(\\vFunc(\\mNrm))$ gives the consumption equivalent of lifetime utility. It is more linear than $\\vFunc(\\mNrm)$ near the borrowing constraint, making it better suited for interpolation. [](#fig:inverse-value-functions) compares the three solutions."
848+
"The **inverse value function** ${\\scriptsize \\boldsymbol{\\Lambda}}(m) = \\mathbf{u}^{-1}(\\mathbf{v}(m))$ gives the consumption equivalent of lifetime utility. It is more linear than $\\mathbf{v}(m)$ near the borrowing constraint, making it better suited for interpolation. [](#fig:inverse-value-functions) compares the three solutions."
849849
]
850850
},
851851
{
@@ -892,15 +892,15 @@
892892
"metadata": {},
893893
"source": [
894894
"```{note} Inverse Value Function Interpretation\n",
895-
"The inverse transformation converts utility to consumption units: $\\vInv(5) = 0.8$ means 5 units of wealth provides lifetime utility equivalent to consuming 0.8 forever. HARK uses this more linear representation for interpolation.\n",
895+
"The inverse transformation converts utility to consumption units: ${\\scriptsize \\boldsymbol{\\Lambda}}(5) = 0.8$ means 5 units of wealth provides lifetime utility equivalent to consuming 0.8 forever. HARK uses this more linear representation for interpolation.\n",
896896
"```\n",
897897
"\n",
898898
"### Figure 11: Value Function Moderation Ratio\n",
899899
"\n",
900900
"MoM applies to any bounded function. The **inverse value function moderation ratio** (Eq. {eq}`eq:valModRteReal`):\n",
901901
"\n",
902902
"$$\n",
903-
"\\valModRte(\\mNrm) = \\frac{\\vInvReal(\\mNrm) - \\vInvPes(\\mNrm)}{\\vInvOpt(\\mNrm) - \\vInvPes(\\mNrm)}\n",
903+
"\\boldsymbol{\\Omega}(m) = \\frac{\\hat{{\\scriptsize \\boldsymbol{\\Lambda}}}(m) - \\underline{{\\scriptsize \\boldsymbol{\\Lambda}}}(m)}{\\bar{{\\scriptsize \\boldsymbol{\\Lambda}}}(m) - \\underline{{\\scriptsize \\boldsymbol{\\Lambda}}}(m)}\n",
904904
"$$\n",
905905
"\n",
906906
"follows the same pattern as the consumption ratio, as shown in [](#fig:value-moderation-ratio)."
@@ -949,18 +949,18 @@
949949
"metadata": {},
950950
"source": [
951951
"```{hint} Value Function Moderation Interpretation\n",
952-
"$\\valModRte \\to 1$ at high wealth (low uncertainty cost), $\\valModRte \\to 0$ at low wealth (high uncertainty cost). The pattern confirms uncertainty's welfare cost diminishes with wealth.\n",
952+
"$\\boldsymbol{\\Omega} \\to 1$ at high wealth (low uncertainty cost), $\\boldsymbol{\\Omega} \\to 0$ at low wealth (high uncertainty cost). The pattern confirms uncertainty's welfare cost diminishes with wealth.\n",
953953
"```\n",
954954
"\n",
955955
"### Figure 12: Cusp Point Visualization\n",
956956
"\n",
957957
"The **cusp point** (Eq. {eq}`eq:mNrmCusp`) is where optimist and tighter upper bounds intersect:\n",
958958
"\n",
959959
"$$\n",
960-
"\\mNrmCusp = \\mNrmMin + \\frac{\\MPCmin \\cdot \\hNrmEx}{\\MPCmax - \\MPCmin}\n",
960+
"m^* = \\underline{m} + \\frac{\\underline{\\boldsymbol{\\kappa}} \\cdot \\Delta h}{\\bar{\\boldsymbol{\\kappa}} - \\underline{\\boldsymbol{\\kappa}}}\n",
961961
"$$\n",
962962
"\n",
963-
"Below the cusp, the tighter bound ($\\MPCmax$ slope) constrains; above, the optimist bound constrains. See `IndShockMoMCuspConsumerType` for the three-piece implementation."
963+
"Below the cusp, the tighter bound ($\\bar{\\boldsymbol{\\kappa}}$ slope) constrains; above, the optimist bound constrains. See `IndShockMoMCuspConsumerType` for the three-piece implementation."
964964
]
965965
},
966966
{
@@ -1005,7 +1005,7 @@
10051005
"metadata": {},
10061006
"source": [
10071007
"```{hint} Cusp Point Interpretation\n",
1008-
"Below cusp: MPC near $\\MPCmax$, tighter bound constrains. Above cusp: behavior approaches optimist ($\\MPCmin$), optimist bound constrains. The envelope is the minimum of both bounds.\n",
1008+
"Below cusp: MPC near $\\bar{\\boldsymbol{\\kappa}}$, tighter bound constrains. Above cusp: behavior approaches optimist ($\\underline{\\boldsymbol{\\kappa}}$), optimist bound constrains. The envelope is the minimum of both bounds.\n",
10091009
"```\n",
10101010
"\n",
10111011
"## Further Extensions: Stochastic Rate of Return\n",
@@ -1070,7 +1070,7 @@
10701070
"metadata": {},
10711071
"source": [
10721072
"```{hint} Stochastic Returns Interpretation\n",
1073-
"Deterministic optimist uses $\\MPCmin = 1 - (\\DiscFac \\Rfree)^{1/\\CRRA}$; stochastic optimist uses $\\MPCmin = 1 - (\\DiscFac \\Ex[\\Risky^{1-\\CRRA}])^{1/\\CRRA}$. Return uncertainty raises MPC and narrows the feasible region. See {ref}`stochastic-returns-mgf-derivation` for the MGF derivation.\n",
1073+
"Deterministic optimist uses $\\underline{\\boldsymbol{\\kappa}} = 1 - (\\beta \\text{R})^{1/\\rho}$; stochastic optimist uses $\\underline{\\boldsymbol{\\kappa}} = 1 - (\\beta \\mathbf{\\mathbb{E}}[\\mathbf{R}^{1-\\rho}])^{1/\\rho}$. Return uncertainty raises MPC and narrows the feasible region. See {ref}`stochastic-returns-mgf-derivation` for the MGF derivation.\n",
10741074
"```\n",
10751075
"\n",
10761076
"## Summary\n",

0 commit comments

Comments
 (0)