I have fitted a model where:
Y ~ A + A^2 + B + mixed.effect(C)
Y is continuous A is continuous B actually refers to a DAY and currently looks like this:
This is not really a mixed-model specific question, but rather a general question about model parameterization in R.
Let's try a simple example.
set.seed(101)
d <- data.frame(x=sample(1:4,size=30,replace=TRUE))
d$y <- rnorm(30,1+2*d$x,sd=0.01)
This just does a linear regression: the x
parameter denotes the change in y
per unit of change in x
; the intercept specifies the expected value of y
at x=0
.
coef(lm(y~x,d))
## (Intercept) x
## 0.9973078 2.0001922
coef(lm(y~factor(x),d))
## (Intercept) factor(x)2 factor(x)3 factor(x)4
## 3.001627 1.991260 3.995619 5.999098
The intercept specifies the expected value of y
in the baseline level of the factor (x=1
); the other parameters specify the difference between the expected value of y
when x
takes on other values.
coef(lm(y~ordered(x),d))
## (Intercept) ordered(x).L ordered(x).Q ordered(x).C
## 5.998121421 4.472505514 0.006109021 -0.003125958
Now the intercept specifies the value of y
at the mean factor level (halfway between 2 and 3); the L
(linear) parameter gives a measure of the linear trend (not quite sure I can explain the particular value ...), Q
and C
specify quadratic and cubic terms (which are close to zero in this case because the pattern is linear); if there were more levels the higher-order contrasts would be numbered 5, 6, ...
coef(lm(y~factor(x),d,contrasts=list(`factor(x)`=MASS::contr.sdif)))
## (Intercept) factor(x)2-1 factor(x)3-2 factor(x)4-3
## 5.998121 1.991260 2.004359 2.003478
This contrast specifies the parameters as the differences between successive levels, which are all a constant value of (approximately) 2.