A wrapper function for several graduation methods, primarily for count data ("sprague", "beers(ord)", "beers(mod)", "grabill", "mono" (Monotonic spline), "uniform", "pclm"), but also with one ("pclm") with an option for graduating rates if both event counts and population at risk are available.

graduate(
  Value,
  Age,
  AgeInt = age2int(Age),
  OAG = TRUE,
  OAnew = max(Age),
  method = c("sprague", "beers(ord)", "beers(mod)", "grabill", "pclm", "mono",
    "uniform"),
  keep0 = FALSE,
  constrain = FALSE,
  ...
)

Arguments

Value

numeric vector, presumably counts in grouped ages

Age

integer vector, lower bounds of age groups

AgeInt

integer vector, age interval widths

OAG

logical, default = TRUE is the final age group open?

OAnew

integer, optional new open age, higher than max(Age). See details.

method

character, either "sprague", "beers(ord)"), "beers(mod)"), "mono"), "uniform"), or "pclm"

keep0

logical. Default FALSE. If available, should the value in the infant age group be maintained, and ages 1-4 constrained?

constrain

logical. Default FALSE. Should output be constrained to sum within the input age groups?

...

extra arguments passed to graduate_beers() or graduate_pclm()

Details

"sprague", "beers(ord)", "beers(mod)" methods require original data to be in uniform five-year age groups. If they are not (for example, the infant group is separate) then they are grouped to uniform width prior to splitting. If you want to keep the original infant count in output, then specify keep0 = TRUE. In this case, it is imputed, and ages 1-4 are rescaled, which may introduce a discontinuity in results from age 4 to 5. keep0 = TRUE may also be desired along with method = "pclm".

Some methods are constrained, others not, and others are optionally constrained. If this is required, then this function can be followed up with rescaleAgeGroups(), which may have the effect of breaking continuity in smooth results. This is inconsequential for downstream demography, but if this aesthetic side effect is undesired, then try one of the constrained methods: "sprague", "mono", "pclm" (with control = list(lambda = 1/1e7) specified or similar).

Beers may either be ordinary "beers(ord)" or modified "beers(mod)", and either can pass on the optional argument johnson = TRUE if desired (this has a different distribution pattern for young ages, FALSE by default). If method = "beers" is given, then "beers(ord)" is used.

