# [R] mixed model with factor

Irene Mantzouni ima at difres.dk
Sun Oct 21 00:28:39 CEST 2007

```Dear all

I am trying to fit a mixed model with a factor and a random effect on a slope:
y~F*x+...,random=~x
where F is a factor with 2 levels and x the covariate.
the random effects for the 2 levels of F should be equal so I am fitting the model like:

ex.lme=lme(y~x+F+z*x+F*x-1,
random=list(group=pdBlocked(list(pdIdent(~F-1),pdIdent(~F*x-1)))))

In that case the random effect part of the summary is like:

Block 2: F1:x, F2:x
Formula: ~F:x - 1 | group
Structure: Multiple of an Identity
F1:x F2:x  Residual
StdDev:  4.015003e-06  4.015003e-06 0.7636376

but the fixed part is like:

Fixed effects: y ~ z + F + z * x + F * x - 1
Value Std.Error  DF   t-value p-value
z      -0.1012095 0.1174244  18 -0.861913  0.4001
F1      2.4558678 0.7743866  18  3.171372  0.0053
F2      1.4761337 0.7913741  18  1.865279  0.0785
x       0.0000006 0.0000040 705  0.158342  0.8742
z:x    -0.0000010 0.0000007 705 -1.297161  0.1950
F2:x    0.0000030 0.0000027 705  1.082969  0.2792

I suppose that x value corresponds to the F1:x.

However, when I extract the coef() I get columns for x, F1:x, F2:x.

x coef is constant as if it was a fixed effect. I guess that F1:x is the random  and x the fixed part of the F1:x interaction so I should simply add these columns for the final group-level coefficient.

Is that right?

Can I formally check or fix that to get a straightforward result?

Thank you!

Irene

```