-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
Adjusted code to allow users to modify mortality assumptions in cstwMPC #214
Changes from 1 commit
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,120 @@ | ||
0 0.092840 100000.00 49.820000 0.082350 100000.00 53.600000 | ||
1 0.034110 90716.00 53.890000 0.033160 91765.00 57.390000 | ||
2 0.016660 87622.00 54.770000 0.016850 88722.00 58.340000 | ||
3 0.011400 86162.00 54.690000 0.011350 87227.00 58.330000 | ||
4 0.007310 85180.00 54.320000 0.006890 86237.00 57.990000 | ||
5 0.005190 84558.00 53.710000 0.004930 85643.00 57.390000 | ||
6 0.003860 84118.00 52.990000 0.003620 85221.00 56.680000 | ||
7 0.003320 83794.00 52.200000 0.002880 84912.00 55.880000 | ||
8 0.002470 83515.00 51.370000 0.002200 84667.00 55.040000 | ||
9 0.002240 83309.00 50.490000 0.002040 84481.00 54.160000 | ||
10 0.001950 83123.00 49.610000 0.001780 84309.00 53.270000 | ||
11 0.001760 82961.00 48.700000 0.001730 84158.00 52.360000 | ||
12 0.001700 82815.00 47.790000 0.001810 84013.00 51.450000 | ||
13 0.001830 82674.00 46.870000 0.001910 83861.00 50.550000 | ||
14 0.002040 82523.00 45.950000 0.002370 83701.00 49.640000 | ||
15 0.002690 82355.00 45.050000 0.003160 83502.00 48.760000 | ||
16 0.003270 82133.00 44.170000 0.003690 83238.00 47.910000 | ||
17 0.004250 81865.00 43.310000 0.004480 82931.00 47.090000 | ||
18 0.005490 81516.00 42.490000 0.005270 82560.00 46.300000 | ||
19 0.006810 81069.00 41.720000 0.006250 82125.00 45.540000 | ||
20 0.007670 80517.00 41.010000 0.007050 81611.00 44.820000 | ||
21 0.008320 79900.00 40.320000 0.007360 81036.00 44.140000 | ||
22 0.008700 79235.00 39.650000 0.007410 80439.00 43.460000 | ||
23 0.009000 78545.00 39.000000 0.007800 79843.00 42.780000 | ||
24 0.009010 77838.00 38.350000 0.007870 79220.00 42.110000 | ||
25 0.008980 77137.00 37.690000 0.007710 78597.00 41.440000 | ||
26 0.008640 76444.00 37.030000 0.007290 77992.00 40.760000 | ||
27 0.008660 75783.00 36.350000 0.007370 77423.00 40.060000 | ||
28 0.008120 75127.00 35.660000 0.007200 76853.00 39.350000 | ||
29 0.008370 74517.00 34.950000 0.007300 76299.00 38.630000 | ||
30 0.007960 73893.00 34.240000 0.007160 75742.00 37.910000 | ||
31 0.007950 73304.00 33.510000 0.007070 75200.00 37.180000 | ||
32 0.008200 72722.00 32.770000 0.006950 74668.00 36.440000 | ||
33 0.008240 72125.00 32.040000 0.007040 74149.00 35.700000 | ||
34 0.008040 71531.00 31.300000 0.006860 73627.00 34.950000 | ||
35 0.008230 70956.00 30.550000 0.006880 73121.00 34.180000 | ||
36 0.008340 70372.00 29.800000 0.007120 72618.00 33.420000 | ||
37 0.008740 69785.00 29.050000 0.007220 72101.00 32.650000 | ||
38 0.008680 69175.00 28.300000 0.007130 71580.00 31.890000 | ||
39 0.008730 68575.00 27.540000 0.007410 71070.00 31.110000 | ||
40 0.009470 67976.00 26.780000 0.007720 70543.00 30.340000 | ||
41 0.009340 67333.00 26.030000 0.007880 69998.00 29.570000 | ||
42 0.009620 66704.00 25.270000 0.008100 69447.00 28.800000 | ||
43 0.010190 66062.00 24.510000 0.007940 68884.00 28.040000 | ||
44 0.010620 65389.00 23.760000 0.007900 68337.00 27.260000 | ||
45 0.010960 64694.00 23.010000 0.008200 67797.00 26.470000 | ||
46 0.011760 63985.00 22.260000 0.008730 67241.00 25.680000 | ||
47 0.012690 63232.00 21.520000 0.009370 66654.00 24.910000 | ||
48 0.013030 62430.00 20.790000 0.009510 66030.00 24.140000 | ||
49 0.014260 61617.00 20.060000 0.010490 65402.00 23.360000 | ||
50 0.014520 60738.00 19.340000 0.011150 64716.00 22.610000 | ||
51 0.016330 59856.00 18.620000 0.011660 63994.00 21.860000 | ||
52 0.017440 58879.00 17.920000 0.012320 63248.00 21.110000 | ||
53 0.019030 57852.00 17.230000 0.013180 62469.00 20.360000 | ||
54 0.019960 56751.00 16.550000 0.013510 61645.00 19.630000 | ||
55 0.021060 55618.00 15.880000 0.014080 60813.00 18.890000 | ||
56 0.022660 54447.00 15.210000 0.015340 59956.00 18.150000 | ||
57 0.025530 53213.00 14.550000 0.016240 59036.00 17.430000 | ||
58 0.028600 51855.00 13.920000 0.018510 58077.00 16.710000 | ||
59 0.030000 50372.00 13.310000 0.019790 57002.00 16.010000 | ||
60 0.034990 48861.00 12.710000 0.022820 55874.00 15.330000 | ||
61 0.034940 47151.00 12.150000 0.022980 54599.00 14.670000 | ||
62 0.040080 45503.00 11.570000 0.026490 53344.00 14.010000 | ||
63 0.043510 43680.00 11.040000 0.028820 51931.00 13.370000 | ||
64 0.046940 41779.00 10.520000 0.030620 50435.00 12.760000 | ||
65 0.051890 39818.00 10.010000 0.033470 48891.00 12.140000 | ||
66 0.055470 37752.00 9.530000 0.037040 47254.00 11.550000 | ||
67 0.059860 35658.00 9.060000 0.038920 45504.00 10.970000 | ||
68 0.065600 33523.00 8.600000 0.044050 43733.00 10.400000 | ||
69 0.068880 31324.00 8.170000 0.046940 41807.00 9.850000 | ||
70 0.076820 29166.00 7.740000 0.052840 39844.00 9.310000 | ||
71 0.080870 26926.00 7.340000 0.059250 37739.00 8.800000 | ||
72 0.088810 24748.00 6.950000 0.062340 35503.00 8.330000 | ||
73 0.094750 22551.00 6.570000 0.068960 33289.00 7.850000 | ||
74 0.100180 20414.00 6.210000 0.074540 30994.00 7.390000 | ||
75 0.113710 18369.00 5.850000 0.084760 28684.00 6.950000 | ||
76 0.115380 16280.00 5.530000 0.089250 26252.00 6.540000 | ||
77 0.124310 14402.00 5.190000 0.095790 23909.00 6.140000 | ||
78 0.139990 12611.00 4.850000 0.103760 21619.00 5.730000 | ||
79 0.153290 10846.00 4.560000 0.120300 19376.00 5.340000 | ||
80 0.162240 9183.00 4.300000 0.133970 17045.00 5.000000 | ||
81 0.179590 7693.00 4.030000 0.143500 14762.00 4.700000 | ||
82 0.192120 6312.00 3.810000 0.157600 12643.00 4.400000 | ||
83 0.209300 5099.00 3.590000 0.181680 10651.00 4.130000 | ||
84 0.205880 4032.00 3.410000 0.175550 8716.00 3.940000 | ||
85 0.235560 3202.00 3.170000 0.193400 7186.00 3.670000 | ||
86 0.254840 2448.00 2.990000 0.211150 5796.00 3.430000 | ||
87 0.270670 1824.00 2.840000 0.224150 4572.00 3.210000 | ||
88 0.276560 1330.00 2.710000 0.242320 3547.00 3.000000 | ||
89 0.292410 962.00 2.550000 0.268720 2688.00 2.800000 | ||
90 0.300610 681.00 2.400000 0.290810 1965.00 2.640000 | ||
91 0.348930 476.00 2.220000 0.294450 1394.00 2.520000 | ||
92 0.355130 310.00 2.140000 0.323630 983.00 2.370000 | ||
93 0.370420 200.00 2.050000 0.344300 665.00 2.260000 | ||
94 0.386760 126.00 1.950000 0.340750 436.00 2.180000 | ||
95 0.401470 77.00 1.870000 0.367690 288.00 2.050000 | ||
96 0.417630 46.00 1.790000 0.385080 182.00 1.950000 | ||
97 0.433390 27.00 1.720000 0.402200 112.00 1.870000 | ||
98 0.448660 15.00 1.650000 0.418940 67.00 1.780000 | ||
99 0.463410 8.00 1.590000 0.435230 39.00 1.710000 | ||
100 0.477580 5.00 1.540000 0.451000 22.00 1.640000 | ||
101 0.491130 2.00 1.490000 0.466200 12.00 1.580000 | ||
102 0.504050 1.00 1.440000 0.480760 6.00 1.530000 | ||
103 0.516300 1.00 1.400000 0.494660 3.00 1.470000 | ||
104 0.527890 0.00 1.360000 0.507860 2.00 1.430000 | ||
105 0.538800 0.00 1.330000 0.520340 1.00 1.390000 | ||
106 0.549050 0.00 1.300000 0.532110 0.00 1.350000 | ||
107 0.558640 0.00 1.270000 0.543150 0.00 1.320000 | ||
108 0.567590 0.00 1.250000 0.553480 0.00 1.290000 | ||
109 0.575920 0.00 1.230000 0.563110 0.00 1.260000 | ||
110 0.584250 0.00 1.210000 0.572740 0.00 1.230000 | ||
111 0.592580 0.00 1.190000 0.582370 0.00 1.200000 | ||
112 0.600910 0.00 1.170000 0.592000 0.00 1.170000 | ||
113 0.609240 0.00 1.150000 0.601630 0.00 1.140000 | ||
114 0.617570 0.00 1.130000 0.611260 0.00 1.110000 | ||
115 0.625900 0.00 1.110000 0.620890 0.00 1.080000 | ||
116 0.634230 0.00 1.090000 0.630520 0.00 1.050000 | ||
117 0.642560 0.00 1.070000 0.640150 0.00 1.020000 | ||
118 0.650890 0.00 1.050000 0.649780 0.00 0.990000 | ||
119 0.659220 0.00 1.030000 0.659410 0.00 0.960000 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
0 0.00199 100000 80.98 0.00202 100000 87.13 | ||
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. Same as above (Matt already mentioned the no-spaces-in-filenames point.) |
||
1 0.00034 99801 80.14 0.00031 99798 86.31 | ||
2 0.00018 99767 79.16 0.00017 99766 85.34 | ||
3 0.00013 99749 78.18 0.0001 99749 84.35 | ||
4 0.00009 99736 77.19 0.00009 99739 83.36 | ||
5 0.0001 99726 76.2 0.00008 99731 82.37 | ||
6 0.00011 99716 75.2 0.00008 99722 81.37 | ||
7 0.00007 99705 74.21 0.00005 99714 80.38 | ||
8 0.00008 99698 73.22 0.00005 99709 79.38 | ||
9 0.00006 99690 72.22 0.00005 99704 78.39 | ||
10 0.00007 99684 71.23 0.00007 99699 77.39 | ||
11 0.00008 99677 70.23 0.00007 99692 76.4 | ||
12 0.00007 99669 69.24 0.00007 99685 75.4 | ||
13 0.00009 99662 68.24 0.00008 99678 74.41 | ||
14 0.00014 99653 67.25 0.00006 99670 73.41 | ||
15 0.00017 99639 66.26 0.00008 99664 72.42 | ||
16 0.00021 99622 65.27 0.00013 99656 71.42 | ||
17 0.00026 99601 64.28 0.00013 99643 70.43 | ||
18 0.0003 99576 63.3 0.00013 99630 69.44 | ||
19 0.00039 99546 62.32 0.00014 99618 68.45 | ||
20 0.0004 99507 61.34 0.00016 99604 67.46 | ||
21 0.00056 99467 60.37 0.00019 99589 66.47 | ||
22 0.0005 99411 59.4 0.00022 99569 65.48 | ||
23 0.00047 99361 58.43 0.00025 99547 64.5 | ||
24 0.0005 99315 57.46 0.00025 99523 63.51 | ||
25 0.00057 99265 56.48 0.00027 99498 62.53 | ||
26 0.0005 99208 55.52 0.00024 99471 61.55 | ||
27 0.00052 99158 54.54 0.00024 99447 60.56 | ||
28 0.00056 99107 53.57 0.00025 99423 59.58 | ||
29 0.00056 99051 52.6 0.00026 99397 58.59 | ||
30 0.00059 98995 51.63 0.00029 99372 57.61 | ||
31 0.00057 98937 50.66 0.0003 99343 56.62 | ||
32 0.00061 98881 49.69 0.00031 99313 55.64 | ||
33 0.00065 98821 48.72 0.00034 99283 54.66 | ||
34 0.00067 98756 47.75 0.00038 99249 53.67 | ||
35 0.00069 98690 46.78 0.00041 99211 52.69 | ||
36 0.00074 98621 45.82 0.00045 99170 51.72 | ||
37 0.00084 98548 44.85 0.0005 99126 50.74 | ||
38 0.00083 98466 43.89 0.00051 99077 49.76 | ||
39 0.0009 98384 42.92 0.00054 99026 48.79 | ||
40 0.00096 98295 41.96 0.00055 98972 47.82 | ||
41 0.0011 98201 41 0.00069 98917 46.84 | ||
42 0.00119 98093 40.05 0.00077 98849 45.87 | ||
43 0.00133 97976 39.09 0.00075 98773 44.91 | ||
44 0.00139 97846 38.14 0.00085 98698 43.94 | ||
45 0.00156 97710 37.2 0.00092 98614 42.98 | ||
46 0.00183 97558 36.25 0.00104 98523 42.02 | ||
47 0.00193 97380 35.32 0.00112 98421 41.06 | ||
48 0.00214 97192 34.39 0.00125 98310 40.11 | ||
49 0.00244 96985 33.46 0.00142 98188 39.16 | ||
50 0.00274 96748 32.54 0.00151 98049 38.21 | ||
51 0.00275 96483 31.63 0.00164 97900 37.27 | ||
52 0.00311 96218 30.71 0.00173 97739 36.33 | ||
53 0.00353 95919 29.81 0.00198 97570 35.39 | ||
54 0.0037 95580 28.91 0.00204 97377 34.46 | ||
55 0.00412 95227 28.02 0.00206 97179 33.53 | ||
56 0.00461 94834 27.13 0.00227 96979 32.6 | ||
57 0.00509 94397 26.25 0.00249 96759 31.67 | ||
58 0.00553 93916 25.39 0.00262 96517 30.75 | ||
59 0.00619 93397 24.52 0.00292 96265 29.83 | ||
60 0.00675 92819 23.67 0.00302 95984 28.91 | ||
61 0.00726 92192 22.83 0.00329 95694 28 | ||
62 0.00797 91523 21.99 0.0035 95380 27.09 | ||
63 0.00906 90794 21.17 0.00379 95046 26.18 | ||
64 0.00997 89971 20.36 0.00402 94686 25.28 | ||
65 0.01094 89075 19.56 0.00465 94305 24.38 | ||
66 0.01189 88100 18.77 0.00481 93867 23.49 | ||
67 0.013 87053 17.99 0.0053 93415 22.6 | ||
68 0.01461 85921 17.22 0.00602 92920 21.72 | ||
69 0.0163 84666 16.46 0.00662 92361 20.85 | ||
70 0.01579 83285 15.73 0.00669 91749 19.99 | ||
71 0.01891 81970 14.97 0.00795 91135 19.12 | ||
72 0.02088 80420 14.25 0.00861 90411 18.27 | ||
73 0.02146 78741 13.55 0.00933 89633 17.42 | ||
74 0.02502 77051 12.83 0.01083 88796 16.58 | ||
75 0.02668 75123 12.15 0.01197 87834 15.76 | ||
76 0.02999 73119 11.47 0.01323 86783 14.94 | ||
77 0.03255 70926 10.81 0.01509 85635 14.14 | ||
78 0.03776 68617 10.15 0.0179 84343 13.34 | ||
79 0.04123 66026 9.53 0.0197 82833 12.58 | ||
80 0.04786 63304 8.92 0.02349 81201 11.82 | ||
81 0.05292 60274 8.34 0.02654 79294 11.09 | ||
82 0.06065 57085 7.78 0.03006 77189 10.38 | ||
83 0.0689 53623 7.25 0.03583 74869 9.69 | ||
84 0.07668 49928 6.75 0.04047 72186 9.03 | ||
85 0.08828 46100 6.27 0.04813 69265 8.39 | ||
86 0.09783 42030 5.83 0.05378 65931 7.79 | ||
87 0.11101 37919 5.41 0.06222 62385 7.2 | ||
88 0.12157 33709 5.02 0.07078 58504 6.65 | ||
89 0.13658 29611 4.65 0.08448 54363 6.12 | ||
90 0.15483 25567 4.3 0.09903 49770 5.63 | ||
91 0.16722 21608 4 0.11179 44841 5.2 | ||
92 0.18625 17995 3.7 0.12621 39828 4.79 | ||
93 0.20458 14643 3.43 0.14197 34802 4.41 | ||
94 0.22061 11648 3.19 0.15993 29861 4.06 | ||
95 0.24455 9078 2.95 0.17727 25085 3.73 | ||
96 0.26578 6858 2.74 0.19811 20638 3.43 | ||
97 0.28759 5035 2.56 0.2203 16550 3.15 | ||
98 0.30982 3587 2.39 0.24368 12904 2.9 | ||
99 0.33225 2476 2.23 0.26805 9760 2.68 | ||
100 0.35469 1653 2.09 0.29317 7144 2.47 | ||
101 0.37694 1067 1.97 0.31876 5049 2.29 | ||
102 0.3988 665 1.86 0.34452 3440 2.13 | ||
103 0.42009 400 1.76 0.37015 2255 1.99 | ||
104 0.44065 232 1.67 0.39535 1420 1.86 | ||
105 0.46034 130 1.59 0.41984 859 1.75 | ||
106 0.47904 70 1.52 0.44336 498 1.65 | ||
107 0.49667 36 1.46 0.46571 277 1.57 | ||
108 0.51317 18 1.41 0.48674 148 1.5 | ||
109 0.52852 9 1.37 0.50632 76 1.44 | ||
110 0.54387 4 1.34 0.5259 38 1.41 | ||
111 0.55922 2 1.31 0.54548 17 1.38 | ||
112 0.57457 1 1.28 0.56506 8 1.35 | ||
113 0.58992 0 1.25 0.58464 3 1.32 | ||
114 0.60527 0 1.22 0.60422 1 1.29 | ||
115 0.62062 0 1.19 0.6238 0 1.26 | ||
116 0.63597 0 1.16 0.64338 0 1.23 | ||
117 0.65132 0 1.13 0.66296 0 1.2 | ||
118 0.66667 0 1.1 0.68254 0 1.17 | ||
119 0.68202 0 1.07 0.70212 0 1.14 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,9 +112,24 @@ | |
slope_prev = 1.0 # Initial slope of kNextFunc (aggregate shocks model) | ||
intercept_prev = 0.0 # Initial intercept of kNextFunc (aggregate shocks model) | ||
|
||
from pathlib import Path | ||
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.
|
||
|
||
# Import survival probabilities from SSA data | ||
data_location = os.path.dirname(os.path.abspath(__file__)) | ||
f = open(data_location + '/' + 'USactuarial.txt','r') | ||
# The default is US SSA data from year 2010 in USactuarial.txt, but should the users wish to use data from other years | ||
# or other countries, they could do so by naming the alternative data file "alternativedata.txt" and save this in the "/home/users/Downloads/" folder | ||
|
||
|
||
README = Path("/home/users/Downloads/alternativedata.txt") | ||
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. Matt touched upon this already, but I'm not sure he mentioned the following: why not just allow for the user to provide a string? No reason to hardcode this. Also, there's no guarantee to even have a Edit: oh, and |
||
if README.is_file(): | ||
print ("File does exist") | ||
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. This seems like a mistake. The file does exist, that was what that |
||
data_location = os.path.dirname(os.path.abspath(__file__)) | ||
f = open(data_location + '/' + 'alternativedata.txt','r') | ||
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. The whole purpose of
|
||
|
||
else: | ||
print ("File does not exist") | ||
data_location = os.path.dirname(os.path.abspath(__file__)) | ||
f = open(data_location + '/' + 'USactuarial.txt','r') | ||
|
||
actuarial_reader = csv.reader(f,delimiter='\t') | ||
raw_actuarial = list(actuarial_reader) | ||
base_death_probs = [] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Instructions on modifying the mortality assumptions used in Section 5 of Carroll et al. (2017) | ||
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 it's preferable to put information like this in a docstring, manual and/or inline comment. It must also describe the format. |
||
|
||
The default data used in the life cycle specifications in Carroll et al. (2017) are US 2010 actuarial life table data from the Social Security Administration. | ||
|
||
To run the model using alternative data (from other years or other countries), users can name the alternative data file "alternativedata.txt", and save this in the "home/users/Downloads/" folder. | ||
|
||
Actuarial life tables for Japan are provided in the same folder as this file's location as an example. |
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.
It's problematic to distribute data without proper license information. It's not at all clear that this data can be shared like this, and it doesn't contain a source either. What website/researcher/other was this obtained from? In general, it can be much easier to supply a function to generate such a table to avoid these types of considerations.