data-raw/examples_migresid.R

################### For single ages year age groups #####################

# Vector of population for males
pop_m <-
  c(46011,46514,48735,53185,57403,60020,63472,64955,65268,61853,60372,56365,55737,54188,51960,50854,51302,51310,52906,52011,50482,52187,53403,56249,59642,59454,60947,61687,59757,59948,63005,67548,68574,69056,68923,64527,61492,59630,58540,59615,59451,59775,60793,59447,58431,60118,59595,59054,61898,63808,65958,66805,67780,67466,66619,62014,56901,50008,47556,47461,45041,42714,40984,39320,37387,36423,37212,36594,36499,35006,35263,33928,33718,33577,32654,32342,30482,31057,30845,23826,21610,20155,18066,15752,14433.59,12565.72,10606.96,8911.94,7299.2,5877.03,4414.61,3413.12,2429.45,1701.38,1173,823,540,332,187,115,133,
    45309,46291,46652,48893,53295,57477,60109,63588,65113,65406,61972,60506,56490,55876,54329,52138,50992,51514,51417,53036,52080,50558,52339,53620,56529,59958,59699,61147,61921,59900,60083,63142,67572,68719,69057,68920,64522,61450,59574,58477,59496,59341,59681,60676,59338,58304,59960,59475,58840,61668,63597,65714,66546,67507,67153,66213,61645,56536,49656,47191,47017,44638,42259,40541,38794,36789,35827,36530,35863,35671,34119,34278,32821,32595,32348,31216,30866,28957,29257,28872,22116,19872,18353,16218,14027,12714.59,10894.72,8955.96,7456.94,5964.2,4659.03,3481.61,2579.12,1815.45,1208.38,834,547,358,213,119,141,
    46764,45641,46503,46902,49080,53464,57625,60277,63755,65302,65588,62175,60765,56697,56080,54532,52392,51201,51730,51581,53199,52292,50866,52734,54154,57028,60395,60091,61449,62287,60254,60359,63366,67716,68870,69188,69053,64574,61542,59641,58485,59539,59334,59663,60670,59303,58237,59869,59322,58712,61537,63422,65494,66298,67198,66857,65848,61287,56194,49291,46796,46586,44233,41804,40030,38222,36251,35201,35895,35039,34813,33233,33288,31712,31451,31048,29834,29311,27348,27458,26887,20484,18136,16584,14466,12372,10974.59,9236.72,7498.96,6149.94,4836.2,3683.03,2642.61,1898.12,1318.45,845.38,536,358,228,127,155,
    47214,47187,45911,46749,47174,49297,53704,57797,60499,63980,65488,65854,62407,61039,56953,56322,54784,52659,51464,51924,51788,53427,52569,51300,53292,54680,57583,60869,60499,61883,62701,60620,60721,63617,67914,69044,69319,69192,64703,61595,59677,58618,59555,59294,59661,60596,59275,58151,59769,59190,58588,61375,63243,65259,66010,66917,66522,65478,60878,55819,48910,46398,46164,43766,41301,39450,37643,35650,34550,35151,34283,33931,32268,32267,30604,30201,29709,28390,27797,25751,25507,24892,18733,16478,14772,12844,10744,9438.59,7775.72,6165.96,4955.94,3732.2,2837.03,1931.61,1386.12,928.45,567.38,330,222,140,152,
    49275,47631,47449,46190,47047,47404,49544,53918,58034,60706,64210,65720,66135,62678,61290,57198,56598,55088,52949,51653,52139,52029,53944,53130,51965,53855,55288,58066,61339,60942,62297,63041,60923,61052,63910,68152,69190,69502,69310,64788,61649,59764,58642,59590,59320,59636,60604,59214,58086,59681,59092,58416,61149,63023,65019,65725,66601,66155,65087,60415,55381,48519,46006,45689,43267,40773,38877,37005,35010,33827,34321,33438,33027,31233,31135,29419,28913,28302,26841,26193,23948,23648,22779,16970,14815,13035,11171,9106,7901.59,6376.72,4935.96,3914.94,2856.2,2091.03,1343.61,978.12,621.45,355.38,206,134,158,
    51138,49687,47852,47680,46438,47322,47587,49748,54127,58274,60944,64393,65920,66380,62910,61546,57461,56887,55386,53137,51846,52409,52501,54561,53777,52613,54324,55770,58540,61714,61327,62604,63342,61217,61231,64056,68304,69360,69569,69287,64913,61657,59692,58662,59591,59284,59608,60531,59084,57967,59520,58920,58275,60914,62775,64722,65380,66266,65776,64672,59973,54971,48023,45558,45202,42665,40145,38251,36338,34308,33048,33427,32529,31994,30152,30008,28174,27503,26855,25325,24466,22200,21645,20660,15182,13146,11340,9582,7641,6509.59,5193.72,3942.96,2971.94,2153.2,1531.03,964.61,660.12,384.45,225.38,133,168,
    52037,51460,49910,48059,47877,46626,47510,47765,49940,54321,58481,61124,64585,66113,66551,63125,61740,57660,57117,55563,53308,52116,52854,53141,55164,54451,53228,54824,56254,58916,61992,61571,62778,63495,61412,61329,64151,68445,69263,69559,69279,64884,61579,59679,58620,59564,59190,59496,60390,58940,57789,59335,58709,58087,60662,62447,64402,64951,65874,65357,64197,59441,54478,47559,45068,44602,42045,39511,37572,35595,33573,32234,32520,31598,30940,29081,28858,26921,26166,25390,23808,22760,20446,19821,18588,13518,11538,9807,8085,6317,5332.59,4143.72,3056.96,2234.94,1576.2,1106.03,666.61,449.12,252.45,128.38,173,
    52135,52476,51641,50081,48207,48036,46782,47628,47971,50044,54481,58658,61303,64765,66293,66740,63290,61943,57850,57260,55710,53562,52637,53643,53936,55904,55213,53850,55348,56727,59376,62391,61828,63065,63660,61621,61449,64245,68522,69253,69609,69227,64900,61549,59669,58555,59458,59118,59386,60260,58809,57656,59182,58462,57790,60371,62115,64025,64595,65432,64821,63645,58896,53957,47036,44481,43972,41360,38833,36853,34835,32821,31426,31615,30511,29780,27975,27598,25592,24683,23781,22099,21031,18591,17927,16484,11883,9905,8270,6715,5119,4237.59,3242.72,2267.96,1582.94,1105.2,759.03,442.61,293.12,159.45,187.38,
    54684,52730,52925,52057,50472,48506,48509,47110,48009,48357,50436,54929,59025,61708,65166,66672,67172,63729,62364,58240,57733,56425,54503,53887,54949,55071,57098,56200,54757,56183,57472,59954,63080,62324,63689,64108,62167,61730,64522,68782,69481,69807,69345,65088,61666,59757,58700,59456,59116,59376,60225,58724,57527,58972,58267,57567,60104,61790,63637,64191,64973,64312,63066,58312,53411,46426,43844,43340,40724,38154,36108,34067,31942,30585,30692,29424,28681,26757,26289,24177,23248,22129,20394,19299,16773,15983,14416,10342,8377,6904,5437,4081,3297.59,2435.72,1705.96,1135.94,781.2,496.03,296.61,173.12,205.83,
    55427,55242,53140,53368,52417,50809,48946,48864,47516,48396,48776,50878,55344,59407,62045,65580,67281,67882,64281,62724,58644,58335,57323,55781,55288,56233,56220,58145,57236,55710,57016,58225,60706,63731,62908,64245,64574,62635,62129,64924,69069,69797,69987,69487,65250,61813,59865,58787,59504,59105,59379,60134,58569,57411,58802,58074,57322,59820,61451,63257,63758,64522,63785,62464,57661,52790,45798,43215,42631,40063,37397,35379,33295,31074,29718,29722,28296,27550,25448,24966,22753,21700,20439,18669,17507,14996,14100,12528,8826,7027,5612,4337,3163,2501.59,1738.72,1210.96,750.94,544.2,318.03,181.61,210.95,
    56528,56162,55789,53638,53870,52819,51221,49360,49307,47970,48790,49197,51329,55769,59919,62549,66175,67953,68411,64643,63152,59088,59128,58441,56997,56507,57291,57286,59076,58162,56473,57777,58936,61243,64195,63406,64664,64851,62994,62475,65140,69208,69947,70109,69590,65308,61846,59891,58773,59425,59010,59277,60015,58384,57222,58607,57850,57028,59495,61075,62811,63294,63989,63231,61809,57004,52106,45155,42586,41852,39304,36610,34559,32464,30143,28720,28687,27181,26297,24186,23559,21196,20080,18714,16918,15705,13254,12229,10677,7391,5720,4540,3389,2355,1826.59,1271.72,816.96,510.94,359.2,208.03,218.56,
    57720,57188,56635,56210,54073,54261,53193,51641,49753,49726,48339,49239,49596,51849,56215,60461,63344,66904,68513,68789,65092,63694,60203,60518,59998,58452,57899,58534,58288,60107,58993,57266,58502,59544,61838,64743,63871,65097,65178,63352,62786,65436,69359,70120,70229,69650,65460,61913,59934,58819,59410,58968,59214,59893,58261,57088,58418,57604,56726,59160,60747,62429,62795,63483,62686,61125,56320,51438,44546,41911,41115,38544,35827,33680,31534,29167,27724,27557,25953,25017,22816,22049,19689,18512,17004,15185,13898,11538,10459,8928,6108,4622,3545,2552,1705,1285.59,880.72,545.96,325.94,214.2,236.59,
    59496,58366,57606,56944,56519,54366,54549,53547,51884,50102,50016,48645,49552,49897,52223,56659,61106,64082,67450,68877,69153,65572,64671,61600,62005,61517,59933,59093,59646,59035,60964,59638,57840,58996,59954,62268,65009,64119,65289,65299,63567,62942,65544,69419,70115,70231,69629,65398,61835,59920,58724,59326,58801,59051,59686,58075,56798,58152,57307,56365,58765,60306,61953,62249,62821,61983,60397,55560,50743,43873,41117,40303,37679,34976,32758,30575,28146,26678,26308,24602,23649,21337,20490,18116,16878,15315,13418,12133,9890,8801,7360,4897,3626,2725,1888,1228,903.59,582.72,357.96,205.94,233.79,
    57359,60199,58808,57971,57288,56802,54614,54836,53794,52202,50400,50332,48971,49896,50306,52783,57550,62016,64628,67791,69202,69571,66177,65504,62435,62850,62430,60669,59751,60222,59660,61504,60123,58297,59456,60300,62583,65334,64383,65513,65536,63774,63080,65686,69517,70172,70229,69610,65367,61856,59831,58676,59205,58678,58906,59507,57827,56571,57900,56975,56008,58388,59865,61425,61706,62157,61199,59594,54772,49929,43091,40341,39445,36778,34055,31853,29533,27003,25513,25033,23263,22282,19868,18924,16487,15120,13666,11727,10443,8352,7322,5911,3827,2780,2021,1355,844,608.59,391.72,225.96,263.73,
    58309,58059,60713,59270,58372,57661,57207,55017,55213,54209,52588,50781,50768,49421,50408,51005,53772,58464,62590,64959,68172,69633,70276,67072,66421,63400,63620,63151,61321,60362,60767,60172,62061,60544,58693,59813,60609,62958,65651,64659,65707,65763,63964,63192,65873,69612,70232,70267,69610,65318,61798,59777,58627,59031,58567,58701,59245,57585,56338,57606,56688,55619,58009,59398,60879,61085,61424,60441,58785,53921,49114,42318,39520,38540,35781,33028,30811,28446,25802,24313,23682,21831,20745,18293,17278,14824,13434,11897,10092,8743,6849,5869,4660,2913,2054,1428,935,544,392.59,249.72,261.7,
    58649,59039,58721,61260,59825,59012,58259,57858,55695,55908,54901,53319,51412,51540,50159,51294,52075,54930,59303,63191,65509,68717,70380,71269,68113,67543,64434,64599,63986,62199,61068,61415,60722,62630,61120,59198,60299,61052,63295,66041,64953,66017,66035,64284,63400,66064,69752,70370,70368,69655,65313,61816,59707,58581,58927,58434,58619,59028,57390,56059,57265,56292,55179,57532,58871,60249,60413,60677,59620,57952,53017,48189,41429,38671,37574,34699,31947,29708,27360,24658,23059,22309,20425,19214,16730,15603,13222,11861,10280,8546,7232,5545,4551,3579,2156,1462,1001,629,334,260.59,295.41,
    59584,59489,59807,59395,61909,60375,59709,58891,58475,56305,56538,55521,53958,52106,52295,51042,52562,53392,55983,60076,63988,66497,69807,71632,72659,69542,68963,65739,65838,65156,63210,61908,62292,61486,63464,61905,59855,60893,61568,63888,66529,65490,66433,66449,64664,63745,66353,69945,70575,70465,69788,65351,61861,59711,58567,58857,58327,58441,58834,57097,55781,56899,55916,54719,57057,58321,59610,59693,59804,58761,56989,52043,47217,40598,37734,36498,33581,30774,28511,26177,23460,21739,20870,18938,17589,15178,13953,11671,10260,8792,7103,5873,4449,3504,2703,1595,1019,698,415,206,314,
    59994,60640,60292,60662,60196,62686,61064,60445,59572,59189,57076,57224,56218,54687,52930,53287,52338,54090,54569,56738,60980,64998,67834,71230,73156,74108,70944,70264,66794,66873,66050,64131,62723,63016,62086,64146,62458,60446,61504,62109,64301,67023,65852,66894,66798,65017,64020,66594,70122,70648,70537,69871,65335,61817,59610,58464,58745,58200,58239,58643,56807,55456,56522,55515,54290,56539,57633,58884,58854,58965,57842,55898,51013,46178,39566,36691,35344,32475,29571,27213,24870,22113,20396,19335,17456,15899,13556,12261,10096,8707,7299,5805,4597,3386,2653,1953,1107,694,448,254,307,
    61005,61352,61817,61378,61840,61241,63718,62065,61409,60568,60092,57999,58201,57211,55766,54366,55217,54633,56389,55970,58246,62753,66921,69854,73247,75157,76198,73101,72176,68585,68631,67738,65662,64040,64250,63207,65309,63415,61383,62275,62848,65049,67683,66374,67451,67252,65397,64393,66912,70318,70850,70720,69963,65468,61865,59613,58410,58637,58069,58083,58403,56461,55117,56107,55074,53727,55938,56982,58101,58026,57977,56884,54759,49925,45028,38563,35574,34133,31214,28284,25911,23418,20783,18979,17826,15847,14233,11956,10671,8731,7259,5917,4631,3533,2514,1939,1350,712,464,296,328,
    59899,62531,62258,62825,62332,62742,62154,64652,62973,62365,61423,60983,58927,59056,58168,57017,56202,57284,58077,57482,56782,59099,63967,68404,71283,74734,76708,77718,74573,73635,69972,69933,68898,66723,65009,65301,63991,66102,64107,62043,62854,63394,65491,68126,66786,67842,67519,65717,64677,67104,70472,70929,70758,69966,65410,61811,59464,58275,58503,57852,57876,58071,56075,54706,55562,54552,53201,55266,56269,57296,57076,56955,55850,53625,48784,43877,37482,34368,32825,29894,27002,24520,22041,19257,17432,16212,14239,12543,10382,9065,7157,5900,4634,3568,2666,1803,1324,927,443,289,348,
    60032,60973,63361,63030,63640,63087,63441,62905,65385,63716,63197,62172,61758,59680,59838,58915,57928,57108,58716,61135,59115,57501,60048,65065,69439,72416,75873,77948,78928,75783,74871,71078,70994,69885,67627,65850,66033,64670,66751,64708,62516,63259,63806,65851,68483,67096,68161,67733,65874,64826,67216,70496,70938,70698,69839,65308,61738,59263,58138,58287,57581,57551,57691,55654,54220,54980,53986,52503,54578,55476,56382,56132,55859,54707,52391,47508,42615,36201,33125,31488,28459,25539,23013,20477,17718,15899,14566,12574,10883,8857,7538,5809,4717,3597,2682,1936,1288,897,607,264,359)
