graduate_pclm | R Documentation |
ungroup::pclm
method of splitting binned countsThis is exactly the function pclm()
from the ungroup
package, except with arguments using standard DemoTools
argument names.
graduate_pclm(Value, Age, AgeInt, OAnew = max(Age), OAG = TRUE, ...)
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 |
OAG |
logical, default = |
... |
further arguments passed to |
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.
pascariu2018ungroupDemoTools \insertRefrizzi2015efficientDemoTools
pclm
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.