contr_code_poly | R Documentation |
Polynomial coding sets the grand mean as the intercept. Each contrast tests a trend (linear, quadratic, cubic, etc.). This is only suitable for ordered factors.
contr_code_poly(fct, levels = NULL)
fct |
the factor to contrast code (or a vector) |
levels |
the levels of the factor in order |
the factor with contrasts set
df <- sim_design(within = list(time = 1:6),
mu = 1:6 + (1:6-3.5)^2,
long = TRUE, plot = FALSE)
df$time <- contr_code_poly(df$time)
lm(y ~ time, df) %>% broom::tidy()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.