-
-
Notifications
You must be signed in to change notification settings - Fork 204
Description
The possibility to allow a finite number of cycles, but more than one, isn't really used for any purpose other than testing an infinite horizon model for a finite number of periods. I.e. make a "one period cycle" that you intend as a repeated infinite horizon, and then set cycles to 2, 5, 10, 25, etc, in testing before putting it at 0.
The solution of such specifications is correct, but the built-in AgentType.sim_one_period gets the timing wrong when simulating. This problem has likely existed since the absolute very beginning of HARK when I wrote that method, and it's never been detected because no one has ever simulated such a specification and cared about the results.
The simulation code doesn't distinguish between where agents are in their "cycle" for the purposes of parameters vs their solution. When cycles > 1, these aren't necessarily aligned. E.g. if you tell it to solve with cycles = 25 of a one-period problem, the solver and simulator will correctly use the same parameters for all 25 non-terminal periods... but it will use the t=0 policy function in all of them.
Here's quick code that shows the problem (omitting imports):
MyType = IndShockConsumerType(cycles=200, T_sim=200, LivPrb=[1.], track_vars=["aNrm"], aNrmInitMean=-12.)
MyType.solve()
MyType.initialize_sim()
MyType.simulate()
A = np.mean(MyType.history["aNrm"], axis=1)
plt.plot(A)
plt.show()
That's the problem of someone who knows they will live for exactly 201 periods: 200 copies of the default period with LivPrb=1 and then the terminal period. The aNrmInitMean=-12 is because that parameter is in logs but the default dictionary has it as 0. When simulating this type, they should run up their assets to some buffer stock level, hang there for a while, and then run down their assets toward zero as their well-planned death approaches. Instead, our simulated agents just sit at their target buffer stock assets forever.
If this same (intended) specification were done with cycles=1 and making all of the time-varying parameters length-200 constant lists, it works as expected.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status