# quant-econ Solutions: The Lucas Asset Pricing Model



In [1]:

%matplotlib inline




In [2]:

from __future__ import division  # Omit for Python 3.x
import numpy as np
import matplotlib.pyplot as plt
from quantecon import AssetPrices



## Exercise 1



In [3]:

"""
Authors: David Evans, John Stachurski and Thomas J. Sargent
"""

# == Define primitives == #
n = 5
P = 0.0125 * np.ones((n, n))
P += np.diag(0.95 - 0.0125 * np.ones(5))
s = np.array([1.05, 1.025, 1.0, 0.975, 0.95])
gamma = 2.0
beta = 0.94
zeta = 1.0

ap = AssetPrices(beta, P, s, gamma)

v = ap.tree_price()
print "Lucas Tree Prices: ", v

v_consol = ap.consol_price(zeta)
print "Consol Bond Prices: ", v_consol

P_tilde = P * s**(1-gamma)
temp = beta * P_tilde.dot(v) - beta * P_tilde.dot(np.ones(n))
print "Should be 0: ",  v - temp

p_s = 150.0
w_bar, w_bars = ap.call_option(zeta, p_s, T = [10,20,30])




Lucas Tree Prices:  [ 12.28465197  14.42111319  17.45713702  22.11237355  30.15323666]
Consol Bond Prices:  [  75.51427238   98.64225987  140.69501276  240.82930111  786.23683599]
Should be 0:  [ 1.72509033  1.79371484  1.86577057  1.94152147  2.02125926]



## Exercise 2



In [4]:

from quantecon import lucas_tree, compute_lt_price

fig, ax = plt.subplots(figsize=(10,7))

ax.set_xlabel(r'$y$', fontsize=16)
ax.set_ylabel(r'price', fontsize=16)

for beta in (.95, 0.98):
tree = lucas_tree(gamma=2, beta=beta, alpha=0.90, sigma=0.1)
grid, price_vals = compute_lt_price(tree)
label = r'$\beta = {}$'.format(beta)
ax.plot(grid, price_vals, lw=2, alpha=0.7, label=label)

ax.legend(loc='upper left')
ax.set_xlim(min(grid), max(grid))




2.04938432509
1.66149297725
1.37803173269
1.15663751147
0.978062304284
0.832668325534
0.713060167719
0.61371626793
0.53063330463
0.460668631589
0.401394661594
0.350903428553
0.307676036308
0.27049798974
0.238388117941
0.210548793647
0.186327054293
0.165184942744
0.146676609164
0.130430429253
0.116134976434
0.103527938351
0.0923873003367
0.0825242944775
0.0737777259241
0.0660093832382
0.0591003057495
0.05294773235
0.0474625949005
0.0425674491262
0.0381947586263
0.034285465252
0.0307877927868
0.0276562415505
0.0248507399348
0.0223359254809
0.0200805333435
0.0180568741442
0.0162403865331
0.0146092524399
0.0131440651338
0.0118275419375
0.0106442748427
0.00958051340986
0.00862397526576
0.00776368027316
0.00698980507068
0.00629355519812
0.00566705244881
0.00510323544463
2.11410172483
1.76808626632
1.51274814702
1.30980654015
1.14255962452
1.00342950503
0.886428008071
0.787022953298
0.70196706799
0.628656405159
0.565065466631
0.509585728274
0.460920248439
0.418021507936
0.380033307102
0.346251994641
0.316095210172
0.289077922146
0.264793792094
0.242900456854
0.223107882629
0.20516908162
0.18887265966
0.174036808194
0.16050443042
0.148139169445
0.136822155668
0.126449331046
0.116929238194
0.108181185858
0.100133720391
0.0927233470658
0.085893456185
0.079593417688
0.0737778149219
0.0684057937383
0.063440507501
0.0588486421254
0.0546000081206
0.0506671889097
0.0470252365742
0.0436514076887
0.0405249331561
0.0376268169703
0.0349396596699
0.0324475029337
0.0301356923393
0.0279907557738
0.0260002953794
0.0241528912394

Out[4]:

(0.39945149497311855, 2.5034328637756031)




In [ ]: