Create polynomial contrasts for testing trends across ordered factor levels. This is particularly useful for analyzing factors with a natural ordering (e.g., time, dose).
Value
A poly_contrast_spec object containing the specification for generating polynomial contrast weights.
Details
The function creates orthogonal polynomial contrasts up to the specified degree. These contrasts can test for linear, quadratic, cubic, and higher-order trends in the data. The value_map parameter allows for non-uniform spacing between levels.
See also
oneway_contrast
for categorical contrasts,
interaction_contrast
for interaction effects
Examples
# Linear trend across time points
pcon <- poly_contrast(~ time, name = "linear_time", degree = 1)
# Cubic trend with custom spacing
pcon <- poly_contrast(~ dose, name = "dose_cubic",
degree = 3,
value_map = list("low" = 0, "med" = 2, "high" = 5))