# Problems fitting a repeated measures model (time series analysis): fixed-effect model matrix is rank deficient so dropping 1 column / coefficient

I’m trying to fit a model with 4 parameters by not including all the interactions, just including the interaction which got biological sense.

This is my data

> str(data)
'data.frame':   168 obs. of  7 variables:
$session : Factor w/ 7 levels "five","four",..: 5 1 5 2 2 2 1 4 5 1 ...$ indiv    : chr  "8" "21" "23" "26" ...
$age : Factor w/ 2 levels "ad","juv": 1 1 1 1 1 1 1 1 1 1 ...$ treatment: Factor w/ 2 levels "control","fleas": 1 1 1 1 1 1 1 1 1 1 ...
$daytype : Factor w/ 2 levels "after","before": 1 1 1 1 1 1 1 1 1 1 ...$ time     : Factor w/ 2 levels "dark","light": 2 2 2 2 2 2 2 2 2 2 ...
$dayba : int 947 286 480 948 135 112 616 274 543 237 ...  where session is the number of experiment, indiv is each one of the 42 inviduals, daytype is day before treatment or after time is night or day and movs is my response variable and is the only numerical, a number of movements I try to fit repeated measures model (time series analysis) being ‘indiv’ the random factor with 4 observations for each of the 42 individuals (=168 observations), using both, lme from package nlme and lmer from lme4 and this is what I obtained: > lme.hp<-lmer(movs~age+treatment+daytype+time+ treatment:daytype+ daytype:age + treatment:daytype:time+ treatment:daytype:age + treatment:daytype:time:age+(1|indiv)) fixed-effect model matrix is rank deficient so dropping 1 column / coefficient > lme.hp<-lme(movs~age+treatment+daytype+ time+treatment:daytype+ daytype:age + treatment:daytype:time+ treatment:daytype:age + treatment:daytype:time:age,random=~1|factor(indiv)) Error in MEEM(object, conLin, control$niterEM) :
Singularity in backsolve at level 0, block 1


I read that two reasons for that:

1. It means that the fixed effects are multicollinear, i.e. there is some linear combination of them that's constant (https://stackoverflow.com/questions/22788314/linear-mixed-model-matrix-is-rank-deficient)
2. cause of this error is apparently rank deficiency (What is rank deficiency, and how to deal with it?)

However, this is no sense for me as I am able to fit a saturated model with all possible interactions, not just the ones I want it without receiving a warning message

 lme.hp <- lmer(movs~age*treatment*daytype*time+(1|indiv))
lme.hp <- lme(dayba~age*treatment*daytype*time,random=~1|factor(indiv))


I think (not sure) that if I had any of the problems discussed above, I would not be able to fit a model saturated with all interactions.

Anybody knows?

• Take a look at stackoverflow.com/questions/26449969/… and see if you can work out the answer to your problem this way. I'm pretty sure it's the same issue -- R's model.matrix doesn't automatically remove redundancies from the model frame if the interactions are specified as separate terms – Ben Bolker Feb 11 '15 at 21:09