# Vector of population for females
pop_f <-
  c(43223,44201,46785,50270,55029,57483,60108,61137,62014,58559,56838,54092,52692,51013,48980,47946,48405,49020,50491,49770,48387,49690,51371,54350,57556,57378,58737,59423,58131,57421,60791,63912,64855,65160,65747,60738,58457,56937,56440,56870,56841,58290,57987,57846,56706,58136,58011,57659,59922,62718,65031,65443,66164,65300,64080,60379,54951,49118,46646,47274,45624,43454,42597,40532,40079,39246,40884,40748,41680,40175,41456,40087,40559,40998,40948,40531,40114,41820,42633,33718,32125,31086,28696,26808,25475.62,23187.66,21172.03,18152.55,15774.37,13757.16,11231.82,9027.71,7096.01,5321.9,3950.87,2892.06,1996.22,1330,863,519,755,
    43058,43599,44356,46880,50383,55150,57586,60189,61253,62139,58685,56948,54201,52820,51148,49082,48083,48576,49267,50587,50113,48684,50036,51740,54672,57858,57724,58974,59665,58313,57586,60945,64070,64973,65235,65838,60845,58559,56961,56472,56883,56851,58282,58004,57811,56659,58100,57949,57606,59862,62580,64909,65287,65978,65160,63885,60158,54718,48912,46454,47053,45357,43184,42308,40212,39745,38855,40462,40301,41169,39617,40827,39437,39814,40118,39943,39441,38859,40493,40983,32102,30444,29335,26817,24911,23316.62,20964.66,18921.03,15990.55,13573.37,11666.16,9347.82,7311.71,5606.01,4099.9,3015.87,2143.06,1404.22,906,554,752,
    43950,43589,43801,44555,47065,50619,55297,57776,60351,61446,62314,58898,57149,54411,52959,51326,49271,48259,48865,49423,51050,50511,49155,50562,52199,55151,58326,58124,59374,59933,58655,57891,61150,64352,65177,65452,65947,61026,58625,57040,56624,56962,56960,58285,58041,57852,56682,58088,57947,57568,59785,62442,64779,65194,65819,64947,63648,59900,54490,48719,46242,46796,45101,42881,42008,39897,39391,38491,40037,39835,40655,39053,40142,38701,39027,39205,38875,38287,37605,39020,39109,30450,28734,27509,24914,22815,21181.62,18740.66,16725.03,13846.55,11551.37,9753.16,7609.82,5842.71,4356.01,3114.9,2189.87,1526.06,948.22,614,809,
    44439,44441,43868,44027,44757,47291,50810,55534,57963,60525,61652,62561,59100,57415,54639,53160,51573,49493,48549,49133,49862,51471,51017,49743,51164,52691,55676,58771,58545,59723,60326,59057,58186,61440,64542,65416,65684,66170,61182,58771,57195,56758,57062,57053,58341,58052,57908,56703,58054,57901,57499,59696,62335,64630,65053,65661,64760,63440,59668,54254,48493,46017,46550,44849,42629,41668,39554,38984,38054,39575,39319,40012,38388,39426,37931,38106,38280,37764,36995,36152,37333,37130,28858,26911,25532,22942,20634,18964.62,16475.66,14514.03,11774.55,9617.37,7868.16,6019.82,4487.71,3335.01,2306.9,1568.87,1047.06,646.22,863,
    46751,45055,44731,44131,44239,44976,47531,51001,55739,58183,60720,61924,62781,59300,57632,54877,53400,51824,49804,48835,49553,50367,51943,51571,50363,51727,53244,56138,59225,58924,60130,60695,59354,58506,61703,64770,65639,65898,66365,61304,58893,57315,56917,57133,57127,58448,58113,57951,56715,58026,57868,57458,59653,62248,64510,64922,65455,64539,63214,59409,54006,48221,45800,46320,44570,42312,41348,39164,38555,37621,39019,38671,39357,37701,38609,37089,37170,37215,36516,35608,34496,35534,35095,27019,25040,23388,20807,18389,16613.62,14333.66,12214.03,9686.55,7800.37,6239.16,4603.82,3370.71,2404.01,1589.9,1064.87,705.06,929.22,
    48092,47392,45352,44934,44321,44446,45187,47750,51206,55952,58413,60898,62145,63004,59498,57835,55095,53622,52170,50161,49426,50022,50800,52537,52138,50989,52191,53720,56530,59560,59356,60492,61035,59655,58844,61951,64999,65818,66076,66476,61437,59050,57389,56979,57197,57181,58471,58112,57928,56706,57981,57791,57368,59556,62118,64354,64772,65228,64296,62962,59158,53725,47938,45527,45999,44198,41995,40947,38736,38094,37101,38454,38062,38650,36980,37799,36171,36163,36057,35187,34092,32864,33656,32970,25202,23054,21315,18673,16260,14428.62,12212.66,10258.03,7947.55,6192.37,4860.16,3494.82,2450.71,1708.01,1083.9,698.87,974.28,
    49053,48821,47715,45484,45142,44514,44633,45344,47861,51405,56121,58565,61093,62288,63183,59673,58064,55310,53928,52517,50575,49895,50617,51469,53173,52800,51562,52671,54121,56892,59908,59666,60789,61201,59825,59028,62123,65185,65902,66167,66576,61549,59099,57458,57042,57229,57206,58470,58075,57878,56642,57905,57726,57290,59441,61954,64149,64549,64975,64028,62659,58834,53421,47632,45195,45639,43832,41606,40553,38293,37620,36561,37843,37418,37886,36178,36922,35165,35070,34806,33787,32567,31195,31676,30823,23330,20956,19211,16595,14195,12328.62,10289.66,8489.03,6429.55,4865.37,3682.16,2589.82,1747.71,1189.01,739.9,1050.15,
    49420,49715,49157,47890,45623,45300,44601,44781,45507,48037,51557,56266,58713,61254,62454,63365,59862,58263,55558,54249,52925,50992,50449,51267,52147,53839,53395,52071,53161,54553,57300,60162,59903,61118,61473,60077,59219,62280,65296,66053,66300,66635,61586,59193,57496,57107,57221,57238,58463,58047,57814,56558,57788,57628,57131,59272,61763,63898,64277,64734,63726,62327,58496,53074,47304,44838,45220,43382,41184,40138,37792,37082,36026,37188,36719,37075,35363,35882,34129,33861,33398,32331,30935,29336,29624,28530,21346,18893,17080,14510,12172,10385.62,8457.66,6793.03,5068.55,3728.37,2759.16,1881.82,1195.71,793.01,1101.05,
    51594,50183,50166,49522,48250,45947,45688,44906,45115,45874,48413,51954,56659,59086,61607,62779,63745,60236,58707,56078,54885,53656,51905,51416,52218,53103,54747,54002,52755,53818,55110,57826,60629,60402,61559,61856,60502,59613,62573,65594,66284,66506,66836,61852,59397,57644,57251,57346,57309,58490,58064,57802,56487,57748,57479,57064,59161,61592,63711,64040,64440,63399,62007,58149,52780,46913,44503,44884,42971,40795,39663,37297,36518,35447,36475,35997,36240,34453,34804,33013,32512,31960,30733,29193,27380,27356,26145,19338,16841,14878,12515,10260,8502.62,6823.66,5363.03,3814.55,2715.37,1978.16,1317.82,780.71,1159.06,
    52330,52289,50657,50530,49905,48602,46305,46055,45254,45491,46243,48787,52318,56951,59441,61920,63142,64114,60769,59335,56716,55506,54471,52961,52501,53236,54025,55542,54729,53376,54435,55751,58372,61178,60879,62024,62285,60876,59944,62856,65822,66509,66737,67013,62016,59570,57789,57356,57450,57389,58480,58108,57795,56437,57687,57426,56949,59062,61418,63483,63770,64182,63097,61671,57793,52357,46490,44136,44458,42548,40310,39174,36747,35904,34836,35716,35157,35258,33415,33603,31745,31060,30362,28949,27373,25273,25044,23550,17185,14627,12804,10549,8471,6743.62,5312.66,4073.03,2785.55,1921.37,1340.16,892.82,1194.77,
    53136,53001,52823,51118,50917,50307,48980,46707,46412,45652,45870,46630,49159,52682,57340,59830,62322,63608,64637,61280,59884,57330,56537,55603,54175,53563,54214,54854,56477,55459,54151,55219,56382,59025,61836,61407,62605,62705,61296,60308,63172,66141,66792,66964,67187,62226,59772,57926,57509,57523,57437,58505,58083,57760,56377,57605,57294,56800,58924,61228,63248,63509,63902,62781,61285,57385,51966,46062,43746,43959,42081,39838,38634,36203,35276,34168,34922,34270,34241,32363,32369,30349,29589,28629,27110,25359,23076,22663,20942,15059,12502,10713,8630,6786,5319.62,4071.66,2979.03,1999.55,1316.37,889.16,1268.59,
    54400,53714,53495,53263,51524,51321,50719,49372,47097,46851,46035,46236,47085,49578,53114,57765,60344,62833,64254,65326,61986,60734,58389,57893,56946,55401,54699,55273,55608,57498,56329,54956,55964,57034,59643,62425,61895,63045,63138,61754,60716,63555,66507,67075,67277,67405,62377,59926,58047,57615,57615,57494,58528,58044,57709,56310,57520,57182,56643,58703,61033,63058,63248,63555,62421,60871,56974,51573,45647,43352,43442,41589,39269,38000,35574,34583,33445,34095,33353,33167,31136,31067,28931,28035,26860,25142,23282,20938,20246,18404,12968,10632,8920,6971,5270,4092.62,3051.66,2157.03,1383.55,857.37,1355.75,
    56414,55057,54111,53710,53565,51764,51557,50945,49578,47365,47101,46349,46500,47367,49864,53413,58130,60745,63385,64758,65878,62648,61738,59627,59124,58057,56485,55645,56155,56357,58206,56937,55490,56357,57487,60080,62798,62199,63368,63453,62050,60897,63813,66689,67190,67397,67557,62465,60005,58090,57631,57612,57454,58476,57972,57660,56220,57412,56996,56454,58446,60780,62781,62921,63123,61967,60397,56525,51075,45165,42854,42918,41063,38634,37313,34872,33836,32609,33130,32286,32002,29881,29589,27367,26313,25002,23136,21131,18691,17807,15923,10914,8796,7211,5433,4032,3062.62,2234.66,1533.03,950.55,1376.12,
    54755,57043,55477,54473,53996,53828,52021,51811,51183,49846,47615,47407,46598,46818,47621,50230,53825,58532,61214,63807,65190,66300,63330,62588,60565,59907,58875,57169,56368,56895,56991,58784,57484,55943,56869,57914,60492,63203,62579,63647,63717,62323,61184,64029,66867,67383,67526,67616,62534,60118,58097,57662,57601,57444,58402,57909,57518,56121,57257,56852,56247,58247,60513,62452,62570,62719,61545,59921,56063,50564,44680,42315,42312,40446,37969,36612,34102,33054,31753,32099,31144,30710,28438,27989,25750,24510,22974,21035,18873,16481,15385,13528,9059,7083,5705,4153,2987,2251.62,1551.66,1040.03,1449.67,
    55178,55393,57511,55905,54873,54410,54185,52405,52131,51555,50220,48075,47861,46960,47201,47980,50709,54332,59099,61717,64395,65817,67221,64449,63697,61637,60870,59677,57906,57116,57677,57596,59375,58088,56514,57317,58371,60851,63619,62929,63972,64001,62574,61425,64225,67024,67516,67631,67668,62612,60116,58125,57685,57580,57402,58337,57850,57396,56007,57121,56664,56019,58024,60160,62107,62141,62244,61071,59386,55433,50055,44120,41765,41605,39775,37239,35795,33279,32109,30789,30927,29872,29328,26904,26294,23926,22497,20873,18772,16548,14163,13075,11206,7316,5476,4329,3058,2128,1547.62,1040.66,1513.7,
    55359,55884,55839,58024,56419,55491,55037,54800,53099,52791,52180,50890,48649,48492,47590,47892,48753,51433,55043,59713,62395,65043,66677,68255,65582,64809,62631,61849,60426,58779,57818,58314,58205,60080,58617,57076,57808,58812,61303,64028,63266,64348,64301,62909,61686,64499,67194,67673,67767,67787,62710,60144,58159,57698,57520,57362,58251,57754,57287,55851,56948,56463,55800,57736,59809,61696,61651,61772,60511,58815,54841,49460,43600,41126,40923,39037,36458,34926,32359,31152,29662,29645,28518,27813,25292,24509,22089,20495,18789,16511,14348,12010,10792,9141,5818,4247,3215,2206,1459,1023.62,1570.37,
    56296,56083,56582,56429,58583,57024,56106,55641,55404,53684,53364,52753,51450,49199,49078,48184,48627,49442,52155,55773,60532,63057,65991,67789,69577,66754,65984,63617,62807,61355,59655,58615,59039,58930,60779,59182,57655,58375,59288,61759,64433,63611,64725,64606,63174,61929,64715,67340,67767,67910,67926,62789,60156,58213,57682,57503,57346,58147,57649,57107,55667,56743,56217,55543,57420,59441,61215,61133,61237,59923,58208,54188,48852,42977,40451,40182,38288,35612,34030,31428,30146,28580,28325,27109,26168,23617,22594,20184,18472,16686,14442,12285,10032,8794,7257,4503,3214,2324,1544,980,1611.98,
    55884,57292,56834,57297,57127,59253,57748,56851,56272,56038,54402,53989,53410,52088,49783,49781,48995,49443,50346,52885,56630,61405,64097,67142,68976,70649,67776,66894,64532,63579,62224,60279,59298,59740,59524,61427,59759,58154,58845,59722,62161,64873,64000,65084,64958,63449,62199,64912,67560,67902,68054,67992,62839,60211,58199,57680,57448,57264,58030,57481,56940,55469,56481,55919,55248,57082,58999,60737,60604,60634,59271,57521,53430,48179,42271,39688,39364,37380,34674,33077,30374,28936,27332,26833,25534,24417,21864,20615,18264,16377,14540,12354,10194,8154,6968,5614,3371,2320,1619,1057,1567,
    58018,57216,58348,57775,58292,58092,60258,58604,57759,57139,56862,55212,54752,54149,52856,50526,50694,49977,50542,51298,54032,57679,62872,65697,68878,70528,72240,69341,68358,66003,64938,63471,61455,60386,60605,60418,62364,60532,58908,59506,60254,62680,65474,64495,65508,65359,63848,62537,65200,67775,68104,68254,68150,62962,60348,58257,57719,57402,57272,57956,57313,56770,55296,56247,55634,54935,56687,58548,60230,60092,60001,58592,56713,52612,47420,41544,38911,38487,36460,33616,31957,29228,27678,25973,25277,23865,22556,19992,18542,16313,14219,12323,10351,8322,6439,5422,4189,2455,1602,1128,1644.99,
    56715,59444,58123,59233,58684,59279,58916,61077,59410,58612,57936,57688,55943,55436,54893,53557,51353,51508,51083,51275,52151,54920,58872,64263,67178,70320,72030,73732,70759,69794,67193,66138,64686,62531,61410,61495,61178,63145,61249,59582,60163,60791,63208,65995,64867,65858,65698,64129,62766,65367,67947,68266,68353,68215,62984,60368,58228,57689,57304,57120,57803,57102,56556,55026,55930,55289,54520,56251,58049,59699,59444,59301,57810,55893,51746,46580,40689,38033,37459,35393,32489,30728,27919,26285,24448,23638,22099,20605,17943,16417,14223,12142,10357,8446,6572,4939,4072,3038,1688,1042,1726,
    56807,57789,60164,58792,59910,59388,60056,59582,61763,60150,59409,58669,58337,56602,56096,55462,54240,51997,52341,51671,51958,52827,55923,60187,65530,68439,71550,73283,75086,72016,71014,68303,67238,65650,63481,62250,62345,61856,63801,61855,60119,60699,61239,63585,66279,65186,66180,65942,64364,62977,65531,68095,68376,68451,68209,63010,60297,58148,57577,57201,56939,57580,56860,56282,54708,55570,54916,54101,55730,57471,59046,58745,58481,56937,54968,50787,45668,39805,37004,36418,34250,31285,29393,26572,24821,22866,21880,20265,18589,15922,14245,12196,10206,8427,6796,5065,3691,2972,2115,1139,1697.99)

