Transition Path Functions#
TPI.py modules
ogcore.TPI#
Time path iteration (TPI) module for OG-Core.
- This module contains the following functions:
get_initial_SS_values() firstdoughnutring() twist_doughnut() inner_loop() run_TPI()
- ogcore.TPI.firstdoughnutring(guesses, r, w, p_tilde, p_i, bq, rm, tr, theta, factor, ubi, j, initial_b, p)[source]#
Solves the first entries of the upper triangle of the twist doughnut. This is separate from the main TPI function because the values of b and n are scalars, so it is easier to just have a separate function for these cases.
- Parameters:
guesses (Numpy array) – initial guesses for b and n, length 2
r (scalar) – real interest rate
w (scalar) – real wage rate
p_tilde (scalar) – composite good price
p_i (Numpy array) – output goods prices
bq (scalar) – bequest amounts by age
rm (scalar) – remittance amounts by age
tr (scalar) – government transfer amount
theta (Numpy array) – retirement replacement rates, length J
factor (scalar) – scaling factor converting model units to dollars
ubi (scalar) – individual UBI credit to household s=E+S of type j in period 0
j (int) – index of ability type
initial_b (Numpy array) – SxJ matrix, savings of agents alive at T=0
p (OG-Core Specifications object) – model parameters
- Returns:
- errors from first order conditions,
length 2
- Return type:
euler errors (Numpy array)
- ogcore.TPI.get_initial_SS_values(p)[source]#
Get values of variables for the initial period and the steady state equilibrium values.
- Parameters:
p (OG-Core Specifications object) – model parameters
- Returns:
initial period and steady state values:
- initial_values (tuple): initial period variable values,
(b_sinit, b_splus1init, factor, initial_b, initial_n)
- ss_vars (dictionary): dictionary with steady state
solution results
- theta (Numpy array): steady-state retirement replacement
rates, length J
- baseline_values (tuple): (Ybaseline, TRbaseline, Gbaseline,
D0_baseline), GDP, lump sum transfer, and government spending amounts from the baseline model run
- Return type:
(tuple)
- ogcore.TPI.inner_loop(guesses, outer_loop_vars, initial_values, ubi, j, ind, p)[source]#
Given path of economic aggregates and factor prices, solves household problem. This has been termed the inner-loop (in contrast to the outer fixed point loop that solves for GE factor prices and economic aggregates).
- Parameters:
guesses (tuple) – initial guesses for b and n, (guesses_b, guesses_n)
outer_loop_vars (tuple) – values for factor prices and economic aggregates used in household problem (r_p, r, w, p_m, BQ, RM, TR, theta)
r_p (Numpy array) – real interest rate on household portfolio
r (Numpy array) – real interest rate on private capital
w (Numpy array) – real wage rate
p_m (Numpy array) – output goods prices
BQ (array_like) – aggregate bequest amounts
TR (Numpy array) – lump sum transfer amount
theta (Numpy array) – retirement replacement rates, length J
initial_values (tuple) – initial period variable values, (b_sinit, b_splus1init, factor, initial_b, initial_n, D0_baseline)
ubi (array_like) – T+S x S x J array time series of UBI transfers in model units for each type-j age-s household in every period t
j (int) – index of ability type
ind (Numpy array) – integers from 0 to S-1
p (OG-Core Specifications object) – model parameters
- Returns:
household solution results:
euler_errors (Numpy array): errors from FOCs, size = Tx2S
b_mat (Numpy array): savings amounts, size = TxS
n_mat (Numpy array): labor supply amounts, size = TxS
- Return type:
(tuple)
- ogcore.TPI.run_TPI(p, client=None)[source]#
Solve for transition path equilibrium of OG-Core.
- Parameters:
p (OG-Core Specifications object) – model parameters
client (Dask client object) – client
- Returns:
- dictionary with transition path solution
results
- Return type:
output (dictionary)
- ogcore.TPI.twist_doughnut(guesses, r, w, p_tilde, p_i, bq, rm, tr, theta, factor, ubi, j, s, t, etr_params, mtrx_params, mtry_params, initial_b, p)[source]#
Solves the upper triangle of time path iterations. These are the agents who are alive at time T=0 so that we do not solve for their full lifetime (so of their life was before the model begins).
- Parameters:
guesses (list) – initial guesses for b and n, length 2s
r (Numpy array) – real interest rate
w (Numpy array) – real wage rate
p_tilde (Numpy array) – composite good price
p_i (Numpy array) – output goods prices
bq (Numpy array) – bequest amounts by age, length s
rm (Numpy array) – remittance amounts by age, length s
tr (Numpy array) – government transfer amount
theta (Numpy array) – retirement replacement rates, length J
factor (scalar) – scaling factor converting model units to dollars
ubi (Numpy array) – length remaining periods of life UBI payout to household
j (int) – index of ability type
s (int) – years of life remaining
t (int) – model period
etr_params (list) – ETR function parameters, list of lists with size = sxsxnum_params
mtrx_params (list) – labor income MTR function parameters, list of lists with size = sxsxnum_params
mtry_params (list) – capital income MTR function parameters, lists of lists with size = sxsxnum_params
initial_b (Numpy array) – savings of agents alive at T=0, size = SxJ
p (OG-Core Specifications object) – model parameters
- Returns:
- errors from first order conditions,
length 2s
- Return type:
euler errors (Numpy array)