Skip to contents

Given the vectors (breaks[1],...,breaks[n]) and the list of IBMPopSim compatible functions funs = (f[0],f[1],...,f[n]) (one value more!), piecewise_xy(breaks, funs) returns the function $$f(x,y) = f_0(x) {1}_{y\le breaks[1]}+\sum_{k=1}^{n-1} f_k(x) {1}_{[breaks_{k}, breaks_{k+1})}(y) + f_n(x){1}_{y \ge breaks[n]}$$

Usage

piecewise_xy(breaks, funs)

Arguments

breaks

Numeric vector giving the breaks of functions given in funs. Must be sorted with unique values.

funs

List of functions.

Value

Piecewise bivariate function built with the given intervals and functions.

Details

A C++ version of this function is available. See vignette('IBMPopSim_cpp') for more details.

Examples

time_dep_function <- piecewise_xy(c(5),
                                  list(gompertz(0.1, 0.005), gompertz(0.08, 0.005)))
time_dep_function(0, 65)  # death intensity at time 0 and age 65.
#> [1] 0.1384031