graduate_beers: The ordinary modified Beers splitting methods

View source: R/graduate.R

graduate_beersR Documentation

The ordinary modified Beers splitting methods

Description

This method offers both ordinary and modified Beers splitting, with an optional Demographic Analysis & Population Projection System Software adjustment johnson for ages under 10.

Usage

graduate_beers(Value, Age, AgeInt, OAG = TRUE, method = "ord", johnson = FALSE)

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?

method

character. Valid values are "ord" or "mod". Default "ord".

johnson

logical. Whether or not to adjust young ages according to the Demographic Analysis & Population Projection System Software method. Default FALSE.

Details

Ages should refer to lower age bounds. Value must be labeled with ages unless Age is given separately. There must be at least six 5-year age groups (including the open group, 5 otherwise). If you want the johnson adjustment then Value must contain a single-year estimate of the population count in age 0. That means Value must come either as standard abridged or single age data.

method option "ord" conserves sums in 5-year age groups, whereas "mod" does some smoothing between 5-year age groups too, and is not constrained.

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

A numeric vector of single age data.

References

\insertRef

beers1945modifiedDemoTools \insertRefshryock1973methodsDemoTools \insertRefsiegel2004methodsDemoTools \insertRefstover2008spectrumDemoTools

Examples

p5 <- pop5_mat
a5 <- as.integer(rownames(p5))
head(p5) # this is the entire matrix
p1 <- graduate_beers(p5[,1], Age = a5, OAG = FALSE)
head(p1)
# note some negatives in high ages
tail(p1)
sum(p1) - sum(p5[,1])

# another case, starting with single ages
# note beers() groups ages.
Value        <- pop1m_ind
Age          <- 0:100
names(Value) <- Age
ord1 <-  graduate_beers(Value, Age, OAG = TRUE, method = "ord")
mod1 <- graduate_beers(Value, Age, OAG = TRUE, method = "mod")
## Not run: 
plot(Age,Value,
ylab = 'The counts', xlab = 'Age groups')
lines(Age, ord1, t='l', col='blue')
lines(Age, mod1, t = 'l', col ='red', lty =2)
legend(80,15000000,
      legend = c('Ordinary',
                 'Modified'),
      col=c('blue', 'red'),
      lty = c(1,2))

## End(Not run)

# notice this negative value. Yuck!
tail(mod1)
# this replaces ages 90+, guaranteed no negatives.
graduate_mono_closeout(Value, Age = Age, pops = mod1, OAG = TRUE)
# Note: there are no kludges built into beers() to handle such cases.
# graduate() deals with this automatically.

# This replicates Johnson_2016_BEERSP.XLS, males
M <- c(184499,752124-184499,582662,463534,369976,286946,235867,
		199561,172133,151194,131502,113439,95614,
		78777,60157,40960,21318,25451)
Age <- c(0,1,seq(5,80,by=5))
Age0        <- 184499
johnson     <- graduate_beers(
		         Value = M,
		         Age = Age,
		         OAG = TRUE,
			       method = "ord",
			       johnson = TRUE)

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