# Vector of age-specific fertility rates
asfr <- c(0.000415,0.00209,0.004145,0.010155,0.017665,0.027095,0.038225,0.046765,0.0582,0.07097,0.083335,0.09792,0.10819,0.11661,0.117465,0.11389,0.10584,0.095805,0.081925,0.07266,0.06205,0.05031,0.0402,0.029295,0.023435,0.015425,0.010325,0.006225,0.00378,0.001845,0.00083,0.00046,0.00005,0.000085,0.00003,
          0.00052,0.001915,0.005605,0.009435,0.01871,0.02803,0.03896,0.04524,0.057105,0.070205,0.084105,0.1004,0.10972,0.12058,0.121825,0.11956,0.109495,0.099345,0.090625,0.075065,0.064575,0.05104,0.0413,0.03231,0.02354,0.01639,0.009985,0.00634,0.004215,0.001875,0.00091,0.00048,0.00014,0.00012,0.000065,
          0.000685,0.00211,0.00459,0.009075,0.0181,0.026515,0.036495,0.04599,0.058185,0.070745,0.082965,0.097255,0.10583,0.116975,0.12034,0.121645,0.118705,0.105155,0.0935,0.078975,0.069225,0.055105,0.04294,0.032315,0.024895,0.01653,0.012175,0.007115,0.003845,0.002,0.00081,0.000385,0.000135,0.0001,0.00007,
          0.000395,0.002155,0.00538,0.01025,0.01744,0.02757,0.03798,0.047435,0.059845,0.070295,0.085905,0.097875,0.113365,0.12143,0.12913,0.13287,0.126885,0.11332,0.098785,0.08711,0.070315,0.05895,0.044535,0.034625,0.026315,0.018275,0.012505,0.007335,0.00418,0.002295,0.000985,0.000415,0.000175,0.000105,0.000035,
          0.00056,0.001925,0.00536,0.00899,0.01594,0.02764,0.0387,0.048325,0.05559,0.069995,0.085535,0.09787,0.11428,0.126135,0.135655,0.13816,0.132265,0.12517,0.106395,0.09231,0.07695,0.06148,0.05132,0.037605,0.0289,0.019855,0.013335,0.007535,0.00457,0.002155,0.00108,0.00065,0.00012,0.000105,0.000035,
          0.000515,0.00204,0.00449,0.008325,0.01641,0.027835,0.03772,0.046995,0.054845,0.071795,0.08601,0.09841,0.11213,0.129055,0.137675,0.138955,0.136445,0.128615,0.11401,0.09782,0.0793,0.06689,0.051755,0.04049,0.030265,0.02152,0.014165,0.00863,0.00531,0.00286,0.0009,0.000485,0.00024,0.00005,0.000035,
          0.00061,0.001715,0.004275,0.00819,0.017095,0.02619,0.03677,0.047475,0.05763,0.069865,0.081945,0.09929,0.110015,0.13017,0.13437,0.14298,0.13867,0.13124,0.114545,0.10012,0.0854,0.07069,0.05289,0.04139,0.0313,0.021265,0.01365,0.009055,0.005025,0.0026,0.001515,0.000605,0.00019,0.00014,0.00005,
          0.00043,0.001745,0.00483,0.00803,0.017205,0.026975,0.03812,0.0498,0.05848,0.0711,0.085385,0.099465,0.116595,0.132605,0.141035,0.145675,0.14637,0.13643,0.1226,0.109555,0.09091,0.07415,0.05954,0.044,0.03277,0.023015,0.015135,0.009085,0.00577,0.00288,0.000945,0.000925,0.000365,0.00016,0.000035,
          0.00058,0.00181,0.00414,0.007795,0.0171,0.02706,0.040175,0.0497,0.06138,0.0754,0.0849,0.101365,0.113765,0.12703,0.14095,0.145175,0.1454,0.13895,0.125435,0.109375,0.0931,0.07791,0.060535,0.046815,0.03495,0.02434,0.01647,0.010475,0.006015,0.003015,0.00146,0.000735,0.000505,0.000145,0.000085,
          0.0005,0.00131,0.00409,0.007815,0.016955,0.02869,0.041145,0.05194,0.062625,0.07733,0.089215,0.09915,0.114505,0.13087,0.14321,0.1474,0.14718,0.13722,0.125395,0.110985,0.09451,0.078285,0.060645,0.049175,0.036805,0.024725,0.01707,0.01021,0.00565,0.002975,0.001535,0.000875,0.000295,0.00017,0.00007,
          0.00059,0.00142,0.004095,0.007065,0.01605,0.028775,0.038975,0.05168,0.062965,0.07423,0.08839,0.102815,0.11722,0.128075,0.140695,0.14827,0.147145,0.139575,0.124925,0.115005,0.10046,0.07994,0.065455,0.05039,0.036865,0.02644,0.018245,0.01033,0.006675,0.003285,0.0018,0.00082,0.0003,0.000275,0.000155,
          0.000415,0.001565,0.00368,0.007465,0.015375,0.027185,0.039185,0.05004,0.06393,0.078245,0.091495,0.10549,0.119415,0.132825,0.14508,0.146535,0.152615,0.14506,0.129695,0.116805,0.100135,0.08581,0.06692,0.0517,0.04117,0.027675,0.01863,0.01183,0.006305,0.00375,0.00199,0.00091,0.000435,0.000115,0.000185,
          0.00039,0.00167,0.003365,0.00721,0.015025,0.02415,0.03536,0.0473,0.05979,0.07669,0.08609,0.099455,0.11409,0.127615,0.135055,0.139255,0.142215,0.13442,0.12758,0.11536,0.095805,0.084415,0.06851,0.050215,0.03904,0.028855,0.01871,0.011115,0.00661,0.00322,0.001785,0.000885,0.00032,0.00016,0.00017,
          0.00037,0.00139,0.00349,0.00648,0.013235,0.022885,0.03429,0.04627,0.06062,0.0747,0.08875,0.102265,0.113975,0.126025,0.133335,0.14266,0.145635,0.135565,0.125785,0.11608,0.099185,0.082475,0.064515,0.053475,0.03974,0.028015,0.01857,0.012445,0.006835,0.003715,0.00195,0.001035,0.000495,0.000385,0.000245,
          0.00055,0.00141,0.003325,0.0063,0.013195,0.02156,0.03351,0.044095,0.057585,0.07177,0.08555,0.10087,0.11176,0.12691,0.133945,0.14199,0.14091,0.140015,0.126205,0.11514,0.096115,0.082895,0.06829,0.05249,0.04038,0.0289,0.018745,0.0116,0.006765,0.00338,0.00179,0.000925,0.00052,0.000375,0.00023,
          0.00046,0.001105,0.00294,0.006765,0.01239,0.019805,0.029245,0.04243,0.056205,0.071675,0.086795,0.104835,0.113775,0.126065,0.136305,0.140305,0.139335,0.134685,0.12758,0.11418,0.0979,0.080865,0.066865,0.052935,0.04007,0.030485,0.01916,0.01159,0.0076,0.003765,0.00198,0.00097,0.0007,0.000265,0.000115,
          0.000295,0.00114,0.003045,0.0056,0.0115,0.02006,0.028345,0.042025,0.053665,0.0689,0.088195,0.102155,0.11291,0.126765,0.13238,0.139095,0.137405,0.13127,0.119895,0.11279,0.097485,0.08156,0.06475,0.05382,0.03895,0.029045,0.018885,0.01236,0.006625,0.003655,0.002055,0.00118,0.00053,0.000275,0.000295,
          0.0005,0.001235,0.002775,0.005245,0.01218,0.019915,0.029575,0.038195,0.052965,0.06899,0.084725,0.101895,0.11375,0.126235,0.135615,0.13995,0.13603,0.130845,0.119245,0.11024,0.09851,0.083725,0.067125,0.053155,0.041975,0.03034,0.020565,0.0128,0.0077,0.00427,0.00218,0.00107,0.000655,0.000375,0.000175,
          0.00033,0.00123,0.002695,0.00597,0.01165,0.01963,0.03009,0.03768,0.048195,0.063535,0.078305,0.09598,0.107535,0.119215,0.129095,0.131615,0.133445,0.128725,0.120115,0.10175,0.09485,0.081035,0.06597,0.05288,0.040885,0.030075,0.020595,0.01365,0.0073,0.00487,0.00216,0.001375,0.0006,0.000285,0.000465,
          0.00026,0.00117,0.00229,0.00592,0.011875,0.01965,0.027745,0.039155,0.04793,0.061335,0.0765,0.0926,0.10439,0.120235,0.12707,0.13096,0.13116,0.12526,0.116655,0.10556,0.092845,0.07854,0.063975,0.05414,0.04103,0.02982,0.0198,0.01193,0.00737,0.003905,0.002225,0.00128,0.000515,0.000455,0.0002)

