コード例 #1
0
    cAggImpulseResponse = cAggImpulseResponse[TimeBefore:]

    return cAggImpulseResponse


###############################################################################

if __name__ == '__main__':
    import ConsumerParameters as Params
    from time import clock
    mystr = lambda number: "{:.4f}".format(number)

    # Make and solve an example consumer with idiosyncratic income shocks
    IndShockExample = IndShockConsumerType(**Params.init_idiosyncratic_shocks)
    IndShockExample.cycles = 0  # Make this type have an infinite horizon
    IndShockExample.DiePrb = 1 - IndShockExample.LivPrb[
        0]  # Not sure why this is not already in the object

    start_time = clock()
    IndShockExample.solve()
    end_time = clock()
    print('Solving a consumer with idiosyncratic shocks took ' +
          mystr(end_time - start_time) + ' seconds.')
    IndShockExample.unpackcFunc()
    IndShockExample.timeFwd()

    PermShk = 1.1
    TranShk = 1
    cPermImpulseResponse = AggCons_impulseResponseInd(IndShockExample, PermShk,
                                                      TranShk, 100, 25)
    plt.plot(cPermImpulseResponse)