Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

The MPC out of Credit vs the MPC Out of Income

This notebook compares the Marginal Propensity to Consume (MPC) out of an increase in a credit limit, and the MPC out of transitory shock to income.

The notebook is heavily commented to help newcomers, and does some things (like importing modules in the body of the code rather than at the top), that are typically deprecated by Python programmers. This is all to make the code easier to read and understand.

The notebook illustrates one simple way to use HARK: import and solve a model for different parameter values, to see how parameters affect the solution.

The first step is to create the ConsumerType we want to solve the model for.

The next step is to change the values of parameters as we want.

To see all the parameters used in the model, along with their default values, see π™²πš˜πš—πšœπšžπš–πšŽπš›π™ΏπšŠπš›πšŠπš–πšŽπšπšŽπš›πšœ.πš™πš’

Parameter values are stored as attributes of the π™²πš˜πš—πšœπšžπš–πšŽπš›πšƒπš’πš™πšŽ the values are used for. For example, the risk-free interest rate πšπšπš›πšŽπšŽ is stored as π™±πšŠπšœπšŽπš•πš’πš—πšŽπ™΄πš‘πšŠπš–πš™πš•πšŽ.πšπšπš›πšŽπšŽ. Because we created π™±πšŠπšœπšŽπš•πš’πš—πšŽπ™΄πš‘πšŠπš–πš™πš•πšŽ using the default parameters values at the moment π™±πšŠπšœπšŽπš•πš’πš—πšŽπ™΄πš‘πšŠπš–πš™πš•πšŽ.πšπšπš›πšŽπšŽ is set to the default value of πšπšπš›πšŽπšŽ (which, at the time this demo was written, was 1.03). Therefore, to change the risk-free interest rate used in π™±πšŠπšœπšŽπš•πš’πš—πšŽπ™΄πš‘πšŠπš–πš™πš•πšŽ to (say) 1.02, all we need to do is:

Now we are ready to solve the consumers’ problems. In HARK, this is done by calling the solve() method of the ConsumerType.

Now that we have the solutions to the 2 different problems, we can compare them.

We are going to compare the consumption functions for the two different consumers. Policy functions (including consumption functions) in HARK are stored as attributes of the solution of the ConsumerType. The solution, in turn, is a list, indexed by the time period the solution is for. Since in this demo we are working with infinite-horizon models where every period is the same, there is only one time period and hence only one solution. e.g. BaselineExample.solution[0] is the solution for the BaselineExample. If BaselineExample had 10 time periods, we could access the 5th with BaselineExample.solution[4] (remember, Python counts from 0!) Therefore, the consumption function cFunc from the solution to the BaselineExample is π™±πšŠπšœπšŽπš•πš’πš—πšŽπ™΄πš‘πšŠπš–πš™πš•πšŽ.πšœπš˜πš•πšžπšπš’πš˜πš—[𝟢].πšŒπ™΅πšžπš—πšŒ

The XtraCredit consumption function allows the consumer to spend a tiny bit more
The difference is so small that the baseline is obscured by the XtraCredit solution
<Figure size 640x480 with 1 Axes>
MPC out of Credit v MPC out of Income
<Figure size 640x480 with 1 Axes>