do_smoothing: Wrapper for Smoothing Populations in 5-year Age Groups

Description Usage Arguments Details Value See Also Examples

View source: R/SmoothingMethods.R

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
do_smoothing(
  X,
  method = c("Carrier-Farrag", "KKN", "Arriaga", "United Nations", "Strong", "Zigzag",
    "MAV"),
  ageMin = 10,
  ageMax = 65,
  n = 3,
  young.tail = c("Original", "Arriaga", "Strong", NA),
  old.tail = young.tail,
  verbose = TRUE,
  ...
)

Arguments

X

Input data. UN format.

method

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

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".

verbose

Logical value. If TRUE messages are printed as the method is applied. Set verbose = FALSE to silent the function.

...

Other arguments to be passed on to other methods and functions.

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.

Value

A data.frame having the same number of columns as input data. Different numbers of rows. UN format.

See Also

smooth_age_5

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
P5 <- DDSQLtools.data$Pop5_Egypt_M_DB

M <- c("Carrier-Farrag", "KKN", "Arriaga",
       "United Nations", "Strong", "Zigzag", "MAV")

S1 <- do_smoothing(P5, method = M[1])
S2 <- do_smoothing(P5, method = M[2])
S3 <- do_smoothing(P5, method = M[3])
S4 <- do_smoothing(P5, method = M[4])
S5 <- do_smoothing(P5, method = M[5])
S6 <- do_smoothing(P5, method = M[6])
S7 <- do_smoothing(P5, method = M[7])

select_columns <- c("AgeID", "AgeStart", "AgeMid", "AgeEnd", "AgeLabel",
                    "DataTypeName", "DataTypeID", "DataValue")
S1[, select_columns]

S <- cbind(S1$DataValue, S2$DataValue, S3$DataValue,
           S4$DataValue, S5$DataValue, S6$DataValue, S7$DataValue)
dimnames(S) <- list(Age = S1$AgeLabel, SmoothingMethod = M)

S

timriffe/DDSQLtools documentation built on Oct. 6, 2021, 5:34 p.m.