shade-econ / sequence-jacobian

A unified framework to solve and analyze heterogeneous-agent macro models.
MIT License
253 stars 149 forks source link

Problem setting up stage_block with no variable to propagate backward in stage two (taste shock) #32

Open GuiAll opened 14 hours ago

GuiAll commented 14 hours ago

I am setting up a discrete choice agent problem using a value function iteration as an iterative method, rather than EGM (I could not managed to build a DC-EGM for a firm with dicrete and convex adjustment costs)

As a result, I don not have a backward variable, such as Va, to propagate backward : the value function V is enough for the VFI iteration step. My code to set up

choice_stage = LogitChoice(value='V', backward=None, index=0, name='inv_choice', taste_shock_scale='taste_shock', f=discrete_cost)

Then I set up the continuous chice stage (there are two investment choice available, hence the continous 2D) :

invt_stage = Continuous2D(backward=['V'], policy=['policy_i1', 'policy_i2'], f=iteration, name='invt', hetoutputs=None)

Then I get the following error message :

ValueError: Some stage taking another non-immediate-successor stage backward [None] as input

I tried to look into the code of the sj package, but could not make sense of the mechanic sitting behind this error. I do not need a backward variable, but it looks like I need to set one up to move one. Am I missing something ? I can provide more elements of the code if needed

Thank you in advance