Random effect and variance-covariance matrix of random effect with lme4 package are extracted as following:
library(lme4)
fm1 <- lmer(Reaction ~ Days + (1|Subject), sleepstudy)
fm1.rr <- ranef(fm1,condVar=TRUE)
fm1.pv <- attr(rr[[1]],"postVar")
I wonder how I can do this with mgcv? 'gam.vcomp' function does extract the estimated variance components, but not for each level of random effect.
library(mgcv)
fm2 <- gam(Reaction ~ Days + s (Subject, bs="re"), data = sleepstudy, method = "REML")
gam.vcomp(fm2)