Estimates a polynomial approximation for prevalences by age
Source:R/prevalence_to_polynomial.R
prevalence_to_polynomial.RdGiven a vector of ages and a vector of prevalences (constant over each age brackets), the function returns the vector of prevalences by age smoothed by polynomial approximation of degree 4 (default).
Usage
prevalence_to_polynomial(
prevalence,
agecuts = NULL,
agemin,
agemax,
weight = rep(1, (agemax - agemin + 1)),
degree = 4
)Arguments
- prevalence
a vector with observed prevalences by age or agebracket
- agecuts
an optional 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 the regression (optional)
- degree
the degree of the polynomial function used to smooth prevalences (default value is 4)