OPAG_fit_stable_standard: creates stable standard based on optimizing the growth rate

View source: R/OPAG.R

OPAG_fit_stable_standardR Documentation

creates stable standard based on optimizing the growth rate

Description

The stationary standard, nLx is transformed into a stable standard by optimizing a growth rate, r such that the stable standard matches observed population counts in selected age groups. Usually the ages used for fitting are wide age groups in older ages preceding the open age group. The standard output by this function is used by OPAG to create the standard used to redistribute counts over older age groups up to a specified open age group, such as 100.

Usage

OPAG_fit_stable_standard(Pop_fit, Age_fit, AgeInt_fit, Lx1, Age_Lx1)

Arguments

Pop_fit

numeric vector of at least two population counts to use for fitting

Age_fit

integer vector of lower bounds for age groups of Pop_fit

AgeInt_fit

integer vector of widths of age groups of Pop_fit

Lx1

numeric vector of stable population standard by single ages

Age_Lx1

integer vector of lower bounds for age groups of Lx1

Details

The argument method don't have much leverage on the result. In short, the stable population transformation is done by ungrouping nLx to single ages (if it isn't already), and method controls which graduation method is used for this, where "uniform", "mono", "pclm" are the reasonable choices at this writing.

Value

list constaining

  1. Standard numeric vector, the transformed nLx to be used for redistribution in OPAG()

  2. r_opt the output of optimize(), where min is the growth parameter, r

Examples

Pop_fit    <- c(85000,37000)
Age_fit    <- c(70,80)
nLx        <- downloadnLx(NULL, "Spain","female",1971)
Age_nLx    <- names2age(nLx)
Lx1 <- graduate(nLx,Age=Age_nLx,method = "mono")
Age_Lx1 <- 0:100
# India Males, 1971
Pop        <- smooth_age_5(pop1m_ind,
                           Age = 0:100,
                           method = "Arriaga")
Pop80      <- groupOAG(Pop, names2age(Pop), 80)
Age        <- names2age(Pop80)

nLx        <- downloadnLx(NULL, "India","male",1971)
Age_nLx    <- names2age(nLx)


Pop_fit    <- groupAges(Pop80, Age, N = 10)[c("60","70")]
Age_fit    <- c(60,70)
AgeInt_fit <- c(10,10)

Standard <- OPAG_fit_stable_standard(
  Pop_fit = Pop_fit,
  Age_fit = Age_fit,
  AgeInt_fit = AgeInt_fit,
  Lx1=Lx1,
  Age_Lx1 = Age_Lx1
)

# A visual comparison:
nL60 <- rescale_vector(nLx[Age_nLx >= 60])
St60p <- rescale_vector( Standard$Standard[c(0:100) >= 60] )
ages_plot <- seq(60,100,by=5)
## Not run: 
  plot(ages_plot,nL60, type = 'l')
  lines(60:100, St60p, col = "blue")

## End(Not run)

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