I am trying to build a (mixed) model using several predictor variables, and including some interactions and potentially higher degree polynomial versions of the continuous variables. The model formula looks like this:
y ~ factor * poly(x, 2) # where x is a continuous variable
However, the resulting model ends up being quite complex in terms of coefficients, because in addition to the factor level I also have a complex structure of nested random effects.
There, I was thinking about only testing the interaction with x of degree 1, not with the quadratic term. I would write that formula as this:
y ~ factor * x + poly(x, 2) # where x is a continuous variable
However, when I run
lmer() using that formula, I get the following warning:
fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
I believe that the warning is produced because the formula states twice to use
x as a predictor -- once as part of the interaction, and once as part of the polynomial term.
I am aware that the warning() does not necessarily imply that this is problematic. But, is it in this case?
Also, I am curious about whether there is a clean way to write the formula where I can achieve what I was looking for (including quadratic terms, but not as part of the interaction). Thanks!