This wrapper standardizes some inconsistencies in how open ages are dealt with. For example, with the "pclm" method, the last age group can be redistributed over a specified interval implied by increase OAnew beyond the range of Age. To get this same behavior from "mono", or "uniform" specify OAG = FALSE along with an appropriately high OAnew (or integer final value of AgeInt.

OAnew cannot be higher than max(Age)+4 for "sprague" or "beers" methods. For "uniform","mono","pclm" it can be higher than this, and in each case the open age group is completely redistributed within this range, meaning it's not really open anymore.

For all methods, negative values are detected in output. If present, we deal with these in the following way: we take the geometric mean between the given output (with negative imputed with 0s) and the output of graduate_mono(), which is guaranteed non-negative. This only affects age groups where negatives were produced in the first pass. In our experience this only arises when using Sprague, Beers, or Grabill methods, whereas all others are guaranteed non-negative.

For any case where input data are in single ages, constraining results to sum to values in the original age groups will simply return the original input data, which is clearly not your intent. This might arise when using graduation as an implicit two-step smoother (group + graduate). In this case, separate the steps, first group using groupAges() then use graduate(..., constrain = TRUE).

References

Pascariu MD, Dańko MJ, Schöley J, Rizzi S (2018). “ungroup: An R package for efficient estimation of smooth distributions from coarsely binned data.” Age, 10, 0. Rizzi S, Gampe J, Eilers PH (2015). “Efficient estimation of smooth distributions from coarsely grouped data.” American journal of epidemiology, 182(2), 138--147. Sprague TB (1880). “Explanation of a new formula for interpolation.” Journal of the Institute of Actuaries, 22(4), 270--285. Shryock HS, Siegel JS, Larmon EA (1973). The methods and materials of demography. US Bureau of the Census. Siegel Jacob S, Swanson David A (eds.) (2004). The Methods and Materials of Demography, 2 edition. Elsevier Academic Press, California, USA, San Diego, USA. Beers HS (1945). “Modified-interpolation formulas that minimize fourth differences.” Record of the American Institute of Actuaries, 34(69), 14--20.

See also

Examples

Value <- pop5_mat[, 1] Value <- c(10000,44170,Value[-1]) Age <- sort(c(1,seq(0,100,by=5))) graduate(Value, Age, method = "sprague")
#> 0 1 2 3 4 5 6 #> 12172.4912 11380.4480 10717.4480 10171.0000 9728.6128 9377.7952 9106.0560 #> 7 8 9 10 11 12 13 #> 8900.9040 8749.8480 8640.3968 8573.6144 8550.5648 8490.9808 8355.2608 #> 14 15 16 17 18 19 20 #> 8171.5792 8008.3808 7852.7792 7694.2592 7534.6752 7373.9056 7210.8208 #> 21 22 23 24 25 26 27 #> 7046.6624 6881.6064 6715.9664 6550.9440 6386.5216 6221.6160 6065.6560 #> 28 29 30 31 32 33 34 #> 5922.9920 5789.2144 5656.4784 5527.4512 5393.8752 5251.2032 5103.9920 #> 35 36 37 38 39 40 41 #> 4958.4544 4809.8784 4676.3904 4566.5184 4469.7584 4372.0480 4282.1632 #> 42 43 44 45 46 47 48 #> 4161.7152 3992.0912 3793.9824 3600.3712 3397.0752 3237.6592 3149.6752 #> 49 50 51 52 53 54 55 #> 3104.2192 3052.7728 3014.5648 2923.2688 2744.0448 2513.3488 2294.2640 #> 56 57 58 59 60 61 62 #> 2064.3184 1897.9424 1835.3744 1836.1008 1826.9504 1831.6544 1779.1824 #> 63 64 65 66 67 68 69 #> 1629.7344 1422.4784 1231.8448 1037.5024 891.8304 826.6464 813.1760 #> 70 71 72 73 74 75 76 #> 792.0960 776.7936 745.8176 683.0176 601.2752 529.6992 462.5600 #> 77 78 79 80 81 82 83 #> 401.2800 349.5120 304.9488 261.4336 219.9616 183.1696 151.6816 #> 84 85 86 87 88 89 90 #> 124.7536 100.7200 79.5568 61.8448 47.5888 36.2896 27.1456 #> 91 92 93 94 95 96 97 #> 19.9600 14.5360 10.5760 7.7824 5.8576 4.5040 3.4240 #> 98 99 100 #> 2.3200 0.8944 0.0000
graduate(Value, Age, method = "sprague", keep0=FALSE)
#> 0 1 2 3 4 5 6 #> 12172.4912 11380.4480 10717.4480 10171.0000 9728.6128 9377.7952 9106.0560 #> 7 8 9 10 11 12 13 #> 8900.9040 8749.8480 8640.3968 8573.6144 8550.5648 8490.9808 8355.2608 #> 14 15 16 17 18 19 20 #> 8171.5792 8008.3808 7852.7792 7694.2592 7534.6752 7373.9056 7210.8208 #> 21 22 23 24 25 26 27 #> 7046.6624 6881.6064 6715.9664 6550.9440 6386.5216 6221.6160 6065.6560 #> 28 29 30 31 32 33 34 #> 5922.9920 5789.2144 5656.4784 5527.4512 5393.8752 5251.2032 5103.9920 #> 35 36 37 38 39 40 41 #> 4958.4544 4809.8784 4676.3904 4566.5184 4469.7584 4372.0480 4282.1632 #> 42 43 44 45 46 47 48 #> 4161.7152 3992.0912 3793.9824 3600.3712 3397.0752 3237.6592 3149.6752 #> 49 50 51 52 53 54 55 #> 3104.2192 3052.7728 3014.5648 2923.2688 2744.0448 2513.3488 2294.2640 #> 56 57 58 59 60 61 62 #> 2064.3184 1897.9424 1835.3744 1836.1008 1826.9504 1831.6544 1779.1824 #> 63 64 65 66 67 68 69 #> 1629.7344 1422.4784 1231.8448 1037.5024 891.8304 826.6464 813.1760 #> 70 71 72 73 74 75 76 #> 792.0960 776.7936 745.8176 683.0176 601.2752 529.6992 462.5600 #> 77 78 79 80 81 82 83 #> 401.2800 349.5120 304.9488 261.4336 219.9616 183.1696 151.6816 #> 84 85 86 87 88 89 90 #> 124.7536 100.7200 79.5568 61.8448 47.5888 36.2896 27.1456 #> 91 92 93 94 95 96 97 #> 19.9600 14.5360 10.5760 7.7824 5.8576 4.5040 3.4240 #> 98 99 100 #> 2.3200 0.8944 0.0000
graduate(Value, Age, method = "beers(ord)")
#> 0 1 2 3 4 5 6 #> 11932.7336 11342.3240 10788.6128 10280.2888 9826.0408 9435.4048 9117.0696 #> 7 8 9 10 11 12 13 #> 8877.1824 8717.6544 8627.6888 8582.9336 8547.1760 8479.1200 8351.8720 #> 14 15 16 17 18 19 20 #> 8180.8984 8008.1091 7852.8780 7694.6050 7534.7740 7373.6339 7210.9429 #> 21 22 23 24 25 26 27 #> 7046.6180 6881.4510 6715.9220 6551.0661 6385.3171 6222.0540 6067.1890 #> 28 29 30 31 32 33 34 #> 5923.4300 5788.0099 5657.7302 5526.9960 5392.2820 5250.7480 5105.2438 #> 35 36 37 38 39 40 41 #> 4955.8375 4810.8300 4679.7210 4567.4700 4467.1415 4377.4523 4280.1980 #> 42 43 44 45 46 47 48 #> 4154.8370 3990.1260 3799.3867 3592.6085 3399.8980 3247.5390 3152.4980 #> 49 50 51 52 53 54 55 #> 3096.4565 3062.5760 3011.0000 2910.7920 2740.4800 2523.1520 2283.1606 #> 56 57 58 59 60 61 62 #> 2068.3560 1912.0740 1839.4120 1824.9974 1837.8085 1827.7060 1765.3630 #> 63 64 65 66 67 68 69 #> 1625.7860 1433.3365 1223.5134 1040.5320 902.4340 829.6760 804.8446 #> 70 71 72 73 74 75 76 #> 796.0879 775.3420 740.7370 681.5660 605.2671 528.8797 462.8580 #> 77 78 79 80 81 82 83 #> 402.3230 349.8100 304.1293 261.2455 220.0300 183.4090 151.7500 #> 84 85 86 87 88 89 90 #> 124.5655 100.6507 79.5820 61.9330 47.6140 36.2203 27.2401 #> 91 92 93 94 95 96 97 #> 20.1994 14.7124 10.4941 7.3540 5.1331 3.6913 2.8948 #> 98 99 100 #> 2.6035 2.6773 0.0000
graduate(Value, Age, method = "beers(ord)", keep0=TRUE)
#> 0 1 2 3 4 5 6 #> 10000.0000 11861.3370 11282.2886 10750.7042 10275.6703 9435.4048 9117.0696 #> 7 8 9 10 11 12 13 #> 8877.1824 8717.6544 8627.6888 8582.9336 8547.1760 8479.1200 8351.8720 #> 14 15 16 17 18 19 20 #> 8180.8984 8008.1091 7852.8780 7694.6050 7534.7740 7373.6339 7210.9429 #> 21 22 23 24 25 26 27 #> 7046.6180 6881.4510 6715.9220 6551.0661 6385.3171 6222.0540 6067.1890 #> 28 29 30 31 32 33 34 #> 5923.4300 5788.0099 5657.7302 5526.9960 5392.2820 5250.7480 5105.2438 #> 35 36 37 38 39 40 41 #> 4955.8375 4810.8300 4679.7210 4567.4700 4467.1415 4377.4523 4280.1980 #> 42 43 44 45 46 47 48 #> 4154.8370 3990.1260 3799.3867 3592.6085 3399.8980 3247.5390 3152.4980 #> 49 50 51 52 53 54 55 #> 3096.4565 3062.5760 3011.0000 2910.7920 2740.4800 2523.1520 2283.1606 #> 56 57 58 59 60 61 62 #> 2068.3560 1912.0740 1839.4120 1824.9974 1837.8085 1827.7060 1765.3630 #> 63 64 65 66 67 68 69 #> 1625.7860 1433.3365 1223.5134 1040.5320 902.4340 829.6760 804.8446 #> 70 71 72 73 74 75 76 #> 796.0879 775.3420 740.7370 681.5660 605.2671 528.8797 462.8580 #> 77 78 79 80 81 82 83 #> 402.3230 349.8100 304.1293 261.2455 220.0300 183.4090 151.7500 #> 84 85 86 87 88 89 90 #> 124.5655 100.6507 79.5820 61.9330 47.6140 36.2203 27.2401 #> 91 92 93 94 95 96 97 #> 20.1994 14.7124 10.4941 7.3540 5.1331 3.6913 2.8948 #> 98 99 100 #> 2.6035 2.6773 0.0000
graduate(Value, Age, method = "beers(ord)", keep0=TRUE, johnson = TRUE)
#> 0 1 2 3 4 5 6 #> 10000.0000 11342.3240 11462.1335 11023.6236 10341.9189 9651.0947 9097.9694 #> 7 8 9 10 11 12 13 #> 8762.3499 8635.8972 8627.6888 8582.9336 8547.1760 8479.1200 8351.8720 #> 14 15 16 17 18 19 20 #> 8180.8984 8008.1091 7852.8780 7694.6050 7534.7740 7373.6339 7210.9429 #> 21 22 23 24 25 26 27 #> 7046.6180 6881.4510 6715.9220 6551.0661 6385.3171 6222.0540 6067.1890 #> 28 29 30 31 32 33 34 #> 5923.4300 5788.0099 5657.7302 5526.9960 5392.2820 5250.7480 5105.2438 #> 35 36 37 38 39 40 41 #> 4955.8375 4810.8300 4679.7210 4567.4700 4467.1415 4377.4523 4280.1980 #> 42 43 44 45 46 47 48 #> 4154.8370 3990.1260 3799.3867 3592.6085 3399.8980 3247.5390 3152.4980 #> 49 50 51 52 53 54 55 #> 3096.4565 3062.5760 3011.0000 2910.7920 2740.4800 2523.1520 2283.1606 #> 56 57 58 59 60 61 62 #> 2068.3560 1912.0740 1839.4120 1824.9974 1837.8085 1827.7060 1765.3630 #> 63 64 65 66 67 68 69 #> 1625.7860 1433.3365 1223.5134 1040.5320 902.4340 829.6760 804.8446 #> 70 71 72 73 74 75 76 #> 796.0879 775.3420 740.7370 681.5660 605.2671 528.8797 462.8580 #> 77 78 79 80 81 82 83 #> 402.3230 349.8100 304.1293 261.2455 220.0300 183.4090 151.7500 #> 84 85 86 87 88 89 90 #> 124.5655 100.6507 79.5820 61.9330 47.6140 36.2203 27.2401 #> 91 92 93 94 95 96 97 #> 20.1994 14.7124 10.4941 7.3540 5.1331 3.6913 2.8948 #> 98 99 100 #> 2.6035 2.6773 0.0000
graduate(Value, Age, method = "beers(mod)")
#> 0 1 2 3 4 5 6 #> 11952.2354 11325.4173 10766.2996 10274.8823 9851.1654 9494.3017 9201.8161 #> 7 8 9 10 11 12 13 #> 8969.8051 8790.9099 8653.8682 8546.7035 8455.2302 8364.7480 8264.2114 #> 14 15 16 17 18 19 20 #> 8146.8109 8009.2966 7855.8211 7697.9395 7537.0673 7374.4965 7210.6243 #> 21 22 23 24 25 26 27 #> 7045.7255 6879.9525 6714.4613 6550.4634 6389.8558 6233.6499 6081.9715 #> 28 29 30 31 32 33 34 #> 5935.0481 5792.5597 5653.0084 5514.9350 5376.9190 5238.6834 5100.5202 #> 35 36 37 38 39 40 41 #> 4965.5251 4835.6769 4711.8375 4593.0579 4477.1996 4357.2582 4228.5099 #> 42 43 44 45 46 47 48 #> 4088.5115 3937.6585 3778.8029 3621.7683 3474.4487 3342.8085 3227.5557 #> 49 50 51 52 53 54 55 #> 3125.8698 3025.7427 2916.8358 2790.4800 2645.7098 2486.0157 2325.0249 #> 56 57 58 59 60 61 62 #> 2175.3008 2048.3430 1946.4600 1866.9133 1796.7846 1722.9549 1632.1045 #> 63 64 65 66 67 68 69 #> 1521.2719 1392.4311 1255.2308 1121.3870 1004.6830 909.3898 835.9914 #> 70 71 72 73 74 75 76 #> 780.7211 736.2617 691.7455 643.7115 590.5132 532.0976 471.0073 #> 77 78 79 80 81 82 83 #> 412.3805 357.4547 307.0949 261.9439 221.8201 185.7175 153.5851 #> 84 85 86 87 88 89 90 #> 125.2864 100.8658 80.1571 62.7835 48.3745 36.5281 26.8663 #> 91 92 93 94 95 96 97 #> 19.0789 12.9361 8.2390 4.8817 2.7712 1.8763 2.1907 #> 98 99 100 #> 3.7144 6.4474 0.0000
graduate(Value, Age, method = "beers(mod)", keep0=TRUE)
#> 0 1 2 3 4 5 6 #> 10000.0000 11849.1277 11264.1552 10750.0138 10306.7033 9494.3017 9201.8161 #> 7 8 9 10 11 12 13 #> 8969.8051 8790.9099 8653.8682 8546.7035 8455.2302 8364.7480 8264.2114 #> 14 15 16 17 18 19 20 #> 8146.8109 8009.2966 7855.8211 7697.9395 7537.0673 7374.4965 7210.6243 #> 21 22 23 24 25 26 27 #> 7045.7255 6879.9525 6714.4613 6550.4634 6389.8558 6233.6499 6081.9715 #> 28 29 30 31 32 33 34 #> 5935.0481 5792.5597 5653.0084 5514.9350 5376.9190 5238.6834 5100.5202 #> 35 36 37 38 39 40 41 #> 4965.5251 4835.6769 4711.8375 4593.0579 4477.1996 4357.2582 4228.5099 #> 42 43 44 45 46 47 48 #> 4088.5115 3937.6585 3778.8029 3621.7683 3474.4487 3342.8085 3227.5557 #> 49 50 51 52 53 54 55 #> 3125.8698 3025.7427 2916.8358 2790.4800 2645.7098 2486.0157 2325.0249 #> 56 57 58 59 60 61 62 #> 2175.3008 2048.3430 1946.4600 1866.9133 1796.7846 1722.9549 1632.1045 #> 63 64 65 66 67 68 69 #> 1521.2719 1392.4311 1255.2308 1121.3870 1004.6830 909.3898 835.9914 #> 70 71 72 73 74 75 76 #> 780.7211 736.2617 691.7455 643.7115 590.5132 532.0976 471.0073 #> 77 78 79 80 81 82 83 #> 412.3805 357.4547 307.0949 261.9439 221.8201 185.7175 153.5851 #> 84 85 86 87 88 89 90 #> 125.2864 100.8658 80.1571 62.7835 48.3745 36.5281 26.8663 #> 91 92 93 94 95 96 97 #> 19.0789 12.9361 8.2390 4.8817 2.7712 1.8763 2.1907 #> 98 99 100 #> 3.7144 6.4474 0.0000
graduate(Value, Age, method = "beers(mod)", keep0=TRUE, johnson = TRUE)
#> 0 1 2 3 4 5 6 #> 10000.0000 11325.4173 11441.7180 11025.7228 10377.1420 9717.5927 9184.3461 #> 7 8 9 10 11 12 13 #> 8850.5817 8704.3123 8653.8682 8546.7035 8455.2302 8364.7480 8264.2114 #> 14 15 16 17 18 19 20 #> 8146.8109 8009.2966 7855.8211 7697.9395 7537.0673 7374.4965 7210.6243 #> 21 22 23 24 25 26 27 #> 7045.7255 6879.9525 6714.4613 6550.4634 6389.8558 6233.6499 6081.9715 #> 28 29 30 31 32 33 34 #> 5935.0481 5792.5597 5653.0084 5514.9350 5376.9190 5238.6834 5100.5202 #> 35 36 37 38 39 40 41 #> 4965.5251 4835.6769 4711.8375 4593.0579 4477.1996 4357.2582 4228.5099 #> 42 43 44 45 46 47 48 #> 4088.5115 3937.6585 3778.8029 3621.7683 3474.4487 3342.8085 3227.5557 #> 49 50 51 52 53 54 55 #> 3125.8698 3025.7427 2916.8358 2790.4800 2645.7098 2486.0157 2325.0249 #> 56 57 58 59 60 61 62 #> 2175.3008 2048.3430 1946.4600 1866.9133 1796.7846 1722.9549 1632.1045 #> 63 64 65 66 67 68 69 #> 1521.2719 1392.4311 1255.2308 1121.3870 1004.6830 909.3898 835.9914 #> 70 71 72 73 74 75 76 #> 780.7211 736.2617 691.7455 643.7115 590.5132 532.0976 471.0073 #> 77 78 79 80 81 82 83 #> 412.3805 357.4547 307.0949 261.9439 221.8201 185.7175 153.5851 #> 84 85 86 87 88 89 90 #> 125.2864 100.8658 80.1571 62.7835 48.3745 36.5281 26.8663 #> 91 92 93 94 95 96 97 #> 19.0789 12.9361 8.2390 4.8817 2.7712 1.8763 2.1907 #> 98 99 100 #> 3.7144 6.4474 0.0000
graduate(Value, Age, method = "mono")
#> 0 1 2 3 4 5 #> 10000.000000 10850.481727 11280.016176 11257.267224 10782.234872 9965.472958 #> 6 7 8 9 10 11 #> 9249.196842 8743.960363 8449.763521 8366.606317 8447.848263 8506.927414 #> 12 13 14 15 16 17 #> 8497.203282 8418.675868 8271.345172 8069.013989 7866.893502 7678.786508 #> 18 19 20 21 22 23 #> 7504.693006 7344.612996 7195.295781 7043.738577 6886.690686 6724.152109 #> 24 25 26 27 28 29 #> 6556.122846 6385.146886 6221.400190 6067.426747 5923.226557 5788.799621 #> 30 31 32 33 34 35 #> 5661.452674 5530.412664 5392.986327 5249.173663 5098.974671 4946.090416 #> 36 37 38 39 40 41 #> 4805.325153 4680.379945 4571.254792 4477.949695 4392.929661 4286.054725 #> 42 43 44 45 46 47 #> 4149.789895 3984.135169 3789.090550 3576.638938 3394.711946 3255.292477 #> 48 49 50 51 52 53 #> 3158.380531 3103.976107 3076.530586 3013.849489 2900.384196 2736.134707 #> 54 55 56 57 58 59 #> 2521.101022 2273.886718 2068.906098 1924.762739 1841.456641 1818.987804 #> 60 61 62 63 64 65 #> 1838.178543 1822.318119 1752.228848 1627.910728 1449.363761 1233.631109 #> 66 67 68 69 70 71 #> 1048.885424 912.169870 823.484446 782.829152 779.113021 767.972184 #> 72 73 74 75 76 77 #> 738.315673 690.143490 623.455633 542.884808 466.961841 400.319437 #> 78 79 80 81 82 83 #> 342.957596 294.876318 254.979747 218.884453 185.494579 154.810127 #> 84 85 86 87 88 89 #> 126.831094 101.692205 79.932348 61.686245 46.953897 35.735304 #> 90 91 92 93 94 95 #> 27.603433 20.850155 15.048439 10.198284 6.299690 3.438064 #> 96 97 98 99 100 #> 1.955032 1.936000 3.380968 6.289936 0.000000
graduate(Value, Age, method = "mono", keep0=TRUE)
#> 0 1 2 3 4 5 #> 10000.000000 10850.481727 11280.016176 11257.267224 10782.234872 9965.472958 #> 6 7 8 9 10 11 #> 9249.196842 8743.960363 8449.763521 8366.606317 8447.848263 8506.927414 #> 12 13 14 15 16 17 #> 8497.203282 8418.675868 8271.345172 8069.013989 7866.893502 7678.786508 #> 18 19 20 21 22 23 #> 7504.693006 7344.612996 7195.295781 7043.738577 6886.690686 6724.152109 #> 24 25 26 27 28 29 #> 6556.122846 6385.146886 6221.400190 6067.426747 5923.226557 5788.799621 #> 30 31 32 33 34 35 #> 5661.452674 5530.412664 5392.986327 5249.173663 5098.974671 4946.090416 #> 36 37 38 39 40 41 #> 4805.325153 4680.379945 4571.254792 4477.949695 4392.929661 4286.054725 #> 42 43 44 45 46 47 #> 4149.789895 3984.135169 3789.090550 3576.638938 3394.711946 3255.292477 #> 48 49 50 51 52 53 #> 3158.380531 3103.976107 3076.530586 3013.849489 2900.384196 2736.134707 #> 54 55 56 57 58 59 #> 2521.101022 2273.886718 2068.906098 1924.762739 1841.456641 1818.987804 #> 60 61 62 63 64 65 #> 1838.178543 1822.318119 1752.228848 1627.910728 1449.363761 1233.631109 #> 66 67 68 69 70 71 #> 1048.885424 912.169870 823.484446 782.829152 779.113021 767.972184 #> 72 73 74 75 76 77 #> 738.315673 690.143490 623.455633 542.884808 466.961841 400.319437 #> 78 79 80 81 82 83 #> 342.957596 294.876318 254.979747 218.884453 185.494579 154.810127 #> 84 85 86 87 88 89 #> 126.831094 101.692205 79.932348 61.686245 46.953897 35.735304 #> 90 91 92 93 94 95 #> 27.603433 20.850155 15.048439 10.198284 6.299690 3.438064 #> 96 97 98 99 100 #> 1.955032 1.936000 3.380968 6.289936 0.000000
graduate(Value, Age, method = "uniform")
#> 0 1 2 3 4 5 6 7 8 9 #> 10000.0 11042.5 11042.5 11042.5 11042.5 8955.0 8955.0 8955.0 8955.0 8955.0 #> 10 11 12 13 14 15 16 17 18 19 #> 8428.4 8428.4 8428.4 8428.4 8428.4 7692.8 7692.8 7692.8 7692.8 7692.8 #> 20 21 22 23 24 25 26 27 28 29 #> 6881.2 6881.2 6881.2 6881.2 6881.2 6077.2 6077.2 6077.2 6077.2 6077.2 #> 30 31 32 33 34 35 36 37 38 39 #> 5386.6 5386.6 5386.6 5386.6 5386.6 4696.2 4696.2 4696.2 4696.2 4696.2 #> 40 41 42 43 44 45 46 47 48 49 #> 4120.4 4120.4 4120.4 4120.4 4120.4 3297.8 3297.8 3297.8 3297.8 3297.8 #> 50 51 52 53 54 55 56 57 58 59 #> 2849.6 2849.6 2849.6 2849.6 2849.6 1985.6 1985.6 1985.6 1985.6 1985.6 #> 60 61 62 63 64 65 66 67 68 69 #> 1698.0 1698.0 1698.0 1698.0 1698.0 960.2 960.2 960.2 960.2 960.2 #> 70 71 72 73 74 75 76 77 78 79 #> 719.8 719.8 719.8 719.8 719.8 409.6 409.6 409.6 409.6 409.6 #> 80 81 82 83 84 85 86 87 88 89 #> 188.2 188.2 188.2 188.2 188.2 65.2 65.2 65.2 65.2 65.2 #> 90 91 92 93 94 95 96 97 98 99 #> 16.0 16.0 16.0 16.0 16.0 3.4 3.4 3.4 3.4 3.4 #> 100 #> 0.0
graduate(Value, Age, method = "pclm")
#> #> 0s detected in Value, replacing with .01
#> 0 1 2 3 4 5 #> 10022.215013 10787.284952 11254.927495 11275.878141 10807.945737 10074.820067 #> 6 7 8 9 10 11 #> 9328.990796 8736.954126 8394.295366 8273.423000 8318.186994 8432.063491 #> 12 13 14 15 16 17 #> 8510.161955 8497.041470 8366.763507 8151.826000 7903.088751 7662.043415 #> 18 19 20 21 22 23 #> 7459.549206 7296.415870 7161.468953 7035.158379 6896.994675 6740.483732 #> 24 25 26 27 28 29 #> 6566.732244 6387.046021 6215.809887 6060.718142 5925.006272 5801.820878 #> 30 31 32 33 34 35 #> 5679.677222 5548.087900 5398.664503 5234.736788 5066.280979 4908.166239 #> 36 37 38 39 40 41 #> 4776.279043 4674.568329 4598.978894 4531.953370 4447.596301 4325.842633 #> 42 43 44 45 46 47 #> 4153.829634 3942.404051 3717.819885 3511.257711 3353.616522 3254.024393 #> 48 49 50 51 52 53 #> 3206.437472 3185.637396 3149.057772 3061.485892 2899.842199 2676.396203 #> 54 55 56 57 58 59 #> 2430.918221 2205.098826 2036.292267 1935.380958 1895.250695 1894.349683 #> 60 61 62 63 64 65 #> 1891.968479 1851.208654 1745.246502 1577.503188 1381.551771 1192.259170 #> 66 67 68 69 70 71 #> 1038.630147 929.284819 859.268152 818.952155 792.502498 766.383285 #> 72 73 74 75 76 77 #> 729.250203 676.034500 610.317889 538.451097 468.334362 404.620404 #> 78 79 80 81 82 83 #> 348.592969 299.925248 257.029245 218.669115 184.007169 152.690106 #> 84 85 86 87 88 89 #> 124.764414 100.308814 79.376504 61.864847 47.546364 36.083333 #> 90 91 92 93 94 95 #> 27.083527 20.136500 14.849153 10.872898 7.911233 5.723911 #> 96 97 98 99 100 #> 4.120705 2.953872 2.110491 1.504532 1.071260
graduate(Value, Age, method = "pclm", keep0=TRUE)
#> #> 0s detected in Value, replacing with .01
#> 0 1 2 3 4 5 #> 10000.000000 10798.032545 11266.141010 11287.112529 10818.713915 10074.820067 #> 6 7 8 9 10 11 #> 9328.990796 8736.954126 8394.295366 8273.423000 8318.186994 8432.063491 #> 12 13 14 15 16 17 #> 8510.161955 8497.041470 8366.763507 8151.826000 7903.088751 7662.043415 #> 18 19 20 21 22 23 #> 7459.549206 7296.415870 7161.468953 7035.158379 6896.994675 6740.483732 #> 24 25 26 27 28 29 #> 6566.732244 6387.046021 6215.809887 6060.718142 5925.006272 5801.820878 #> 30 31 32 33 34 35 #> 5679.677222 5548.087900 5398.664503 5234.736788 5066.280979 4908.166239 #> 36 37 38 39 40 41 #> 4776.279043 4674.568329 4598.978894 4531.953370 4447.596301 4325.842633 #> 42 43 44 45 46 47 #> 4153.829634 3942.404051 3717.819885 3511.257711 3353.616522 3254.024393 #> 48 49 50 51 52 53 #> 3206.437472 3185.637396 3149.057772 3061.485892 2899.842199 2676.396203 #> 54 55 56 57 58 59 #> 2430.918221 2205.098826 2036.292267 1935.380958 1895.250695 1894.349683 #> 60 61 62 63 64 65 #> 1891.968479 1851.208654 1745.246502 1577.503188 1381.551771 1192.259170 #> 66 67 68 69 70 71 #> 1038.630147 929.284819 859.268152 818.952155 792.502498 766.383285 #> 72 73 74 75 76 77 #> 729.250203 676.034500 610.317889 538.451097 468.334362 404.620404 #> 78 79 80 81 82 83 #> 348.592969 299.925248 257.029245 218.669115 184.007169 152.690106 #> 84 85 86 87 88 89 #> 124.764414 100.308814 79.376504 61.864847 47.546364 36.083333 #> 90 91 92 93 94 95 #> 27.083527 20.136500 14.849153 10.872898 7.911233 5.723911 #> 96 97 98 99 100 #> 4.120705 2.953872 2.110491 1.504532 1.071260
# pclm can also graduate rates if both # numerators and denominators are on hand: Exposures <- c(100958,466275,624134,559559,446736,370653,301862,249409, 247473,223014,172260,149338,127242,105715,79614,53660, 31021,16805,8000,4000,2000,1000) Deaths <- c(8674,1592,618,411,755,1098,1100,1357, 1335,3257,2200,4023,2167,4578,2956,4212, 2887,2351,1500,900,500,300) Age <- c(0, 1, seq(5, 100, by = 5)) AgeInt <- c(diff(Age), NA) # exclude infants for better fit. mx <- graduate( Value = Deaths[-1], Age = Age[-1], AgeInt = AgeInt[-1], OAG = TRUE, OAnew = 110, offset = Exposures[-1], method = "pclm") mx_sm <- graduate( Value = Deaths[-1], Age = Age[-1], AgeInt = AgeInt[-1], OAG = TRUE, OAnew = 110, offset = Exposures[-1], method = "pclm", control = list(lambda = 1e7)) if (FALSE) { plot(Age, Deaths / Exposures, type = 's', log = 'y', main = "Underlying data have differential heaping on 0s and 5s") lines(1:110, mx) lines(1:110, mx_sm, col = "blue") legend("bottomright", col = c("black","blue"), lty = c(1, 1), legend = c("lambda optimized (almost constrained)", "higher lambda = smoother") ) }