I'm trying to fit a number of linear models as shown below. It is important that all interaction terms are sorted lexicographically. Note that the second model is missing the main effect for x.
x = rnorm(100)
y = rnorm(100)
z = x + y + rnorm(100)
m1 = glm(z ~ x + y + x:y)
m2 = glm(z ~ y + x:y)
The models don't behave as expected with respect to the interaction terms:
m1:
x:y -0.1565 0.1151 -1.360 0.1770
m2:
y:x -0.2776 0.1416 -1.961 0.0528 .
I understand that there may be a way to use the interaction() function with the lex.order argument but I can't figure out how or, indeed, whether this is the best way to go. Advice?