"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Uncertainty Traps"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Overview\n",
"\n",
"In this lecture we study a simplified version of an uncertainty traps model of Fajgelbaum, Schaal and Taschereau-Dumouchel [[FSTD15]](zreferences.ipynb#fun)\n",
"\n",
"The model features self-reinforcing uncertainty that has big impacts on economic activity\n",
"\n",
"In the model,\n",
"\n",
"- Fundamentals vary stochastically and are not fully observable \n",
"- At any moment there are both active and inactive entrepreneurs; only active entrepreneurs produce \n",
"- Agents – active and inactive entrepreuneurs – have beliefs about the fundamentals expressed as probability distributions \n",
"- Greater uncertainty means greater dispersions of these distributions \n",
"- Entrepreneurs are risk averse and hence less inclined to be active when uncertainty is high \n",
"- The output of active entrepreneurs is observable, supplying a noisy signal that helps everyone inside the model infer fundamentals \n",
"- Entrepreneurs update their beliefs about fundamentals using Bayes’ Law, implemented via [Kalman filtering](tools_and_techniques/kalman.ipynb) \n",
"\n",
"\n",
"Uncertainty traps emerge because:\n",
"\n",
"- High uncertainty discourages entrepreneurs from becoming active \n",
"- A low level of participation – i.e., a smaller number of active entrepreneurs – diminishes the flow of information about fundamentals \n",
"- Less information translates to higher uncertainty, further discouraging entrepreneurs from choosing to be active, and so on \n",
"\n",
"\n",
"Uncertainty traps stem from a positive externality: high aggregate economic activity levels generates valuable information"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The Model\n",
"\n",
"The original model described in [[FSTD15]](zreferences.ipynb#fun) has many interesting moving parts\n",
"\n",
"Here we examine a simplified version that nonetheless captures many of the key ideas"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Fundamentals\n",
"\n",
"The evolution of the fundamental process $ \\{\\theta_t\\} $ is given by\n",
"\n",
"$$\n",
"\\theta_{t+1} = \\rho \\theta_t + \\sigma_{\\theta} w_{t+1}\n",
"$$\n",
"\n",
"where\n",
"\n",
"- $ \\sigma_\\theta > 0 $ and $ 0 < \\rho < 1 $ \n",
"- $ \\{w_t\\} $ is IID and standard normal \n",
"\n",
"\n",
"The random variable $ \\theta_t $ is not observable at any time"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Output\n",
"\n",
"There is a total $ \\bar M $ of risk averse entrepreneurs\n",
"\n",
"Output of the $ m $-th entrepreneur, conditional on being active in the market at\n",
"time $ t $, is equal to\n",
"\n",
"\n",
"\n",
"$$\n",
"x_m = \\theta + \\epsilon_m\n",
"\\quad \\text{where} \\quad\n",
"\\epsilon_m \\sim N \\left(0, \\gamma_x^{-1} \\right) \\tag{1}\n",
"$$\n",
"\n",
"Here the time subscript has been dropped to simplify notation\n",
"\n",
"The inverse of the shock variance, $ \\gamma_x $, is called the shock’s **precision**\n",
"\n",
"The higher is the precision, the more informative $ x_m $ is about the fundamental\n",
"\n",
"Output shocks are independent across time and firms"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Information and Beliefs\n",
"\n",
"All entrepreneurs start with identical beliefs about $ \\theta_0 $\n",
"\n",
"Signals are publicly observable and hence all agents have identical beliefs always\n",
"\n",
"Dropping time subscripts, beliefs for current $ \\theta $ are represented by the normal\n",
"distribution $ N(\\mu, \\gamma^{-1}) $\n",
"\n",
"Here $ \\gamma $ is the precision of beliefs; its inverse is the degree of uncertainty\n",
"\n",
"These parameters are updated by Kalman filtering\n",
"\n",
"Let\n",
"\n",
"- $ \\mathbb M \\subset \\{1, \\ldots, \\bar M\\} $ denote the set of currently active firms \n",
"- $ M := |\\mathbb M| $ denote the number of currently active firms \n",
"- $ X $ be the average output $ \\frac{1}{M} \\sum_{m \\in \\mathbb M} x_m $ of the active firms \n",
"\n",
"\n",
"With this notation and primes for next period values, we can write the updating of the mean and precision via\n",
"\n",
"\n",
"\n",
"$$\n",
"\\mu' = \\rho \\frac{\\gamma \\mu + M \\gamma_x X}{\\gamma + M \\gamma_x} \\tag{2}\n",
"$$\n",
"\n",
"\n",
"\n",
"$$\n",
"\\gamma' =\n",
" \\left(\n",
" \\frac{\\rho^2}{\\gamma + M \\gamma_x} + \\sigma_\\theta^2\n",
" \\right)^{-1} \\tag{3}\n",
"$$\n",
"\n",
"These are standard Kalman filtering results applied to the current setting\n",
"\n",
"Exercise 1 provides more details on how [(2)](#equation-update-mean) and [(3)](#equation-update-prec) are derived, and then asks you to fill in remaining steps\n",
"\n",
"The next figure plots the law of motion for the precision in [(3)](#equation-update-prec)\n",
"as a 45 degree diagram, with one curve for each $ M \\in \\{0, \\ldots, 6\\} $\n",
"\n",
"The other parameter values are $ \\rho = 0.99, \\gamma_x = 0.5, \\sigma_\\theta =0.5 $\n",
"\n",
"![_static/figures/uncertainty_traps_45.png](_static/figures/uncertainty_traps_45.png) \n",
"Points where the curves hit the 45 degree lines are long run steady\n",
"states for precision for different values of $ M $\n",
"\n",
"Thus, if one of these values for $ M $ remains fixed, a corresponding steady state is the equilibrium level of precision\n",
"\n",
"- high values of $ M $ correspond to greater information about the\n",
" fundamental, and hence more precision in steady state \n",
"- low values of $ M $ correspond to less information and more uncertainty in steady state \n",
"\n",
"\n",
"In practice, as we’ll see, the number of active firms fluctuates stochastically"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Participation\n",
"\n",
"Omitting time subscripts once more, entrepreneurs enter the market in the current period if\n",
"\n",
"\n",
"\n",
"$$\n",
"\\mathbb E [ u(x_m - F_m) ] > c \\tag{4}\n",
"$$\n",
"\n",
"Here\n",
"\n",
"- the mathematical expectation of $ x_m $ is based on [(1)](#equation-xgt) and beliefs $ N(\\mu, \\gamma^{-1}) $ for $ \\theta $ \n",
"- $ F_m $ is a stochastic but previsible fixed cost, independent across time and firms \n",
"- $ c $ is a constant reflecting opportunity costs \n",
"\n",
"\n",
"The statement that $ F_m $ is previsible means that it is realized at the start of the period and treated as a constant in [(4)](#equation-pref1)\n",
"\n",
"The utility function has the constant absolute risk aversion form\n",
"\n",
"\n",
"\n",
"$$\n",
"u(x) = \\frac{1}{a} \\left(1 - \\exp(-a x) \\right) \\tag{5}\n",
"$$\n",
"\n",
"where $ a $ is a positive parameter\n",
"\n",
"Combining [(4)](#equation-pref1) and [(5)](#equation-pref2), entrepreneur $ m $ participates in the market (or is said to be active) when\n",
"\n",
"$$\n",
"\\frac{1}{a}\n",
" \\left\\{\n",
" 1 - \\mathbb E [ \\exp \\left(\n",
" -a (\\theta + \\epsilon_m - F_m)\n",
" \\right) ]\n",
" \\right\\}\n",
" > c\n",
"$$\n",
"\n",
"Using standard formulas for expectations of [lognormal](https://en.wikipedia.org/wiki/Log-normal_distribution) random variables, this is equivalent to the condition\n",
"\n",
"\n",
"\n",
"$$\n",
"\\psi(\\mu, \\gamma, F_m) :=\n",
"\\frac{1}{a}\n",
" \\left(\n",
" 1 - \\exp \\left(\n",
" -a \\mu + a F_m +\n",
" \\frac{a^2 \\left( \\frac{1}{\\gamma} + \\frac{1}{\\gamma_x} \\right)}{2}\n",
" \\right)\n",
" \\right) - c > 0 \\tag{6}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Implementation\n",
"\n",
"We want to simulate this economy\n",
"\n",
"We’ll want a named tuple generator of the kind that we’ve seen before\n",
"\n",
"And we need methods to update $ \\theta $, $ \\mu $ and $ \\gamma $, as well as to determine the number of active firms and their outputs\n",
"\n",
"The updating methods follow the laws of motion for $ \\theta $, $ \\mu $ and $ \\gamma $ given above\n",
"\n",
"The method to evaluate the number of active firms generates $ F_1,\n",
"\\ldots, F_{\\bar M} $ and tests condition [(6)](#equation-firm-test) for each firm"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Setup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": true
},
"outputs": [],
"source": [
"using InstantiateFromURL\n",
"github_project(\"QuantEcon/quantecon-notebooks-julia\", version = \"0.2.0\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"using LinearAlgebra, Statistics, Compat\n",
"using DataFrames, Parameters, Plots"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"UncertaintyTrapEcon = @with_kw (a = 1.5, # risk aversion\n",
" γ_x = 0.5, # production shock precision\n",
" ρ = 0.99, # correlation coefficient for θ\n",
" σ_θ = 0.5, # standard dev. of θ shock\n",
" num_firms = 100, # number of firms\n",
" σ_F = 1.5, # standard dev. of fixed costs\n",
" c = -420.0, # external opportunity cost\n",
" μ_init = 0.0, # initial value for μ\n",
" γ_init = 4.0, # initial value for γ\n",
" θ_init = 0.0, # initial value for θ\n",
" σ_x = sqrt(a / γ_x)) # standard dev. of shock"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the results below we use this code to simulate time series for the major variables"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results\n",
"\n",
"Let’s look first at the dynamics of $ \\mu $, which the agents use to track $ \\theta $\n",
"\n",
"![_static/figures/uncertainty_traps_mu.png](_static/figures/uncertainty_traps_mu.png) \n",
"We see that $ \\mu $ tracks $ \\theta $ well when there are sufficient firms in the market\n",
"\n",
"However, there are times when $ \\mu $ tracks $ \\theta $ poorly due to\n",
"insufficient information\n",
"\n",
"These are episodes where the uncertainty traps take hold\n",
"\n",
"During these episodes\n",
"\n",
"- precision is low and uncertainty is high \n",
"- few firms are in the market \n",
"\n",
"\n",
"To get a clearer idea of the dynamics, let’s look at all the main time series\n",
"at once, for a given set of shocks\n",
"\n",
"![_static/figures/uncertainty_traps_sim.png](_static/figures/uncertainty_traps_sim.png) \n",
"Notice how the traps only take hold after a sequence of bad draws for the fundamental\n",
"\n",
"Thus, the model gives us a *propagation mechanism* that maps bad random draws into long downturns in economic activity"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercises\n",
"\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exercise 1\n",
"\n",
"Fill in the details behind [(2)](#equation-update-mean) and [(3)](#equation-update-prec) based on\n",
"the following standard result (see, e.g., p. 24 of [[YS05]](zreferences.ipynb#young2005))\n",
"\n",
"**Fact** Let $ \\mathbf x = (x_1, \\ldots, x_M) $ be a vector of IID draws\n",
"from common distribution $ N(\\theta, 1/\\gamma_x) $\n",
"and let $ \\bar x $ be the sample mean. If $ \\gamma_x $\n",
"is known and the prior for $ \\theta $ is $ N(\\mu, 1/\\gamma) $, then the posterior\n",
"distribution of $ \\theta $ given $ \\mathbf x $ is\n",
"\n",
"$$\n",
"\\pi(\\theta \\,|\\, \\mathbf x) = N(\\mu_0, 1/\\gamma_0)\n",
"$$\n",
"\n",
"where\n",
"\n",
"$$\n",
"\\mu_0 = \\frac{\\mu \\gamma + M \\bar x \\gamma_x}{\\gamma + M \\gamma_x}\n",
"\\quad \\text{and} \\quad\n",
"\\gamma_0 = \\gamma + M \\gamma_x\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exercise 2\n",
"\n",
"Modulo randomness, replicate the simulation figures shown above\n",
"\n",
"- Use the parameter values listed as defaults in the function UncertaintyTrapEcon "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Solutions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exercise 1\n",
"\n",
"This exercise asked you to validate the laws of motion for\n",
"$ \\gamma $ and $ \\mu $ given in the lecture, based on the stated\n",
"result about Bayesian updating in a scalar Gaussian setting\n",
"\n",
"The stated result tells us that after observing average output $ X $ of the\n",
"$ M $ firms, our posterior beliefs will be\n",
"\n",
"$$\n",
"N(\\mu_0, 1/\\gamma_0)\n",
"$$\n",
"\n",
"where\n",
"\n",
"$$\n",
"\\mu_0 = \\frac{\\mu \\gamma + M X \\gamma_x}{\\gamma + M \\gamma_x}\n",
"\\quad \\text{and} \\quad\n",
"\\gamma_0 = \\gamma + M \\gamma_x\n",
"$$\n",
"\n",
"If we take a random variable $ \\theta $ with this distribution and\n",
"then evaluate the distribution of $ \\rho \\theta + \\sigma_\\theta w $\n",
"where $ w $ is independent and standard normal, we get the\n",
"expressions for $ \\mu' $ and $ \\gamma' $ given in the lecture."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 2\n",
"\n",
"First let’s replicate the plot that illustrates the law of motion for\n",
"precision, which is\n",
"\n",
"$$\n",
"\\gamma_{t+1} =\n",
" \\left(\n",
" \\frac{\\rho^2}{\\gamma_t + M \\gamma_x} + \\sigma_\\theta^2\n",
" \\right)^{-1}\n",
"$$\n",
"\n",
"Here $ M $ is the number of active firms. The next figure plots\n",
"$ \\gamma_{t+1} $ against $ \\gamma_t $ on a 45 degree diagram for\n",
"different values of $ M $"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"econ = UncertaintyTrapEcon()\n",
"@unpack ρ, σ_θ, γ_x = econ # simplify names\n",
"\n",
"# grid for γ and γ_{t+1}\n",
"γ = range(1e-10, 3, length = 200)\n",
"M_range = 0:6\n",
"γp = 1 ./ (ρ^2 ./ (γ .+ γ_x .* M_range') .+ σ_θ^2)\n",
"\n",
"labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\"]\n",
"\n",
"plot(γ, γ, lw = 2, label = \"45 Degree\")\n",
"plot!(γ, γp, lw = 2, label = labels)\n",
"plot!(xlabel = \"Gamma\", ylabel = \"Gamma'\", legend_title = \"M\", legend = :bottomright)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The points where the curves hit the 45 degree lines are the long run\n",
"steady states corresponding to each $ M $, if that value of\n",
"$ M $ was to remain fixed. As the number of firms falls, so does the\n",
"long run steady state of precision\n",
"\n",
"Next let’s generate time series for beliefs and the aggregates – that\n",
"is, the number of active firms and average output"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"function simulate(uc, capT = 2_000)\n",
" # unpack parameters\n",
" @unpack a, γ_x, ρ, σ_θ, num_firms, σ_F, c, μ_init, γ_init, θ_init, σ_x = uc\n",
"\n",
" # draw standard normal shocks\n",
" w_shocks = randn(capT)\n",
"\n",
" # aggregate functions\n",
" # auxiliary function ψ\n",
" function ψ(γ, μ, F)\n",
" temp1 = -a * (μ - F)\n",
" temp2 = 0.5 * a^2 / (γ + γ_x)\n",
" return (1 - exp(temp1 + temp2)) / a - c\n",
" end\n",
"\n",
" # compute X, M\n",
" function gen_aggregates(γ, μ, θ)\n",
" F_vals = σ_F * randn(num_firms)\n",
" M = sum(ψ.(Ref(γ), Ref(μ), F_vals) .> 0) # counts number of active firms\n",
" if any(ψ(γ, μ, f) > 0 for f in F_vals) # ∃ an active firm\n",
" x_vals = θ .+ σ_x * randn(M)\n",
" X = mean(x_vals)\n",
" else\n",
" X = 0.0\n",
" end\n",
" return (X = X, M = M)\n",
" end\n",
"\n",
" # initialize dataframe\n",
" X_init, M_init = gen_aggregates(γ_init, μ_init, θ_init)\n",
" df = DataFrame(γ = γ_init, μ = μ_init, θ = θ_init, X = X_init, M = M_init)\n",
"\n",
" # update dataframe\n",
" for t in 2:capT\n",
" # unpack old variables\n",
" θ_old, γ_old, μ_old, X_old, M_old = (df.θ[end], df.γ[end], df.μ[end], df.X[end], df.M[end])\n",
"\n",
" # define new beliefs\n",
" θ = ρ * θ_old + σ_θ * w_shocks[t-1]\n",
" μ = (ρ * (γ_old * μ_old + M_old * γ_x * X_old))/(γ_old + M_old * γ_x)\n",
" γ = 1 / (ρ^2 / (γ_old + M_old * γ_x) + σ_θ^2)\n",
"\n",
" # compute new aggregates\n",
" X, M = gen_aggregates(γ, μ, θ)\n",
" push!(df, (γ = γ, μ = μ, θ = θ, X = X, M = M))\n",
" end\n",
"\n",
" # return\n",
" return df\n",
"end"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First let’s see how well $ \\mu $ tracks $ \\theta $ in these\n",
"simulations"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"df = simulate(econ)\n",
"\n",
"plot(eachindex(df.μ), df.μ, lw = 2, label = \"Mu\")\n",
"plot!(eachindex(df.θ), df.θ, lw = 2, label = \"Theta\")\n",
"plot!(xlabel = \"x\", ylabel = \"y\", legend_title = \"Variable\", legend = :bottomright)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now let’s plot the whole thing together"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"len = eachindex(df.θ)\n",
"yvals = [df.θ, df.μ, df.γ, df.M]\n",
"vars = [\"Theta\", \"Mu\", \"Gamma\", \"M\"]\n",
"\n",
"plt = plot(layout = (4,1), size = (600, 600))\n",
"\n",
"for i in 1:4\n",
" plot!(plt[i], len, yvals[i], xlabel = \"t\", ylabel = vars[i], label = \"\")\n",
"end\n",
"\n",
"plot(plt)"
]
}
],
"metadata": {
"filename": "uncertainty_traps.rst",
"kernelspec": {
"display_name": "Julia 1.2",
"language": "julia",
"name": "julia-1.2"
},
"title": "Uncertainty Traps"
},
"nbformat": 4,
"nbformat_minor": 2
}