I have to setup an experiment for which generating data is very expensive. But we also want to assess the effects of several parameters. The experiment looks like this:

enter image description here

  • Summary : On the first day, a technician prepares a QC at 2 levels (.a & .b), each QC is tested on two types of devices (A, B) which are represented by 2 devices each (.1, .2). Each device runs a synchronized analysis on the two QC using two differents settings (X,Y), after the first synchronized analysis (R1), another one is started. This is repeated until devices ran 10 synchronized analysis. This is repeated a second day.
  • R is the dependent variable, N=320

I think Mixed Linear Model is appropriate here to deal with technical replicates and the several sources of variability :

  1. First, we want to evaluate the effect of Setting (X or Y) on the results we would consider the other variables as random.
  2. For the second part, we want to check whether the results are different between two Device Types, Setting would be a Random effect.

My problem here is the heavily nested/crossed structure of the experiment, and as I'm new to mixed models, I'm looking for help to validate my models :

  1. lmer(R ~ Setting + (1|DeviceType/Device) + (1|Day/QC) + (1|Device Type) + (1|Setting/R), data=df)
  2. lmer(R ~ DeviceType + (1|DeviceType/Device) + (1|Day/QC) + (1|Setting) + (1|Setting/R), data=df)

Are they correctly Specified ?


1 Answer 1


I try here to explain how I understand your problem :

Your variables

As you say, the dependant variable is R and it can be explained by 5 others : Settings, Device, Device type, QC and Day

Why a mixed model

The first question here is why do you want to use a mixed model. One way to see a random variable is that this variable as a lot (maybe an infinity) of possible levels. For example, in a experiment where a drink is tested by different persons, the persons effect can be see as random because in theory you could test the drink with much more persons but the reality of the experiment doesn't allow it.

From what I understand, here the experiment is expensive so you can't replicate it a lot. I agree with variable Day, QC and Device to be random because you could have done the experiment on others day with more QC and devices. I also agree that Device is nested in Device Type and QC is nested in Day.

For Setting and Device Type, whether there are random or fixed is maybe not as obvious. I think a good question to ask is : are the two settings/device types the only one you are interested in? If the answer is yes then I would recommand fixed effects.

How would I write the model

Considering Setting and Device Type as fixed :

lmer(R ~ Setting + DeviceType + (1|DeviceType/Device) + (1|Day/QC) + (1|Day), data=df)

With this model, I only intend to add the random effects on the intercept. You could also test the random effects on the fixed effect coefficient such as :

lmer(R ~ Setting + DeviceType + (Setting + DeviceType|DeviceType/Device) + (Setting + DeviceType|Day/QC) + (Setting + DeviceType|Day), data=df)

In the latter, the intercept will vary according to random effects depending on device, day and QC as well as the coefficients associated with each device type and each setting. This model is much more complicated and it is possible that lmer don't converge. You can also tested two nested models (i.e. all the variables in the simplest model are present in the more complex) for example to test if adding random effects on the fixed effect coefficient gives a better model but you have to change the REML argument to FALSEin order to do it.

A useful reference for mixed model : Pinheiro, J., Bates, D., 2000. Mixed-effects models in S and S-PLUS. New York.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.