graduate_sprague: The basic Sprague age-splitting method.

View source: R/graduate.R

graduate_spragueR Documentation

The basic Sprague age-splitting method.

Description

This method is used to interpolate counts based on the Sprague formula. It is based on the first stage of the Sprague R script prepared by Thomas Buettner and Patrick Gerland, itself based on the description in Siegel and Swanson, 2004, p. 727.

Usage

graduate_sprague(Value, Age, AgeInt, 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

OAG

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

Details

Ages should refer to lower age bounds, ending in the open age group in the last row (not a closed terminal age). Dimension labeling is necessary. There must be at least six age groups (including the open group). One year of data will work as well, as long as it's given as or coercible to a single-column matrix. This method may produce negative values, most likely in the youngest or oldest ages. This case is dealt with in the graduate() wrapper function but not in this function.

If the highest age does not end in a 0 or 5, and OAG == TRUE, then the open age will be grouped down to the next highest age ending in 0 or 5. If the highest age does not end in a 0 or 5, and OAG == FALSE, then results extend to single ages covering the entire 5-year age group.

Value

Numeric vector of counts split into single ages.

References

\insertRef

sprague1880explanationDemoTools \insertRefshryock1973methodsDemoTools \insertRefsiegel2004methodsDemoTools

Examples

head(pop5_mat) # this is the entire matrix
a5 <- as.integer(rownames(pop5_mat))
# the last value is an open age group, preserve as such:
p1   <- graduate_sprague(Value = pop5_mat[,1], Age = a5, OAG = TRUE)
head(p1); tail(p1)
sum(p1) - sum(pop5_mat[,1])

# another case, starting with single ages
Age   <- 0:100
# notice how this particular case produces a negative value in the last age
# before OAG:
pops  <- graduate_sprague(Value = pop1m_ind, Age = Age, OAG = TRUE)
# the graduate() wrapper deals with this automatically.
## Not run: 
  plot(seq(0,100,by=5), pop5_mat[,1]/5, type = 's')
  lines(0:100,
    p1,
    lty = 1,
    col = "red")


## End(Not run)

timriffe/DemoTools documentation built on Jan. 28, 2024, 5:13 a.m.