This topic contains 3 replies, has 2 voices, and was last updated by Fabian Kindermann March 25, 2021 at 8:30 am.
March 23, 2021 at 4:39 pm #1911
I just run the prog11_01.f90 and find that the elements in the probability phi(ij, ia, ip, is) can even be negative. How could it happen? How can we fix it?
You can see that results by adding the following codes in prog11_01.f90:
write(*,'(a,a)’) ‘consumption, probability’
do ij = 1, JJ
do ia = 1, NA
do ip = 1, NP
do is = 1, NS
write(*,'(f12.6,a,f12.6)’) c(ij, ia, ip, is)*phi(ij, ia, ip, is), ‘,’, phi(ij, ia, ip, is)
end subroutine`March 23, 2021 at 7:03 pm #1912
I tried to replicate your problem, but I couldn’t. In my version of
prog11_01.f90, all entries of
phiare non-negative. Could you tell me if you changed something somewhere else in the program? Or could you send me a program version that creates this problem? Then I might be of further help.
FabianMarch 24, 2021 at 9:30 am #1913
I just found the reason. When I changed the value of household preference for consumption nu in
, from 0.335d0 to 0.8d0 for instance, I can obtain many negative numbers of phi. But the whole program can still converge to a GE very soon.
Shengzhi MaoMarch 25, 2021 at 8:30 am #1914
this is in fact an excellent question. I figured out what the problem is:
If you change to
nu = 0.8d0then households want to save much more than the size of your asset grid. In the baseline specification, the size of the asset grid is
a_u = 35d0. But when you simulate the model and open the file
output_initial.out, you will see that in the column
IAMAXthere are a lot of values of
100. This means that there is a significant amount of households located at the upper end of your asset grid, which is not a good idea. And those households would like to save an amount higher than this upper grid limit.
As a result, to still reach convergence, the subroutine that calculates the distribution of households will extrapolate the decisions of households beyond the grid, which causes negative values for distributions. Actually it is true that this is not a very save procedure. So I would and will do the following changes to the program: Change line 337-339 to
ial = max(min(ial, NA-1), 0)
iar = max(min(iar, NA), 1)
varphi = max(min(varphi, 1d0), 0d0)
This is the much safer procedure, but it will cause the program to not converge anymore when you set
nu = 0.8d0. What you will have to do in addition is widen the grid space. If you, for example, set
a_u = 70d0, this should solve your problem.
I hope this answer helps. Thanks for posing such an excellent question and for contributing to the success of our book.
Let me know if I can be of any further help.
You must be logged in to reply to this topic.