survRatioError | R Documentation |
This function family implements the spreadsheets from the UN repository "Adult Mortality Estimation Files/countries/JAPAN/CENSUS~1.SUR", prepared by Griffith Feeney ca 2007.
survRatioError(pop1, pop2, Age, date1, date2, exprior, OAG = TRUE)
pop1 |
numeric. Vector of population counts in 5-year age groups of census 1. |
pop2 |
numeric. Vector of population counts in 5-year age groups of census 2. |
Age |
numeric. Vector of ages corresponding to the lower integer bound of the counts. |
date1 |
date. Date of the first census. See details for ways to express it. |
date2 |
date. Date of the second census. See details for ways to express it. |
exprior |
numeric. Vector of remaining life expectancy (not e(0), see details) for same population and time but from a different source. |
OAG |
logical. Whether or not the final age group is open. Default |
The lengths of pop1
and pop2
should match. We assume that the last age group is open, and throw it out. If your last age group is not open then specify OAG = FALSE
. Dates can be given in three ways 1) a Date
class object, 2) an unambiguous character string in the format "YYYY-MM-DD"
, or 3) as a decimal date consisting in the year plus the fraction of the year passed as of the given date. Value for life expectancy at birth e(0) in exprior
should be set to NA
.
The median absolute percent error of the census survival remaining life expectancy vector compared with the external remaining life expectancy estimate (exprior
).
united1955manualDemoTools \insertRefunited1983manualDemoTools
# Based on Feeney's spreadsheets CENSUR~1.XLS, CENSUR~2.XLS, and CENSUR~3.XLS
# this is census data from Japan
# create a bunch of data to show the three variants.
pop1960 <- c(3831870,4502304,5397061,4630775,4193184,4114704,3770907,3274822,
2744786,2559755,2160716,1839025,1494043,1133409,870238,577972,313781,131547)
pop1965 <- c(3983902,3854281,4513237,5373547,4572392,4206801,4110076,3751030,
3231736,2697217,2485095,2071540,1719370,1343444,955567,644043,341170,176068)
pop1970 <- c(4292503,3988292,3852101,4492096,5347327,4571868,4190340,4085338,
3674127,3198934,2648360,2382691,1970485,1584699,1172155,736258,408191,53116)
Age <- seq(0, 85, by = 5)
date1960 <- "1960-10-01"
date1965 <- "1965-10-01"
date1970 <- "1970-10-01"
date1960fake <- "1960-10-05"
ex1 <- c(NA,69.45,64.62,59.72,54.87,50.11,45.37,40.65,35.99,
31.40,26.94,22.64,18.52,14.67,11.20,8.25,5.95,6.00)
ex2 <- c(NA,70.19,65.33,60.41,55.54,50.74,45.96,41.21,
36.52,31.89,27.39,23.05,18.89,14.99,11.45,8.43,6.06)
# reproduces CENSUR~1.XLS
# this method called under the hood when censuses are a clean 10 years apart
(s10 <- survRatioError(
pop1 = pop1960,
pop2 = pop1970,
Age = Age,
date1 = date1960,
date2 = date1970,
exprior = ex1)) #.44
# reproduces CENSUR~3.XLS
# this method called under the hood when censuses are a clean 5 years apart
(s5 <- survRatioError(
pop1 = pop1965,
pop2 = pop1970,
Age = Age,
date1 = date1965,
date2 = date1970,
exprior = ex2)) #.40
# reproduces CENSUR~2.XLS (if indeed censuses are oddly spaced)
# this method called under the hood when censuses are not spaced
# a clean 5 or 10 years apart.
(sn <- survRatioError(
pop1 = pop1960,
pop2 = pop1970,
Age = Age,
date1 = date1960fake,
date2 = date1970,
exprior = ex1)) # 1.067818
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.