{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Robustness\n",
"\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Contents\n",
"\n",
"- [Robustness](#Robustness) \n",
" - [Overview](#Overview) \n",
" - [The Model](#The-Model) \n",
" - [Constructing More Robust Policies](#Constructing-More-Robust-Policies) \n",
" - [Robustness as Outcome of a Two-Person Zero-Sum Game](#Robustness-as-Outcome-of-a-Two-Person-Zero-Sum-Game) \n",
" - [The Stochastic Case](#The-Stochastic-Case) \n",
" - [Implementation](#Implementation) \n",
" - [Application](#Application) \n",
" - [Appendix](#Appendix) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Overview\n",
"\n",
"\n",
"\n",
"This lecture modifies a Bellman equation to express a decision maker’s doubts about transition dynamics\n",
"\n",
"His specification doubts make the decision maker want a *robust* decision rule\n",
"\n",
"*Robust* means insensitive to misspecification of transition dynamics\n",
"\n",
"The decision maker has a single *approximating model*\n",
"\n",
"He calls it *approximating* to acknowledge that he doesn’t completely trust it\n",
"\n",
"He fears that outcomes will actually be determined by another model that he cannot describe explicitly\n",
"\n",
"All that he knows is that the actual data-generating model is in some (uncountable) set of models that surrounds his approximating model\n",
"\n",
"He quantifies the discrepancy between his approximating model and the genuine data-generating model by using a quantity called *entropy*\n",
"\n",
"(We’ll explain what entropy means below)\n",
"\n",
"He wants a decision rule that will work well enough no matter which of those other models actually governs outcomes\n",
"\n",
"This is what it means for his decision rule to be “robust to misspecification of an approximating model”\n",
"\n",
"This may sound like too much to ask for, but $ \\ldots $\n",
"\n",
"$ \\ldots $ a *secret weapon* is available to design robust decision rules\n",
"\n",
"The secret weapon is max-min control theory\n",
"\n",
"A value-maximizing decision maker enlists the aid of an (imaginary) value-minimizing model chooser to construct *bounds* on the value attained by a given decision rule under different models of the transition dynamics\n",
"\n",
"The original decision maker uses those bounds to construct a decision rule with an assured performance level, no matter which model actually governs outcomes\n",
"\n",
">**Note**\n",
">\n",
">In reading this lecture, please don’t think that our decision maker is paranoid when he conducts a worst-case analysis. By designing a rule that works well against a worst-case, his intention is to construct a rule that will work well across a *set* of models.\n",
"\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Sets of Models Imply Sets Of Values\n",
"\n",
"Our “robust” decision maker wants to know how well a given rule will work when he does not *know* a single transition law $ \\ldots $\n",
"\n",
"$ \\ldots $ he wants to know *sets* of values that will be attained by a given decision rule $ F $ under a *set* of transition laws\n",
"\n",
"Ultimately, he wants to design a decision rule $ F $ that shapes these *sets* of values in ways that he prefers\n",
"\n",
"With this in mind, consider the following graph, which relates to a particular decision problem to be explained below\n",
"\n",
"\n",
"\n",
" \n",
"The figure shows a *value-entropy correspondence* for a particular decision rule $ F $\n",
"\n",
"The shaded set is the graph of the correspondence, which maps entropy to a set of values associated with a set of models that surround the decision maker’s approximating model\n",
"\n",
"Here\n",
"\n",
"- *Value* refers to a sum of discounted rewards obtained by applying the decision rule $ F $ when the state starts at some fixed initial state $ x_0 $ \n",
"- *Entropy* is a nonnegative number that measures the size of a set of models surrounding the decision maker’s approximating model \n",
" \n",
" - Entropy is zero when the set includes only the approximating model, indicating that the decision maker completely trusts the approximating model \n",
" - Entropy is bigger, and the set of surrounding models is bigger, the less the decision maker trusts the approximating model \n",
" \n",
"\n",
"\n",
"The shaded region indicates that for **all** models having entropy less than or equal to the number on the horizontal axis, the value obtained will be somewhere within the indicated set of values\n",
"\n",
"Now let’s compare sets of values associated with two different decision rules, $ F_r $ and $ F_b $\n",
"\n",
"In the next figure,\n",
"\n",
"- The red set shows the value-entropy correspondence for decision rule $ F_r $ \n",
"- The blue set shows the value-entropy correspondence for decision rule $ F_b $ \n",
"\n",
"\n",
"\n",
"\n",
" \n",
"The blue correspondence is skinnier than the red correspondence\n",
"\n",
"This conveys the sense in which the decision rule $ F_b $ is *more robust* than the decision rule $ F_r $\n",
"\n",
"- *more robust* means that the set of values is less sensitive to *increasing misspecification* as measured by entropy \n",
"\n",
"\n",
"Notice that the less robust rule $ F_r $ promises higher values for small misspecifications (small entropy)\n",
"\n",
"(But it is more fragile in the sense that it is more sensitive to perturbations of the approximating model)\n",
"\n",
"Below we’ll explain in detail how to construct these sets of values for a given $ F $, but for now $ \\ldots $\n",
"\n",
"Here is a hint about the *secret weapons* we’ll use to construct these sets\n",
"\n",
"> - We’ll use some min problems to construct the lower bounds \n",
"- We’ll use some max problems to construct the upper bounds \n",
"\n",
"\n",
"\n",
"We will also describe how to choose $ F $ to shape the sets of values\n",
"\n",
"This will involve crafting a *skinnier* set at the cost of a lower *level* (at least for low values of entropy)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Inspiring Video\n",
"\n",
"If you want to understand more about why one serious quantitative researcher is interested in this approach, we recommend [Lars Peter Hansen’s Nobel lecture](http://www.nobelprize.org/mediaplayer/index.php?id=1994)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Other References\n",
"\n",
"Our discussion in this lecture is based on\n",
"\n",
"- [[HS00]](https://lectures.quantecon.org/py/zreferences.html#hansensargent2000) \n",
"- [[HS08]](https://lectures.quantecon.org/py/zreferences.html#hansensargent2008) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The Model\n",
"\n",
"For simplicity, we present ideas in the context of a class of problems with linear transition laws and quadratic objective functions\n",
"\n",
"To fit in with [our earlier lecture on LQ control](https://lectures.quantecon.org/py/lqcontrol.html), we will treat loss minimization rather than value maximization\n",
"\n",
"To begin, recall the [infinite horizon LQ problem](https://lectures.quantecon.org/py/lqcontrol.html#lq-ih), where an agent chooses a sequence of controls $ \\{u_t\\} $ to minimize\n",
"\n",
"\n",
"\n",
"$$\n",
"\\sum_{t=0}^{\\infty} \\beta^t\n",
" \\left\\{\n",
" x_t' R x_t + u_t' Q u_t\n",
" \\right\\} \\tag{1}\n",
"$$\n",
"\n",
"subject to the linear law of motion\n",
"\n",
"\n",
"\n",
"$$\n",
"x_{t+1} = A x_t + B u_t + C w_{t+1},\n",
"\\qquad t = 0, 1, 2, \\ldots \\tag{2}\n",
"$$\n",
"\n",
"As before,\n",
"\n",
"- $ x_t $ is $ n \\times 1 $, $ A $ is $ n \\times n $ \n",
"- $ u_t $ is $ k \\times 1 $, $ B $ is $ n \\times k $ \n",
"- $ w_t $ is $ j \\times 1 $, $ C $ is $ n \\times j $ \n",
"- $ R $ is $ n \\times n $ and $ Q $ is $ k \\times k $ \n",
"\n",
"\n",
"Here $ x_t $ is the state, $ u_t $ is the control, and $ w_t $ is a shock vector\n",
"\n",
"For now we take $ \\{ w_t \\} := \\{ w_t \\}_{t=1}^{\\infty} $ to be deterministic — a single fixed sequence\n",
"\n",
"We also allow for *model uncertainty* on the part of the agent solving this optimization problem\n",
"\n",
"In particular, the agent takes $ w_t = 0 $ for all $ t \\geq 0 $ as a benchmark model, but admits the possibility that this model might be wrong\n",
"\n",
"As a consequence, she also considers a set of alternative models expressed in terms of sequences $ \\{ w_t \\} $ that are “close” to the zero sequence\n",
"\n",
"She seeks a policy that will do well enough for a set of alternative models whose members are pinned down by sequences $ \\{ w_t \\} $\n",
"\n",
"Soon we’ll quantify the quality of a model specification in terms of the maximal size of the expression $ \\sum_{t=0}^{\\infty} \\beta^{t+1}w_{t+1}' w_{t+1} $"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Constructing More Robust Policies\n",
"\n",
"If our agent takes $ \\{ w_t \\} $ as a given deterministic sequence, then, drawing on intuition from earlier lectures on dynamic programming, we can anticipate Bellman equations such as\n",
"\n",
"$$\n",
"J_{t-1} (x)\n",
"= \\min_u\n",
"\\{\n",
" x' R x + u' Q u + \\beta \\,\n",
" J_t (Ax + B u + C w_t)\n",
"\\}\n",
"$$\n",
"\n",
"(Here $ J $ depends on $ t $ because the sequence $ \\{w_t\\} $ is not recursive)\n",
"\n",
"Our tool for studying robustness is to construct a rule that works well even if an adverse sequence $ \\{ w_t \\} $ occurs\n",
"\n",
"In our framework, “adverse” means “loss increasing”\n",
"\n",
"As we’ll see, this will eventually lead us to construct the Bellman equation\n",
"\n",
"\n",
"\n",
"$$\n",
"J (x) =\n",
"\\min_u\n",
"\\max_w\n",
"\\{\n",
" x' R x + u' Q u + \\beta \\,\n",
" [J (Ax + B u + C w) - \\theta w'w]\n",
"\\} \\tag{3}\n",
"$$\n",
"\n",
"Notice that we’ve added the penalty term $ - \\theta w'w $\n",
"\n",
"Since $ w'w = \\| w \\|^2 $, this term becomes influential when $ w $ moves away from the origin\n",
"\n",
"The penalty parameter $ \\theta $ controls how much we penalize the maximizing agent for “harming” the minimizing agent\n",
"\n",
"By raising $ \\theta $ more and more, we more and more limit the ability of maximizing agent to distort outcomes relative to the approximating model\n",
"\n",
"So bigger $ \\theta $ is implicitly associated with smaller distortion sequences $ \\{w_t \\} $"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Analyzing the Bellman equation\n",
"\n",
"So what does $ J $ in [(3)](#equation-rb-wcb0) look like?\n",
"\n",
"As with the [ordinary LQ control model](https://lectures.quantecon.org/py/lqcontrol.html), $ J $ takes the form $ J(x) = x' P x $ for some symmetric positive definite matrix $ P $\n",
"\n",
"One of our main tasks will be to analyze and compute the matrix $ P $\n",
"\n",
"Related tasks will be to study associated feedback rules for $ u_t $ and $ w_{t+1} $\n",
"\n",
"First, using [matrix calculus](https://lectures.quantecon.org/py/linear_algebra.html#la-mcalc), you will be able to verify that\n",
"\n",
"\n",
"\n",
"$$\n",
"\\begin{aligned}\n",
"\\max_w\n",
"&\\{\n",
" (Ax + B u + C w)' P (Ax + B u + C w) - \\theta w'w\n",
"\\}\n",
"\\\\\n",
"& \\hspace{20mm} = (Ax + Bu)' \\mathcal D(P) (Ax + Bu)\n",
"\\end{aligned} \\tag{4}\n",
"$$\n",
"\n",
"where\n",
"\n",
"\n",
"\n",
"$$\n",
"\\mathcal D(P) := P + PC (\\theta I - C' P C)^{-1} C' P \\tag{5}\n",
"$$\n",
"\n",
"and $ I $ is a $ j \\times j $ identity matrix. Substituting this expression for the maximum into [(3)](#equation-rb-wcb0) yields\n",
"\n",
"\n",
"\n",
"$$\n",
"x'Px =\n",
"\\min_u\n",
"\\{\n",
" x' R x + u' Q u + \\beta \\,\n",
" (Ax + Bu)' \\mathcal D(P) (Ax + Bu)\n",
"\\} \\tag{6}\n",
"$$\n",
"\n",
"Using similar mathematics, the solution to this minimization problem is $ u = - F x $ where $ F := (Q + \\beta B' \\mathcal D (P) B)^{-1} \\beta B' \\mathcal D(P) A $\n",
"\n",
"Substituting this minimizer back into [(6)](#equation-rb-owb) and working through the algebra gives\n",
"$ x' P x = x' \\mathcal B ( \\mathcal D( P )) x $ for all $ x $, or, equivalently,\n",
"\n",
"$$\n",
"P = \\mathcal B ( \\mathcal D( P ))\n",
"$$\n",
"\n",
"where $ \\mathcal D $ is the operator defined in [(5)](#equation-rb-d) and\n",
"\n",
"$$\n",
"\\mathcal B(P)\n",
":= R - \\beta^2 A' P B (Q + \\beta B' P B)^{-1} B' P A + \\beta A' P A\n",
"$$\n",
"\n",
"The operator $ \\mathcal B $ is the standard (i.e., non-robust) LQ Bellman operator, and $ P = \\mathcal B(P) $ is the standard matrix Riccati equation coming from the\n",
"Bellman equation — see [this discussion](https://lectures.quantecon.org/py/lqcontrol.html#lq-ih)\n",
"\n",
"Under some regularity conditions (see [[HS08]](https://lectures.quantecon.org/py/zreferences.html#hansensargent2008)), the operator $ \\mathcal B \\circ \\mathcal D $\n",
"has a unique positive definite fixed point, which we denote below by $ \\hat P $\n",
"\n",
"A robust policy, indexed by $ \\theta $, is $ u = - \\hat F x $ where\n",
"\n",
"\n",
"\n",
"$$\n",
"\\hat F\n",
":= (Q + \\beta B' \\mathcal D (\\hat P) B)^{-1} \\beta B' \\mathcal D(\\hat P) A \\tag{7}\n",
"$$\n",
"\n",
"We also define\n",
"\n",
"\n",
"\n",
"$$\n",
"\\hat K\n",
":= (\\theta I - C' \\hat PC)^{-1} C' \\hat P (A - B \\hat F) \\tag{8}\n",
"$$\n",
"\n",
"The interpretation of $ \\hat K $ is that $ w_{t+1} = \\hat K x_t $ on the worst-case path of $ \\{x_t \\} $, in the sense that this vector is the maximizer of [(4)](#equation-rb-mp0) evaluated at the fixed rule $ u = - \\hat F x $\n",
"\n",
"Note that $ \\hat P, \\hat F, \\hat K $ are all determined by the\n",
"primitives and $ \\theta $\n",
"\n",
"Note also that if $ \\theta $ is very large, then $ \\mathcal D $ is\n",
"approximately equal to the identity mapping\n",
"\n",
"Hence, when $ \\theta $ is large, $ \\hat P $ and $ \\hat F $ are approximately equal to their standard LQ values\n",
"\n",
"Furthermore, when $ \\theta $ is large, $ \\hat K $ is approximately equal to zero\n",
"\n",
"Conversely, smaller $ \\theta $ is associated with greater fear of model misspecification, and greater concern for robustness"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Robustness as Outcome of a Two-Person Zero-Sum Game\n",
"\n",
"What we have done above can be interpreted in terms of a two-person zero-sum game in which $ \\hat F, \\hat K $ are Nash equilibrium objects\n",
"\n",
"Agent 1 is our original agent, who seeks to minimize loss in the LQ program while admitting the possibility of misspecification\n",
"\n",
"Agent 2 is an imaginary malevolent player\n",
"\n",
"Agent 2’s malevolence helps the original agent to compute bounds on his value function across a set of models\n",
"\n",
"We begin with agent 2’s problem\n",
"\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Agent 2’s Problem\n",
"\n",
"Agent 2\n",
"\n",
"1. knows a fixed policy $ F $ specifying the behavior of agent 1, in the sense that $ u_t = - F x_t $ for all $ t $ \n",
"1. responds by choosing a shock sequence $ \\{ w_t \\} $ from a set of paths sufficiently close to the benchmark sequence $ \\{0, 0, 0, \\ldots\\} $ \n",
"\n",
"\n",
"A natural way to say “sufficiently close to the zero sequence” is to restrict the\n",
"summed inner product $ \\sum_{t=1}^{\\infty} w_t' w_t $ to be small\n",
"\n",
"However, to obtain a time-invariant recursive formulation, it turns out to be convenient to\n",
"restrict a discounted inner product\n",
"\n",
"\n",
"\n",
"$$\n",
"\\sum_{t=1}^{\\infty} \\beta^t w_t' w_t \\leq \\eta \\tag{9}\n",
"$$\n",
"\n",
"Now let $ F $ be a fixed policy, and let $ J_F(x_0, \\mathbf w) $ be the\n",
"present-value cost of that policy given sequence $ \\mathbf w := \\{w_t\\} $\n",
"and initial condition $ x_0 \\in \\mathbb R^n $\n",
"\n",
"Substituting $ -F x_t $ for $ u_t $ in [(1)](#equation-rob-sih), this value can be written as\n",
"\n",
"\n",
"\n",
"$$\n",
"J_F(x_0, \\mathbf w) :=\n",
" \\sum_{t=0}^{\\infty} \\beta^t\n",
" x_t' (R + F' Q F) x_t \\tag{10}\n",
"$$\n",
"\n",
"where\n",
"\n",
"\n",
"\n",
"$$\n",
"x_{t+1} = (A - B F) x_t + C w_{t+1} \\tag{11}\n",
"$$\n",
"\n",
"and the initial condition $ x_0 $ is as specified in the left side of [(10)](#equation-rob-fpv)\n",
"\n",
"Agent 2 chooses $ {\\mathbf w} $ to maximize agent 1’s loss $ J_F(x_0, \\mathbf w) $ subject to [(9)](#equation-rb-dec)\n",
"\n",
"Using a Lagrangian formulation, we can express this problem as\n",
"\n",
"$$\n",
"\\max_{\\mathbf w}\n",
" \\sum_{t=0}^{\\infty} \\beta^t\n",
" \\left\\{\n",
" x_t' (R + F' Q F) x_t - \\beta \\theta (w_{t+1}' w_{t+1} - \\eta)\n",
" \\right\\}\n",
"$$\n",
"\n",
"where $ \\{x_t\\} $ satisfied [(11)](#equation-rob-lomf) and $ \\theta $ is a Lagrange multiplier on constraint [(9)](#equation-rb-dec)\n",
"\n",
"For the moment, let’s take $ \\theta $ as fixed, allowing us to drop the constant $ \\beta \\theta \\eta $ term in the objective function, and hence write the problem as\n",
"\n",
"$$\n",
"\\max_{\\mathbf w}\n",
" \\sum_{t=0}^{\\infty} \\beta^t\n",
" \\left\\{\n",
" x_t' (R + F' Q F) x_t - \\beta \\theta w_{t+1}' w_{t+1}\n",
" \\right\\}\n",
"$$\n",
"\n",
"or, equivalently,\n",
"\n",
"\n",
"\n",
"$$\n",
"\\min_{\\mathbf w}\n",
"\\sum_{t=0}^{\\infty} \\beta^t\n",
"\\left\\{\n",
" -x_t' (R + F' Q F) x_t + \\beta \\theta w_{t+1}' w_{t+1}\n",
"\\right\\} \\tag{12}\n",
"$$\n",
"\n",
"subject to [(11)](#equation-rob-lomf)\n",
"\n",
"What’s striking about this optimization problem is that it is once again an LQ discounted dynamic programming problem, with $ \\mathbf w = \\{ w_t \\} $ as the sequence of controls\n",
"\n",
"The expression for the optimal policy can be found by applying the usual LQ formula ([see here](https://lectures.quantecon.org/py/lqcontrol.html#lq-ih))\n",
"\n",
"We denote it by $ K(F, \\theta) $, with the interpretation $ w_{t+1} = K(F, \\theta) x_t $\n",
"\n",
"The remaining step for agent 2’s problem is to set $ \\theta $ to enforce the constraint [(9)](#equation-rb-dec), which can be done by choosing $ \\theta = \\theta_{\\eta} $ such that\n",
"\n",
"\n",
"\n",
"$$\n",
"\\beta \\sum_{t=0}^{\\infty} \\beta^t x_t' K(F, \\theta_\\eta)' K(F, \\theta_\\eta) x_t = \\eta \\tag{13}\n",
"$$\n",
"\n",
"Here $ x_t $ is given by [(11)](#equation-rob-lomf) — which in this case becomes $ x_{t+1} = (A - B F + CK(F, \\theta)) x_t $\n",
"\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Using Agent 2’s Problem to Construct Bounds on the Value Sets"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### The Lower Bound\n",
"\n",
"Define the minimized object on the right side of problem [(12)](#equation-rb-a2o) as $ R_\\theta(x_0, F) $\n",
"\n",
"Because “minimizers minimize” we have\n",
"\n",
"$$\n",
"R_\\theta(x_0, F) \\leq \\sum_{t=0}^\\infty \\beta^t \\left\\{ - x_t' (R + F' Q F) x_t \\right\\} + \\beta \\theta \\sum_{t=0}^\\infty \\beta^t w_{t+1}' w_{t+1},\n",
"$$\n",
"\n",
"where $ x_{t+1} = (A - B F + CK(F, \\theta)) x_t $ and $ x_0 $ is a given initial condition\n",
"\n",
"This inequality in turn implies the inequality\n",
"\n",
"\n",
"\n",
"$$\n",
"R_\\theta(x_0, F) - \\theta \\ {\\rm ent}\n",
"\\leq \\sum_{t=0}^\\infty \\beta^t \\left\\{ - x_t' (R + F' Q F) x_t \\right\\} \\tag{14}\n",
"$$\n",
"\n",
"where\n",
"\n",
"$$\n",
"{\\rm ent} := \\beta \\sum_{t=0}^\\infty \\beta^t w_{t+1}' w_{t+1}\n",
"$$\n",
"\n",
"The left side of inequality [(14)](#equation-rob-bound) is a straight line with slope $ -\\theta $\n",
"\n",
"Technically, it is a “separating hyperplane”\n",
"\n",
"At a particular value of entropy, the line is tangent to the lower bound of values as a function of entropy\n",
"\n",
"In particular, the lower bound on the left side of [(14)](#equation-rob-bound) is attained when\n",
"\n",
"\n",
"\n",
"$$\n",
"{\\rm ent} = \\beta \\sum_{t=0}^{\\infty} \\beta^t x_t' K(F, \\theta)' K(F, \\theta) x_t \\tag{15}\n",
"$$\n",
"\n",
"To construct the *lower bound* on the set of values associated with all perturbations $ {\\mathbf w} $ satisfying the entropy constraint [(9)](#equation-rb-dec) at a given entropy level, we proceed as follows:\n",
"\n",
"> - For a given $ \\theta $, solve the minimization problem [(12)](#equation-rb-a2o) \n",
"- Compute the minimizer $ R_\\theta(x_0, F) $ and the associated entropy using [(15)](#equation-rb-pdt22) \n",
"- Compute the lower bound on the value function $ R_\\theta(x_0, F) - \\theta \\ {\\rm ent} $ and plot it against $ {\\rm ent} $ \n",
"- Repeat the preceding three steps for a range of values of $ \\theta $ to trace out the lower bound \n",
"\n",
"\n",
"\n",
">**Note**\n",
">\n",
">This procedure sweeps out a set of separating hyperplanes indexed by different values for the Lagrange multiplier $ \\theta $"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### The Upper Bound\n",
"\n",
"To construct an *upper bound* we use a very similar procedure\n",
"\n",
"We simply replace the *minimization* problem [(12)](#equation-rb-a2o) with the *maximization* problem\n",
"\n",
"\n",
"\n",
"$$\n",
"V_{\\tilde \\theta}(x_0, F) = \\max_{\\mathbf w}\n",
" \\sum_{t=0}^{\\infty} \\beta^t\n",
" \\left\\{\n",
" -x_t' (R + F' Q F) x_t - \\beta \\tilde \\theta w_{t+1}' w_{t+1}\n",
" \\right\\} \\tag{16}\n",
"$$\n",
"\n",
"where now $ \\tilde \\theta >0 $ penalizes the choice of $ {\\mathbf w} $ with larger entropy\n",
"\n",
"(Notice that $ \\tilde \\theta = - \\theta $ in problem [(12)](#equation-rb-a2o))\n",
"\n",
"Because “maximizers maximize” we have\n",
"\n",
"$$\n",
"V_{\\tilde \\theta}(x_0, F) \\geq \\sum_{t=0}^\\infty \\beta^t \\left\\{ - x_t' (R + F' Q F) x_t \\right\\} - \\beta \\tilde \\theta \\sum_{t=0}^\\infty \\beta^t w_{t+1}' w_{t+1}\n",
"$$\n",
"\n",
"which in turn implies the inequality\n",
"\n",
"\n",
"\n",
"$$\n",
"V_{\\tilde \\theta}(x_0, F) + \\tilde \\theta \\ {\\rm ent} \\geq \\sum_{t=0}^\\infty \\beta^t \\left\\{ - x_t' (R + F' Q F) x_t \\right\\} \\tag{17}\n",
"$$\n",
"\n",
"where\n",
"\n",
"$$\n",
"{\\rm ent} \\equiv \\beta \\sum_{t=0}^\\infty \\beta^t w_{t+1}' w_{t+1}\n",
"$$\n",
"\n",
"The left side of inequality [(17)](#equation-robboundmax) is a straight line with slope $ \\tilde \\theta $\n",
"\n",
"The upper bound on the left side of [(17)](#equation-robboundmax) is attained when\n",
"\n",
"\n",
"\n",
"$$\n",
"{\\rm ent} = \\beta \\sum_{t=0}^{\\infty} \\beta^t x_t' K(F, \\tilde \\theta)' K(F, \\tilde \\theta) x_t \\tag{18}\n",
"$$\n",
"\n",
"To construct the *upper bound* on the set of values associated all perturbations $ {\\mathbf w} $ with a given entropy we proceed much as we did for the lower bound\n",
"\n",
"> - For a given $ \\tilde \\theta $, solve the maximization problem [(16)](#equation-rba2omax) \n",
"- Compute the maximizer $ V_{\\tilde \\theta}(x_0, F) $ and the associated entropy using [(18)](#equation-rbpdt223) \n",
"- Compute the upper bound on the value function $ V_{\\tilde \\theta}(x_0, F) + \\tilde \\theta \\ {\\rm ent} $ and plot it against $ {\\rm ent} $ \n",
"- Repeat the preceding three steps for a range of values of $ \\tilde \\theta $ to trace out the upper bound "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Reshaping the set of values\n",
"\n",
"Now in the interest of *reshaping* these sets of values by choosing $ F $, we turn to agent 1’s problem"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Agent 1’s Problem\n",
"\n",
"Now we turn to agent 1, who solves\n",
"\n",
"\n",
"\n",
"$$\n",
"\\min_{\\{u_t\\}}\n",
" \\sum_{t=0}^{\\infty} \\beta^t\n",
" \\left\\{\n",
" x_t' R x_t + u_t' Q u_t - \\beta \\theta w_{t+1}' w_{t+1}\n",
" \\right\\} \\tag{19}\n",
"$$\n",
"\n",
"where $ \\{ w_{t+1} \\} $ satisfies $ w_{t+1} = K x_t $\n",
"\n",
"In other words, agent 1 minimizes\n",
"\n",
"\n",
"\n",
"$$\n",
"\\sum_{t=0}^{\\infty} \\beta^t\n",
" \\left\\{\n",
" x_t' (R - \\beta \\theta K' K ) x_t + u_t' Q u_t\n",
" \\right\\} \\tag{20}\n",
"$$\n",
"\n",
"subject to\n",
"\n",
"\n",
"\n",
"$$\n",
"x_{t+1} = (A + C K) x_t + B u_t \\tag{21}\n",
"$$\n",
"\n",
"Once again, the expression for the optimal policy can be found [here](https://lectures.quantecon.org/py/lqcontrol.html#lq-ih) — we denote\n",
"it by $ \\tilde F $\n",
"\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Nash Equilibrium\n",
"\n",
"Clearly the $ \\tilde F $ we have obtained depends on $ K $, which, in agent 2’s problem,\n",
"depended on an initial policy $ F $\n",
"\n",
"Holding all other parameters fixed, we can represent this relationship as a mapping $ \\Phi $, where\n",
"\n",
"$$\n",
"\\tilde F = \\Phi(K(F, \\theta))\n",
"$$\n",
"\n",
"The map $ F \\mapsto \\Phi (K(F, \\theta)) $ corresponds to a situation in which\n",
"\n",
"1. agent 1 uses an arbitrary initial policy $ F $ \n",
"1. agent 2 best responds to agent 1 by choosing $ K(F, \\theta) $ \n",
"1. agent 1 best responds to agent 2 by choosing $ \\tilde F = \\Phi (K(F, \\theta)) $ \n",
"\n",
"\n",
"As you may have already guessed, the robust policy $ \\hat F $ defined in [(7)](#equation-rb-oc-ih) is a fixed point of the mapping $ \\Phi $\n",
"\n",
"In particular, for any given $ \\theta $,\n",
"\n",
"1. $ K(\\hat F, \\theta) = \\hat K $, where $ \\hat K $ is as given in [(8)](#equation-rb-kd) \n",
"1. $ \\Phi(\\hat K) = \\hat F $ \n",
"\n",
"\n",
"A sketch of the proof is given in [the appendix](#rb-appendix)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The Stochastic Case\n",
"\n",
"Now we turn to the stochastic case, where the sequence $ \\{w_t\\} $ is treated as an iid sequence of random vectors\n",
"\n",
"In this setting, we suppose that our agent is uncertain about the *conditional probability distribution* of $ w_{t+1} $\n",
"\n",
"The agent takes the standard normal distribution $ N(0, I) $ as the baseline conditional distribution, while admitting the possibility that other “nearby” distributions prevail\n",
"\n",
"These alternative conditional distributions of $ w_{t+1} $ might depend nonlinearly on the history $ x_s, s \\leq t $\n",
"\n",
"To implement this idea, we need a notion of what it means for one distribution\n",
"to be near another one\n",
"\n",
"Here we adopt a very useful measure of closeness for distributions known as the *relative entropy*, or [Kullback-Leibler divergence](https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence)\n",
"\n",
"For densities $ p, q $, the Kullback-Leibler divergence of $ q $ from $ p $ is defined as\n",
"\n",
"$$\n",
"D_{KL} (p, q) := \\int \\ln \\left[ \\frac{p(x)}{q(x)} \\right] p(x) \\, dx\n",
"$$\n",
"\n",
"Using this notation, we replace [(3)](#equation-rb-wcb0) with the stochastic analogue\n",
"\n",
"\n",
"\n",
"$$\n",
"J (x) =\n",
"\\min_u\n",
"\\max_{\\psi \\in \\mathcal P}\n",
"\\left\\{\n",
" x' R x + u' Q u + \\beta \\,\n",
" \\left[\n",
" \\int J (Ax + B u + C w) \\, \\psi(dw) - \\theta D_{KL}(\\psi, \\phi)\n",
" \\right]\n",
"\\right\\} \\tag{22}\n",
"$$\n",
"\n",
"Here $ \\mathcal P $ represents the set of all densities on $ \\mathbb R^n $ and $ \\phi $ is the benchmark distribution $ N(0, I) $\n",
"\n",
"The distribution $ \\phi $ is chosen as the least desirable conditional distribution in terms of next period outcomes, while taking into account the penalty term $ \\theta D_{KL}(\\psi, \\phi) $\n",
"\n",
"This penalty term plays a role analogous to the one played by the deterministic penalty $ \\theta w'w $ in [(3)](#equation-rb-wcb0), since it discourages large deviations from the benchmark"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Solving the Model\n",
"\n",
"The maximization problem in [(22)](#equation-rb-wcb1) appears highly nontrivial — after all,\n",
"we are maximizing over an infinite dimensional space consisting of the entire set of densities\n",
"\n",
"However, it turns out that the solution is tractable, and in fact also falls within the class of normal distributions\n",
"\n",
"First, we note that $ J $ has the form $ J(x) = x' P x + d $ for some positive definite matrix $ P $ and constant real number $ d $\n",
"\n",
"Moreover, it turns out that if $ (I - \\theta^{-1} C' P C)^{-1} $ is nonsingular, then\n",
"\n",
"\n",
"\n",
"$$\n",
"\\begin{aligned}\n",
"\\max_{\\psi \\in \\mathcal P}\n",
"&\\left\\{\n",
" \\int (Ax + B u + C w)' P (Ax + B u + C w) \\, \\psi(dw) - \\theta D_{KL}(\\psi, \\phi)\n",
"\\right\\}\n",
"\\\\\n",
"& \\hspace{20mm} = (Ax + Bu)' \\mathcal D (P) (Ax + Bu) + \\kappa(\\theta, P)\n",
"\\end{aligned} \\tag{23}\n",
"$$\n",
"\n",
"where\n",
"\n",
"$$\n",
"\\kappa(\\theta, P) := \\theta \\ln [ \\det(I - \\theta^{-1} C' P C)^{-1} ]\n",
"$$\n",
"\n",
"and the maximizer is the Gaussian distribution\n",
"\n",
"\n",
"\n",
"$$\n",
"\\psi = N\n",
"\\left(\n",
" (\\theta I - C' P C)^{-1} C' P (Ax + Bu), (I - \\theta^{-1} C' P C)^{-1}\n",
"\\right) \\tag{24}\n",
"$$\n",
"\n",
"Substituting the expression for the maximum into Bellman equation\n",
"[(22)](#equation-rb-wcb1) and using $ J(x) = x'Px + d $ gives\n",
"\n",
"\n",
"\n",
"$$\n",
"x' P x + d =\n",
"\\min_u\n",
"\\left\\{\n",
" x' R x + u' Q u + \\beta \\,\n",
" (Ax + Bu)' \\mathcal D (P) (Ax + Bu) + \\beta \\, [d + \\kappa(\\theta, P)]\n",
"\\right\\} \\tag{25}\n",
"$$\n",
"\n",
"Since constant terms do not affect minimizers, the solution is the same as\n",
"[(6)](#equation-rb-owb), leading to\n",
"\n",
"$$\n",
"x' P x + d\n",
"= x' \\mathcal B( \\mathcal D(P)) x + \\beta \\, [d + \\kappa(\\theta, P)]\n",
"$$\n",
"\n",
"To solve this Bellman equation, we take $ \\hat P $ to be the positive definite fixed point of\n",
"$ \\mathcal B \\circ \\mathcal D $\n",
"\n",
"In addition, we take $ \\hat d $ as the real number solving $ d = \\beta \\, [d + \\kappa(\\theta, P)] $, which is\n",
"\n",
"\n",
"\n",
"$$\n",
"\\hat d := \\frac{\\beta}{1 - \\beta} \\kappa(\\theta, P) \\tag{26}\n",
"$$\n",
"\n",
"The robust policy in this stochastic case is the minimizer in\n",
"[(25)](#equation-rb-wcb2), which is once again $ u = - \\hat F x $ for $ \\hat F $ given by [(7)](#equation-rb-oc-ih)\n",
"\n",
"Substituting the robust policy into [(24)](#equation-rb-md) we obtain the worst case shock\n",
"distribution:\n",
"\n",
"$$\n",
"w_{t+1} \\sim\n",
"N( \\hat K x_t, (I - \\theta^{-1} C' \\hat PC)^{-1} )\n",
"$$\n",
"\n",
"where $ \\hat K $ is given by [(8)](#equation-rb-kd)\n",
"\n",
"Note that the mean of the worst-case shock distribution is equal to the same worst-case $ w_{t+1} $ as in the earlier deterministic setting\n",
"\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Computing Other Quantities\n",
"\n",
"Before turning to implementation, we briefly outline how to compute several other quantities of interest"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Worst-Case Value of a Policy\n",
"\n",
"One thing we will be interested in doing is holding a policy fixed and\n",
"computing the discounted loss associated with that policy\n",
"\n",
"So let $ F $ be a given policy and let $ J_F(x) $ be\n",
"the associated loss, which, by analogy with [(22)](#equation-rb-wcb1), satisfies\n",
"\n",
"$$\n",
"J_F(x) =\n",
"\\max_{\\psi \\in \\mathcal P}\n",
"\\left\\{\n",
" x' (R + F'QF) x + \\beta \\,\n",
" \\left[\n",
" \\int J_F ( (A - BF)x + C w) \\, \\psi(dw) - \\theta D_{KL}(\\psi, \\phi)\n",
" \\right]\n",
"\\right\\}\n",
"$$\n",
"\n",
"Writing $ J_F(x) = x'P_Fx + d_F $ and applying the same argument used to\n",
"derive [(23)](#equation-rb-mls) we get\n",
"\n",
"$$\n",
"x' P_F x + d_F =\n",
"x' (R + F'QF) x + \\beta \\,\n",
"\\left[\n",
" x' (A - BF)' \\mathcal D(P_F) (A - BF) x + d_F + \\kappa(\\theta, P_F)\n",
"\\right]\n",
"$$\n",
"\n",
"To solve this we take $ P_F $ to be the fixed point\n",
"\n",
"$$\n",
"P_F = R + F'QF + \\beta (A - BF)' \\mathcal D(P_F) (A - BF)\n",
"$$\n",
"\n",
"and\n",
"\n",
"\n",
"\n",
"$$\n",
"d_F\n",
":= \\frac{\\beta}{1 - \\beta} \\kappa(\\theta, P_F)\n",
"= \\frac{\\beta}{1 - \\beta}\n",
" \\theta \\ln [ \\det(I - \\theta^{-1} C' P_F C)^{-1} ] \\tag{27}\n",
"$$\n",
"\n",
"If you skip ahead to [the appendix](#rb-appendix), you will be able to\n",
"verify that $ -P_F $ is the solution to the Bellman equation in\n",
"agent 2’s problem [discussed above](#rb-a2) — we use this in our\n",
"computations"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Implementation\n",
"\n",
"The [QuantEcon.py](http://quantecon.org/python_index.html) package provides a class called `RBLQ` for implementation of robust LQ optimal control\n",
"\n",
"The code can be found [on GitHub](https://github.com/QuantEcon/QuantEcon.py/blob/master/quantecon/robustlq.py)\n",
"\n",
"Here is a brief description of the methods of the class\n",
"\n",
"- `d_operator()` and `b_operator()` implement $ \\mathcal D $\n",
" and $ \\mathcal B $ respectively \n",
"- `robust_rule()` and `robust_rule_simple()` both solve for the\n",
" triple $ \\hat F, \\hat K, \\hat P $, as described in equations [(7)](#equation-rb-oc-ih) – [(8)](#equation-rb-kd) and the surrounding discussion \n",
" \n",
" - `robust_rule()` is more efficient \n",
" - `robust_rule_simple()` is more transparent and easier to follow \n",
" \n",
"- `K_to_F()` and `F_to_K()` solve the decision problems\n",
" of [agent 1](#rb-a1) and [agent 2](#rb-a2) respectively \n",
"- `compute_deterministic_entropy()` computes the left-hand side of [(13)](#equation-rb-pdt) \n",
"- `evaluate_F()` computes the loss and entropy associated with a given\n",
" policy — see [this discussion](#rb-coq) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Application\n",
"\n",
"Let us consider a monopolist similar to [this one](https://lectures.quantecon.org/py/lqcontrol.html#lqc-mwac), but now facing model uncertainty\n",
"\n",
"The inverse demand function is $ p_t = a_0 - a_1 y_t + d_t $\n",
"\n",
"where\n",
"\n",
"$$\n",
"d_{t+1} = \\rho d_t + \\sigma_d w_{t+1},\n",
"\\quad \\{w_t\\} \\stackrel{\\textrm{iid}}{\\sim} N(0,1)\n",
"$$\n",
"\n",
"and all parameters are strictly positive\n",
"\n",
"The period return function for the monopolist is\n",
"\n",
"$$\n",
"r_t = p_t y_t - \\gamma \\frac{(y_{t+1} - y_t)^2}{2} - c y_t\n",
"$$\n",
"\n",
"Its objective is to maximize expected discounted profits, or, equivalently, to minimize $ \\mathbb E \\sum_{t=0}^\\infty \\beta^t (- r_t) $\n",
"\n",
"To form a linear regulator problem, we take the state and control to be\n",
"\n",
"$$\n",
"x_t\n",
"= \\begin{bmatrix}\n",
" 1 \\\\ y_t \\\\ d_t\n",
" \\end{bmatrix}\n",
" \\quad \\text{and} \\quad\n",
" u_t = y_{t+1} - y_t\n",
"$$\n",
"\n",
"Setting $ b := (a_0 - c) / 2 $ we define\n",
"\n",
"$$\n",
"R\n",
"= -\n",
"\\begin{bmatrix}\n",
" 0 & b & 0 \\\\\n",
" b & -a_1 & 1/2 \\\\\n",
" 0 & 1/2 & 0\n",
"\\end{bmatrix}\n",
"\\quad \\text{and} \\quad\n",
"Q = \\gamma / 2\n",
"$$\n",
"\n",
"For the transition matrices we set\n",
"\n",
"$$\n",
"A\n",
"= \\begin{bmatrix}\n",
" 1 & 0 & 0 \\\\\n",
" 0 & 1 & 0 \\\\\n",
" 0 & 0 & \\rho\n",
" \\end{bmatrix},\n",
"\\qquad\n",
"B\n",
"= \\begin{bmatrix}\n",
" 0 \\\\\n",
" 1 \\\\\n",
" 0\n",
" \\end{bmatrix},\n",
"\\qquad\n",
"C\n",
"= \\begin{bmatrix}\n",
" 0 \\\\\n",
" 0 \\\\\n",
" \\sigma_d\n",
" \\end{bmatrix}\n",
"$$\n",
"\n",
"Our aim is to compute the value-entropy correspondences [shown above](#rb-vec)\n",
"\n",
"The parameters are\n",
"\n",
"$$\n",
"a_0 = 100, a_1 = 0.5, \\rho = 0.9, \\sigma_d = 0.05, \\beta = 0.95, c = 2, \\gamma = 50.0\n",
"$$\n",
"\n",
"The standard normal distribution for $ w_t $ is understood as the\n",
"agent’s baseline, with uncertainty parameterized by $ \\theta $\n",
"\n",
"We compute value-entropy correspondences for two policies\n",
"\n",
"1. The no concern for robustness policy $ F_0 $, which is the ordinary LQ\n",
" loss minimizer \n",
"1. A “moderate” concern for robustness policy $ F_b $, with $ \\theta = 0.02 $ \n",
"\n",
"\n",
"The code for producing the graph shown above, with blue being for the robust policy, is as follows"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"hide-output": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/quantecon/anaconda3/lib/python3.7/site-packages/quantecon/lqcontrol.py:242: RuntimeWarning: divide by zero encountered in double_scalars\n",
" d = self.beta * np.trace(dot(P, dot(C, C.T))) / (1 - self.beta)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[]\n",
"[]\n",
"[]\n",
"[]\n"
]
},
{
"data": {
"text/plain": [
"