NumEconCopenhagen / IntroProg-lectures

Introductionary programming lectures
MIT License
30 stars 72 forks source link

Model project: Phase diagram of Malthus #16

Closed viktortexel closed 5 months ago

viktortexel commented 1 year ago

Hi!

In our attempt to create a phase diagram of the Malthus Model in our model project we can't get the curve to converge. Can you help us troubleshoot if it is the code or the parameter-values that are causing the issue? We have tried to change all parameter values, but without success.

Kind regards, Jos, P og Tex

AskerNC commented 1 year ago

Hi, I'll try to take a look tomorrow

AskerNC commented 1 year ago

Hi I've made a fork of your project and fixed the problem, I'm not quite certain whether it was the parameters or the range of the x-axis that was the issue. I reorganized the code such that the parameters are all determined by the SimpleNamespace object 'par' (you could also use a dictionary). This makes it much easier to keep track of which parameters you're using

Best regards Asker

viktortexel commented 1 year ago

Hi Asker!

Thank you so much for helping - it looks much better now!

We are currently experiencing some issues with plotting the convergence. We wanna show how L adjust towards steady state, but we are having difficulties showing the adjustment path to steady state. We have tried updating some code in the py.file and we have tried showing it by using the Law of Motion equation - but so far, nothing works. Ideally, we would like to show the different convergence paths for different parameter values. Do you have any tips or tricks to resolve this? :)

Best regards,

Josefine, Pernille and Viktor

AskerNC commented 1 year ago

Hi I think the problem you're having is that you're updating the variable L_init, in the c step, but in the equation in the a step you're using par.L_init. There are many ways to solve this, but I think the most elegant is to not use L_init at all, and just use L_path[i-1] instead.

Best regards, Asker