Starting from the formulation of the model, we have measurements $i$ nested in patients $j$ nested in areas $k$. The dataset can be described in three-level formulation:
- Level-1 (measurement):
DV
,DV_Indicator
- Level-2 (patient):
Patient_Age
,Patient_Race
,Patient_Sex
- Level-3 (area):
ArealExposure
The model is then:
$$\text{logit}\{\text{Pr}(\text{DV}_{ijk}=1 | a_{jk},\text{DV_Ind}_{ijk})\} = a_{jk} + \beta \text{DV_Ind}_{ijk}$$
with the varying intercept
$$a_{jk} = b_{0k} + b_1\text{Patient_Age}_{jk} + b_2 \text{Patient_Race}_{jk} + b_3 \text{Patient_Sex} + \zeta_{jk}^{(2)} $$
and this varying intercept
$$b_{0k} = \delta_0 + \delta_1 \text{ArealExposure}_{k} + \zeta_k^{(3)} $$
In the above case you only have random intercepts as random effect, and you can incorporate that in the glmer
function as you correctly stated:
m1 <- glmer(DV ~ DV_Indicator + Patient_Age + Patient_Race + Patient_Sex + ArealExposure + (1 | ArealID/PatientID), data=mydata, family=binomial)
m1 <- glmer(DV ~ DV_Indicator + Patient_Age + Patient_Race +
Patient_Sex + ArealExposure + (1 | ArealID/PatientID), data=mydata,
family=binomial)
however I would suggest you to think of it in its alternative expression:
m1 <- glmer(DV ~ DV_Indicator + Patient_Age + Patient_Race + Patient_Sex + ArealExposure + (1 | ArealID)
- (1 | ArealID:PatientID), data=mydata,family=binomial)
m1 <- glmer(DV ~ DV_Indicator + Patient_Age + Patient_Race +
Patient_Sex + ArealExposure + (1 | ArealID)
+ (1 | ArealID:PatientID), data=mydata,family=binomial)
Both of them, give you the same result, and in the random part you will get only random intercepts. You don't have to worry whether you have included the variables correctly at the 'right' level as you say, since for the computational part it doesn't make any difference. Patient-level variables have the same value for each measurement within each patient, so there is no variability at all.
However, if at any level you suspect that there is any variability at higher level, e.g. Patient_Age
at areal-level, or something measure-specific at patient-level, you can include a random slope for each case in the respective level. If you require to add varying slopes to the 1
intercepts, it's easier to do so using the second expression as you have a distinction on the levels.
This is something different from what you have written for the second model m2
. This is the case of non-nested grouping factors.