Description Usage Arguments Value Examples
View source: R/createFormula.R
Creates a formula with interactions and polynomials up to a
desired order. If the input formula
already includes interactions,
exponents or other functions (e.g., sqrt
), they are
ignored.
1 2 | createFormula(formula, maxExponent = 1, interactionDepth = 1,
intercept = TRUE)
|
formula |
formula object: formula object without exponents or
interactions. If |
maxExponent |
positive integer: highest exponent included in the formula. Default is 1, e.g., only linear effects. |
interactionDepth |
positive integer: maximum order of interaction. Default is 1, e.g., only main effects (no interactions). |
intercept |
logical: include intercept or not? |
A formula containing the original independent variables and their polynomials and interactions.
1 2 3 4 5 | createFormula("y ~ x1 + x2", 2, 3)
createFormula(as.formula("y ~ x1 + x2"), interactionDepth = 2)
carFormula <- createFormula("mpg ~ cyl + disp + drat", 2, 3)
summary(lm(carFormula, mtcars))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.