Matches the (single) ages of a census to single cohorts. For use in intercensal interpolations. Ages are potentially blended to match single cohort line assuming that the population in each age is uniformly distributed over the age group.

shift_census_ages_to_cohorts(
  pop,
  age,
  date,
  censusYearOpt = "frac",
  OAG = TRUE
)

Arguments

pop

numeric vector. Population counts in age groups, presumably from a census with an exact reference date.

age

integer vector. Lower bound of single age groups

date

Either a Date class object or an unambiguous character string in the format "YYYY-MM-DD".

censusYearOpt

character or NA. Options include:

  • "frac" keep the partial cohort observed in the year of the census.

  • "drop" remove the partial cohort from the census year (and trim other outputs to match)

  • "extrap" inflate the partial cohort from the census year. Specifically we keep it the same as the input age 0.

  • NA return NA for the census year cohort size.

OAG

logical. Is the highest age group an open age? If TRUE

Examples

pop <- seq(10000,100,length.out = 101) age <- 0:100 d1 <- "2020-01-01" d2 <- "2020-07-01" d3 <- "2020-12-21" shift_census_ages_to_cohorts(pop, age, d1)
#> $cohort_size #> [1] 10000 9901 9802 9703 9604 9505 9406 9307 9208 9109 9010 8911 #> [13] 8812 8713 8614 8515 8416 8317 8218 8119 8020 7921 7822 7723 #> [25] 7624 7525 7426 7327 7228 7129 7030 6931 6832 6733 6634 6535 #> [37] 6436 6337 6238 6139 6040 5941 5842 5743 5644 5545 5446 5347 #> [49] 5248 5149 5050 4951 4852 4753 4654 4555 4456 4357 4258 4159 #> [61] 4060 3961 3862 3763 3664 3565 3466 3367 3268 3169 3070 2971 #> [73] 2872 2773 2674 2575 2476 2377 2278 2179 2080 1981 1882 1783 #> [85] 1684 1585 1486 1387 1288 1189 1090 991 892 793 694 595 #> [97] 496 397 298 199 #> #> $birth_year #> [1] 2019 2018 2017 2016 2015 2014 2013 2012 2011 2010 2009 2008 2007 2006 2005 #> [16] 2004 2003 2002 2001 2000 1999 1998 1997 1996 1995 1994 1993 1992 1991 1990 #> [31] 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 1975 #> [46] 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 #> [61] 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 1945 #> [76] 1944 1943 1942 1941 1940 1939 1938 1937 1936 1935 1934 1933 1932 1931 1930 #> [91] 1929 1928 1927 1926 1925 1924 1923 1922 1921 1920 #> #> $age #> [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #> [26] 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 #> [51] 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 #> [76] 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 #> #> $date #> [1] 2020 #> #> $f1 #> [1] 0 #>
shift_census_ages_to_cohorts(pop, age, d2)
#> $cohort_size #> [1] 4972.6776 9950.7705 9851.7705 9752.7705 9653.7705 9554.7705 9455.7705 #> [8] 9356.7705 9257.7705 9158.7705 9059.7705 8960.7705 8861.7705 8762.7705 #> [15] 8663.7705 8564.7705 8465.7705 8366.7705 8267.7705 8168.7705 8069.7705 #> [22] 7970.7705 7871.7705 7772.7705 7673.7705 7574.7705 7475.7705 7376.7705 #> [29] 7277.7705 7178.7705 7079.7705 6980.7705 6881.7705 6782.7705 6683.7705 #> [36] 6584.7705 6485.7705 6386.7705 6287.7705 6188.7705 6089.7705 5990.7705 #> [43] 5891.7705 5792.7705 5693.7705 5594.7705 5495.7705 5396.7705 5297.7705 #> [50] 5198.7705 5099.7705 5000.7705 4901.7705 4802.7705 4703.7705 4604.7705 #> [57] 4505.7705 4406.7705 4307.7705 4208.7705 4109.7705 4010.7705 3911.7705 #> [64] 3812.7705 3713.7705 3614.7705 3515.7705 3416.7705 3317.7705 3218.7705 #> [71] 3119.7705 3020.7705 2921.7705 2822.7705 2723.7705 2624.7705 2525.7705 #> [78] 2426.7705 2327.7705 2228.7705 2129.7705 2030.7705 1931.7705 1832.7705 #> [85] 1733.7705 1634.7705 1535.7705 1436.7705 1337.7705 1238.7705 1139.7705 #> [92] 1040.7705 941.7705 842.7705 743.7705 644.7705 545.7705 446.7705 #> [99] 347.7705 248.7705 #> #> $birth_year #> [1] 2020 2019 2018 2017 2016 2015 2014 2013 2012 2011 2010 2009 2008 2007 2006 #> [16] 2005 2004 2003 2002 2001 2000 1999 1998 1997 1996 1995 1994 1993 1992 1991 #> [31] 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 #> [46] 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 #> [61] 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 #> [76] 1945 1944 1943 1942 1941 1940 1939 1938 1937 1936 1935 1934 1933 1932 1931 #> [91] 1930 1929 1928 1927 1926 1925 1924 1923 1922 1921 #> #> $age #> [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #> [26] 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 #> [51] 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 #> [76] 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 #> #> $date #> [1] 2020.497 #> #> $f1 #> [1] 0.4972678 #>
shift_census_ages_to_cohorts(pop, age, d3)
#> $cohort_size #> [1] 9699.4536 9903.9754 9804.9754 9705.9754 9606.9754 9507.9754 9408.9754 #> [8] 9309.9754 9210.9754 9111.9754 9012.9754 8913.9754 8814.9754 8715.9754 #> [15] 8616.9754 8517.9754 8418.9754 8319.9754 8220.9754 8121.9754 8022.9754 #> [22] 7923.9754 7824.9754 7725.9754 7626.9754 7527.9754 7428.9754 7329.9754 #> [29] 7230.9754 7131.9754 7032.9754 6933.9754 6834.9754 6735.9754 6636.9754 #> [36] 6537.9754 6438.9754 6339.9754 6240.9754 6141.9754 6042.9754 5943.9754 #> [43] 5844.9754 5745.9754 5646.9754 5547.9754 5448.9754 5349.9754 5250.9754 #> [50] 5151.9754 5052.9754 4953.9754 4854.9754 4755.9754 4656.9754 4557.9754 #> [57] 4458.9754 4359.9754 4260.9754 4161.9754 4062.9754 3963.9754 3864.9754 #> [64] 3765.9754 3666.9754 3567.9754 3468.9754 3369.9754 3270.9754 3171.9754 #> [71] 3072.9754 2973.9754 2874.9754 2775.9754 2676.9754 2577.9754 2478.9754 #> [78] 2379.9754 2280.9754 2181.9754 2082.9754 1983.9754 1884.9754 1785.9754 #> [85] 1686.9754 1587.9754 1488.9754 1389.9754 1290.9754 1191.9754 1092.9754 #> [92] 993.9754 894.9754 795.9754 696.9754 597.9754 498.9754 399.9754 #> [99] 300.9754 201.9754 #> #> $birth_year #> [1] 2020 2019 2018 2017 2016 2015 2014 2013 2012 2011 2010 2009 2008 2007 2006 #> [16] 2005 2004 2003 2002 2001 2000 1999 1998 1997 1996 1995 1994 1993 1992 1991 #> [31] 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 #> [46] 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 #> [61] 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 #> [76] 1945 1944 1943 1942 1941 1940 1939 1938 1937 1936 1935 1934 1933 1932 1931 #> [91] 1930 1929 1928 1927 1926 1925 1924 1923 1922 1921 #> #> $age #> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #> [19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 #> [37] 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 #> [55] 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 #> [73] 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 #> [91] 91 92 93 94 95 96 97 98 99 100 #> #> $date #> [1] 2020.97 #> #> $f1 #> [1] 0.9699454 #>
shift_census_ages_to_cohorts(pop, age, 2020.5)
#> $cohort_size #> [1] 5000.0 9950.5 9851.5 9752.5 9653.5 9554.5 9455.5 9356.5 9257.5 9158.5 #> [11] 9059.5 8960.5 8861.5 8762.5 8663.5 8564.5 8465.5 8366.5 8267.5 8168.5 #> [21] 8069.5 7970.5 7871.5 7772.5 7673.5 7574.5 7475.5 7376.5 7277.5 7178.5 #> [31] 7079.5 6980.5 6881.5 6782.5 6683.5 6584.5 6485.5 6386.5 6287.5 6188.5 #> [41] 6089.5 5990.5 5891.5 5792.5 5693.5 5594.5 5495.5 5396.5 5297.5 5198.5 #> [51] 5099.5 5000.5 4901.5 4802.5 4703.5 4604.5 4505.5 4406.5 4307.5 4208.5 #> [61] 4109.5 4010.5 3911.5 3812.5 3713.5 3614.5 3515.5 3416.5 3317.5 3218.5 #> [71] 3119.5 3020.5 2921.5 2822.5 2723.5 2624.5 2525.5 2426.5 2327.5 2228.5 #> [81] 2129.5 2030.5 1931.5 1832.5 1733.5 1634.5 1535.5 1436.5 1337.5 1238.5 #> [91] 1139.5 1040.5 941.5 842.5 743.5 644.5 545.5 446.5 347.5 248.5 #> #> $birth_year #> [1] 2020 2019 2018 2017 2016 2015 2014 2013 2012 2011 2010 2009 2008 2007 2006 #> [16] 2005 2004 2003 2002 2001 2000 1999 1998 1997 1996 1995 1994 1993 1992 1991 #> [31] 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 #> [46] 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 #> [61] 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 #> [76] 1945 1944 1943 1942 1941 1940 1939 1938 1937 1936 1935 1934 1933 1932 1931 #> [91] 1930 1929 1928 1927 1926 1925 1924 1923 1922 1921 #> #> $age #> [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #> [26] 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 #> [51] 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 #> [76] 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 #> #> $date #> [1] 2020.5 #> #> $f1 #> [1] 0.5 #>