# Vector of survival rates for males
sr_m <- c(0.9966,0.9993,0.9998,0.9999,0.9999,0.9999,0.9999,0.9998,0.9999,0.9999,0.9999,0.9998,0.9998,0.9998,0.9998,0.9998,0.9998,0.9997,0.9996,0.9995,0.9994,0.9993,0.9993,0.9994,0.9994,0.9993,0.9993,0.9994,0.9993,0.9992,0.9993,0.9993,0.9993,0.9993,0.9992,0.9991,0.999,0.9989,0.9989,0.9987,0.9986,0.9985,0.9983,0.9981,0.9982,0.998,0.9979,0.9978,0.9973,0.9969,0.9967,0.9965,0.9963,0.9957,0.9951,0.9945,0.9941,0.9938,0.9931,0.9922,0.9913,0.9908,0.99,0.9882,0.9866,0.9856,0.9844,0.9823,0.9796,0.9775,0.9755,0.9718,0.9685,0.9664,0.9631,0.958,0.9541,0.9495,0.9423,0.9358,0.929,0.9193,0.9094,0.9001,0.8908,0.8804,0.8633,0.849,0.8363,0.8167,0.7994,0.7831,0.7606,0.74,0.7174,0.6948,0.6811,0.6598,0.6388,0.6174,0.7246,
          0.9965,0.9993,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9997,0.9995,0.9993,0.9992,0.9992,0.9992,0.9992,0.9993,0.9993,0.9991,0.9993,0.9993,0.9993,0.9993,0.9993,0.9992,0.9992,0.9992,0.9991,0.9991,0.9991,0.9989,0.9989,0.9989,0.9987,0.9987,0.9986,0.9981,0.9979,0.9979,0.9977,0.9971,0.9968,0.997,0.9966,0.996,0.9959,0.9954,0.995,0.9946,0.9941,0.9934,0.9925,0.9918,0.9907,0.9896,0.9891,0.9875,0.9857,0.9845,0.983,0.9812,0.9785,0.9757,0.9736,0.9701,0.9668,0.9641,0.9599,0.9556,0.95,0.9447,0.9384,0.9315,0.925,0.9143,0.9031,0.8924,0.8799,0.8653,0.8488,0.8359,0.8257,0.8106,0.7911,0.7647,0.7396,0.7218,0.6989,0.6796,0.6577,0.6363,0.6142,0.5535,
          0.9966,0.9993,0.9998,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9997,0.9996,0.9995,0.9992,0.9991,0.9991,0.9992,0.9993,0.9993,0.9993,0.9993,0.9993,0.9994,0.9994,0.9993,0.9993,0.9992,0.9991,0.9992,0.9991,0.999,0.9989,0.9987,0.9986,0.9986,0.9985,0.9984,0.9982,0.9981,0.9978,0.9973,0.9971,0.9971,0.9969,0.9967,0.9965,0.9958,0.9953,0.9951,0.9945,0.9937,0.9929,0.9926,0.9923,0.9906,0.99,0.9892,0.9874,0.9864,0.9848,0.983,0.981,0.979,0.9775,0.9747,0.9715,0.969,0.9653,0.9612,0.9565,0.9513,0.9466,0.9398,0.932,0.924,0.9177,0.9076,0.8949,0.8828,0.8699,0.8589,0.8413,0.8234,0.8063,0.782,0.7602,0.7399,0.7241,0.7089,0.679,0.6563,0.6344,0.6134,0.5604,
          0.9969,0.9993,0.9996,0.9997,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9997,0.9996,0.9994,0.9993,0.9993,0.9992,0.999,0.9992,0.9993,0.9993,0.9993,0.9994,0.9995,0.9994,0.9992,0.9992,0.9993,0.9993,0.9993,0.9992,0.9991,0.9991,0.9989,0.9987,0.9987,0.9985,0.9984,0.9983,0.9981,0.998,0.9978,0.9976,0.9976,0.9971,0.9966,0.9962,0.996,0.9956,0.995,0.9947,0.9943,0.9931,0.9923,0.9916,0.991,0.9906,0.9893,0.9879,0.987,0.9851,0.9833,0.9817,0.9789,0.9767,0.9754,0.9719,0.9679,0.9651,0.9612,0.9577,0.9521,0.9454,0.94,0.9328,0.9256,0.9161,0.9066,0.8969,0.8831,0.87,0.8527,0.8364,0.8206,0.8016,0.7879,0.7665,0.7305,0.7086,0.7018,0.6734,0.6506,0.628,0.6056,0.587,
          0.9969,0.9993,0.9997,0.9997,0.9998,0.9999,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9996,0.9994,0.9993,0.9993,0.9993,0.9993,0.9993,0.9992,0.9994,0.9995,0.9994,0.9994,0.9994,0.9995,0.9995,0.9994,0.9992,0.9991,0.9992,0.9992,0.999,0.9989,0.9988,0.9987,0.9986,0.9985,0.9981,0.9981,0.998,0.9976,0.9974,0.9972,0.9969,0.9968,0.9966,0.9962,0.9955,0.995,0.9945,0.994,0.9938,0.9933,0.9924,0.9914,0.9902,0.9893,0.9885,0.9866,0.9846,0.9837,0.9819,0.9799,0.9778,0.9739,0.9718,0.9695,0.9655,0.9622,0.958,0.9527,0.9476,0.9424,0.9355,0.9248,0.9156,0.9069,0.8979,0.8869,0.8705,0.8563,0.8412,0.8249,0.8104,0.7927,0.7748,0.7577,0.7306,0.7084,0.6884,0.6664,0.6454,0.6234,0.5009,
          0.9972,0.9994,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9997,0.9995,0.9994,0.9992,0.9991,0.9992,0.9993,0.9992,0.9992,0.9993,0.9994,0.9993,0.9993,0.9994,0.9994,0.9993,0.9994,0.9993,0.9992,0.9993,0.9991,0.9991,0.9991,0.9989,0.9989,0.9989,0.9986,0.9983,0.9981,0.998,0.9979,0.9977,0.9972,0.9966,0.9965,0.9965,0.9963,0.9957,0.9953,0.9947,0.994,0.9936,0.9932,0.9925,0.9917,0.991,0.9903,0.9886,0.9869,0.9858,0.9843,0.9825,0.9805,0.9785,0.9756,0.9725,0.9705,0.9681,0.9653,0.9608,0.9554,0.9514,0.946,0.9386,0.9299,0.9223,0.9144,0.9018,0.8894,0.8776,0.8645,0.8453,0.8273,0.8171,0.8011,0.7761,0.749,0.7403,0.7271,0.6924,0.6703,0.6479,0.6255,0.5403,
          0.9979,0.9994,0.9997,0.9998,0.9998,0.9999,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9998,0.9997,0.9996,0.9995,0.9994,0.9993,0.9993,0.9993,0.9994,0.9993,0.9992,0.9993,0.9993,0.9992,0.9993,0.9994,0.9993,0.9994,0.9994,0.9992,0.9992,0.9993,0.9993,0.999,0.9989,0.9989,0.9986,0.9985,0.9984,0.9983,0.9981,0.9979,0.9978,0.9974,0.9972,0.9972,0.9967,0.9958,0.9954,0.9953,0.9946,0.9943,0.9941,0.9933,0.9922,0.9917,0.9908,0.9897,0.989,0.9875,0.9851,0.9841,0.983,0.981,0.9792,0.9772,0.9748,0.9708,0.967,0.9638,0.96,0.9559,0.9513,0.9442,0.9363,0.9294,0.9214,0.9121,0.9011,0.8887,0.8762,0.8614,0.8452,0.8306,0.8111,0.7966,0.7811,0.7447,0.7124,0.6993,0.6873,0.665,0.6426,0.6206,0.6098,
          0.9974,0.9994,0.9998,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9996,0.9996,0.9995,0.9994,0.9994,0.9993,0.9992,0.9993,0.9994,0.9994,0.9994,0.9995,0.9994,0.9993,0.9995,0.9995,0.9993,0.9993,0.9994,0.9992,0.9991,0.9991,0.999,0.999,0.9989,0.9986,0.9986,0.9986,0.9984,0.9982,0.9979,0.9979,0.9978,0.9974,0.9969,0.9965,0.9959,0.9954,0.9953,0.9949,0.9943,0.994,0.9935,0.9926,0.9918,0.991,0.9902,0.9891,0.9872,0.9852,0.985,0.9844,0.9824,0.9797,0.9771,0.975,0.9725,0.9691,0.9658,0.9617,0.9568,0.9522,0.9466,0.9394,0.9306,0.9237,0.916,0.9036,0.8915,0.8787,0.8654,0.8498,0.8306,0.8147,0.7989,0.7774,0.7561,0.7387,0.7168,0.6941,0.672,0.6496,0.6273,0.5327,
          0.9977,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9997,0.9996,0.9993,0.9992,0.9993,0.9993,0.9994,0.9993,0.9992,0.9992,0.9992,0.9993,0.9993,0.9993,0.9994,0.9994,0.9994,0.9993,0.9993,0.9993,0.9992,0.9992,0.9991,0.9989,0.9989,0.9988,0.9986,0.9985,0.9983,0.998,0.998,0.9979,0.9976,0.9971,0.9967,0.9963,0.9962,0.9961,0.9957,0.9952,0.9947,0.994,0.9933,0.993,0.9922,0.991,0.99,0.9888,0.9874,0.9866,0.9854,0.9839,0.9827,0.9807,0.9788,0.9765,0.9734,0.9711,0.9675,0.9634,0.9591,0.9524,0.9475,0.9414,0.9329,0.9248,0.916,0.9056,0.8949,0.8821,0.8679,0.8541,0.8379,0.8184,0.7978,0.7775,0.7522,0.7237,0.7016,0.6906,0.6677,0.6448,0.6226,0.5853,
          0.9979,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9996,0.9995,0.9994,0.9993,0.9993,0.9993,0.9992,0.9993,0.9993,0.9993,0.9992,0.9993,0.9992,0.9992,0.9992,0.9993,0.9993,0.9993,0.9992,0.9992,0.9992,0.9992,0.9991,0.999,0.9988,0.9986,0.9985,0.9984,0.9982,0.9982,0.9981,0.9977,0.9973,0.9968,0.9967,0.9963,0.9957,0.9958,0.9955,0.9947,0.9939,0.9935,0.993,0.9923,0.9914,0.9903,0.9891,0.9879,0.9872,0.9862,0.9843,0.982,0.9807,0.9791,0.9766,0.9743,0.9704,0.9665,0.9646,0.9606,0.954,0.9489,0.9427,0.9326,0.9246,0.9172,0.9075,0.8967,0.8833,0.8673,0.8531,0.8359,0.817,0.8054,0.784,0.7543,0.7308,0.7135,0.6957,0.6731,0.6503,0.6278,0.5519,
          0.9978,0.9994,0.9997,0.9997,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9998,0.9997,0.9997,0.9996,0.9994,0.9994,0.9994,0.9994,0.9992,0.9993,0.9994,0.9993,0.9994,0.9993,0.9992,0.9993,0.9993,0.9993,0.9993,0.9992,0.9991,0.9992,0.9991,0.9991,0.9992,0.9991,0.999,0.9986,0.9984,0.9984,0.9983,0.9981,0.998,0.9977,0.9972,0.997,0.9968,0.9964,0.996,0.9958,0.9955,0.9946,0.994,0.9936,0.9934,0.9926,0.9914,0.9908,0.9901,0.9885,0.9874,0.9868,0.9857,0.9835,0.9818,0.9801,0.9777,0.9748,0.9712,0.968,0.9642,0.9599,0.9554,0.9506,0.9432,0.935,0.9293,0.9207,0.9097,0.8971,0.8852,0.8716,0.854,0.8404,0.8243,0.803,0.7838,0.7586,0.728,0.7077,0.693,0.6698,0.6468,0.6233,0.5746,
          0.9977,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9996,0.9995,0.9995,0.9994,0.9993,0.9993,0.9993,0.9992,0.9994,0.9994,0.9993,0.9992,0.9993,0.9993,0.9992,0.9993,0.9994,0.9994,0.9993,0.9994,0.9994,0.9992,0.999,0.9989,0.9989,0.9987,0.9988,0.9988,0.9984,0.9981,0.9978,0.9976,0.9974,0.9972,0.997,0.9966,0.9961,0.9957,0.9953,0.9949,0.9946,0.9938,0.993,0.9925,0.9918,0.9909,0.9895,0.9883,0.9876,0.9864,0.9857,0.9839,0.9812,0.9796,0.9779,0.9757,0.973,0.9686,0.9652,0.961,0.954,0.949,0.9435,0.9366,0.9294,0.9196,0.9108,0.9006,0.887,0.8732,0.8575,0.8421,0.8245,0.8028,0.7852,0.7671,0.741,0.7179,0.6987,0.6757,0.6526,0.6298,0.55,
          0.9981,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9996,0.9995,0.9995,0.9994,0.9993,0.9993,0.9993,0.9993,0.9994,0.9993,0.9993,0.9993,0.9994,0.9992,0.9993,0.9994,0.9993,0.9993,0.9993,0.9993,0.9993,0.9992,0.9991,0.9991,0.9991,0.9989,0.9986,0.9985,0.9985,0.9982,0.9979,0.9976,0.9974,0.9972,0.9972,0.9969,0.9964,0.9959,0.9952,0.9952,0.9947,0.9934,0.9931,0.9928,0.9922,0.9915,0.9904,0.989,0.9876,0.9867,0.9852,0.9834,0.9819,0.9804,0.9788,0.9763,0.9734,0.9707,0.9659,0.9608,0.9562,0.9509,0.9461,0.9416,0.9336,0.9209,0.9098,0.9,0.8881,0.8748,0.8621,0.8474,0.8282,0.8065,0.7817,0.763,0.7445,0.7198,0.6988,0.6753,0.6519,0.6284,0.5699,
          0.9975,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9997,0.9997,0.9996,0.9995,0.9993,0.9993,0.9993,0.9993,0.9992,0.9992,0.9993,0.9993,0.9994,0.9994,0.9994,0.9993,0.9993,0.9993,0.9994,0.9994,0.9992,0.9991,0.999,0.999,0.9991,0.999,0.9988,0.9986,0.9985,0.9983,0.9981,0.9978,0.9977,0.9976,0.9972,0.9967,0.9962,0.9958,0.9954,0.9952,0.995,0.9944,0.9936,0.9927,0.992,0.9915,0.9907,0.9897,0.9881,0.987,0.9865,0.9849,0.9826,0.9814,0.9796,0.976,0.9724,0.9698,0.9668,0.9622,0.9571,0.9525,0.9464,0.9377,0.93,0.9225,0.9122,0.9007,0.8877,0.8723,0.8573,0.8414,0.8204,0.8008,0.7855,0.7631,0.7423,0.7212,0.6924,0.6687,0.6449,0.6221,0.5931,
          0.9976,0.9995,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9999,0.9999,0.9998,0.9997,0.9995,0.9994,0.9994,0.9994,0.9994,0.9993,0.9993,0.9993,0.9992,0.9992,0.9992,0.9992,0.9992,0.9992,0.9993,0.9994,0.9994,0.9992,0.999,0.9991,0.9992,0.9992,0.999,0.999,0.999,0.9988,0.9986,0.9984,0.9983,0.9983,0.998,0.9975,0.9974,0.9974,0.9967,0.9962,0.9961,0.996,0.9956,0.995,0.9945,0.9937,0.9925,0.9919,0.9913,0.9904,0.9897,0.9885,0.9873,0.9861,0.9846,0.9831,0.9812,0.9794,0.9775,0.9742,0.9706,0.9669,0.9635,0.9607,0.9554,0.9482,0.9416,0.9347,0.9267,0.9148,0.9034,0.894,0.8806,0.8662,0.8452,0.8279,0.8102,0.7831,0.7623,0.7356,0.7147,0.6972,0.6729,0.649,0.6247,0.5506,
          0.9978,0.9995,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9997,0.9996,0.9994,0.9993,0.9994,0.9993,0.9993,0.9993,0.9993,0.9994,0.9993,0.9993,0.9992,0.9992,0.9992,0.9991,0.9991,0.9992,0.9993,0.9992,0.9993,0.9993,0.9992,0.9991,0.9989,0.9988,0.9987,0.9987,0.9986,0.9984,0.998,0.9978,0.9976,0.9972,0.9973,0.9972,0.9969,0.9965,0.996,0.9954,0.995,0.9946,0.9939,0.9929,0.9921,0.9914,0.9909,0.9904,0.9891,0.9874,0.9861,0.9848,0.9831,0.9815,0.9801,0.9787,0.9751,0.9712,0.9683,0.9641,0.9599,0.9562,0.9503,0.9433,0.9355,0.9263,0.9181,0.9065,0.8934,0.8813,0.8702,0.8525,0.8296,0.8156,0.7995,0.7766,0.7577,0.7371,0.7097,0.6864,0.6629,0.6394,0.5187,
          0.9976,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9995,0.9994,0.9994,0.9994,0.9994,0.9993,0.9991,0.9991,0.9992,0.9992,0.9993,0.9993,0.9994,0.9994,0.9992,0.9992,0.9992,0.9991,0.9991,0.9992,0.9993,0.9991,0.999,0.9989,0.9989,0.9989,0.9988,0.9988,0.9985,0.9982,0.9981,0.9978,0.9977,0.9973,0.9967,0.9964,0.9961,0.9958,0.9954,0.9948,0.9944,0.9939,0.9934,0.9928,0.9917,0.9908,0.9898,0.9885,0.9875,0.9868,0.9856,0.984,0.9813,0.9792,0.9781,0.9749,0.9713,0.9693,0.9664,0.9605,0.9552,0.949,0.9427,0.9372,0.9288,0.9191,0.9054,0.8918,0.8799,0.8657,0.8477,0.8314,0.814,0.7884,0.767,0.7501,0.7284,0.7013,0.6772,0.6533,0.6287,0.6158,
          0.9978,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9996,0.9996,0.9995,0.9995,0.9994,0.9995,0.9993,0.9992,0.9993,0.9993,0.9994,0.9993,0.9992,0.9991,0.9992,0.9992,0.9992,0.9992,0.9992,0.9992,0.999,0.9991,0.9991,0.9988,0.9988,0.9988,0.9988,0.9986,0.9984,0.9983,0.9979,0.9978,0.9977,0.9976,0.9974,0.9967,0.9962,0.9959,0.9958,0.9955,0.9949,0.9941,0.993,0.992,0.9918,0.991,0.99,0.9888,0.9874,0.9866,0.9855,0.9839,0.9821,0.9802,0.9775,0.9757,0.9738,0.9693,0.9656,0.9612,0.9563,0.9508,0.9438,0.9375,0.9309,0.9202,0.9081,0.8966,0.8827,0.8714,0.8598,0.8396,0.8147,0.7931,0.772,0.7499,0.7294,0.7059,0.6818,0.6574,0.6333,0.554,
          0.9979,0.9996,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9999,0.9998,0.9996,0.9995,0.9995,0.9995,0.9994,0.9993,0.9993,0.9992,0.9993,0.9993,0.9991,0.9992,0.9992,0.9993,0.9993,0.9992,0.9993,0.9994,0.9991,0.9991,0.9992,0.9991,0.9989,0.9989,0.999,0.9989,0.9988,0.9987,0.9986,0.9986,0.9985,0.9981,0.998,0.9979,0.9974,0.9972,0.997,0.9965,0.9961,0.9956,0.9955,0.9953,0.9946,0.994,0.9932,0.9917,0.9903,0.9901,0.9895,0.9883,0.9877,0.9857,0.9834,0.9828,0.9815,0.979,0.9768,0.9747,0.9716,0.9667,0.9611,0.9571,0.9539,0.9471,0.9387,0.9296,0.9189,0.9088,0.8982,0.8842,0.8669,0.847,0.8249,0.8068,0.7907,0.7732,0.7507,0.7199,0.6941,0.6689,0.6435,0.6187,0.6097,
          0.9981,0.9996,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9999,0.9997,0.9996,0.9996,0.9996,0.9994,0.9993,0.9994,0.9993,0.9993,0.9994,0.9993,0.9992,0.9993,0.9993,0.9994,0.9994,0.9993,0.9992,0.9991,0.9992,0.9992,0.9992,0.9992,0.999,0.999,0.999,0.999,0.9988,0.9988,0.9987,0.9985,0.9985,0.9983,0.9979,0.9978,0.9975,0.997,0.9969,0.9968,0.9964,0.996,0.9956,0.9949,0.9941,0.9935,0.9928,0.9921,0.9912,0.99,0.9888,0.9877,0.9867,0.9856,0.9839,0.9826,0.9807,0.9793,0.9773,0.9739,0.9704,0.9663,0.9632,0.9589,0.953,0.9456,0.9376,0.9295,0.9208,0.9115,0.8987,0.8831,0.8685,0.8532,0.8322,0.8139,0.7997,0.7768,0.7487,0.7253,0.7054,0.681,0.6567,0.6329,0.5357)

