Constructs a set of linear combinations (contrasts) for age, period, and/or cohort effects
across different strata, relative to a specified reference strata, suitable for use with
inla.make.lincomb
from the INLA
package.
generate_apc_lincombs(
apc_format,
data,
strata,
reference_strata,
age = "age",
period = "period",
cohort = "cohort"
)
A named list
of linear combination objects as returned by
inla.make.lincomb()
(INLA
function). Each element corresponds to one contrast,
with names of the form “Age = x, Strata = y vs ref”, “Period = x, Strata = y vs ref”,
or “Cohort = x, Strata = y vs ref”, depending on apc_format
.
Character string containing any combination of "a"
, "p"
, "c"
:
"a"
include age contrasts
"p"
include period contrasts
"c"
include cohort contrasts
e.g. "ap"
to generate age and period contrasts only.
A data.frame
containing the variables specified by age
, period
, cohort
, and strata
.
The age, period, and cohort variables must be integer-valued (or coercible to integer).
String giving the name of the factor column in data
that defines strata.
String indicating which level of strata
should be used as the reference.
String name of the column in data
containing age indices (default "age"
).
String name of the column in data
containing period indices (default "period"
).
String name of the column in data
containing cohort indices (default "cohort"
).
For each specified dimension (a
, p
, c
), the function loops over all
unique values of age, period, or cohort in the data, and over all strata levels except
the reference. It then constructs a contrast that subtracts the effect in the reference
stratum from the effect in the other strata at each index.