Closed timriffe closed 3 years ago
Hi Tim and Sara,
Attached is a description of what I did to create a simplified mig_beta for 1-year intervals and the code with the function compared to the current program.
Let me know if you have any questions, comments, or need more information.
pj
On Sun, Aug 22, 2021 at 4:59 AM Tim Riffe @.***> wrote:
Case submitted by @sarahertog https://github.com/sarahertog needs further investigation. Issue is second year requires no mortality information. Internally a placeholder Sx is created (all 1s).
Jamaica
locid = 388
Male population on 1 January 1963 by single year of age 0:105
popm1 <- c(37474,36019,35191,33413,32098,30739,29163,27519,25850,24318,23227,22313,21213,20287,19351,18212,17254, 16250,15257,14994,14748,14168,13562,13112,12697,12228,11827,11554,11401,11134,10790,10524,10299,10152, 10000,9796,9580,9389,9266,9183,9096,9017,8911,8837,8776,8696,8638,8541,8364,8177,8001,7852,7712,7458, 7179,6923,6570,6202,5866,5541,5197,4859,4567,4286,3955,3632,3349,3023,2654,2375,2200,2023,1847,1679,1556, 1448,1331,1227,1113,1001,892,785,683,569,469,400,338,274,212,167,142,118,94,73,55,42,32,24,18,12,8,5,3,1,0,0)
Male population on 1 January 1964 by single year of age 0:105
popm2 <- c(37483,36075,35590,34745,33038,31698,30295,28681,26988,25273,23706,22556,21595,20506,19596,18690,17618, 16714,15779,14860,14566,14280,13701,13093,12623,12201,11753,11383,11142,11018,10797,10507,10282,10091, 9964,9824,9631,9419,9222,9081,8982,8890,8813,8722,8663,8609,8532,8467,8361,8182,7996,7823,7676,7540,7304, 7042,6792,6451,6089,5751,5423,5081,4745,4449,4166,3840,3522,3240,2920,2566,2292,2110,1930,1752,1585,1459, 1348,1234,1132,1025,918,812,706,602,490,393,325,266,211,161,125,104,84,65,49,36,26,20,15,11,7,5,3,1,0,0)
date1 <- format(as.POSIXct(lubridate::date_decimal(1963),format='%Y/%m/%d %H:%M:%S'),format='%Y-%m-%d') date2 <- format(as.POSIXct(lubridate::date_decimal(1964),format='%Y/%m/%d %H:%M:%S'),format='%Y-%m-%d')
lx for 1x1 life tables, 1963 and 1964
lxMat_m <- as.matrix(cbind(c(1,0.94044,0.933915,0.929242,0.925862,0.923378,0.921505,0.920044,0.918855,0.917838,0.916924,0.916055, 0.915186,0.914271,0.913267,0.912132,0.910825,0.90932,0.907611,0.905715,0.903673,0.901537,0.89936,0.897186, 0.895044,0.89295,0.890908,0.88891,0.886942,0.884983,0.883015,0.881015,0.878964,0.876846,0.874644,0.872343, 0.869928,0.867386,0.864699,0.861853,0.858829,0.855606,0.85216,0.848466,0.844493,0.840209,0.835576,0.830559, 0.825118,0.819211,0.8128,0.805842,0.798298,0.790126,0.781286,0.771733,0.761414,0.750272,0.738241,0.725251, 0.711232,0.696122,0.679873,0.662452,0.643845,0.624043,0.603046,0.580852,0.55746,0.532873,0.507109,0.480207, 0.452243,0.423333,0.393645,0.363396,0.332856,0.302332,0.272155,0.24265,0.214117,0.186817,0.160974,0.136785, 0.114442,0.094131,0.07602,0.060229,0.046791,0.035638,0.026654,0.0195,0.01394,0.00973,0.006625,0.004397, 0.002843,0.00179,0.001097,0.000654,0.000379,0.000214,0.000117,6.3e-05,3.3e-05,1.7e-05), c(1,0.942328,0.936145,0.931705,0.928487,0.926118,0.924331,0.922935,0.921799,0.920828,0.919953,0.91912,0.918285, 0.917404,0.916433,0.915332,0.914062,0.912596,0.910927,0.909075,0.90708,0.904995,0.902871,0.900752,0.898665, 0.896627,0.894638,0.892691,0.890773,0.888864,0.886945,0.884995,0.882995,0.88093,0.878781,0.876536,0.874178, 0.871693,0.869067,0.866282,0.86332,0.860162,0.856784,0.853158,0.849255,0.845042,0.840481,0.835536,0.830167, 0.824334,0.817996,0.811112,0.803641,0.795542,0.786771,0.777282,0.767023,0.755935,0.743951,0.731003,0.717022, 0.701944,0.685721,0.66832,0.64972,0.629914,0.608896,0.586664,0.563218,0.538561,0.512711,0.485708,0.457625, 0.428577,0.398726,0.368288,0.337531,0.306764,0.27632,0.24653,0.217698,0.19009,0.16393,0.139421,0.116757, 0.096127,0.077708,0.061627,0.047923,0.036534,0.027356,0.020037,0.014341,0.010022,0.006832,0.00454,0.002939, 0.001852,0.001136,0.000678,0.000394,0.000222,0.000122,6.5e-05,3.4e-05,1.7e-05))) rownames(lxMat_m) <- 0:105 colnames(lxMat_m) <- c(1963,1964)
lxMat_m <- lxMat_m[,1,drop=FALSE]
test
lxMat_m[,2]<-1
male births in 1963
births_yr <- 38833 years_births <- 1963
run mig beta with my own lx matrix as input
migM_beta_mylx <- DemoTools::mig_beta(c1 = popm1, c2 = popm2, sex = "male", date1 = date1, date2 = date2, location = locid, midyear = FALSE, lxMat = lxMat_m, age_lx = 0:105, dates_lx = c(1963, 1964), births = births_yr, years_births = years_births, child_adjust = "cwr")
run mig beta with NULL inputs for lx so that DemoTools fetches the life table
migM_beta_NULLlx <- DemoTools::mig_beta(c1 = popm1, c2 = popm2, sex = "male", date1 = date1, date2 = date2, location = locid, midyear = FALSE, births = births_yr, years_births = years_births, child_adjust = "cwr")
plot the two results
plot(migM_beta_mylx, type = "l", col = "blue", xlab = "Age", ylab = "net residual migration", main = "Jamaica, males, 1963") lines(migM_beta_NULLlx, col = "red")
lx2 <- interp_coh_download_mortality(location = 388,
sex = "male",
date1 = date1,
date2 = date2,
OAnew = 105,
verbose = FALSE)
dput(lx2)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/timriffe/DemoTools/issues/252, or unsubscribe https://github.com/notifications/unsubscribe-auth/APAK5QSBKHDDGAA4R5ZT72LT6C363ANCNFSM5CSXS6OA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
Hi @peterdavjohnson can you re-try the attachment? In a following email I got the documentation edits, but no function code, thanks!
Hi Tim,
Here it is.
pj
On Mon, Aug 23, 2021 at 5:28 AM Tim Riffe @.***> wrote:
Closed #252 https://github.com/timriffe/DemoTools/issues/252 via 9d5b0e4 https://github.com/timriffe/DemoTools/commit/9d5b0e407aea81a90c34e400e1c7b755d0c361d5 .
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/timriffe/DemoTools/issues/252#event-5193218136, or unsubscribe https://github.com/notifications/unsubscribe-auth/APAK5QTYRGT5BKZNONTAY5DT6IID7ANCNFSM5CSXS6OA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
Case submitted by @sarahertog needs further investigation. Issue is second year requires no mortality information. Internally a placeholder
Sx
is created (all 1s).