Given a vector of prevalences by age brackets and the vector of age cuts (which defines the age brackets), the function returns a vector of prevalences at all ages. The calculation minimises the sum of squares of second-differences of prevalences by age, under the constraint that average prevalences by age brackets (weight according to the 'weight' vector, usually the vector of population size at each age) are equal to the 'prevalence' input vector.

prevalenceApprox(
  prevalence,
  agecuts,
  agemin,
  agemax,
  weight = rep(1, (agemax - agemin + 1))
)

Arguments

prevalence

a vector with observed prevalences by age bracket

agecuts

a vector with age defining the age brackets (minimum age in each age bracket)

agemin

minimum age in the output vector

agemax

maximum age in the output vector

weight

a vector of weights for each age

Value

a vector with prevalences according to polynomial approximation

Details

Note : Second-differences rather than first-differences are used in the minimisation function, since prevalences according to age are usually parabolic.

Examples

prevalenceApprox(prevalence = (FRDreesAPA2017 %>% filter(sex=="female",typepresta=="APA à domicile"))$prevalence, agecuts=c(seq(60,95,5)), agemin=60, agemax=100, weight=(FRInseePopulation %>% filter(sex=="female",year==2018,age0101>=60) %>% arrange(age0101))$popx)
#> Error in FRInseePopulation %>% filter(sex == "female", year == 2018, age0101 >= 60) %>% arrange(age0101): impossible de trouver la fonction "%>%"
prevalenceApprox(prevalence = (FRDreesAPA %>% filter(year==2018,sex=="male",typepresta=="APA à domicile"))$prevalence, agecuts=c(seq(60,90,5)), agemin=60, agemax=100, weight=(FRInseePopulation %>% filter(sex=="male",year==2019,age0101>=60) %>% arrange(age0101))$popx)
#> Error in FRInseePopulation %>% filter(sex == "male", year == 2019, age0101 >= 60) %>% arrange(age0101): impossible de trouver la fonction "%>%"