I'm using the glmer function from lme4 package to model a binomial phenomena in a human DNA dataset. An allele can be missing (1) or not (0). The dataset is created with 10 different samples. Each sample was diluted at 6 different concentrations. And each of this concentration was analysed 15 times (15 replicates).

I think I have nested data, and I have a hard time to figure out how to choose the random intercept.

Given the analysis process, I'm expected correlation coming from the 15 replicates, so I wrote my random intercept as: (1|VariableN). The VariableN contains the name of the sample and its DNA quantity (ex PersX_5pg). So I will have one intercept for each sample at a given DNA quantity.

But this random intercept will not account for possible correlation between the DNA quantity, as the samples are diluted in a row. So I have an another more general random intercept: (1|VariableX). The VariableX contains only the name of the sample (ex: PersX).

-> does (1|VariableX) imply both correlations between the DNA quantity and between the replicates?

-> For the same fixed effects, the AIC value is slightly lower for the random intercept (1|VariableN), but can I only rely on the AIC value?

Thanks in advance for your help.

---------EDIT--------- The question is about the presence or the absence of certain allele at different DNA concentration. As the quantity of DNA is decreasing, this phenomena is increasing, we are "loosing" allele.

The model includes a proxy for the DNA quantity based on the peak height of the allele, called H, the size of the different markers analysed and a random intercept.

The DNA samples didn't have the same concentration before dilution, but after quantification, we could adjust the dilution and get 6 concentrations approximately similar for the 10 persons.

  • $\begingroup$ Could you please say a bit more about what question you are trying to answer here? Presumably, each person either has the allele or not, so you seem to be asking about detectability of the allele as the samples are diluted and re-tested. Showing the complete model you are trying to fit might help. Also, you say that "Each sample was diluted at 6 different concentrations" but did they all start the same initial concentration? $\endgroup$
    – EdM
    Apr 21, 2019 at 21:42
  • $\begingroup$ I edit my post. Hope the new details will help. Thanks $\endgroup$
    – RforLife
    Apr 22, 2019 at 1:10

1 Answer 1


If I understood correctly, your second model should be the correct one. In the first one ((1|VariableN)) the grouping factor that determine the random intercept confounds a random effect (the DNA sample) and another factor that I would consider a fixed-effect (the concentration or DNA quantity). Note that I don't know much about measurements of DNA properties, so I might be wrong, but my instinct would be to consider concentration as a fixed effect for the following reason: if you were to do acquire more samples from additional subjects and do more measurements, the factor coding the DNA samples would get additional levels, whereas you would still have only 6 levels of concentration. In other words I think concentration should be treated as a fixed-effect because it is a manipulation that is under you control, whereas the DNA samples are random samples drawn from a larger population distribution on which (I assume) you would like to make some inferences. You also mention that the samples are diluted 'in a row', which may introduce correlations between replicates. To take there into account I would while treating concentration as a fixed effect I would try something like this:

allele ~ concentration + (concentration | DNAsample)

This model would have random intercept for each sample, a fixed effect of concentration, and sample-specific fluctuations in the effect of concentration level.

About the AIC, yes it can be used to choose the form of the model. For example you could use it to check whether the main fixed effect of concentration is really necessary (that is comparing ~ concentration + (concentration | DNAsample) with ~ 1 + (concentration | DNAsample)). However, keep in mind that it is only an approximation of the predictive ability of the model, and you should not over-rely on it. I would recommend to take into account also other measures, e.g. likelihood ratio tests or (better) to run a bootstrap.

Edit. Based on your comments below, you might want to use nested random effect, that is ~ 1 + concentration + (1|DNAsample/concentration). In this formula the nested random effect and the fixed-effect are not the same thing, because the fixed effect implies systematic differences in your dependent variable due to concentration (systematic in the sense that they are shared by all DNA samples). The nested random effect of concentration instead account for correlation among replicates of the same concentration and DNA sample. The model (assuming a logit link function) could be expressed as $$ \text{logit}(p)= \underbrace{\beta_0 + \beta_1 \times \text{concentration}}_\text{fixed-effects} + \underbrace{ u_{\text{DNA sample}}+ u_{\text{concentration } \mid \text{ DNA sample}}}_{\text{random intercepts}\\ u_{\text{concentration }} \sim \mathcal{N}(0,\sigma_1^2) \\ u_{\text{concentration }\mid \text{ DNA sample}} \sim \mathcal{N}(0,\sigma_2^2)} $$

  • $\begingroup$ Thanks for your explanation. I'm using also the likelihood ratio tests to test my variables in addition of the AIC value. I tried your suggestion and I compare with likelihood ratio test the 2 models. The random effect you suggested (X2(2)=2.6825 and pvalue: 0.2615) is not significantly different from my 2nd intercept. I'm running a (10) k-fold cross-validation (instead of bootstrap) to obtain model predictions. Are predictions the best way to test the random intercept effect? $\endgroup$
    – RforLife
    Apr 22, 2019 at 1:45
  • $\begingroup$ The random effect structure should be, in principle, dictated by your experiment, rather than inferred from the data. Does concentration has a significant fixed-effect? Otherwise you could use nested random effects, e.g. (1|DNAsample/concentration) = (1|DNAsample)+(1|DNAsample:concentration); see here $\endgroup$
    – matteo
    Apr 22, 2019 at 4:29
  • $\begingroup$ Concentration is indeed a significant fixed-effect of the model. I tried the model with the random intercept you suggested below and the ANOVA test show an improvement of the model, as well as the predictions. Is it ok to use the concentration as a fixed and nested variable? Is not redundant? $\endgroup$
    – RforLife
    Apr 22, 2019 at 9:26
  • $\begingroup$ They are not the same thing: the fixed effect represents systematic differences due to concentrations that are assumed to be common to all DNA samples; the nested random effect instead only account for correlations among replicates (from the same DNAsample-concentration combination). I'll update the answer. $\endgroup$
    – matteo
    Apr 22, 2019 at 13:26
  • $\begingroup$ Thank you so much for your clear explanations and the time you took to answer me :D $\endgroup$
    – RforLife
    Apr 22, 2019 at 14:28

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.