# Vector of survival rates for females
sr_f <- c(0.9966,0.9993,0.9998,0.9999,0.9999,0.9999,0.9999,0.9998,0.9999,0.9999,0.9999,0.9998,0.9998,0.9998,0.9998,0.9998,0.9998,0.9997,0.9996,0.9995,0.9994,0.9993,0.9993,0.9994,0.9994,0.9993,0.9993,0.9994,0.9993,0.9992,0.9993,0.9993,0.9993,0.9993,0.9992,0.9991,0.999,0.9989,0.9989,0.9987,0.9986,0.9985,0.9983,0.9981,0.9982,0.998,0.9979,0.9978,0.9973,0.9969,0.9967,0.9965,0.9963,0.9957,0.9951,0.9945,0.9941,0.9938,0.9931,0.9922,0.9913,0.9908,0.99,0.9882,0.9866,0.9856,0.9844,0.9823,0.9796,0.9775,0.9755,0.9718,0.9685,0.9664,0.9631,0.958,0.9541,0.9495,0.9423,0.9358,0.929,0.9193,0.9094,0.9001,0.8908,0.8804,0.8633,0.849,0.8363,0.8167,0.7994,0.7831,0.7606,0.74,0.7174,0.6948,0.6811,0.6598,0.6388,0.6174,0.5734,
          0.9965,0.9993,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9997,0.9995,0.9993,0.9992,0.9992,0.9992,0.9992,0.9993,0.9993,0.9991,0.9993,0.9993,0.9993,0.9993,0.9993,0.9992,0.9992,0.9992,0.9991,0.9991,0.9991,0.9989,0.9989,0.9989,0.9987,0.9987,0.9986,0.9981,0.9979,0.9979,0.9977,0.9971,0.9968,0.997,0.9966,0.996,0.9959,0.9954,0.995,0.9946,0.9941,0.9934,0.9925,0.9918,0.9907,0.9896,0.9891,0.9875,0.9857,0.9845,0.983,0.9812,0.9785,0.9757,0.9736,0.9701,0.9668,0.9641,0.9599,0.9556,0.95,0.9447,0.9384,0.9315,0.925,0.9143,0.9031,0.8924,0.8799,0.8653,0.8488,0.8359,0.8257,0.8106,0.7911,0.7647,0.7396,0.7218,0.6989,0.6796,0.6577,0.6363,0.6142,0.57,
          0.9966,0.9993,0.9998,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9997,0.9996,0.9995,0.9992,0.9991,0.9991,0.9992,0.9993,0.9993,0.9993,0.9993,0.9993,0.9994,0.9994,0.9993,0.9993,0.9992,0.9991,0.9992,0.9991,0.999,0.9989,0.9987,0.9986,0.9986,0.9985,0.9984,0.9982,0.9981,0.9978,0.9973,0.9971,0.9971,0.9969,0.9967,0.9965,0.9958,0.9953,0.9951,0.9945,0.9937,0.9929,0.9926,0.9923,0.9906,0.99,0.9892,0.9874,0.9864,0.9848,0.983,0.981,0.979,0.9775,0.9747,0.9715,0.969,0.9653,0.9612,0.9565,0.9513,0.9466,0.9398,0.932,0.924,0.9177,0.9076,0.8949,0.8828,0.8699,0.8589,0.8413,0.8234,0.8063,0.782,0.7602,0.7399,0.7241,0.7089,0.679,0.6563,0.6344,0.6134,0.5669,
          0.9969,0.9993,0.9996,0.9997,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9997,0.9996,0.9994,0.9993,0.9993,0.9992,0.999,0.9992,0.9993,0.9993,0.9993,0.9994,0.9995,0.9994,0.9992,0.9992,0.9993,0.9993,0.9993,0.9992,0.9991,0.9991,0.9989,0.9987,0.9987,0.9985,0.9984,0.9983,0.9981,0.998,0.9978,0.9976,0.9976,0.9971,0.9966,0.9962,0.996,0.9956,0.995,0.9947,0.9943,0.9931,0.9923,0.9916,0.991,0.9906,0.9893,0.9879,0.987,0.9851,0.9833,0.9817,0.9789,0.9767,0.9754,0.9719,0.9679,0.9651,0.9612,0.9577,0.9521,0.9454,0.94,0.9328,0.9256,0.9161,0.9066,0.8969,0.8831,0.87,0.8527,0.8364,0.8206,0.8016,0.7879,0.7665,0.7305,0.7086,0.7018,0.6734,0.6506,0.628,0.6056,0.5611,
          0.9969,0.9993,0.9997,0.9997,0.9998,0.9999,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9996,0.9994,0.9993,0.9993,0.9993,0.9993,0.9993,0.9992,0.9994,0.9995,0.9994,0.9994,0.9994,0.9995,0.9995,0.9994,0.9992,0.9991,0.9992,0.9992,0.999,0.9989,0.9988,0.9987,0.9986,0.9985,0.9981,0.9981,0.998,0.9976,0.9974,0.9972,0.9969,0.9968,0.9966,0.9962,0.9955,0.995,0.9945,0.994,0.9938,0.9933,0.9924,0.9914,0.9902,0.9893,0.9885,0.9866,0.9846,0.9837,0.9819,0.9799,0.9778,0.9739,0.9718,0.9695,0.9655,0.9622,0.958,0.9527,0.9476,0.9424,0.9355,0.9248,0.9156,0.9069,0.8979,0.8869,0.8705,0.8563,0.8412,0.8249,0.8104,0.7927,0.7748,0.7577,0.7306,0.7084,0.6884,0.6664,0.6454,0.6234,0.5784,
          0.9972,0.9994,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9997,0.9995,0.9994,0.9992,0.9991,0.9992,0.9993,0.9992,0.9992,0.9993,0.9994,0.9993,0.9993,0.9994,0.9994,0.9993,0.9994,0.9993,0.9992,0.9993,0.9991,0.9991,0.9991,0.9989,0.9989,0.9989,0.9986,0.9983,0.9981,0.998,0.9979,0.9977,0.9972,0.9966,0.9965,0.9965,0.9963,0.9957,0.9953,0.9947,0.994,0.9936,0.9932,0.9925,0.9917,0.991,0.9903,0.9886,0.9869,0.9858,0.9843,0.9825,0.9805,0.9785,0.9756,0.9725,0.9705,0.9681,0.9653,0.9608,0.9554,0.9514,0.946,0.9386,0.9299,0.9223,0.9144,0.9018,0.8894,0.8776,0.8645,0.8453,0.8273,0.8171,0.8011,0.7761,0.749,0.7403,0.7271,0.6924,0.6703,0.6479,0.6255,0.5791,
          0.9979,0.9994,0.9997,0.9998,0.9998,0.9999,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9998,0.9997,0.9996,0.9995,0.9994,0.9993,0.9993,0.9993,0.9994,0.9993,0.9992,0.9993,0.9993,0.9992,0.9993,0.9994,0.9993,0.9994,0.9994,0.9992,0.9992,0.9993,0.9993,0.999,0.9989,0.9989,0.9986,0.9985,0.9984,0.9983,0.9981,0.9979,0.9978,0.9974,0.9972,0.9972,0.9967,0.9958,0.9954,0.9953,0.9946,0.9943,0.9941,0.9933,0.9922,0.9917,0.9908,0.9897,0.989,0.9875,0.9851,0.9841,0.983,0.981,0.9792,0.9772,0.9748,0.9708,0.967,0.9638,0.96,0.9559,0.9513,0.9442,0.9363,0.9294,0.9214,0.9121,0.9011,0.8887,0.8762,0.8614,0.8452,0.8306,0.8111,0.7966,0.7811,0.7447,0.7124,0.6993,0.6873,0.665,0.6426,0.6206,0.5745,
          0.9974,0.9994,0.9998,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9996,0.9996,0.9995,0.9994,0.9994,0.9993,0.9992,0.9993,0.9994,0.9994,0.9994,0.9995,0.9994,0.9993,0.9995,0.9995,0.9993,0.9993,0.9994,0.9992,0.9991,0.9991,0.999,0.999,0.9989,0.9986,0.9986,0.9986,0.9984,0.9982,0.9979,0.9979,0.9978,0.9974,0.9969,0.9965,0.9959,0.9954,0.9953,0.9949,0.9943,0.994,0.9935,0.9926,0.9918,0.991,0.9902,0.9891,0.9872,0.9852,0.985,0.9844,0.9824,0.9797,0.9771,0.975,0.9725,0.9691,0.9658,0.9617,0.9568,0.9522,0.9466,0.9394,0.9306,0.9237,0.916,0.9036,0.8915,0.8787,0.8654,0.8498,0.8306,0.8147,0.7989,0.7774,0.7561,0.7387,0.7168,0.6941,0.672,0.6496,0.6273,0.5804,
          0.9977,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9997,0.9996,0.9993,0.9992,0.9993,0.9993,0.9994,0.9993,0.9992,0.9992,0.9992,0.9993,0.9993,0.9993,0.9994,0.9994,0.9994,0.9993,0.9993,0.9993,0.9992,0.9992,0.9991,0.9989,0.9989,0.9988,0.9986,0.9985,0.9983,0.998,0.998,0.9979,0.9976,0.9971,0.9967,0.9963,0.9962,0.9961,0.9957,0.9952,0.9947,0.994,0.9933,0.993,0.9922,0.991,0.99,0.9888,0.9874,0.9866,0.9854,0.9839,0.9827,0.9807,0.9788,0.9765,0.9734,0.9711,0.9675,0.9634,0.9591,0.9524,0.9475,0.9414,0.9329,0.9248,0.916,0.9056,0.8949,0.8821,0.8679,0.8541,0.8379,0.8184,0.7978,0.7775,0.7522,0.7237,0.7016,0.6906,0.6677,0.6448,0.6226,0.5743,
          0.9979,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9996,0.9995,0.9994,0.9993,0.9993,0.9993,0.9992,0.9993,0.9993,0.9993,0.9992,0.9993,0.9992,0.9992,0.9992,0.9993,0.9993,0.9993,0.9992,0.9992,0.9992,0.9992,0.9991,0.999,0.9988,0.9986,0.9985,0.9984,0.9982,0.9982,0.9981,0.9977,0.9973,0.9968,0.9967,0.9963,0.9957,0.9958,0.9955,0.9947,0.9939,0.9935,0.993,0.9923,0.9914,0.9903,0.9891,0.9879,0.9872,0.9862,0.9843,0.982,0.9807,0.9791,0.9766,0.9743,0.9704,0.9665,0.9646,0.9606,0.954,0.9489,0.9427,0.9326,0.9246,0.9172,0.9075,0.8967,0.8833,0.8673,0.8531,0.8359,0.817,0.8054,0.784,0.7543,0.7308,0.7135,0.6957,0.6731,0.6503,0.6278,0.58,
          0.9978,0.9994,0.9997,0.9997,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9998,0.9997,0.9997,0.9996,0.9994,0.9994,0.9994,0.9994,0.9992,0.9993,0.9994,0.9993,0.9994,0.9993,0.9992,0.9993,0.9993,0.9993,0.9993,0.9992,0.9991,0.9992,0.9991,0.9991,0.9992,0.9991,0.999,0.9986,0.9984,0.9984,0.9983,0.9981,0.998,0.9977,0.9972,0.997,0.9968,0.9964,0.996,0.9958,0.9955,0.9946,0.994,0.9936,0.9934,0.9926,0.9914,0.9908,0.9901,0.9885,0.9874,0.9868,0.9857,0.9835,0.9818,0.9801,0.9777,0.9748,0.9712,0.968,0.9642,0.9599,0.9554,0.9506,0.9432,0.935,0.9293,0.9207,0.9097,0.8971,0.8852,0.8716,0.854,0.8404,0.8243,0.803,0.7838,0.7586,0.728,0.7077,0.693,0.6698,0.6468,0.6233,0.575,
          0.9977,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9996,0.9995,0.9995,0.9994,0.9993,0.9993,0.9993,0.9992,0.9994,0.9994,0.9993,0.9992,0.9993,0.9993,0.9992,0.9993,0.9994,0.9994,0.9993,0.9994,0.9994,0.9992,0.999,0.9989,0.9989,0.9987,0.9988,0.9988,0.9984,0.9981,0.9978,0.9976,0.9974,0.9972,0.997,0.9966,0.9961,0.9957,0.9953,0.9949,0.9946,0.9938,0.993,0.9925,0.9918,0.9909,0.9895,0.9883,0.9876,0.9864,0.9857,0.9839,0.9812,0.9796,0.9779,0.9757,0.973,0.9686,0.9652,0.961,0.954,0.949,0.9435,0.9366,0.9294,0.9196,0.9108,0.9006,0.887,0.8732,0.8575,0.8421,0.8245,0.8028,0.7852,0.7671,0.741,0.7179,0.6987,0.6757,0.6526,0.6298,0.5808,
          0.9981,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9996,0.9995,0.9995,0.9994,0.9993,0.9993,0.9993,0.9993,0.9994,0.9993,0.9993,0.9993,0.9994,0.9992,0.9993,0.9994,0.9993,0.9993,0.9993,0.9993,0.9993,0.9992,0.9991,0.9991,0.9991,0.9989,0.9986,0.9985,0.9985,0.9982,0.9979,0.9976,0.9974,0.9972,0.9972,0.9969,0.9964,0.9959,0.9952,0.9952,0.9947,0.9934,0.9931,0.9928,0.9922,0.9915,0.9904,0.989,0.9876,0.9867,0.9852,0.9834,0.9819,0.9804,0.9788,0.9763,0.9734,0.9707,0.9659,0.9608,0.9562,0.9509,0.9461,0.9416,0.9336,0.9209,0.9098,0.9,0.8881,0.8748,0.8621,0.8474,0.8282,0.8065,0.7817,0.763,0.7445,0.7198,0.6988,0.6753,0.6519,0.6284,0.5786,
          0.9975,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9997,0.9997,0.9996,0.9995,0.9993,0.9993,0.9993,0.9993,0.9992,0.9992,0.9993,0.9993,0.9994,0.9994,0.9994,0.9993,0.9993,0.9993,0.9994,0.9994,0.9992,0.9991,0.999,0.999,0.9991,0.999,0.9988,0.9986,0.9985,0.9983,0.9981,0.9978,0.9977,0.9976,0.9972,0.9967,0.9962,0.9958,0.9954,0.9952,0.995,0.9944,0.9936,0.9927,0.992,0.9915,0.9907,0.9897,0.9881,0.987,0.9865,0.9849,0.9826,0.9814,0.9796,0.976,0.9724,0.9698,0.9668,0.9622,0.9571,0.9525,0.9464,0.9377,0.93,0.9225,0.9122,0.9007,0.8877,0.8723,0.8573,0.8414,0.8204,0.8008,0.7855,0.7631,0.7423,0.7212,0.6924,0.6687,0.6449,0.6221,0.5723,
          0.9976,0.9995,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9999,0.9999,0.9998,0.9997,0.9995,0.9994,0.9994,0.9994,0.9994,0.9993,0.9993,0.9993,0.9992,0.9992,0.9992,0.9992,0.9992,0.9992,0.9993,0.9994,0.9994,0.9992,0.999,0.9991,0.9992,0.9992,0.999,0.999,0.999,0.9988,0.9986,0.9984,0.9983,0.9983,0.998,0.9975,0.9974,0.9974,0.9967,0.9962,0.9961,0.996,0.9956,0.995,0.9945,0.9937,0.9925,0.9919,0.9913,0.9904,0.9897,0.9885,0.9873,0.9861,0.9846,0.9831,0.9812,0.9794,0.9775,0.9742,0.9706,0.9669,0.9635,0.9607,0.9554,0.9482,0.9416,0.9347,0.9267,0.9148,0.9034,0.894,0.8806,0.8662,0.8452,0.8279,0.8102,0.7831,0.7623,0.7356,0.7147,0.6972,0.6729,0.649,0.6247,0.5746,
          0.9978,0.9995,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9997,0.9997,0.9996,0.9994,0.9993,0.9994,0.9993,0.9993,0.9993,0.9993,0.9994,0.9993,0.9993,0.9992,0.9992,0.9992,0.9991,0.9991,0.9992,0.9993,0.9992,0.9993,0.9993,0.9992,0.9991,0.9989,0.9988,0.9987,0.9987,0.9986,0.9984,0.998,0.9978,0.9976,0.9972,0.9973,0.9972,0.9969,0.9965,0.996,0.9954,0.995,0.9946,0.9939,0.9929,0.9921,0.9914,0.9909,0.9904,0.9891,0.9874,0.9861,0.9848,0.9831,0.9815,0.9801,0.9787,0.9751,0.9712,0.9683,0.9641,0.9599,0.9562,0.9503,0.9433,0.9355,0.9263,0.9181,0.9065,0.8934,0.8813,0.8702,0.8525,0.8296,0.8156,0.7995,0.7766,0.7577,0.7371,0.7097,0.6864,0.6629,0.6394,0.5885,
          0.9976,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9995,0.9994,0.9994,0.9994,0.9994,0.9993,0.9991,0.9991,0.9992,0.9992,0.9993,0.9993,0.9994,0.9994,0.9992,0.9992,0.9992,0.9991,0.9991,0.9992,0.9993,0.9991,0.999,0.9989,0.9989,0.9989,0.9988,0.9988,0.9985,0.9982,0.9981,0.9978,0.9977,0.9973,0.9967,0.9964,0.9961,0.9958,0.9954,0.9948,0.9944,0.9939,0.9934,0.9928,0.9917,0.9908,0.9898,0.9885,0.9875,0.9868,0.9856,0.984,0.9813,0.9792,0.9781,0.9749,0.9713,0.9693,0.9664,0.9605,0.9552,0.949,0.9427,0.9372,0.9288,0.9191,0.9054,0.8918,0.8799,0.8657,0.8477,0.8314,0.814,0.7884,0.767,0.7501,0.7284,0.7013,0.6772,0.6533,0.6287,0.5782,
          0.9978,0.9995,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9997,0.9996,0.9996,0.9995,0.9995,0.9994,0.9995,0.9993,0.9992,0.9993,0.9993,0.9994,0.9993,0.9992,0.9991,0.9992,0.9992,0.9992,0.9992,0.9992,0.9992,0.999,0.9991,0.9991,0.9988,0.9988,0.9988,0.9988,0.9986,0.9984,0.9983,0.9979,0.9978,0.9977,0.9976,0.9974,0.9967,0.9962,0.9959,0.9958,0.9955,0.9949,0.9941,0.993,0.992,0.9918,0.991,0.99,0.9888,0.9874,0.9866,0.9855,0.9839,0.9821,0.9802,0.9775,0.9757,0.9738,0.9693,0.9656,0.9612,0.9563,0.9508,0.9438,0.9375,0.9309,0.9202,0.9081,0.8966,0.8827,0.8714,0.8598,0.8396,0.8147,0.7931,0.772,0.7499,0.7294,0.7059,0.6818,0.6574,0.6333,0.5815,
          0.9979,0.9996,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9999,0.9998,0.9996,0.9995,0.9995,0.9995,0.9994,0.9993,0.9993,0.9992,0.9993,0.9993,0.9991,0.9992,0.9992,0.9993,0.9993,0.9992,0.9993,0.9994,0.9991,0.9991,0.9992,0.9991,0.9989,0.9989,0.999,0.9989,0.9988,0.9987,0.9986,0.9986,0.9985,0.9981,0.998,0.9979,0.9974,0.9972,0.997,0.9965,0.9961,0.9956,0.9955,0.9953,0.9946,0.994,0.9932,0.9917,0.9903,0.9901,0.9895,0.9883,0.9877,0.9857,0.9834,0.9828,0.9815,0.979,0.9768,0.9747,0.9716,0.9667,0.9611,0.9571,0.9539,0.9471,0.9387,0.9296,0.9189,0.9088,0.8982,0.8842,0.8669,0.847,0.8249,0.8068,0.7907,0.7732,0.7507,0.7199,0.6941,0.6689,0.6435,0.6187,0.5669,
          0.9981,0.9996,0.9998,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9999,0.9998,0.9998,0.9999,0.9997,0.9996,0.9996,0.9996,0.9994,0.9993,0.9994,0.9993,0.9993,0.9994,0.9993,0.9992,0.9993,0.9993,0.9994,0.9994,0.9993,0.9992,0.9991,0.9992,0.9992,0.9992,0.9992,0.999,0.999,0.999,0.999,0.9988,0.9988,0.9987,0.9985,0.9985,0.9983,0.9979,0.9978,0.9975,0.997,0.9969,0.9968,0.9964,0.996,0.9956,0.9949,0.9941,0.9935,0.9928,0.9921,0.9912,0.99,0.9888,0.9877,0.9867,0.9856,0.9839,0.9826,0.9807,0.9793,0.9773,0.9739,0.9704,0.9663,0.9632,0.9589,0.953,0.9456,0.9376,0.9295,0.9208,0.9115,0.8987,0.8831,0.8685,0.8532,0.8322,0.8139,0.7997,0.7768,0.7487,0.7253,0.7054,0.681,0.6567,0.6329,0.5804)


all_years <- c("1999", "2000", "2001", "2002", "2003", "2004",
               "2005", "2006", "2007", "2008", "2009", "2010",
               "2011", "2012", "2013", "2014", "2015", "2016",
               "2017", "2018", "2019")

# Population for males as matrix
pop_m_mat <- matrix(pop_m, nrow = 101, ncol = 21)
colnames(pop_m_mat) <- all_years

# Population for females as matrix
pop_f_mat <- matrix(pop_f, nrow = 101, ncol = 21)
colnames(pop_f_mat) <- all_years

# Age-specific-fertility-rate for as matrix
asfr_mat <- matrix(asfr, nrow = 35, ncol = 20)
colnames(asfr_mat) <- all_years[-length(all_years)]

# Sex ratio at birth as vector
srb_vec <- c(1.06,	1.06,	1.06,	1.06,	1.06, 1.06,	1.06,	1.06,	1.06, 1.06,
             1.06,	1.06,	1.06,	1.06,	1.06, 1.06,	1.06,	1.06,	1.06,	1.06, 1.06)

names(srb_vec) <- all_years[-length(all_years)]

# Survival ratio for males as matrix
sr_m_mat <- matrix(sr_m, nrow = 101, ncol = 20)
colnames(sr_m_mat) <- all_years[-length(all_years)]

# Survival ratio for females as matrix
sr_f_mat <- matrix(sr_f, nrow = 101, ncol = 20)
colnames(sr_f_mat) <- all_years[-length(all_years)]

# Age/year sequence of all the data from above
interval <- 1
ages <- seq(0, 100, by = interval)
years <- seq(1999, 2019, by = interval)
ages_fertility <- seq(15, 50, by = interval)

row.names(pop_m_mat) <- ages
row.names(pop_f_mat) <- ages
row.names(sr_m_mat) <- ages
row.names(sr_f_mat) <- ages
row.names(asfr_mat) <- 15:49
names(srb_vec) <- years

mig_res <-
  mig_resid_stock(
    pop_m_mat = pop_m_mat,
    pop_f_mat = pop_f_mat,
    sr_m_mat = sr_m_mat,
    sr_f_mat = sr_f_mat,
    asfr_mat = asfr_mat,
    srb_vec = srb_vec,
    ages = ages,
    ages_asfr = ages_fertility
  )

mig_res <-
  mig_resid_cohort(
    pop_m_mat = pop_m_mat,
    pop_f_mat = pop_f_mat,
    sr_m_mat = sr_m_mat,
    sr_f_mat = sr_f_mat,
    asfr_mat = asfr_mat,
    srb_vec = srb_vec,
    ages = ages,
    ages_asfr = ages_fertility
  )

mig_res <-
  mig_resid_time(
    pop_m_mat = pop_m_mat,
    pop_f_mat = pop_f_mat,
    sr_m_mat = sr_m_mat,
    sr_f_mat = sr_f_mat,
    asfr_mat = asfr_mat,
    srb_vec = srb_vec,
    ages = ages,
    ages_asfr = ages_fertility
  )

# Save data
## pop_m_mat_single = pop_m_mat
## pop_f_mat_single = pop_f_mat
## sr_m_mat_single = sr_m_mat
## sr_f_mat_single = sr_f_mat
## asfr_mat_single = asfr_mat
## srb_vec_single = srb_vec
## ages_single = ages
## ages_asfr_single = ages_fertility

## usethis::use_data(pop_m_mat_single,
##                   pop_f_mat_single,
##                   sr_m_mat_single,
##                   sr_f_mat_single,
##                   asfr_mat_single,
##                   srb_vec_single,
##                   ages_single,
##                   ages_asfr_single,
##                   overwrite = TRUE)

################### For five year age groups #####################

# Vector of population for males
pop_m <-
  c(835, 671, 570.999, 544, 552, 550, 513, 487.998, 432.002,
    378.001, 338.001, 295.999, 263.001, 220.999, 156, 92.001, 42.204,
    18.001, 4.331, 0.639, 0.07, 989.592, 880.029, 697.435, 575.575,
    561.146, 595.087, 582.08, 544.567, 507.247, 440.909, 373.935,
    316.617, 265.548, 235.035, 182.951, 110.75, 57.555, 18.737, 5.459,
    0.807, 0.065, 1133.424, 1037.502, 905.664, 698.771, 586.798,
    616.9, 638.007, 615.889, 550.076, 504.215, 430.131, 353.696,
    286.403, 238.634, 194.496, 130.76, 69.399, 26.238, 5.809, 1.011,
    0.083, 1149.519, 1149.942, 1042.707, 897.087, 691.317, 605.519,
    628.132, 641.442, 608.262, 532.131, 486.313, 401.381, 321.04,
    251.388, 197.567, 138.127, 81.716, 32.255, 8.386, 1.152, 0.112,
    959.81, 1167.439, 1166.318, 1054.263, 929.596, 770.233, 655.408,
    649.175, 641.542, 602.148, 513.273, 463.968, 371.397, 286.345,
    203.426, 141.486, 87.742, 38.904, 10.533, 1.647, 0.131, 904.577,
    990.842, 1195.275, 1192.299, 1096.101, 1010.808, 817.203, 673.368,
    657.377, 631.756, 591.218, 483.434, 432.18, 330.595, 237.691,
    147.718, 86.849, 42.396, 13.172, 2.217, 0.2, 914.965, 926.002,
    1008.784, 1224.923, 1217.653, 1099.911, 1019.023, 813.755, 676.39,
    643.237, 614.691, 562.266, 449.355, 383.548, 273.038, 176.289,
    92.764, 43.563, 15.48, 3.067, 0.316, 943.289, 927.824, 937.572,
    1036.631, 1265.185, 1225.442, 1108.122, 1014.48, 806.487, 659.135,
    627.186, 594.356, 527.096, 404.537, 320.095, 205.116, 112.331,
    47.821, 16.391, 3.791, 0.466, 982.718, 980.995, 958.024, 988.65,
    1076.907, 1293.734, 1267.032, 1135.973, 1031.081, 804.56, 654.945,
    615.926, 567.992, 487.466, 348.485, 248.7, 133.025, 58.273, 17.722,
    3.888, 0.553, 1012.228, 1014.939, 1019.3, 1013.749, 1016.987,
    1100.959, 1315.154, 1281.21, 1143.215, 1026.976, 788.317, 641.579,
    592.945, 521.839, 418.599, 270.316, 163.215, 70.003, 21.874,
    4.186, 0.549, 914.063, 1038.649, 1049.297, 1073.621, 1055.672,
    1047.487, 1138.313, 1344.753, 1295.431, 1144.702, 1016.992, 771.165,
    615.065, 550.259, 457.748, 334.624, 185.735, 87.221, 26.085,
    4.898, 0.538, 879.05, 952.912, 1081.565, 1116.92, 1130.826, 1092.34,
    1097.179, 1186.645, 1381.02, 1305.446, 1143.75, 989.552, 751.696,
    577.344, 489.506, 377.661, 245.003, 105.627, 34.645, 6.138, 0.619,
    967.471, 930.238, 993.227, 1141.416, 1220.943, 1218.465, 1152.732,
    1154.005, 1219.105, 1404.229, 1303.056, 1126.891, 960.563, 712.717,
    522.094, 415.611, 295.598, 149.226, 44.788, 8.64, 0.793, 996.168,
    1002.283, 955.049, 1097.332, 1284.199, 1236.929, 1269.189, 1192.192,
    1174.32, 1216.076, 1400.008, 1311.348, 1099.315, 941.078, 652.11,
    452.242, 319.415, 186.665, 65.652, 11.458, 1.11, 1020.925, 1011.765,
    1014.23, 1017.281, 1208.233, 1389.541, 1315.956, 1321.892, 1224.232,
    1189.671, 1215.983, 1380.774, 1275.239, 1047.397, 867.426, 568.286,
    355.943, 205.33, 83.6, 17, 1.474, 1028.191, 1035.869, 1023.388,
    1074.814, 1125.935, 1311.078, 1465.662, 1367.022, 1352.787, 1239.604,
    1191.356, 1203.245, 1346.713, 1220.838, 973.366, 765.273, 455.163,
    235.912, 97.148, 22.528, 2.061, 1035.917, 1043.755, 1047.947,
    1086.086, 1187.203, 1232.794, 1390.453, 1518.531, 1399.596, 1369.011,
    1242.733, 1181.749, 1178.339, 1295.414, 1142.767, 869.016, 624.221,
    310.175, 115.614, 27.037, 2.784, 1045.967, 1052.236, 1056.4,
    1113.398, 1203.477, 1298.811, 1316.2, 1446.37, 1552.621, 1417.392,
    1372.669, 1234.502, 1160.392, 1138.346, 1219.39, 1029.28, 718.949,
    434.576, 156.257, 33.016, 3.417, 1068.682, 1062.337, 1064.906,
    1121.9, 1230.868, 1315.242, 1382.275, 1372.643, 1481.225, 1570.215,
    1421.698, 1364.113, 1214.291, 1124.645, 1077.332, 1107.059, 862.313,
    510.375, 224.598, 45.72, 4.224, 1102.822, 1085.121, 1075.057,
    1130.572, 1239.683, 1342.955, 1399.057, 1438.921, 1408.243, 1499.967,
    1574.252, 1414.059, 1343.384, 1179.959, 1069.144, 985.391, 938.14,
    623.089, 270.065, 67.236, 5.855, 1140.8, 1119.328, 1097.897,
    1140.924, 1248.743, 1352.213, 1427.121, 1456.061, 1474.768, 1428.008,
    1505.633, 1566.169, 1394.527, 1308.152, 1126.043, 984.266, 844,
    689.026, 337.068, 82.618, 8.662)
