graduate_pclm: wrapper for 'ungroup::pclm' method of splitting binned counts

View source: R/graduate.R

graduate_pclmR Documentation

wrapper for ungroup::pclm method of splitting binned counts

Description

This is exactly the function pclm() from the ungroup package, except with arguments using standard DemoTools argument names.

Usage

graduate_pclm(Value, Age, AgeInt, OAnew = max(Age), OAG = TRUE, ...)

Arguments

Value

numeric vector, presumably counts in grouped ages

Age

integer vector, lower bounds of age groups

AgeInt

integer vector, age interval widths

OAnew

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

OAG

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

...

further arguments passed to ungroup::pclm()

Details

The PCLM method can also be used to graduate rates using an offset if both numerators and denominators are available. In this case Value is the event count and offset is person years of exposure. The denominator must match the length of Value or else the length of the final single age result length(min(Age):OAnew). This method can be used to redistribute counts in the open age group if OAnew gives sufficient space. Likewise, it can give a rate extrapolation beyond the open age.

If there are 0s in Value, these are replaced with a small value prior to fitting. If negatives result from the pclm fit, we retry after multiplying Value by 10, 100, or 1000, as sometimes a temporary rescale for fitting can help performance.

Age be any age range, it does not need to start at 0.

References

\insertRef

pascariu2018ungroupDemoTools \insertRefrizzi2015efficientDemoTools

See Also

pclm

Examples

a5  <- seq(0,100,by=5)
p5  <- pop5_mat[, 1]
p1  <- graduate_pclm(Value = p5, Age = a5)
p1s <- graduate_sprague(Value = p5, Age = a5)
## Not run: 
plot(a5, p5/5, type = "s",xlim=c(40,60),ylim=c(2000,4000))
lines(0:100, p1, lwd = 2, col = "red")
lines(0:100, p1s, lwd = 1, col = "blue",lty="8282")

## End(Not run)
# example of how to graduate rates by splitting deaths using population
# as PCLM offset
dth.ind <- c(49, 14, 9, 39, 60, 101, 147, 178, 177, 232)
pop.ind <- c(7231, 28400, 66836, 52380, 38022, 36886, 26145, 14205, 6406, 
             3322)
age <- c(0,1,5,15,25,35,45,55,65,75)
mx <- graduate_pclm(Value = dth.ind, 
              Age = age, 
              OAnew = 85, 
              offset = pop.ind)
## Not run: 
  plot(age, dth.ind / pop.ind, type = 's', log = 'y', xlim = c(0,85))
  lines(0:85, mx, col = "red")

## End(Not run)

timriffe/DemoTools documentation built on Oct. 14, 2024, 12:53 p.m.