timriffe / DemoTools

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

lt_abridged: Error in if (any(ind)) { : missing value where TRUE/FALSE needed #243

Closed patrick-gerland closed 3 years ago

patrick-gerland commented 3 years ago

lt_abridged(Deaths, Exposures, Age, AgeInt, radix=1e+05, axmethod="un", Sex="b", region="w", mod=TRUE, OAG=FALSE, OAnew=100)

with this input data Deaths <- c(4.97558685, 2.25622114, 0.06666667, 0.46666933, 0.80000000, 0.26666667, 1.66666933, 2.33333333, 1.71662582, 1.20000000, 1.60000267, 1.66666667, 2.20000000, 5.93333333, 5.33333333, 4.86480818, 3.44238651, 2.09001738) Exposures <- c(177.13333, 676.66667, 733.80000, 618.13333, 496.86667, 378.60000, 302.20000, 262.66667, 241.06667, 208.40000, 167.46667, 130.60000, 106.40000, , 86.46667, , 68.60000, , 62.66667, , 53.20000, , 36.60000) Age <- c(0, , 1, , 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80) AgeInt <- c(1, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)

causes an error: Error in if (any(ind)) { : missing value where TRUE/FALSE needed

peterdavjohnson commented 3 years ago

Tim and Patrick,

When I made some changes to your code it seems to work ok:

library(DemoTools)

Deaths <- c(4.97558685, 2.25622114, 0.06666667, 0.46666933, 0.80000000, 0.26666667, 1.66666933, 2.33333333, 1.71662582, 1.20000000, 1.60000267, 1.66666667, 2.20000000, 5.93333333, 5.33333333, 4.86480818, 3.44238651, 2.09001738) Exposures <- c(177.13333, 676.66667, 733.80000, 618.13333, 496.86667, 378.60000, 302.20000, 262.66667, 241.06667, 208.40000, 167.46667, 130.60000, 106.40000, 86.46667, 68.60000, 62.66667, 53.20000, 36.60000) Age <- c(0, 1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80) AgeInt <- c(1, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)

MyLT <- lt_abridged(Deaths, Exposures, Age=Age, AgeInt=AgeInt, radix=1e+05, axmethod="un", Sex="b", region="w", mod=TRUE, OAG=FALSE, OAnew=100)

I get an e0=61.83 pj

On Wed, Jun 23, 2021 at 8:55 AM patrick-gerland @.***> wrote:

lt_abridged(Deaths, Exposures, Age, AgeInt, radix=1e+05, axmethod="un", Sex="b", region="w", mod=TRUE, OAG=FALSE, OAnew=100)

with this input data Deaths <- c(4.97558685, 2.25622114, 0.06666667, 0.46666933, 0.80000000, 0.26666667, 1.66666933, 2.33333333, 1.71662582, 1.20000000, 1.60000267, 1.66666667, 2.20000000, 5.93333333, 5.33333333, 4.86480818, 3.44238651, 2.09001738) Exposures <- c(177.13333, 676.66667, 733.80000, 618.13333, 496.86667, 378.60000, 302.20000, 262.66667, 241.06667, 208.40000, 167.46667, 130.60000, 106.40000, , 86.46667, , 68.60000, , 62.66667, , 53.20000, , 36.60000) Age <- c(0, , 1, , 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80) AgeInt <- c(1, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)

causes an error: Error in if (any(ind)) { : missing value where TRUE/FALSE needed

— 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/243, or unsubscribe https://github.com/notifications/unsubscribe-auth/APAK5QUALD5H6SPYTHANAELTUHKVDANCNFSM47FXZYOA .

patrick-gerland commented 3 years ago

Thanks Peter - you are right. Actually my problem was elsewhere for a different input series of deaths that had in some age groups negative deaths which of course are numerical artefacts that should not exist, but were created thru some unconstrained interpolations for very small population with very low mortality or no deaths in some age groups..