Smooth population counts in 5-year age groups using the Carrier-Farrag, Karup-King-Newton, Arriaga, United Nations, Strong, MAV or Zigzag methods. Allows for imputation of values in the youngest and oldest age groups for the Carrier-Farrag, Karup-King-Newton, and United Nations methods.

smooth_age_5(
  Value,
  Age,
  method = c("Carrier-Farrag", "KKN", "Arriaga", "United Nations", "Strong", "Zigzag",
    "MAV"),
  OAG = TRUE,
  ageMin = 10,
  ageMax = 65,
  n = 3,
  young.tail = c("Original", "Arriaga", "Strong", "Cascade", NA),
  old.tail = young.tail
)

Arguments

Value

numeric vector of counts in single, abridged, or 5-year age groups.

Age

integer vector of ages corresponding to the lower integer bound of the counts.

method

character string. Options include "Carrier-Farrag","Arriaga","KKN","United Nations", "Strong", MAV and "Zigzag". See details. Default "Carrier-Farrag".

OAG

logical. Whether or not the top age group is open. Default TRUE.

ageMin

integer. The lowest age included included in intermediate adjustment. Default 10. Only relevant for Strong method.

ageMax

integer. The highest age class included in intermediate adjustment. Default 65. Only relevant for Strong method.

n

integer. The width of the moving average. Default 3 intervals (x-5 to x+9). Only relevant for moving average method.

young.tail

NA or character. Method to use for ages 0-9. See details. Default "original".

old.tail

NA or character. Method to use for the final age groups. See details. Default "original".

Value

numeric vector of smoothed counts in 5-year age groups.

Details

The Carrier-Farrag, Karup-King-Newton (KKN), and Arriaga methods do not modify the totals in each 10-year age group, whereas the United Nations, Strong, Zigzag, and moving average (MAV) methods do. The age intervals of input data could be any integer structure (single, abridged, 5-year, other), but output is always in 5-year age groups. All methods except the United Nations and MAV methods operate based on 10-year age group totals, excluding the open age group.

The Carrier-Farrag, Karup-King-Newton, and United Nations methods do not produce estimates for the first and final 10-year age groups. By default, these are imputed with the original 5-year age group totals, but you can also specify to impute with NA, or the results of the Arriaga, Strong and Cascade methods. If the terminal digit of the open age group is 5, then the terminal 10-year age group shifts down, so imputations may affect more ages in this case. Imputation can follow different methods for young and old ages.

Method names are simplified using simplify.text and checked against a set of plausible matches designed to give some flexibility in case you're not sure

In accordance with the description of these methods in Arriaga (1994), it is advised to compare the results from a variety of methods.

Examples

Ages         <- seq(0, 80, by = 5)

# names a bit flexible:
cf <- smooth_age_5(Value = pop5m_pasex,
  Age = Ages,
  method = "Carrier-Farrag",
  OAG = TRUE)
# old.tail be default same as young.tail
# "cf" also works

# no need to specify tails for Arriaga or Strong
arr <- smooth_age_5(Value = pop5m_pasex,
  Age = Ages,
  method = "Arriaga",
  OAG = TRUE)
strong <- smooth_age_5(Value = pop5m_pasex,
  Age = Ages,
  method = "Strong",
  OAG = TRUE)
# other methods:
un <- smooth_age_5(Value = pop5m_pasex,
  Age = Ages,
  method = "United Nations",
  OAG = TRUE)
kkn <- smooth_age_5(Value = pop5m_pasex,
  Age = Ages,
  method = "KKN",
  OAG = TRUE)
# zigzag, not plotted.
zz <- smooth_age_5(pop5m_pasex,Ages,OAG=TRUE,method="Zigzag",ageMin = 30, ageMax = 80)
# mav, not plotted.
ma3 <- smooth_age_5(pop5m_pasex,Ages,OAG=TRUE,method="MAV",n=3)

if (FALSE) {
plot(Ages,pop5m_pasex,pch=16)
lines(Ages, cf)
lines(Ages, arr, col = "red")
lines(Ages, strong, col = "#FF000080", lwd = 3)
lines(Ages, kkn, col = "blue")
lines(Ages, un, col = "magenta")
legend("topright",
    pch=c(16,NA,NA,NA,NA,NA),
    lty = c(NA,1,1,1,1,1),
    lwd = c(NA,1,1,3,1,1),
    col = c("black","black","red","#FF000080","blue","magenta"),
    legend = c("orig 5","Carrier-Farrag","Arriaga","Strong","KKN","UN"))
}
# an extreme case:
 Age <- 0:99

 V5 <- groupAges(pop1m_pasex, Age=Age)
 Age5 <- as.integer(names(V5))
 cf2 <- smooth_age_5(Value = pop1m_pasex,
    Age = Age,
    method = "Carrier-Farrag",
    OAG = TRUE)
 st2 <- smooth_age_5(Value = pop1m_pasex,
    Age = Age,
    method = "Strong",
    OAG = TRUE)
 if (FALSE) {
 plot(Age,pop1m_pasex,pch=16)
 lines(Age,graduate_uniform(V5,Age=Age5,OAG=FALSE), lty=2, lwd = 2)
 lines(Age,graduate_uniform(cf2,Age=Age5,OAG=FALSE),col="blue")
 lines(Age,graduate_uniform(st2,Age=Age5,OAG=FALSE),col="red")
 legend("topright",
    pch=c(16,NA,NA,NA),
    lty=c(NA,2,1,1),
    col=c("black","black","blue","red"),
    lwd=c(NA,2,1,1),
    legend=c("orig single","orig 5","Carrier-Farrag","Strong"))
}

# it might make sense to do this level of smoothing as intermediate step
# in Sprague-like situation. Compare:
spr1 <- graduate_sprague(pop1m_pasex, Age=Age,OAG=FALSE)
spr2 <- graduate_sprague(cf2, Age=Age5,OAG=FALSE)
spr3 <- graduate_sprague(st2, Age=Age5,OAG=FALSE)
if (FALSE) {
plot(Age,Value,pch=16, main = "Smoothing as pre-step to graduation")
lines(Age,spr1,lty=2)
lines(Age,spr2,col="blue")
lines(Age,spr3,col="red")
legend("topright",
  pch=c(16,NA,NA,NA),
  lty=c(NA,2,1,1),
  col=c("black","black","blue","red"),
  lwd=c(NA,2,1,1),
  legend=c("orig single","orig->Sprague","C-F->Sprague","Strong->Sprague"))
}