Skip to content
Prev 19119 / 20628 Next

A three-level GLMM with binomial link in R

I'll think more about how to share a data set that would create the same error. Sorry, I am not very simulation savvy but I'll try harder next time.

On the bright side, I was able to run the following model by implicitly defining the group structure (slightly different from what was suggested in the previous email) and it does give me the same estimation as lme() with random = ~1|site/family/id random structure - so the memory issue resolved for this model! Thank you for the suggestion.

dd$site_family <- interaction(dd$site, dd$family)
m2.1 <- lmer(cbcl_scr_syn_internal_r ~ 1 + X1 + X2 + X3+ (1|site) +(1|site_family/id), data=dd,  REML = FALSE)

But now getting to my last question: My data has 22945 rows, and some individuals have only baseline measurement, some individuals have baseline and 1 year measurement. A variable called eventname is the indicator of that. I am now confused as my "id" variable does not have this information (i.e. the order of measurement). How would the model recognize that which repeated measure is measurment1 (i.e. baseline) and which one is measurment2 (i.e. 1 year)?  Or maybe because I don't have a random slope, I don't need to define the repeated measure structure and adding eventname as a fixed effect is sufficient?

OR do I need to run a model with additional random intercept of eventname but in doing so lme() gives me the number of observation equal to umber of grouping for eventname %in% id %in% family %in% site as follows. Would that be okay?

Number of Observations: 13388
Number of Groups:
                                                       site                                               family %in% site
                                                        21                                                       9393
                                              id %in% family %in% site                  eventname %in% id %in% family %in% abcd_site
                                                     11111                                                      13388

The model formula with eventname as random slope in lme() would be as follows but I have not been able to reproduce this in lmer() similar to implicit formatting of m2.1 shown above - any help would be appreciated here. Keep in mind created an implicit three-way and four-way interaction takes too much memory on my personal PC so I am trying to find a way around it as I did in m2.1.

m3 <- lme(cbcl_scr_syn_internal_r ~ 1 +X1+ X2 + X3, random = ~1|site/family/id//eventname ,
    data=dd, na.action=na.exclude,method="ML")

Again, thank you so much for your time.

Best,

Hedyeh Ahmadi, Ph.D.
Statistician
Keck School of Medicine
Department of Preventive Medicine
University of Southern California

Postdoctoral Scholar
Institute for Interdisciplinary Salivary Bioscience Research (IISBR)
University of California, Irvine

LinkedIn
www.linkedin.com/in/hedyeh-ahmadi<http://www.linkedin.com/in/hedyeh-ahmadi>
<http://www.linkedin.com/in/hedyeh-ahmadi><http://www.linkedin.com/in/hedyeh-ahmadi>