Skip to content
Prev 19113 / 20628 Next

A three-level GLMM with binomial link in R

Hi Ben,
Thank you for all the help and informative replies. Here is some info about my data and my answers:

  *   Yes, I am running the exact model however this is just my toy model to get the code to work.
  *   Reminder, I am trying to get lmer with a continuous outcome (but same data structure, with 3 random intercept) work before moving to glmer() with a logit link with a categorical 0/1 outcome.
  *   Here are some information about my data:
     *   X1: num [1:22945] 9.25 NA 9.22 NA 9.22 NA 9.42 NA 9.25 NA ...
     *   X2: int [1:22945] 117 140 128 125 113 138 126 130 120 121 ...
     *   X3: chr [1:22945] "Female" "Male" "Male" "Male" "Male"
     *   site: chr [1:22945] "site15" "site15" "site15" "site15" "site15" ... (I have 21 sites)
     *   family: int [1:22945] 0 1 1 1 1 3 3 4 4 5 ...
     *   id: chr [1:22945] "id1" "id2" "id2" "id3" "id3"...
  *   The following model gives me the error that "Error: couldn't evaluate grouping factor id:(family:site) within model frame: try adding grouping factor to data frame explicitly if possible" - I ran this same model on a supercomputer and it gave me the same error, so this is not a memory limit issue.
     *   m2 <- lmer(cbcl_scr_syn_internal_r ~ 1 + X1 + X2 + X3 + (1|site/family/id),  data=dd, REML = FALSE)
  *   The following model ran on a supercomputer.  This is the model that previously would give me the error "Error: cannot allocate vector of size 2.3 Gb". Here I am reducing the number of sites to see if it runs, and it did run on a supercomputer.
     *   m11 <- lmer(cbcl_scr_syn_internal_r ~ 1 + X1 +X2 + X3 +(1|site/family/id) ,
    data=dd[-which(dd$abcd_site %in% c("site01","site02", "site04", "site05", "site06", "site07", "site08","site09")),],  na.action=na.exclude, REML=FALSE)

Questions:

  1.  What I don't understand is that in m2, why lmer() does not recognizes the grouping factor that it does recognize in m11?
  2.  At this point I don't think this is a memory issue as m2 did not run on a supercomputer and it's giving me the same error as my personal computer. However, in m11, the same grouping structure is being recognized when I reduce the number of sites from 21 to 13 - could this be because of severe imbalance in my family/id nesting, meaning most families have only one kid but some have 2 and a few have 3 kids?

Sorry about the long email and thank you for your help in advance.

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>