Skip to content
Prev 19105 / 20628 Next

A three-level GLMM with binomial link in R

Here's an example that conforms approximately to the structure of 
your data: on my machine the peak RAM usage is 121 Mb, far short of your 
2.3 Gb ...  so I still suspect there is something going on that we don't 
know about/haven't guessed yet.

set.seed(101)
N <- 22945
ns <- 100
nf <- 100
nid <- 100
dd <- data.frame(X1=rnorm(N),
                  X2=rnorm(N),
                  X3=rnorm(N),
                  site=sample(ns, replace=TRUE, size=N),
                  family=sample(nf, replace=TRUE, size=N),
                  id=sample(nid, replace=TRUE, size=N))
form <- Y ~ 1 + X1 + X2 + X3 + (1|site/family/id)
dd$Y <- simulate(form[-2], newdata=dd, family=gaussian,
                  newparams=list(beta=rep(1,4),theta=rep(1,3),sigma=1))[[1]]
library(peakRAM)
mem <- peakRAM(
     m <- lmer(form, data=dd, REML=FALSE)
)

mem
                      Function_Call Elapsed_Time_sec Total_RAM_Used_MiB
1 m<-lmer(form,data=dd,REML=FALSE)            1.754               10.3
   Peak_RAM_Used_MiB
1             120.7
On 3/5/21 4:52 PM, Robert Long wrote: