Open ghost opened 8 years ago
Yes, this should be fixed. Off the top of my head, I'm not actually sure what MPCnvrs should be when CRRA=1. This issue seems to exist for other classes as well, when calculating the value function is requested.
The problem isn't in the MPC, it's in dividing by 1-1 = 0
We should add an "if CRRA == 1" and in that case use the fact that d/dc log c = 1/c.
Seems sprintable for an economist.
So I think this comes back to the fact that more than one user has turned into a question mark when reading the lines that define MPCnvrs
. Should we/you/someone maybe sit down and do the math and put a note somewhere? It's the slope of the inverse MPC function in a perfect foresight model right @mnwhite ?
@llorracc @mnwhite if CRRA == 1
is the slope of the inverse MPC function then 1 ? That's the limit of that expression, right? I can make a PR with the change so we can fix this :)
I worked this out in my head around the time that Patrick last commented, but that was also when my daughter was born and now I forget.
A quick hack-ish way of fixing it to check if self.CRRA == 1.0
and replace it with self.CRRA = 1.0 + \epsilon
.
Print out a warning after doing the transformation.
Inspired by demo file, I am writing demos for each model in ConsIndShockModel. It is fun to play with parameters and helps me to understand consumption-saving dynamics model. In fact, I talked to other graduate students and realized only a few had experienced Python language. David's example is superb, and I think more demos would be instructive. Of course, I noticed David left homework assignment in the demo. For some people, I guess it is quite difficult.. Learning by doing would be ideal, but more guidelines also are useful. I just want to share struggles I faced earlier (even now:) ).
Anyway, I checked some variant versions of perfect foresight case.
It throws out an error. This is because line 410 in ConsIndShockModel.py MPCnvrs = self.MPC**(-self.CRRA/(1.0-self.CRRA))
I guess we need to fix defValueFuncs function. Am I right?
p.s. CRRA=1.0 works for other types.