-
Notifications
You must be signed in to change notification settings - Fork 7
testing SS #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
testing SS #41
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import numpy as np | ||
| import demographics | ||
| import SS | ||
|
|
||
|
|
||
| def test_get_pop_objs(): | ||
| """ | ||
| Test of the that omega_SS and the last period of omega_path_S are | ||
| close to each other. | ||
| """ | ||
| E = 20 | ||
| S = 80 | ||
| T = int(round(4.0 * S)) | ||
| start_year = 2018 | ||
|
|
||
| (omega, g_n_ss, omega_SS, surv_rate, rho, g_n_vector, imm_rates, | ||
| omega_S_preTP) = demographics.get_pop_objs(E, S, T, 1, 100, | ||
| start_year, False) | ||
| return omega_SS,imm_rates | ||
|
|
||
| omega_SS,imm_rates = test_get_pop_objs() | ||
|
|
||
| def test_SS(): | ||
| """ | ||
| Test whether the SS funtion works well and what the returns look like | ||
| """ | ||
| r_init = 0.1 | ||
| beta = 0.8 | ||
| sigma = 1.5 | ||
| alpha = 0.3 | ||
| A = 1.0 | ||
| delta = 0.1 | ||
| xi = 0.1 | ||
| S = 80 | ||
| imm_rates_SS = imm_rates | ||
|
|
||
| (r,w,b_sp1,euler_errors) = SS.solve_ss(r_init,params=(beta, sigma, alpha, | ||
| A, delta, xi, omega_SS, | ||
| imm_rates_SS, S)) | ||
| print("r = ",r) | ||
| print("w = ",w) | ||
| print("b_sp1 = ",b_sp1) | ||
| print("euler_errors = ",euler_errors) | ||
|
Comment on lines
+40
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is no need to print
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. The print was only for checking whether SS works in terms of executability. I would like to use the expected_r in Table 8.2 of Chapter 8 and add the assert statement. But I am still struggling on other parts. For example, there is a valueError issue in SS to apply HH module. |
||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this test will run correctly. I believe it needs an
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jtregde Thanks for the comment. Yes, I should have to make the assert statement inside the function. The problem is I don't know what I can compare at this point. I will continue to think of it.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JLian401 You could solve the SS in the case that you know the answer of (either by finding it analytically (could be hard!) or by using the solution from a version fo the code you trust - then then you could have an assert statement like: |
||
| test_SS() | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend thinking of 3 periods as we did in class so you can compare the results with SS in that
For 3 periods:
'SS interest rate is ', 1.0036834614021983
The only problem that I can think of is the exogenous labor in that model. I am trying to figure out a solution for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right - the answer will be different with exogenous labor.
Maybe you could have your scripts (e.g., SS.py) raise an assertion if the SS is not obtained before the maximum iterations are reached. In that way, this test will fail if the SS isn't found and pass if it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdebacker Yes. OK. Milton n I are working on that