For single age count data, perturb the data in such a way as to induce heaping on ages ending in 0 and 5. This is a common phenomenon that several age heaping evaluation methods are designed to test for. In order to estimate how these methods respond to different degrees of heaping in a systematic way, a function such as this may be useful. The way this works is purely a guess, and no checks are in place, so use with caution.

heapify(
Value,
Age,
p0 = 2,
p5 = p0,
pdf0 = c(1, 6, 15, 20, 15, 6, 1),
pdf5 = c(c(1, 4, 6, 4, 1)),
ageMin = 25,
ageMax = max(Age[Age%%5 == 0])
)

## Arguments

Value numeric. A vector of demographic counts by single age. numeric. A vector of ages corresponding to the lower integer bound of the counts. total size of bias to round to 0s. Default 2. total size of bias to round to 5s. Defaults to p0. numeric vector of length 7 giving the pdf to apply around 0s. numeric vector of length 5 giving the pdf to apply around 5s. integer ending in 0 or 5. The lowest age to be heaped upon, default 25. integer ending in 0 or 5. The highest age to be heaped upon, defaults to highest age evenly divisible by 10.

## Value

Value numeric vector perturbed to look like age heaping as happened.

## Details

We use pascal weights, c(1,4,6,4,1) scaled to argument p5 and c(1,6,15,20,15,6,1) scaled to argument p0 to shift individuals from surrounding ages to ages endings in 5 and 0, respectively. This assumes that ages closer to digits 0 or 5 are more likely to be declared as 0 or 5, that this bias is symmetrical, and that such rounding can come from farther away ages for terminal digit 0 than for 5. The user can also make heaping scale differently for 0s and 5s, but there is no control over the shape of bias.

## Examples

# example to show what we're talking about.
# pop1m_pasex is already quite heaped:
Age <- 0:99
A5 <- seq(0,95,by=5)
if (FALSE) {
plot(Age,pop1m_pasex)
# here it is again, smoothed: