11/9/2023 0 Comments Matlab vs python syntax![]() ![]() Space of size 501 (points in $D_t$ ) x 21 (points in $Y_t^T$ x 11 In Matlab, it takes around 53 seconds to solve the VFI with a state Problem reduces to choosing both consumption and debt. States are debt ( $D_T$ ), tradable income shock ( $Y_t^T$ ), and Once you do the math, you can show that in this model, the relevant This model, a planner chooses the Optimal Exchange Rate to eliminate the ![]() To solve a model of an SOE with downward nominal wage rigidities. In particular, I adapted the example you gave us about optimal savings I've tried replicating some of my Matlab codes in Python + Numba. Files: OER.ipynb (solves the model by VFI), tpm.py (discretizes VAR) PythonVFIcode.zip.mat containing parameters), TransitionMatrix.m (discretizes the VAR process), vfi_OER.m (solves the model by VFI), tpm.m (Function required to discretize VAR) MatlabVFIcode.zip Matlab files: Folder "Matlab VFI code") which includes a script that runs everything up to timing the VFI function.Would you mind looking at my code and letting me know if you can spot something that might be causing the extra time? I know pure Python sometimes is slow, but since I'm using Numba, I don't know what might be happening. However, when I solved the VFI problem in Python (using jitted functions), it took 13 minutes and 16 seconds ( almost 14 times slower than Matlab!!!!) In Matlab, it takes around 39 seconds to solve the VFI with a state space of size 501 (points in $D_t$ ) x 21 (points in $Y_t^T$ x 11 (points in $r_t$). You forget about the wage, and the problem reduces to choosing both consumption and debt. Once you do the math, you can show that in this model, the relevant states are debt ( $D_T$ ), tradable income shock ( $Y_t^T$ ), and interest rate shock ( $r_t$ ). In this model, a planner chooses the Optimal Exchange Rate to eliminate the friction in the labor market. In particular, I adapted the example you gave us about optimal savings to solve a model of an SOE with downward nominal wage rigidities. Hi tried replicating some of my Matlab codes in Python + Numba. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |