I want to do the same thing as described here but for glmer models: How do I store lm object in a data frame in R
example model
fit1 <- glmer(y ~ scale(x) + (1 | ID), data=dat, family = binomial, control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
the code described in the above post works well and also gives model summary with
list_models
But does not show specific model elements when requested as below
list_models$fit1$coefficents
#Error in list_models$vasb3$coefficients : $ operator not defined for this S4 class
Question 1(unsolved): I would like to make it work so I can request any elements (e.g. coefficients) from list_models
Question 2 (solved): how should I store it so next time I do not need to re-run models and get the model fit elements from a file?
for question 2 solution:
#save objects to R
saveRDS(list_models, file="list_models.RData")
#read object
readRDS("list_models.RData")
Thanking you!