PHEindicatormethods
PHEindicatormethods copied to clipboard
Why phe_life_expectancy returns all estimates as NA
Hi all. I am using your package to compute life expectancy. My dataset is small and I do not know what I need to fix or if data is damaged to get estimates. My data is next:
Input2 <- structure(list(startage = c("0", "1 - 4", "5 - 9", "10 - 14",
"15 - 19", "20 - 24", "25 - 29", "30 - 34", "35 - 39", "40 - 44",
"45 - 49", "50 - 54", "55 - 59", "60 - 64", "65 - 69", "70 - 74",
"75 - 79", "80 +"), deaths = c(1726L, 585L, 320L, 341L, 887L,
1411L, 1538L, 1390L, 1154L, 1232L, 1385L, 1604L, 1840L, 2119L,
2342L, 2790L, 3311L, 9391L), pops = c(173908, 692941, 842279,
795867, 732101, 662920, 599205, 535044, 472396, 418872, 370223,
317984, 262088, 209118, 162215, 121593, 87301, 111621)), row.names = c(NA,
-18L), class = "data.frame")
Then I use the function:
##Code
phe_life_expectancy(data = Input2,deaths = deaths,population = pops,
startage = startage,age_contents = c("0", "1 - 4", "5 - 9", "10 - 14", "15 - 19", "20 - 24",
"25 - 29", "30 - 34", "35 - 39", "40 - 44", "45 - 49", "50 - 54",
"55 - 59", "60 - 64", "65 - 69", "70 - 74", "75 - 79", "80 +"
))
And I get this message and all values for estimate with NA:
Warning message:
In phe_life_expectancy(data = Input2, deaths = deaths, population = pops, :
some groups contain a different number of age bands than 20; life expectancy cannot be calculated for these. These groups will contain NAs.
Is possible to fix the issue? Many thanks for the help.