You found a minor bug. Look at nlme:::fitted.lme
to see what happens:
The fitted values are extracted from the model using
object[["fitted"]]
fixed X1 X2
1 0.6014526 0.1686912 0.1686912
2 0.6014526 0.1686912 0.1686912
4 0.6014526 0.1686912 0.1686912
5 0.6014526 1.0342140 1.0342140
6 0.6014526 1.0342140 1.0342140
7 0.6014526 1.0342140 1.0342140
8 0.6014526 1.0342140 1.0342140
Note how there are 8 fitted values even though observation 3 was omitted from the fit due to the missing y
-value and shouldn't be there. The names are then created from
object[["groups"]]
X1 X2
1 1 1/1
2 1 1/1
3 1 1/2
4 2 2/1
5 2 2/1
6 2 2/2
7 2 2/2
Note how there are only 7 names. The NA gets introduced, when match
is used.
Ultimately the problem is in lme
, which should only return 7 fitted values. However, I don't have time to find out how this could be fixed. Feel free to report it.