# glmer: how to test intra- and inter-individual variability of a variable on outcome

I am an R beginner so I wish I could get some help with glmer model.

I have 165 subjects and each of them has been measured for drug concentration (continuous variable) and outcome (binary variable Y/N) for 14 days. Drug concentration and outcome data might vary within an individual on different days; while genotype (categorical, 3 groups) is fixed within an individual. I hypothesize drug concentration and genotype would affect outcome. Therefore, I aim to test the effect of intra- or inter-individual drug concentration variability, and genotype on outcome.

I have two models:

glmer1 <- glmer(outcome~genotype+drug concen+(1|patient ID), family="binomial", data=data1)

glmer2 <- glmer(outcome~genotype+drug concen+(drug concen|patient ID), family="binomial", data=data1)


My questions are: is glmer1 testing intra-individual drug concentration variability on outcome? And is glmer2 testing inter-individual drug concentration variability on outcome? Or any sub-analysis to test my hypothesis?

For genotype, I know it's testing the genetic effects of inter-individual variability on outcome because each patient only has one fixed genotype. However, I don't know how it works for drug concentration.

glmer1 <- glmer(outcome ~ genotype + drug_concen+(1|patient_ID), family="binomial", data=data1)


here you modelling the association of genotype and drug_concen on outcome, on a patient, while adjusting for the clustering effect of repeated observations withing patients (which may lead to correlated observations on the same patient). The fixed effects coefficients tell you the change in outcome associated with a change in either of the covariates, while the other remains unchanged.

The model will also output the variance of the random intercepts for patient_id. This will give you a measure of the clustering effect of repeated measures - a high value indicates high correlation between measurements on the same patient (intra-patient variability), and an assessment of the intra-class correlation (ICC) will help to quantify this (though since you have a glmm, the ICC is not quite as straight forward as it would be if it was a (not generalised) linear model. See here for details of computing the ICC for mixed effects models. To test whether there is in fact a clustering effect (whether intra-patient variability is zero), you can do a likelihood ratio test, or compare AIC values.

The second model:

glmer2 <- glmer(outcome~genotype+drug_concen+(drug_concen|patient ID), family="binomial", data=data1)


is the same as the first, but this time you are allowing each patient to have their own "slope" for the variable drug_concen.