Normalizes a target grid and validates it against a specific imugap_fit.
Details
Accepts either the output of [create_target()] or a plain data.frame /
data.table with loc_id, age, cohort, and dose columns (optionally
weight / obs_id). Fills obs_c_id and weight when absent, checks that
every loc_id exists in the fit and that dose, age, and cohort are
within the fit's ranges, and adds the canonical loc_c_id. Errors on any
out-of-range value. [predict.imugap_fit()] calls this internally, so most
users do not call it directly.
Examples
data("fit_sim")
target <- create_target(
location = c("Blue Heron School", "Bluebird Learning Center"),
age = c(1, 2, 3), cohort = 5, dose = c(1), mode = "snapshot"
)
canonicalize_target(target, fit_sim)
#> obs_c_id loc_id age cohort dose weight loc_c_id
#> <int> <char> <num> <num> <num> <num> <int>
#> 1: 1 Blue Heron School 1 7 1 1 5
#> 2: 2 Bluebird Learning Center 1 7 1 1 6
#> 3: 3 Blue Heron School 2 6 1 1 5
#> 4: 4 Bluebird Learning Center 2 6 1 1 6
#> 5: 5 Blue Heron School 3 5 1 1 5
#> 6: 6 Bluebird Learning Center 3 5 1 1 6
