More than four state variables with time iteration
TimMunday opened this issue · 2 comments
Hello -
I'm trying to solve a non-linear model which has some lagged variables in it. I was getting an error message putting them in directly into the 'arbitrage' section, so I created new state variables, and added them to the 'transition' section.
Whilst this seems to be fine for perturbation methods, once more than 4 state variables are in the transition section I get a complicated error message. Is this because time iteration doesn't support more than 4 states?
Since github won't let me attach a .yaml, below is a very simple minimum workable example. Its a 3 eq linear new keynesian model where the taylor rule uses some lagged variables (the actual model I'm solving is non-linear, hence the desire to use time iteration). I also include the error message below as well.
Any help much appreciated. Great library
Tim
# Minimum workable example for lagged vars
name: MWE
symbols:
states: [pi_s, r_s, x_1, i_1, i_2]
controls: [pi, x, i]
exogenous: [eps_pi, eps_r]
parameters: [bbeta, kkappa, ssigma, rho_pi]
equations:
arbitrage:
- pi = bbeta*pi(+1) + kkappa*x + pi_s
- x = -(1/ssigma)*(i - pi(+1)) + x(+1) + r_s
- i = 2.5*pi + x_1 + 0.25*i_1 + 0.1*i_2
transition:
- pi_s = rho_pi*pi_s(-1) + eps_pi
- r_s = 0.7*r_s(-1) + eps_r
- x_1 = x(-1)
- i_1 = i(-1)
- i_2 = i_1(-1)
calibration:
bbeta : 0.9
kkappa : 0.4
ssigma : 2
rho_pi : 0.7
# ss vals
x_1 : 0
i_1 : 0
i_2 : 0
pi : 0
x : 0
i : 0
pi_s : 0
r_s : 0
volrs : 0
exogenous: !Normal
Sigma: [[0.1, 0], [0, 0.1]]
domain:
pi_s : [-0.1, 0.1]
r_s : [-0.1, 0.1]
x_1 : [-0.3, 0.3]
i_1 : [-0.3, 0.3]
i_2 : [-0.3, 0.3]
options:
grid: !CartesianGrid
orders: [5, 5, 5, 5, 5]
The error message takes the form:
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function _filter_cubic at 0x0000024A0C8E6168>) with argument(s) of type(s): (UniTuple(Tuple(float64, float64, int32) x 5), array(float64, 6d, C))
* parameterized
In definition 0:
TypeError: __filter_cubic() missing 1 required positional argument: 'C'
raised from C:\Users\tmund\Anaconda3\envs\Taylor\lib\site-packages\numba\core\typing\templates.py:579
In definition 1:
TypeError: __filter_cubic() missing 1 required positional argument: 'C'
raised from C:\Users\tmund\Anaconda3\envs\Taylor\lib\site-packages\numba\core\typing\templates.py:579
In definition 2:
UnboundLocalError: local variable '___filter_cubic' referenced before assignment
raised from C:\Users\tmund\Anaconda3\envs\Taylor\lib\site-packages\interpolation\splines\prefilter_cubic.py:293
In definition 3:
UnboundLocalError: local variable '___filter_cubic' referenced before assignment
raised from C:\Users\tmund\Anaconda3\envs\Taylor\lib\site-packages\interpolation\splines\prefilter_cubic.py:293
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function(<function _filter_cubic at 0x0000024A0C8E6168>)
[2] During: typing of call at C:\Users\tmund\Anaconda3\envs\Taylor\lib\site-packages\interpolation\splines\prefilter_cubic.py (298)
File "..\..\..\..\Anaconda3\envs\Taylor\lib\site-packages\interpolation\splines\prefilter_cubic.py", line 298:
def prefilter_cubic(*args):
return _filter_cubic(*args)
^
yes, interpolation.py doesn't support prefiltering for more than four dimensions . It is issue EconForge/interpolation.py#40 .
What you can probably do is change the interpolation method, try passing interp_method='linear'
to time_iteration
.
Thanks for the quick reply - much appreciated.