Validate or construct an attained-age baseline hazard table
Source:R/sim_cox_age_data_helpers.R
dot-make_age_rate_tbl.RdEnsures that a valid attained-age baseline hazard table is available.
Either a piecewise-constant hazard table
(baseline_hazard_by_age) must be supplied, or a single constant
baseline hazard (constant_baseline_hazard) must be provided.
Details
If a constant baseline hazard is given, a one-row table covering
(-Inf, Inf) is constructed.
If a table is supplied, it is validated, coerced to numeric, ordered by
age_lo, and returned.
Exactly one of baseline_hazard_by_age or
constant_baseline_hazard must be non-NULL. Supplying both
or neither results in an error.
All age bands must satisfy age_hi > age_lo and all baseline
hazard rate values must be strictly positive.
Examples
.make_age_rate_table(
baseline_hazard_by_age = data.frame(
age_lo = c(50, 60),
age_hi = c(60, 70),
rate = c(0.01, 0.02)
),
constant_baseline_hazard = NULL
)
#> Error in .make_age_rate_table(baseline_hazard_by_age = data.frame(age_lo = c(50, 60), age_hi = c(60, 70), rate = c(0.01, 0.02)), constant_baseline_hazard = NULL): could not find function ".make_age_rate_table"
.make_age_rate_table(
baseline_hazard_by_age = NULL,
constant_baseline_hazard = 0.01
)
#> Error in .make_age_rate_table(baseline_hazard_by_age = NULL, constant_baseline_hazard = 0.01): could not find function ".make_age_rate_table"