In the statistics programming language R, the following formula (as used in lm() or glm())
z ~ (x+y)^2
is equivalent to
z ~ x + y + x:y
Assuming, I only have continuous predictors, is there a concise way to obtain
z ~ I(x^2) + I(y^2) + I(x) + I(y) + I(x*y)
A formula that does the right thing for factor predictors is a plus.
One possible solution is
z ~ (poly(x,2) + poly(y,2))^2
I am looking for something more elegant.