Randall Romero Aguilar, PhD
This demo is based on the original Matlab demo accompanying the Computational Economics and Finance 2001 textbook by Mario Miranda and Paul Fackler.
Original (Matlab) CompEcon file: demsoc03.m
Running this file requires the Python version of CompEcon. This can be installed with pip by running
!pip install compecon --upgrade
Last updated: 2021-Oct-04
Social benefit maximizing social planner must decide how much society should consume and invest.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from compecon import BasisChebyshev, BasisSpline
α = 0.4 # capital share
δ = 0.1 # capital depreciation rate
θ = 2.0 # relative risk aversion
γ = 0.5 # productivity mean reversion coefficient
σ = 0.05 # productivity volatility
ρ = 0.04 # discount rate
def control(s, q, Vs, α,δ,θ,γ,σ,ρ):
k, y = s
Vk = Vs[0]
return Vk**(-1/θ)
def reward(s, q, Vs, α,δ,θ,γ,σ,ρ):
return (1/(1-θ)) * q**(1-θ)
def drift(s, q, Vs, α,δ,θ,γ,σ,ρ):
k, y = s
f = k**α
return (y*f - δ*k - q), γ*(1-y)
def diffusion(s, q, Vs, α,δ,θ,γ,σ,ρ):
n = s.shape[1]
out = np.zeros(2,2,n)
out[1 ,1] = σ * np.sqrt(y)