65歳から何年繰り下げると年金がお得か?~年金期待値を日本人の生命曲線から計算する
#年金 #繰り下げ #計算 #生命曲線 #期待値 #最大値
計算違いなどがあっても責任は取りかねます。実際は税金や社会保障費が余計に取られたりして単純には行きませんのでお遊びと思ってご覧ください。
既に65歳まで生きている人は、日本人平均余命(0歳の平均余命)より長生きである。
65歳からもらえる年金を繰り下げれば、より多くの年金がもらえるらしい。
しかし、もらえる前に死んでしまうリスクもある。
期待値ではどうなのだろうと疑問に。
令和二年の完全生命表から男女の生命曲線がわかるので計算できる。
Rで計算してみる
条件
基本の年金は月1とする(10万円なら10万倍してください)
月々0.7%もらえる年金が増加
生命表に従い65才以降の死亡を計算。各年の中では月々均等に死亡する。
男性では70才付近、女性では72才付近が年金期待値が良さそうだ。
65歳まで生きた人の余命中央値は男性85.9歳、女性91.1歳
損益分岐点は
繰り下げなしを70才繰り下げが超えるのは81.8歳→男女ともに中央値クリア
繰り下げなしを75才繰り下げが超えるのは86.8歳→女性だけ中央値クリア
70才繰り下げを75才繰り下げが超えるのは91.8歳→男女ともに中央値クリアできず
つまり五分五分以上で損益分岐を上回れるのは、男性は70才繰り下げ。女性は75才繰り下げ。
ただし、女性で75才繰り下げにすると、70才繰り下げを上回れるのは五分五分以下。
まあ期待値から男性は70才、女性は72歳でええんとちゃうと思った次第
Rソースコードは以下
#令和2年完全生命表データ抜粋 dat<-structure(list(x=c(0,1,2,3,4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28, 29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44, 45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60, 61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76, 77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92, 93,94,95,96,97,98,99,100,101,102,103,104,105,106, 107,108,109,110,111,112,113,0,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, 25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56, 57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72, 73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88, 89,90,91,92,93,94,95,96,97,98,99,100,101,102,103, 104,105,106,107,108,109,110,111,112,113,114),lx=c(1e+05, 99816,99792,99775,99764,99756,99750,99744,99739,99733, 99728,99722,99715,99706,99696,99682,99664,99642,99615, 99582,99544,99501,99452,99400,99348,99297,99248,99200, 99152,99103,99054,99003,98948,98889,98825,98759,98690, 98619,98547,98471,98388,98297,98196,98086,97965,97833, 97687,97528,97353,97161,96948,96712,96452,96167,95856, 95515,95140,94729,94280,93793,93263,92681,92041,91337, 90569,89734,88829,87838,86748,85553,84254,82840,81314, 79678,77921,76033,74002,71822,69487,67005,64365,61544, 58523,55293,51850,48204,44378,40399,36312,32179,28082, 24096,20289,16721,13450,10541,8047,5993,4349,3072,2110, 1407,909,569,345,201,113,62,32,16,8,4,2,1,1e+05, 99828,99811,99800,99791,99784,99777,99771,99765,99759, 99753,99748,99742,99735,99727,99719,99707,99693,99676, 99657,99637,99615,99593,99569,99544,99519,99494,99469, 99443,99417,99390,99363,99336,99307,99277,99242,99204, 99161,99115,99066,99012,98954,98892,98826,98752,98672, 98582,98484,98378,98261,98132,97990,97835,97668,97492, 97304,97106,96894,96669,96430,96177,95906,95613,95295, 94951,94580,94181,93747,93272,92751,92183,91555,90865, 90111,89285,88380,87383,86278,85042,83659,82108,80370, 78423,76240,73792,71052,68005,64636,60935,56898,52553, 47944,43100,38066,32936,27856,22971,18479,14477,11028, 8153,5839,4042,2700,1735,1071,633,357,192,98,47,21, 9,4,1),ndx=c(184,24,17,11,8,6,6,5,5,5,6,7,9, 11,14,17,22,28,32,38,44,49,52,52,50,49,48,48,49, 49,51,55,59,63,67,69,70,72,76,83,91,100,110,121, 132,146,160,175,192,213,236,260,285,311,341,375,411, 448,487,530,582,640,704,768,835,906,991,1090,1195, 1299,1414,1526,1636,1757,1888,2031,2180,2335,2482,2639, 2822,3021,3230,3442,3646,3826,3979,4087,4133,4098,3985, 3807,3568,3272,2909,2494,2054,1644,1277,962,703,497, 340,225,143,88,52,29,16,8,4,2,1,0,172,17,12,9, 7,7,7,6,6,5,5,6,7,8,9,11,14,17,19,20,22,23, 24,25,25,25,25,26,26,27,27,27,28,31,34,39,43,46, 50,54,58,62,67,73,81,89,98,107,117,129,142,155, 167,177,187,199,211,225,239,253,271,293,319,344,371, 399,434,475,521,569,627,690,754,826,905,996,1105, 1237,1383,1550,1738,1947,2182,2448,2740,3047,3369,3701, 4037,4345,4609,4844,5034,5130,5080,4884,4493,4002,3449, 2875,2314,1796,1343,964,664,438,276,165,94,51,26, 12,6,2,1),npx=c(0.99816,0.99976,0.99983,0.99989,0.99992, 0.99994,0.99994,0.99995,0.99995,0.99995,0.99994,0.99993, 0.99991,0.99989,0.99986,0.99982,0.99978,0.99972,0.99967, 0.99962,0.99956,0.99951,0.99948,0.99948,0.99949,0.99951, 0.99951,0.99951,0.99951,0.9995,0.99948,0.99945,0.9994, 0.99936,0.99932,0.9993,0.99929,0.99927,0.99923,0.99916, 0.99907,0.99898,0.99888,0.99877,0.99865,0.99851,0.99836, 0.99821,0.99802,0.99781,0.99757,0.99731,0.99705,0.99676, 0.99644,0.99608,0.99568,0.99527,0.99483,0.99434,0.99376, 0.99309,0.99235,0.99159,0.99078,0.9899,0.98885,0.98759, 0.98622,0.98482,0.98322,0.98157,0.97988,0.97795,0.97577, 0.97328,0.97054,0.96749,0.96428,0.96061,0.95616,0.95092, 0.9448,0.93774,0.92968,0.92063,0.91035,0.89882,0.88619, 0.87266,0.85808,0.84201,0.82414,0.80434,0.78374,0.76339, 0.74472,0.72571,0.70637,0.68671,0.66676,0.64654,0.62606, 0.60537,0.58448,0.56342,0.54223,0.52095,0.49961,0.47824, 0.4569,0.43562,0.41444,0.39342,0.99828,0.99983,0.99988, 0.99991,0.99993,0.99993,0.99993,0.99994,0.99994,0.99995, 0.99995,0.99994,0.99993,0.99992,0.99991,0.99989,0.99986, 0.99983,0.99981,0.9998,0.99978,0.99977,0.99976,0.99975, 0.99975,0.99975,0.99975,0.99974,0.99974,0.99973,0.99973, 0.99973,0.99972,0.99969,0.99965,0.99961,0.99957,0.99954, 0.9995,0.99946,0.99942,0.99937,0.99932,0.99926,0.99918, 0.99909,0.99901,0.99892,0.99881,0.99869,0.99855,0.99842, 0.99829,0.99819,0.99808,0.99796,0.99782,0.99767,0.99753, 0.99737,0.99719,0.99695,0.99667,0.99639,0.9961,0.99578, 0.99539,0.99493,0.99442,0.99387,0.99319,0.99246,0.9917, 0.99083,0.98986,0.98873,0.98736,0.98567,0.98374,0.98147, 0.97883,0.97577,0.97217,0.96789,0.96287,0.95711,0.95046, 0.94274,0.93375,0.92364,0.9123,0.89896,0.88321,0.86523, 0.84576,0.82465,0.80442,0.78345,0.76173,0.7393,0.71615, 0.69233,0.66786,0.64278,0.61713,0.59097,0.56436,0.53737, 0.51007,0.48255,0.45491,0.42724,0.39965,0.37226,0.34518 ),nqx=c(0.00184,0.00024,0.00017,0.00011,8e-05,6e-05, 6e-05,5e-05,5e-05,5e-05,6e-05,7e-05,9e-05,0.00011,0.00014, 0.00018,0.00022,0.00028,0.00033,0.00038,0.00044,0.00049, 0.00052,0.00052,0.00051,0.00049,0.00049,0.00049,0.00049, 5e-04,0.00052,0.00055,6e-04,0.00064,0.00068,7e-04,0.00071, 0.00073,0.00077,0.00084,0.00093,0.00102,0.00112,0.00123, 0.00135,0.00149,0.00164,0.00179,0.00198,0.00219,0.00243, 0.00269,0.00295,0.00324,0.00356,0.00392,0.00432,0.00473, 0.00517,0.00566,0.00624,0.00691,0.00765,0.00841,0.00922, 0.0101,0.01115,0.01241,0.01378,0.01518,0.01678,0.01843, 0.02012,0.02205,0.02423,0.02672,0.02946,0.03251,0.03572, 0.03939,0.04384,0.04908,0.0552,0.06226,0.07032,0.07937, 0.08965,0.10118,0.11381,0.12734,0.14192,0.15799,0.17586, 0.19566,0.21626,0.23661,0.25528,0.27429,0.29363,0.31329, 0.33324,0.35346,0.37394,0.39463,0.41552,0.43658,0.45777, 0.47905,0.50039,0.52176,0.5431,0.56438,0.58556,0.60658, 0.00172,0.00017,0.00012,9e-05,7e-05,7e-05,7e-05,6e-05, 6e-05,5e-05,5e-05,6e-05,7e-05,8e-05,9e-05,0.00011,0.00014, 0.00017,0.00019,2e-04,0.00022,0.00023,0.00024,0.00025, 0.00025,0.00025,0.00025,0.00026,0.00026,0.00027,0.00027, 0.00027,0.00028,0.00031,0.00035,0.00039,0.00043,0.00046, 5e-04,0.00054,0.00058,0.00063,0.00068,0.00074,0.00082, 0.00091,0.00099,0.00108,0.00119,0.00131,0.00145,0.00158, 0.00171,0.00181,0.00192,0.00204,0.00218,0.00233,0.00247, 0.00263,0.00281,0.00305,0.00333,0.00361,0.0039,0.00422, 0.00461,0.00507,0.00558,0.00613,0.00681,0.00754,0.0083, 0.00917,0.01014,0.01127,0.01264,0.01433,0.01626,0.01853, 0.02117,0.02423,0.02783,0.03211,0.03713,0.04289,0.04954, 0.05726,0.06625,0.07636,0.0877,0.10104,0.11679,0.13477, 0.15424,0.17535,0.19558,0.21655,0.23827,0.2607,0.28385, 0.30767,0.33214,0.35722,0.38287,0.40903,0.43564,0.46263, 0.48993,0.51745,0.54509,0.57276,0.60035,0.62774,0.65482 ),mux=c(0.07181,0.00048,0.00014,0.00014,9e-05,7e-05, 6e-05,6e-05,5e-05,5e-05,6e-05,7e-05,8e-05,9e-05,0.00012, 0.00015,2e-04,0.00025,3e-04,0.00035,0.00041,0.00047,0.00051, 0.00053,0.00052,5e-04,0.00049,0.00049,0.00049,0.00049, 5e-04,0.00053,0.00057,0.00062,0.00066,0.00069,0.00071, 0.00072,0.00075,8e-04,0.00088,0.00097,0.00107,0.00118, 0.00129,0.00142,0.00156,0.00171,0.00188,0.00208,0.00231, 0.00256,0.00282,0.00309,0.0034,0.00374,0.00413,0.00453, 0.00495,0.00541,0.00595,0.00658,0.0073,0.00805,0.00884, 0.00968,0.01065,0.01182,0.01317,0.01457,0.01609,0.01775, 0.01944,0.02126,0.02337,0.02576,0.02844,0.03143,0.03466, 0.03818,0.04237,0.04743,0.05339,0.06035,0.06841,0.0776, 0.08807,0.10005,0.11352,0.12829,0.14434,0.16213,0.18223, 0.20514,0.23049,0.25797,0.28219,0.30749,0.33391,0.36152, 0.39037,0.4205,0.45198,0.48487,0.51922,0.55512,0.59261, 0.63179,0.67271,0.71547,0.76013,0.8068,0.85554,0.90647, 0.06362,0.00042,7e-05,1e-04,8e-05,7e-05,7e-05,6e-05,6e-05, 6e-05,5e-05,5e-05,6e-05,7e-05,8e-05,1e-04,0.00013,0.00016, 0.00018,2e-04,0.00021,0.00022,0.00024,0.00025,0.00025, 0.00025,0.00025,0.00026,0.00026,0.00027,0.00027,0.00027, 0.00028,3e-04,0.00033,0.00037,0.00041,0.00045,0.00048, 0.00052,0.00056,6e-04,0.00065,0.00071,0.00078,0.00086, 0.00095,0.00104,0.00113,0.00125,0.00138,0.00152,0.00165, 0.00176,0.00187,0.00198,0.00211,0.00225,0.0024,0.00255, 0.00272,0.00293,0.00319,0.00348,0.00376,0.00406,0.00441, 0.00484,0.00533,0.00586,0.00648,0.00719,0.00794,0.00876, 0.00968,0.01073,0.01198,0.01353,0.01537,0.01749,0.01998, 0.02288,0.02627,0.03031,0.03511,0.04069,0.04714,0.05467, 0.06353,0.07376,0.0853,0.09872,0.11487,0.13403,0.15574, 0.18088,0.20496,0.23057,0.25782,0.2868,0.31763,0.35043, 0.38531,0.42242,0.46189,0.50388,0.54855,0.59606,0.6466, 0.70036,0.75755,0.81838,0.8831,0.95193,1.02515),nLx=c(99860, 99801,99784,99769,99760,99753,99747,99741,99736,99731, 99725,99719,99711,99701,99689,99674,99654,99629,99599, 99564,99523,99477,99426,99374,99322,99273,99224,99176, 99128,99079,99028,98976,98919,98857,98792,98724,98654, 98583,98509,98430,98343,98248,98142,98027,97900,97761, 97609,97442,97258,97056,96832,96584,96311,96014,95688, 95330,94937,94508,94040,93532,92977,92366,91694,90959, 90157,89288,88341,87302,86159,84912,83557,82086,80505, 78810,76989,75030,72924,70667,68258,65699,62970,60050, 56925,53589,50043,46305,42400,38362,34246,30124,26077, 22175,18483,15058,11963,9258,6983,5138,3682,2567,1739, 1143,728,449,267,154,85,45,23,11,5,2,1,0,99868, 99817,99806,99795,99787,99781,99774,99768,99762,99756, 99751,99745,99739,99731,99723,99713,99700,99685,99667, 99647,99626,99604,99581,99556,99531,99507,99481,99456, 99430,99403,99376,99349,99322,99292,99260,99223,99183, 99138,99091,99039,98984,98924,98859,98790,98713,98628, 98534,98432,98320,98198,98063,97914,97753,97581,97399, 97206,97001,96783,96551,96305,96043,95762,95456,95125, 94768,94383,93967,93513,93016,92471,91874,91215,90494, 89704,88839,87890,86841,85672,84363,82898,81256,79415, 77352,75040,72447,69555,66348,62814,58944,54749,50269, 45540,40595,35504,30386,25390,20687,16434,12705,9542, 6950,4900,3336,2189,1381,836,484,267,140,70,33,15, 6,2,1),Tx=c(8156116,8056256,7956455,7856671,7756902, 7657142,7557389,7457642,7357901,7258165,7158434,7058709, 6958990,6859280,6759579,6659889,6560216,6460562,6360933, 6261335,6161771,6062248,5962771,5863346,5763972,5664649, 5565377,5466152,5366976,5267849,5168770,5069742,4970766, 4871847,4772990,4674198,4575473,4476819,4378236,4279727, 4181297,4082953,3984706,3886564,3788537,3690637,3592875, 3495267,3397825,3300566,3203510,3106679,3010095,2913784, 2817770,2722082,2626752,2531814,2437307,2343266,2249734, 2156758,2064391,1972697,1881738,1791581,1702293,1613952, 1526650,1440491,1355579,1272023,1189936,1109431,1030621, 953632,878603,805678,735011,666753,601054,538084,478033, 421108,367519,317476,271171,228771,190409,156162,126038, 99961,77786,59303,44245,32283,23025,16041,10903,7221, 4654,2916,1773,1045,596,328,175,89,44,21,9,4,2,1, 8771274,8671407,8571590,8471784,8371988,8272201,8172420, 8072646,7972878,7873117,7773361,7673610,7573865,7474127, 7374395,7274672,7174959,7075258,6975574,6875907,6776260, 6676633,6577029,6477449,6377893,6278361,6178855,6079373, 5979917,5880487,5781084,5681707,5582358,5483036,5383744, 5284484,5185260,5086078,4986939,4887849,4788810,4689826, 4590902,4492043,4393253,4294540,4195913,4097379,3998947, 3900626,3802429,3704366,3606452,3508699,3411119,3313720, 3216514,3119513,3022730,2926179,2829875,2733832,2638070, 2542614,2447489,2352721,2258338,2164371,2070858,1977843, 1885371,1793497,1702282,1611788,1522084,1433245,1345356, 1258515,1172843,1088480,1005581,924326,844911,767558,692519, 620072,550517,484169,421355,362412,307662,257393,211853, 171258,135754,105368,79978,59292,42858,30153,20611,13660, 8761,5425,3235,1854,1018,534,267,127,57,24,10,4,1 ),ex=c(81.56,80.71,79.73,78.74,77.75,76.76,75.76,74.77, 73.77,72.78,71.78,70.78,69.79,68.79,67.8,66.81,65.82, 64.84,63.86,62.88,61.9,60.93,59.96,58.99,58.02,57.05, 56.08,55.1,54.13,53.16,52.18,51.21,50.24,49.27,48.3, 47.33,46.36,45.4,44.43,43.46,42.5,41.54,40.58,39.62, 38.67,37.72,36.78,35.84,34.9,33.97,33.04,32.12,31.21, 30.3,29.4,28.5,27.61,26.73,25.85,24.98,24.12,23.27,22.43, 21.6,20.78,19.97,19.16,18.37,17.6,16.84,16.09,15.36, 14.63,13.92,13.23,12.54,11.87,11.22,10.58,9.95,9.34, 8.74,8.17,7.62,7.09,6.59,6.11,5.66,5.24,4.85,4.49,4.15, 3.83,3.55,3.29,3.06,2.86,2.68,2.51,2.35,2.21,2.07,1.95, 1.83,1.73,1.63,1.54,1.45,1.37,1.3,1.23,1.16,1.1,1.05, 87.71,86.86,85.88,84.89,83.9,82.9,81.91,80.91,79.92, 78.92,77.93,76.93,75.93,74.94,73.95,72.95,71.96,70.97, 69.98,69,68.01,67.02,66.04,65.06,64.07,63.09,62.1,61.12, 60.13,59.15,58.17,57.18,56.2,55.21,54.23,53.25,52.27, 51.29,50.31,49.34,48.37,47.39,46.42,45.45,44.49,43.52, 42.56,41.6,40.65,39.7,38.75,37.8,36.86,35.92,34.99,34.06, 33.12,32.19,31.27,30.35,29.42,28.51,27.59,26.68,25.78, 24.88,23.98,23.09,22.2,21.32,20.45,19.59,18.73,17.89, 17.05,16.22,15.4,14.59,13.79,13.01,12.25,11.5,10.77, 10.07,9.38,8.73,8.1,7.49,6.91,6.37,5.85,5.37,4.92,4.5, 4.12,3.78,3.48,3.21,2.96,2.73,2.53,2.34,2.17,2.01,1.86, 1.73,1.61,1.5,1.39,1.3,1.21,1.13,1.05,0.98,0.92),sexM1=c(1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)),row.names=c(NA, -229L), class = "data.frame") ##dummy data add for long time survival curve mmax <- max(dat[dat$sexM1==1,]$x) fmax <- max(dat[dat$sexM1==0,]$x) dumage <- c((mmax+1):200, (fmax+1):200) len_d <- length(dumage) dat_dummy <- data.frame(x = dumage, lx = rep(0, len_d), ndx = rep(NA,len_d), npx= rep(NA,len_d), nqx= rep(NA,len_d), mux= rep(NA,len_d), nLx= rep(NA,len_d), Tx= rep(NA,len_d), ex= rep(NA,len_d), sexM1 = c(rep(1, length((mmax+1):200)), rep(0, length((fmax+1):200)))) dat <- rbind(dat, dat_dummy) ###年金 max_age <- 130 kurisage_rate <- 0.007 age_nenkin <- seq(65, max_age, by = 1/12) nenkin_len <- length(age_nenkin) nenkin <- seq(1, by=0.007, length.out = nenkin_len) kurisage <- function(kuri_age = 70){ temp <- rep(1, nenkin_len) flag <- which(age_nenkin == kuri_age) if(flag > 1){ temp[1:(flag-1)] <- 0 } temp[flag:length(temp)] <- nenkin[flag] return(temp) } ninnzuu <- function(sexM1F0 =1){ temp_sex <- sexM1F0 max_i <- which(dat$x[dat$sexM1 == temp_sex] == max_age) min_i <- which(dat$x[dat$sexM1 == temp_sex] == 65) temp <- NULL for(i in min_i:(max_i-1)){ temp2 <- seq(dat$lx[dat$sexM1 == temp_sex][i], dat$lx[dat$sexM1 == temp_sex][i+1], length.out = 13) temp <- c(temp, temp2[-13]) } temp <- c(temp, temp2[13]) temp <- temp / temp[1] return(temp) } exp_nenkin <- function(kuri_age = 75, sex = 1){ nenkin_tbl <- kurisage(kuri_age) cum_nen <- cumsum(nenkin_tbl) nin <- ninnzuu(sexM1F0 = sex) sibou <- -diff(nin) ex_nen <- sum(sibou * cum_nen[-length(cum_nen)]) return(ex_nen) } cal.median <- function(y, b){ #age = y #sex=b(F0M1) 以降でのmedian生存期間 #ssp <- smooth.spline(dat$lx[dat$sexM1 == b]/100000, dat$x[dat$sexM1 ==b]) #smooth spline ssp <- approxfun(dat$lx[dat$sexM1 == b]/100000, dat$x[dat$sexM1 ==b], method = "linear", rule = 2, ties = mean) #linear temp <- dat$lx[dat$sexM1 == b & dat$x == y]/100000 #return(predict(ssp, x = temp / 2)$y - y) #spline return(ssp(temp/2) - y) } ave.yomei <- function(age = 80, M1F0 = 1){ temp <- subset(dat, sexM1 == M1F0) temp$ex[temp$x == age] } cal_kurisage <- 65:75 sex <- 0 temp <- numeric(length(cal_kurisage)) for(i in 1:length(cal_kurisage)){ temp[i] <- exp_nenkin(cal_kurisage[i], sex) } plot(cal_kurisage, temp, main = "2020完全生命表による年金期待値(女性)", xlab="繰り下げ年齢", ylab="期待値", type="b", xaxt="n") axis(axis(side=1, at=65:75)) cal_kurisage <- 65:75 sex <- 1 temp <- numeric(length(cal_kurisage)) for(i in 1:length(cal_kurisage)){ temp[i] <- exp_nenkin(cal_kurisage[i], sex) } plot(cal_kurisage, temp, main = "2020完全生命表による年金期待値(男性)", xlab="繰り下げ年齢", ylab="期待値", type="b", xaxt="n") axis(axis(side=1, at=65:75)) plot(age_nenkin, cumsum(kurisage(65)), type="l", xlab="年齢", ylab="年金合計", xlim=c(65, 100)) lines(age_nenkin, cumsum(kurisage(75)), type="l", col =2) lines(age_nenkin, cumsum(kurisage(70)), type="l", col =3) abline(v = seq(70, 130, by=5), lty=2) abline(v=c(86.83333, 81.83333, 91.83333), col=2) a65_75 <- age_nenkin[min(which(cumsum(kurisage(65)) < cumsum(kurisage(75))))] #65を75が超える a65_70 <- age_nenkin[min(which(cumsum(kurisage(65)) < cumsum(kurisage(70))))] #65を70が超える a70_75 <- age_nenkin[min(which(cumsum(kurisage(70)) < cumsum(kurisage(75))))] #70を75が超える m1 <- cal.median(65, 1) + 65 #男性65歳の余命中央値 m0 <- cal.median(65, 0) + 65 #女性65歳の余命中央値 a1 <- ave.yomei(65, 1) + 65 #男性65歳の平均余命 a0 <- ave.yomei(65, 0) + 65 #女性65歳の平均余命 abline(v=c(m1, m0), col="blue") #abline(v=c(a1, a0), col="green") text(a65_75, 20, labels = paste0(round(a65_75, digits=1), "歳\n65=75"), col=2) text(a65_70, 10, labels = paste0(round(a65_70, digits=1), "歳\n65=70"), col=2) text(a70_75, 20, labels = paste0(round(a70_75, digits=1), "歳\n70=75"), col=2) text(m1, 400, labels = paste0(round(m1, digits=1), "歳\n男性中央値"), col="blue") text(m0, 400, labels = paste0(round(m0, digits=1), "歳\n女性中央値"), col="blue")