timriffe / DemoTools

Tools for the evaluation, adjustment, and standardization of demographic data
https://timriffe.github.io/DemoTools
Other
61 stars 31 forks source link

LTabr computation of survival ratios missing #84

Closed patrick-gerland closed 5 years ago

patrick-gerland commented 5 years ago

Insert an extra column between nLx and Tx called Sx for survival ratios

LT <- LTabr(nMx = mx, Age = AgeGrpStart, AgeInt = AgeGrpSpan, radix = 1e+05, axmethod = "UN", Sex = unique(SexCode), region = "W", mod = FALSE, OAG=TRUE)

## compute Sx (missing from the LTbr computation
LT$Sx <- NA
# first age group is survival from births to the second age group       
LT$Sx[1] <- (LT$nLx[1] + LT$nLx[2]) / ((LT$AgeInt[1]+LT$AgeInt[2]) * LT$lx[1])

# second age group is survival age 0-5 to age 5 - 10
LT$Sx[2] <- LT$nLx[3] / (LT$nLx[1] + LT$nLx[2])

# middle age groups  
for(i in 3:(length(LT$Age)-2)) {
    LT$Sx[i] = LT$nLx[i+1] / LT$nLx[i]
}

# last but one age group
i <- length(LT$Age)-1
LT$Sx[i] = LT$nLx[i+1] / (LT$nLx[i] + LT$nLx[i+1])  
LT$Sx[length(LT$Age)]= 0.0
timriffe commented 5 years ago

presently writing identity function Lxlx2Sx() to do this. Q: Do I understand right that Sx, when added to an abridged lifetable, follows strict 5-year age groups, and so in the first two rows it differs in AgeInt and Age interpretations from the other columns?

timriffe commented 5 years ago

LTabr() now includes an Sx column in output.

patrick-gerland commented 5 years ago

Tim - Yes, you are right.

First entry of S(x,n) is for survivorship of 5 cohorts of birth to age group 0-4 = L(0,5) / 500000 Second entry of S(x,n) is for S(0,5) = L(5,5) / L(0,5)

Patrick

On Thu, Oct 3, 2019 at 9:56 AM Tim Riffe notifications@github.com wrote:

presently writing identity function Lxlx2Sx() to do this. Q: Do I understand right that Sx, when added to an abridged lifetable, follows strict 5-year age groups, and so in the first two rows it differs in AgeInt and Age interpretations from the other columns?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/timriffe/DemoTools/issues/84?email_source=notifications&email_token=ACSJOTLSUDCZYWZOWHYA36DQMX22DA5CNFSM4IUP34YKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAIJEIQ#issuecomment-537956898, or mute the thread https://github.com/notifications/unsubscribe-auth/ACSJOTOEUEBNQ4MFJS44CK3QMX22DANCNFSM4IUP34YA .