Skip to contents

Create the Blending and Distilling Object

Usage

alembic(
  f_param,
  f_dense,
  model_partition,
  output_partition,
  pars_interp_opts = list(fun = stats::splinefun, method = "natural"),
  dens_interp_opts = list(fun = stats::approxfun, method = "constant", yleft = 0, yright
    = 0)
)

Arguments

f_param

a function, f(x) which transforms the feature (e.g. age), and yields the parameter value. Alternatively, a data.frame where the first column is the feature (x) and the second is the parameter (y); see xy.coords() for details. If the latter, combined with pars_interp_opts, and defaulting to spline interpolation.

f_dense

like f_param, either a density function (though it does not have to integrate to 1 like a pdf) or a data.frame of values. If the latter, combined with dens_interp_opts and defaulting to constant density from each x to the next.

model_partition

a numeric vector of cut points, which define the partitioning that will be used in the model

output_partition

the partition of the underlying feature

pars_interp_opts

a list, minimally with an element fun, corresponding to an interpolation function. Defaults to splinefun() "natural" interpolation

dens_interp_opts

ibid, but for density. Defaults to approxfun() "constant" interpolation

Value

a data.frame which maps fractions of the original model partitions to the desired partitions, according to underlying relative outcome rates and densities

Examples

ifr_levin <- function(age_in_years) {
  (10^(-3.27 + 0.0524 * age_in_years))/100
}
age_limits <- c(seq(0, 69, by = 5), 70, 80, 100)
age_pyramid <- data.frame(
  from = 0:100, weight = ifelse(0:100 < 65, 1, .99^(0:100-64))
) # flat age distribution, then 1% annual deaths
ifr_alembic <- alembic(ifr_levin, age_pyramid, age_limits, 0:100)