Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Functions needed for vfi with dolo
from dolo import yaml_import
model = yaml_import('examples/models/rbc.yaml')
s = model.calibration['states']
x = model.calibration['controls']
y = model.calibration['auxiliaries']
e = model.calibration['shocks']
v = model.calibration['values']
p = model.calibration['parameters']
f = model.functions['arbitrage']
g = model.functions['transition']
a = model.functions['auxiliary']
val = model.functions['value']
lb = model.functions['arbitrage_lb']
ub = model.functions['arbitrage_ub']
# f(s,x,e,s,x,p) # arbitrage equations
g(s,x,e,p) # transition of the states
a(s,x,p) # definition of auxiliary variables
val(s,x,s,x,v,p) # value-updating equation
x_ub = ub(s,p) # upper bounds
x_lb = lb(s,p) # lower bounds
# state-space :
ss = model.options['approximation_space']
a = ss['a']
b = ss['b']
orders = ss['orders']
# create interpolator
from dolo.numeric.interpolation.import MultivariateSplines
dr = MultivariateSplines(a,b,orders)
dr.set_values(vals) # values to interpolate
dr(points) # points at which to interpolate
# matrix of covariances
sigma = model.covariances
# discretization of the shocks
from dolo.numeric.discretization.quadrature import gauss_hermite_nodes
qorders = [5] # number of nodes for each dimension
[x,w] = gauss_hermite_nodes(qorders, sigma)
# x : (2d) each line is a point
# w : (1d) weights
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment