timriffe / DemoTools

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

"United Nations" method for smooth_age_5() may return negatives #274

Open TTRustam opened 2 weeks ago

TTRustam commented 2 weeks ago

Hello,

Please review the "United Nations" method in the smooth_age_5() function. It occasionally returns negative values when using hypothetical data, which should not happen. We should consider adding a warning and further clarification to the help documentation or implementing a fix. Additionally, please verify the adequacy of the provided example.

For instance, the following example (see age 10) shows unexpected behaviour with synthetic data:

deaths <- c(10266, 618, 411, 755, 1098, 1100, 1357, 1335, 3257, 2200, 4023, 2167, 4578, 2956, 4212, 2887, 2351, 1500, 900, 500, 300)

age <- seq(0, 100, 5)

smooth_age_5(Value = deaths, Age = age, method = "United Nations")