#'
# Vector of population for females
pop_f <-
  c(801, 645, 554.001, 534, 557.999, 564, 521.001, 478.001,
    410.999, 352.999, 318, 276, 239, 196.998, 147, 92, 49.354, 23.001,
    6.5, 1.164, 0.135, 948.057, 844.618, 670.281, 562.978, 556.695,
    589.153, 595.677, 545.622, 488.336, 410.687, 346.698, 303.994,
    257.339, 222.218, 177.703, 111.516, 66.076, 25.155, 8.267, 1.423,
    0.145, 1082.85, 993.185, 866.81, 675.391, 590.032, 594.559, 626.777,
    624.823, 547.167, 485.337, 406.556, 337.02, 285.388, 243.185,
    202.252, 135.464, 80.488, 34.773, 9.379, 1.88, 0.182, 1091.999,
    1101.593, 998.637, 870.126, 696.038, 607.414, 608.372, 634.123,
    618.287, 534.182, 476.099, 390.902, 323.659, 270.819, 222.629,
    158.211, 99.985, 43.526, 13.425, 2.209, 0.243, 916.285, 1113.846,
    1116.448, 1022.769, 918.839, 752.674, 635.897, 619.411, 627.163,
    613.115, 524.316, 470.068, 384.21, 315.25, 247.486, 184.146,
    119.509, 56.879, 17.577, 3.347, 0.307, 858.616, 944.546, 1141.242,
    1148.666, 1080.544, 977.493, 784.947, 647.137, 627.282, 623.897,
    615.885, 510.514, 460.492, 370.614, 286.566, 207.64, 136.385,
    70.415, 24.027, 4.599, 0.483, 868.926, 877.749, 959.791, 1175.057,
    1195.136, 1093.776, 991.924, 782.722, 651.731, 622.015, 618.687,
    605.778, 500.641, 442.912, 341.607, 245.476, 158.844, 84.752,
    32.378, 7.171, 0.792, 895.173, 880.805, 893.824, 982.635, 1215.112,
    1205.436, 1108.77, 989.171, 783.703, 645.936, 620.163, 616.473,
    594.188, 483.99, 407.959, 294.664, 188.001, 102.344, 41.293,
    10.454, 1.36, 936.591, 930.873, 909.761, 937.09, 1040.314, 1261.087,
    1253.31, 1138.156, 1013.326, 789.43, 647.395, 618.625, 607.737,
    578.414, 450.459, 356.927, 227.408, 122.534, 50.048, 13.221,
    1.968, 962.734, 966.476, 967.107, 957.99, 982.293, 1078.452,
    1289.82, 1276.239, 1152.444, 1021.414, 790.697, 651.846, 612.561,
    584.997, 533.268, 389.96, 277.225, 150.795, 61.026, 16.175, 2.495,
    872.149, 989.229, 998.47, 1014.575, 1007.4, 1019.803, 1118.597,
    1322.793, 1295.408, 1160.933, 1017.656, 782.288, 640.445, 591.004,
    544.271, 468.132, 312.504, 184.648, 74.05, 18.888, 2.818, 831.614,
    907.289, 1032.916, 1054.491, 1087.81, 1064.803, 1079.765, 1163.223,
    1358.369, 1304.687, 1162.716, 1010.927, 777.628, 621.991, 554.866,
    485.032, 385.873, 214.234, 93.771, 23.583, 3.281, 918.838, 876.318,
    944.356, 1087.72, 1156.023, 1189.243, 1155.079, 1142.97, 1200.737,
    1385.864, 1307.092, 1157.85, 1000.01, 756.228, 585.003, 501.751,
    414.881, 275.154, 114.55, 31.799, 4.292, 950.252, 955.845, 901.601,
    1034.682, 1232.517, 1230.147, 1278.363, 1207.768, 1177.793, 1204.356,
    1388.633, 1309.444, 1137.271, 975.544, 718.972, 536.404, 423.543,
    303.137, 151.219, 39.364, 5.675, 972.207, 966.024, 968.771, 971.038,
    1155.236, 1343.606, 1310.409, 1330.404, 1239.077, 1193.687, 1207.497,
    1378.179, 1287.326, 1102.782, 925.427, 657.537, 458.654, 313.372,
    169.081, 52.593, 7.072, 976.405, 987.332, 978.581, 1036.217,
    1088.349, 1263.153, 1421.22, 1360.854, 1360.488, 1254.47, 1197.429,
    1200.365, 1355.979, 1250.443, 1049.613, 850.295, 565.065, 343.486,
    179.947, 59.846, 9.474, 983.61, 992.108, 1000.337, 1048.292,
    1157.406, 1200.03, 1343.652, 1473.399, 1392.3, 1376.507, 1258.974,
    1191.956, 1183.853, 1320.389, 1194.661, 970.4, 737.82, 429.619,
    201.231, 64.936, 11.111, 993.232, 1000.063, 1005.704, 1073.068,
    1174.732, 1273.909, 1284.275, 1398.562, 1506.421, 1409.749, 1381.642,
    1254.544, 1177.896, 1156.569, 1266.895, 1112.005, 851.243, 570.482,
    257.474, 74.251, 12.326, 1014.748, 1009.727, 1013.685, 1078.453,
    1199.539, 1291.299, 1358.178, 1339.471, 1432.104, 1523.907, 1415.474,
    1377.117, 1241.194, 1153.335, 1113.937, 1185.875, 984.267, 667.614,
    348.639, 96.877, 14.172, 1047.114, 1031.299, 1023.389, 1086.588,
    1205.189, 1316.366, 1375.813, 1413.531, 1373.503, 1450.422, 1529.735,
    1411.833, 1363.681, 1217.645, 1114.502, 1048.481, 1058.718, 782.58,
    415.883, 133.756, 18.362, 1083.119, 1063.736, 1045.012, 1096.489,
    1213.687, 1322.39, 1401.18, 1431.462, 1447.757, 1392.552, 1457.502,
    1526.287, 1399.672, 1340.065, 1180.192, 1054.342, 943.985, 853.051,
    496.821, 162.711, 25.414) / 1000
#'
# Vector of age-specific fertility rates
asfr <- c(50.369, 202.131, 206.141, 149.211, 87.253, 31.052,
          2.843, 57.919, 226.709, 222.516, 148.992, 87.888, 29.736, 2.64,
          54.096, 223.587, 211.46, 140.311, 76.881, 26.533, 2.132, 45.049,
          159.679, 156.131, 93.96, 50.059, 15.713, 1.409, 37.188, 119.39,
          132.748, 70.029, 28.02, 7.311, 0.514, 30.209, 101.658, 125.692,
          65.483, 19.804, 3.711, 0.243, 24.9, 88.815, 121.231, 68.621,
          20.031, 3.039, 0.163, 23.238, 78.247, 118.743, 75.403, 24.014,
          3.426, 0.129, 25.141, 75.764, 118.592, 85.555, 29.309, 4.303,
          0.136, 20.117, 64.41, 104.081, 85.589, 32.737, 5.247, 0.219,
          14.645, 53.484, 98.176, 92.658, 37.567, 6.397, 0.273, 13.677,
          51.37, 100.418, 104.868, 48.196, 8.278, 0.393, 11.494, 43.287,
          93.809, 106.904, 53.5, 10.662, 0.544, 8.387, 37.053, 86.307,
          106.038, 55.169, 11.345, 0.701, 6.625, 31.576, 80.064, 106.128,
          58.423, 13.087, 0.917, 5.468, 27.869, 76.196, 107.843, 62.296,
          15.036, 1.172, 4.686, 25.34, 73.943, 110.575, 66.487, 17.107,
          1.462, 4.134, 23.539, 72.551, 113.398, 70.423, 19.099, 1.756,
          3.732, 22.206, 71.53, 115.597, 73.588, 20.803, 2.024, 3.467,
          21.39, 71.244, 117.758, 76.268, 22.224, 2.249)
#'
# Vector of survival rates for males
sr_m <- c(0.95557549, 0.9921273, 0.99594764, 0.99510483, 0.99178483,
          0.99134461, 0.99100899, 0.98929784, 0.98473229, 0.97588706,
          0.96048519, 0.93812765, 0.90615821, 0.8622277, 0.8047363,
          0.71333856, 0.596832, 0.44396816, 0.30330032, 0.18642771,
          0.0911662462413327, 0.96275471, 0.99399428, 0.9968488, 0.99563281,
          0.99229006, 0.99196446, 0.99180061, 0.99013625, 0.98594365,
          0.97719516, 0.96239426, 0.93950426, 0.90620399, 0.86117682,
          0.80225284, 0.71307413, 0.60022645, 0.4558758, 0.31005161,
          0.18518342, 0.0956313878791117, 0.96951141, 0.99496609, 0.99727649,
          0.99607245, 0.99233725, 0.99205108, 0.99228027, 0.99056435,
          0.98605767, 0.97783685, 0.96314897, 0.9406932, 0.90642888,
          0.86286999, 0.80387894, 0.71498269, 0.6066814, 0.46479967,
          0.31958557, 0.19836001, 0.101989015830425, 0.97545992, 0.99563858,
          0.99741385, 0.99592654, 0.99152023, 0.99192115, 0.9924163,
          0.990644, 0.98617665, 0.97752991, 0.96353815, 0.94114166,
          0.90833701, 0.86170391, 0.80301014, 0.72151551, 0.6128495,
          0.47608317, 0.32653048, 0.19655555, 0.103730263806538, 0.98060776,
          0.99617149, 0.99761403, 0.99542383, 0.99054495, 0.99194397,
          0.99266261, 0.99089428, 0.98611279, 0.97789594, 0.96434779,
          0.94341044, 0.91191009, 0.86748795, 0.80686197, 0.72532159,
          0.61846149, 0.48319275, 0.33857582, 0.2104904, 0.112385162790671,
          0.98550309, 0.99688352, 0.99803301, 0.9959062,
          0.99126003, 0.99231634, 0.99301369, 0.99160392, 0.98761021,
          0.97986329, 0.96646197, 0.94623899, 0.91718051, 0.87584219,
          0.81662218, 0.73700918, 0.6303803, 0.50160307, 0.3651526,
          0.23288489, 0.130850768617506, 0.98931819, 0.99775357, 0.9984583,
          0.99673481, 0.99301824, 0.99346278, 0.99369545, 0.99294003,
          0.98994327, 0.98356936, 0.97206458, 0.95389895, 0.92644026,
          0.88661213, 0.82907732, 0.74960973, 0.64331764, 0.51551648,
          0.37629084, 0.24487989, 0.137677217644374, 0.99112504, 0.99814201,
          0.99879926, 0.99711429, 0.99389061, 0.99409107, 0.99396033,
          0.99290953, 0.99073493, 0.98586868, 0.97625645, 0.95984456,
          0.93401387, 0.89576747, 0.84146086, 0.76230416, 0.6528808,
          0.51875327, 0.37059318, 0.23716232, 0.129879589178461, 0.99268153,
          0.99853182, 0.99902021, 0.99755244, 0.99471893, 0.99453053,
          0.99383731, 0.99242559, 0.99039498, 0.98664094, 0.97888902,
          0.96514568, 0.94232807, 0.90695918, 0.85686765, 0.78068285,
          0.6693777, 0.52625072, 0.37539746, 0.23620331, 0.123653858706926,
          0.99378702, 0.99880557, 0.99916867, 0.99795758, 0.99537754,
          0.99534488, 0.99484455, 0.99357678, 0.99141921, 0.9878473,
          0.98134482, 0.96932265, 0.94941573, 0.91742454, 0.86776992,
          0.79533967, 0.68311452, 0.5343893, 0.37262307, 0.2239178,
          0.113720633638293, 0.99399248, 0.99897976, 0.99932852, 0.99822431,
          0.99601855, 0.99591387, 0.99569633, 0.99470259, 0.99268715,
          0.98892298, 0.98249955, 0.97238094, 0.9552462, 0.92844911,
          0.88653064, 0.82114141, 0.71875477, 0.56869525, 0.39721252,
          0.23529357, 0.113792166251756, 0.99425766, 0.99909623, 0.99940998,
          0.99846006, 0.99631257, 0.99603178, 0.99592291, 0.99518752,
          0.99322132, 0.98983274, 0.98368064, 0.9741733, 0.9602258,
          0.93745239, 0.9016288, 0.8444638, 0.75222073, 0.60907965,
          0.4240168, 0.24939352, 0.117336219766853, 0.99471736, 0.99933256,
          0.99947765, 0.99871556, 0.99694493, 0.99649396, 0.99655801,
          0.99589338, 0.99413263, 0.99084735, 0.98542046, 0.97725847,
          0.96497949, 0.9452114, 0.9134356, 0.8610204, 0.7737601, 0.63147622,
          0.43996206, 0.25585397, 0.117677375365884, 0.99489165, 0.99937715,
          0.99951763, 0.99880472, 0.99710652, 0.99665932, 0.99675852,
          0.99614922, 0.99444005, 0.99122406, 0.98598437, 0.97827319,
          0.96683874, 0.94835124, 0.91833471, 0.86821514, 0.78398104,
          0.64282533, 0.44786339, 0.25892654, 0.117310656081295, 0.99547488,
          0.99923281, 0.99957341, 0.99911343, 0.99802214, 0.99709297,
          0.99680896, 0.99635099, 0.99498899, 0.99222347, 0.9875931,
          0.98060053, 0.97014661, 0.9536392, 0.92634894, 0.87987019,
          0.79856151, 0.66278044, 0.47312791, 0.2694788, 0.111570323438865,
          0.99610316, 0.99933917, 0.9996362, 0.99923203, 0.99825186,
          0.99737383, 0.99710434, 0.99670571, 0.99548655, 0.99299216,
          0.9888173, 0.98253469, 0.97316181, 0.95828527, 0.93341992,
          0.89062075, 0.81386423, 0.68145805, 0.49006978, 0.27830681,
          0.113218864970809, 0.99653042, 0.99941146, 0.99967816, 0.99931356,
          0.99841616, 0.99758578, 0.9973301, 0.99697294, 0.99585907,
          0.99356834, 0.9897352, 0.98398011, 0.97540572, 0.96174959,
          0.93872789, 0.89876001, 0.8256409, 0.69618678, 0.50377247,
          0.28557404, 0.114591438080939, 0.99688677, 0.99947174, 0.99971275,
          0.99938206, 0.99855794, 0.99777511, 0.99753337, 0.99721139,
          0.99619015, 0.99408084, 0.99055187, 0.98526355, 0.97739317,
          0.9648224, 0.94346085, 0.90607063, 0.83636949, 0.70989474,
          0.51681708, 0.29260349, 0.115932510195963, 0.99718332, 0.99952193,
          0.9997412, 0.99943948, 0.99868001, 0.99794372, 0.99771578,
          0.99742349, 0.99648352, 0.99453532, 0.99127626, 0.98639967,
          0.97914803, 0.96753912, 0.94766613, 0.91261037, 0.84609618,
          0.7225789, 0.52915469, 0.29935668, 0.117233382382913, 0.99743526,
          0.99956461, 0.99976514, 0.9994886, 0.99878699, 0.99809597,
          0.99788161, 0.99761483, 0.99674727, 0.99494418, 0.99192807,
          0.98742013, 0.98072071, 0.96997658, 0.95145635, 0.91854221,
          0.85503156, 0.73446104, 0.54096047, 0.30591861,
          0.118509238191645)
