# Borrowing Constraints in Aiyagari using DDP

We want to introduce a negative borrowing constraint in the code of Aiyagari using DDP.

We start by changing the values of “a” and we introduce a borrowing limit “phi” inside the Reward Function. However, because the value of a is negative, we fail the feasibility test when we create the instance of household. We understand that the A space stands for the indices of possible actions. However, we don’t know exactly understand how we can put that in the Reward Function since when we are calculating the Consumption values we use the asset values as well.

We tried to do that by hand (using the functions inside Quantecon like the S_WISE_MAX) but we are always getting a kink at the beggining of the policy function (graph on the top). Using a code with EGM, the exact same calibration give us the expected policy functions. (middle graph)

Our main goal is to replicate the graph of Aiyagari’s Marginal Propensities to Consume (last graph). However, with that kink, the Consumption policy functions are not correct and so we cannot replicate the above graph.

Do you have a suggestion on how to overcome this problem?

Best Regards,
Valter

That does look wrong, as you say, but I’m finding it hard to diagnose the bug. Would it be possible to post your Jupyter notebook or Python program as a gist (see, e.g., this one)? Please keep it as simple as possible, while still producing the error.

Thank you again for you answer.
I created this gist:

Best,
Valter

I do not know the detail of the model, but generally, if you want to add a side constraint, either

• remove the actions that do not satisfy the constraint from the set of feasible actions, or
• give a reward “negative infinity” to those actions.

This line

``````a_new = max(a_vals[new_a_i], phi) #Borrowing Constraint a>=phi
``````

looks suspicious. Maybe you want to give a reward “negative infinity” if `a_vals[new_a_i] < phi`?