graduate_mono_closeout | R Documentation |
A simple monotonic spline on the cumulative sum of population counts may return more convincing single age count estimates than the Sprague or other splitting methods. This function blends the given single age population estimates starting at pivotAge
.
graduate_mono_closeout(
Value,
Age,
pops,
pivotAge = 90,
splitfun = graduate_sprague,
OAG = TRUE,
...
)
Value |
numeric vector, presumably counts in grouped ages |
Age |
integer vector, lower bounds of age groups |
pops |
optional numeric vector of single age population counts derived from |
pivotAge |
integer (default 90). Age at which to switch to spline-based estimates. |
splitfun |
optional. The function used to create pops. Default |
OAG |
logical (default |
... |
arguments to be optionally passed to |
The pivotAge
must be at least 10 years below the maximum age detected from
rownames(popmat)
, but not lower than 75. In the exact pivotAge
, we may either take the Sprague estimates or the spline estimates, depending on which is larger, then the single-age estimates for this 5-year age group are rescaled to sum to the original total in Value
. Higher ages are taken from the spline-based age splits. The spline results are derive from the "hyman"
method of splinefun()
on the cumulative sum of the original age grouped data. One could use this function to perform the same closeout to Grabill estimates, if these are given via the pops
argument. See examples. Note that the Grabill split method mixed with this closeout will not necessarily preserve the annual totals, and this function performs to rescaling. The open age group is preserved (and must be included in Value
).
numeric matrix of age by year estimates of single-age counts.
a5 <- as.integer(rownames(pop5_mat))
popvec <- pop5_mat[,1]
closed.out <- graduate_mono_closeout(Value = popvec, Age = a5, OAG = TRUE)
sum(closed.out) - sum(popvec)
graduate_mono_closeout(Value = popvec, pivotAge = 85, Age = a5, OAG = TRUE)
# giving a different single-age split to close out this way:
popg <- graduate_grabill(Value = popvec, Age = a5, OAG = TRUE)
grabill.closed.out <- graduate_mono_closeout(Value = popvec, Age = a5, pops = popg)
# totals not necessarily preserved if mixed w Grabill
# I wouldn't recommend a rescale of the total, since the
# only part we mess with here is the old age section. Ergo,
# one may wish to instead rescale results colSums() of
# popg at age pivotAge and higher.
sum(grabill.closed.out) - sum(popvec)
# also works on an age-labeled vector of data
closed.vec <- graduate_mono_closeout(popvec, Age = a5, OAG = TRUE)
# let's compare this one with sprague()
simple.vec <- graduate_sprague(popvec, Age = a5, OAG = TRUE)
# and with a simple monotonic spline
mono.vec <- graduate_mono(popvec, Age = a5, OAG = TRUE)
## Not run:
plot(85:100,simple.vec[86:101], type = 'l',
main = "In this case graduate_sprague() is the smoothest")
lines(85:100,closed.vec[86:101], col = "red", lwd = 2)
lines(85:100,mono.vec[86:101], col = "blue", lty = 2)
legend("topright",lty=c(1,2,2), col = c("black","red","blue"),lwd = c(1,2,1),
legend = c("graduate_sprague()","monoCloseout()", "graduate_mono()"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.