Negative number in the distribution of Prog. 11_01

Forums Questions on specific programs Negative number in the distribution of Prog. 11_01

This topic contains 3 replies, has 2 voices, and was last updated by Fabian Kindermann March 25, 2021 at 8:30 am.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1911

    Shengzhi Mao
    User

    Hi Everyone,
    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)
    enddo
    enddo
    enddo
    enddo

    end subroutine`

    #1912

    Fabian Kindermann
    Moderator

    Dear Shengzhi,

    I tried to replicate your problem, but I couldn’t. In my version of prog11_01.f90, all entries of phi are 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.

    Best,
    Fabian

    #1913

    Shengzhi Mao
    User

    Hi Fabian,

    I just found the reason. When I changed the value of household preference for consumption nu in

    prog11_01m.f90

    , 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.

    Best wishes,
    Shengzhi Mao

    #1914

    Fabian Kindermann
    Moderator

    Dear Shengzhi,

    this is in fact an excellent question. I figured out what the problem is:

    If you change to nu = 0.8d0 then 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 IAMAX there 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.

    Best, Fabian

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.