LME Relevelling Issue I'm in the process of relevelling some factors for an LME using R and have hit an issue. I've reordered the factor levels to enable me to talk about the outcome of the model more easily in relation to my experimental hypotheses.
The model is pretty simple: two factors and an interaction between the two. Weirdly, when I run the base model before relevelling, and then run the relevelled version, one of the factors that was significant before relevlling is now no longer significant. Before doing this, I had assumed that the outcome would be the same before and after relevelling. Both the factors that I have relevelled have only two levels to them, so I'm a bit confused why this might be happening.
I've been going over and over the code all day - but had no luck with it. Is the behavior I've observed expected with LMEs, or is it likely that I've done something wrong when changing my factor levels? 
 A: Consider a linear model like
$$\mathbb{E}[Y] = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \beta_3 (X_1 \times X_2).$$
When $X_1$ and $X_2$ are categorical, this is pure nonsense until somehow the categories have been encoded as numbers.  The default in R, for binary categories, is to encode the first category as $0$ and the second as $1$.  Let the categories for $X_i$ be $a_i, b_i$ (in that order).  With the default coding, the four possible cases (given by the $2 \times 2$ possible combinations of values of the $X_i$) are:
$$\eqalign{
X_1=a_1,\ X_2=a_2: &\mathbb{E}[y] = \beta_0 \\
X_1=b_1,\ X_2=a_2: &\mathbb{E}[y] = \beta_0 + &\beta_1 \\
X_1=a_1,\ X_2=b_2: &\mathbb{E}[y] = \beta_0 + &&\beta_2 \\
X_1=b_1,\ X_2=b_2: &\mathbb{E}[y] = \beta_0 + &\beta_1 + &\beta_2 + \beta_3
}$$
Suppose now that we switch the numeric codes, so that the $a_i$ are coded as $1$ and the $b_i$ as zero.  Now the model is
$$\eqalign{
X_1=a_1,\ X_2=a_2: &\mathbb{E}[y] = \beta'_0 + &\beta'_1 + &\beta'_2 + \beta'_3 \\
X_1=b_1,\ X_2=a_2: &\mathbb{E}[y] = \beta'_0 + &&\beta'_2 \\
X_1=a_1,\ X_2=b_2: &\mathbb{E}[y] = \beta'_0 + &\beta'_1 \\
X_1=b_2,\ X_2=b_2: &\mathbb{E}[y] = \beta'_0
}$$
They are the same model but with different parameterizations.  By comparing these two sets of formulas and solving we find the reparameterization is
$$\beta'_0 = \beta_0 + \beta_1 + \beta_2 + \beta_3,\ \beta'_1 = -(\beta_1+\beta_3),\ \beta'_2 = -(\beta_2+\beta_3),\ \beta'_3 = \beta_3.$$
In the first model $\beta_1, \beta_2,$ and $\beta_3$ were all found to be significantly different from zero.  In the second model "one of the factors"--let's say $X_1$--was not significant.  That means $\beta'_1 = -(\beta_1+\beta_3)$ was not significantly different from zero.  Evidently that is possible when $\hat{\beta_1}\approx -\hat{\beta_3}$.  Because the parameterizations have different meanings, the default significance tests evaluate different hypotheses in the two coding schemes.
For more complex models, such as mixed models and even nonlinear models, the same reasoning applies: changing the coding changes the parameterization and the meanings of default significance tests.
The lesson here is that interpreting statistical output with categorical variables depends on how those variables are numerically coded.  In particular, the tests of significance depend on the coding.