#'
# Vector of survival rates for females
sr_f <- c(0.854489854276296, 0.935421167801612, 0.97813792986728,
          0.982021189677661, 0.976828336081795, 0.97244561985297,
          0.968812772150047, 0.96483427499772, 0.96010802339363,
          0.954056165687121, 0.943306039954761, 0.92448836548943,
          0.890690237758345, 0.835639114030282, 0.754796751406155,
          0.644175707707241, 0.510754359186887, 0.367690608641792,
          0.24038748937665, 0.145450728453873, 0.0826258994519641,
          0.872081445760557, 0.944846444000478, 0.981301676540409,
          0.98454923599414, 0.980025670920247, 0.976133157582757,
          0.972813894527646, 0.968976434023376, 0.964396307993652,
          0.958650557701456, 0.948256461919103, 0.930336619590153,
          0.898721683064412, 0.846943744756808, 0.7693050373115,
          0.660761281137989, 0.526356065457763, 0.380513624627523,
          0.249631099810745, 0.150641910916079, 0.0845984581684562,
          0.886848633625797, 0.952485090106336, 0.983750072193038,
          0.986500893000163, 0.982460467395807, 0.978978117640805,
          0.975938233552867, 0.972378413253193, 0.967941794833695,
          0.962223931611845, 0.952268831689409, 0.935291261627555,
          0.905449822961756, 0.856292233575997, 0.781888442354377,
          0.676068647825169, 0.542224475987347, 0.394762631381521,
          0.260252774164775, 0.156857215747202, 0.0874135544568921,
          0.900784558263659, 0.9596839642243, 0.986196123803518,
          0.988385232322206, 0.984769248387878, 0.981657532920333,
          0.978917213857464, 0.975642526638743, 0.971423457946261,
          0.965729507599766, 0.956020853088256, 0.939966236835617,
          0.912171280137383, 0.865872642393594, 0.794508147678775,
          0.691547047753295, 0.558414706244368, 0.408689574652693,
          0.269878505194327, 0.1624396495176, 0.0898671492416105,
          0.912633835108388, 0.965550681132028, 0.987920059015778,
          0.989848240747598, 0.986695608763104, 0.983981235542121,
          0.981570190639542, 0.97861812228183, 0.974635289736998,
          0.9691431860219, 0.959749667932423, 0.944374872196883,
          0.918112298204692, 0.874309263183862, 0.80582736469469,
          0.705435057343639, 0.573891155573389, 0.423123546270893,
          0.280818298136084, 0.169320472983824, 0.0930347806338448,
          0.922791200429312, 0.970414095250172, 0.989432301168788,
          0.990708732285749, 0.987862933459543, 0.98554556950358,
          0.983439950663867, 0.980726138018158, 0.976956585172812,
          0.971679032024458, 0.962795297767379, 0.948303265698793,
          0.923561621562827, 0.882274284142424, 0.817184362828982,
          0.720298723984997, 0.590336398050365, 0.439061608307152,
          0.293893306863672, 0.178752339638971, 0.0979770657163587,
          0.933750711567667, 0.975650023350237, 0.991430129981753,
          0.99247477931302, 0.989942622594004, 0.987846767986695,
          0.98591292962169, 0.983362542545618, 0.979767042495056,
          0.974726611965329, 0.96628359885727, 0.95251185213316,
          0.929005505885616, 0.889790085932051, 0.827762556372604,
          0.734212960407364, 0.606322257595734, 0.453895037584414,
          0.305625301261282, 0.186403154530675, 0.101364444633525,
          0.942022185331379, 0.979147123918558, 0.992515619501369,
          0.9933310350342, 0.990999245807151, 0.98905130373017,
          0.987257739978207, 0.984897031588263, 0.981492787306857,
          0.9766673141557, 0.968686240948038, 0.955634366723833,
          0.9333801029294, 0.895907358522987, 0.836661271636903,
          0.746801163214231, 0.621415950298903, 0.468910608066693,
          0.317915153427838, 0.195039481469627, 0.105384282613558,
          0.94718229582512, 0.980790142908247, 0.992803300931434,
          0.993541163348349, 0.991307476656705, 0.989225443921528,
          0.987176469101693, 0.98460623719428, 0.981246509709472,
          0.976718447241337, 0.969160984177711, 0.956833654346736,
          0.935783935128507, 0.900223655022325, 0.843512027545961,
          0.75698552882669, 0.634658767009268, 0.482935300037292,
          0.329848456620383, 0.20331169504299, 0.10978246168398,
          0.953756599857967, 0.984059901645376, 0.993955214747401,
          0.994268297381336, 0.991878910452198, 0.989316711233698,
          0.98661050317541, 0.983509725457937, 0.980068840413112,
          0.975865841537748, 0.96873162752321, 0.957191306973029,
          0.937336013374256, 0.903694171906013, 0.84952642553648,
          0.76536853834578, 0.645403389194791, 0.494479119379901,
          0.339863899010747, 0.210826549541289, 0.113471459046826,
          0.960713535654886, 0.987033073900882, 0.994716009106623,
          0.994894234746082, 0.992525302465177, 0.9895538842758,
          0.986152805334012, 0.982472321949589, 0.979073662581534,
          0.975395328209274, 0.968932259296626, 0.958359612326248,
          0.939967835580358, 0.908680780255339, 0.857541392392623,
          0.777353828146545, 0.661131513296524, 0.512711981039796,
          0.357346432815676, 0.224662101978509, 0.121638559000661,
          0.967668081909087, 0.990008068984907, 0.995560889886471,
          0.995641991716643, 0.993624470509278, 0.991059373658537,
          0.988040353436121, 0.984673329703723, 0.981470430737054,
          0.977934939728761, 0.971766487949973, 0.961780792273926,
          0.944588362056491, 0.915303175185752, 0.867175365253056,
          0.790635307536064, 0.677656963580601, 0.530729783448463,
          0.374404597176352, 0.237203123872316, 0.127388492872508,
          0.973550993968318, 0.99237559671888, 0.996334437474569,
          0.996302569319733, 0.994665042785698, 0.992854350176394,
          0.990804628097226, 0.988299827070781, 0.985427217612243,
          0.98180549401774, 0.975726794918091, 0.966103852460658,
          0.949838547130851, 0.92234926803937, 0.877071883537886,
          0.804140728455995, 0.694271895287286, 0.548487335263838,
          0.389191763586342, 0.24733085854494, 0.131770634512774,
          0.977644495019607, 0.993809059507753, 0.996921848401461,
          0.996813848508293, 0.995383460235151, 0.993952685083984,
          0.992408034278954, 0.990393195059418, 0.987756840918104,
          0.984187864274535, 0.978346485320431, 0.969132680765175,
          0.953701455005333, 0.92763044136048, 0.884677298385547,
          0.814988789377917, 0.708878868603095, 0.565946568832964,
          0.40677396957209, 0.26150417331884, 0.138468877454496, 0.99589669,
          0.99939439, 0.99968965, 0.99946356, 0.99900599, 0.99861604,
          0.99832041, 0.99779148, 0.99668581, 0.9946399, 0.9913872,
          0.98672374, 0.97979077, 0.96855904, 0.94971941, 0.9172498,
          0.85796829, 0.74889563, 0.57422822, 0.35395265, 0.158786622360056,
          0.9963443, 0.99946056, 0.99972569, 0.99951979, 0.99909662,
          0.99871978, 0.99844108, 0.9979583, 0.99694158, 0.99505178,
          0.99204825, 0.98775485, 0.98138426, 0.97102475, 0.95351064,
          0.92310744, 0.86661424, 0.76030246, 0.58585433, 0.36085561,
          0.160294341407215, 0.99679414, 0.99952694, 0.99976136, 0.99957681,
          0.99919131, 0.99883301, 0.99857404, 0.99814009, 0.99721897,
          0.99549888, 0.99276597, 0.98887133, 0.98310375, 0.97368874,
          0.95762803, 0.92951136, 0.87619312, 0.77320377,
          0.59930763, 0.36898278, 0.162083812814283, 0.9971375, 0.99957757,
          0.99978821, 0.99962071, 0.99926645, 0.99892672, 0.99868509,
          0.9982903, 0.99744714, 0.99586696, 0.99335694, 0.98978824,
          0.98451115, 0.97587178, 0.96101941, 0.93482131, 0.88424374,
          0.78427805, 0.61113191, 0.37625625, 0.163698785477625, 0.99744017,
          0.99962217, 0.9998116, 0.99965971, 0.99933486, 0.99901498,
          0.99879044, 0.99843159, 0.99766096, 0.99621214, 0.99391125,
          0.99064648, 0.985825, 0.97791169, 0.9642029, 0.93983665,
          0.89194494, 0.79508552, 0.62293587, 0.38364594, 0.165352911452495,
          0.99771115, 0.99966211, 0.99983233, 0.99969485, 0.99939794,
          0.99909887, 0.9988912, 0.99856572, 0.9978633, 0.996539, 0.9944362,
          0.99145779, 0.98706409, 0.97983722, 0.96722115, 0.94462117,
          0.89938678, 0.80574358, 0.63485152, 0.39124343, 0.167067858821075)
#'
#'
all_years <- c("1950", "1955", "1960", "1965", "1970", "1975",
               "1980", "1985", "1990", "1995", "2000", "2005",
               "2010", "2015", "2020", "2025", "2030", "2035",
               "2040", "2045", "2050")
#'
# Population for males as matrix
pop_m_mat <- matrix(pop_m, nrow = 21, ncol = 21)
colnames(pop_m_mat) <- all_years
#'
# Population for females as matrix
pop_f_mat <- matrix(pop_f, nrow = 21, ncol = 21)
colnames(pop_f_mat) <- all_years
#'
# Age-specific-fertility-rate for as matrix
asfr_mat <- matrix(asfr, nrow = 7, ncol = 20)
colnames(asfr_mat) <- all_years[-length(all_years)]
#'
# Sex ratio at birth as vector
srb_vec <- c(1.058, 1.057, 1.055, 1.055, 1.06, 1.056, 1.056, 1.052, 1.056,
             1.054, 1.054, 1.053, 1.054, 1.053, 1.056, 1.056, 1.056, 1.056,
             1.056, 1.056)
#'
names(srb_vec) <- all_years[-length(all_years)]
#'
# Survival ratio for males as matrix
sr_m_mat <- matrix(sr_m, nrow = 21, ncol = 20)
colnames(sr_m_mat) <- all_years[-length(all_years)]
#'
# Survival ratio for females as matrix
sr_f_mat <- matrix(sr_f, nrow = 21, ncol = 20)
colnames(sr_f_mat) <- all_years[-length(all_years)]
#'
# Age/year sequence of all the data from above
interval <- 5
ages <- seq(0, 100, by = interval)
years <- seq(1950, 2050, by = interval)
ages_fertility     <- seq(15, 45, by = interval)
rownames(asfr_mat) <- ages_fertility
rownames(pop_m_mat) <- ages
rownames(pop_f_mat) <- ages
rownames(sr_m_mat) <- ages
rownames(sr_f_mat) <- ages

mig_res <-
  mig_resid_stock(
    pop_m_mat = pop_m_mat,
    pop_f_mat = pop_f_mat,
    sr_m_mat = sr_m_mat,
    sr_f_mat = sr_f_mat,
    asfr_mat = asfr_mat,
    srb_vec = srb_vec,
    ages = ages,
    ages_asfr = ages_fertility
  )

mig_res <-
  mig_resid_cohort(
    pop_m_mat = pop_m_mat,
    pop_f_mat = pop_f_mat,
    sr_m_mat = sr_m_mat,
    sr_f_mat = sr_f_mat,
    asfr_mat = asfr_mat,
    srb_vec = srb_vec,
    ages = ages,
    ages_asfr = ages_fertility
  )

mig_res <-
  mig_resid_time(
    pop_m_mat = pop_m_mat,
    pop_f_mat = pop_f_mat,
    sr_m_mat = sr_m_mat,
    sr_f_mat = sr_f_mat,
    asfr_mat = asfr_mat,
    srb_vec = srb_vec,
    ages = ages,
    ages_asfr = ages_fertility
  )

# Save data
pop_m_mat_five = pop_m_mat
pop_f_mat_five = pop_f_mat
sr_m_mat_five = sr_m_mat
sr_f_mat_five = sr_f_mat
asfr_mat_five = asfr_mat
srb_vec_five = srb_vec
ages_five = ages
ages_asfr_five = ages_fertility

usethis::use_data(pop_m_mat_five,
                  pop_f_mat_five,
                  sr_m_mat_five,
                  sr_f_mat_five,
                  asfr_mat_five,
                  srb_vec_five,
                  ages_five,
                  ages_asfr_five,
                  overwrite = TRUE)


# End
timriffe/DemoTools documentation built on Oct. 14, 2024, 12:53 p.m.