title: How can I extract the random effects information from lmm and lqmm models using multiple imputed data?
body: <p>Continuing from this question: <a href="https://stackoverflow.com/questions/72514230/is-it-possible-to-use-lqmm-with-a-mira-object">Is it possible to use lqmm with a mira object?</a></p>
  <p>I have tried to get the random effects for the mixed models (lmm and lqmm), and it has been hard.</p>
  <pre><code>library(lqmm)
  library(mice)
  library(lme4)
  library(mitml)
  
  summary(airquality)
  imputed&lt;-mice(airquality,m=5)
  summary(imputed)
  fit1&lt;-lqmm(Ozone~Solar.R+Wind+Temp+Day,random=~1,
             tau=0.5, group= Month, data=airquality,na.action=na.omit)
  fit1
  summary(fit1)
  
  fit2&lt;-with(imputed, lqmm(Ozone~Solar.R+Wind+Temp+Day,random=~1,
                           tau=0.5, group= Month, na.action=na.omit)) 
  #did not work because it does not recognize a data frame
  
  fit2 &lt;- with(imputed, 
               lqmm(Ozone ~ Solar.R + Wind + Temp + Day,
                    data = data.frame(mget(ls())),
                    random = ~1, tau = 0.5, group = Month, na.action = na.omit))
  
  tidy.lqmm &lt;- function(x, conf.int = FALSE, conf.level = 0.95, ...) {
    broom:::as_tidy_tibble(data.frame(
      estimate = coef(x),
      std.error = sqrt(
        diag(summary(x, covariance = TRUE, 
                     R = 50)$Cov[names(coef(x)),
                                 names(coef(x))]))))
  }
  glance.lqmm &lt;- function(x, ...) {
    broom:::as_glance_tibble(
      logLik = as.numeric(stats::logLik(x)),
      df.residual = summary(x)$rdf,
      nobs = stats::nobs(x),
      na_types = &quot;rii&quot;)
  }
  
  pool(fit2)
  summary(pool(fit2))
  </code></pre>
  <p>So far so good, but I want to build a table that resembles the sJPlot::tab_model function on lmer objects. For this, I need to extract the random effects from the pooled estimates. This is where I am lost. I have not been able to do it with the linear mixed model, much less with the linear quantile mixed model.</p>
  <pre><code>Extract the Random-effects from an LMM and LQMM.
  ##LMM
  fit3 &lt;- with(imputed, 
               lmer(Ozone ~ Solar.R + Wind + Temp + Day+ (1|Month))) 
  library(broom.mixed)
  summary(pool(fit3))
  
  library(sjPlot)
  tab_model(fit3$analyses) #this will give me the results for each of the 5 lmer, but I need the pooled ones
  pool(fit3)$glanced # also this will five me the random effects for each of the 5 lmer
  
  stargazer(fit3$analyses,type=&quot;text&quot;)#this would give the AIC, LL, and BYC
  
  #something like
  tab_model(pool(fit3$analyses))
  
  &quot;Error ....
    Could not access model information.&quot;
  
  #or
  tab_model(pool(fit3)) #A data frame is not a valid object for this function.
  
  
  ##LQMM
  tab_model(fit2$analyses)#gives me less information
  pool(fit2)$glanced #gives the 5 models logLik, df.residual and nobs individually 
  </code></pre>
  <p><strong>UPDATE</strong>: I could find a formula to extract the random effects of the LMM thanks to <a href="https://stackoverflow.com/questions/37110899/can-i-pool-imputed-random-effect-model-estimates-using-the-mi-package">Can I pool imputed random effect model estimates using the mi package?</a>. However, does not work for LQMM</p>
  <pre><code>testEstimates(as.mitml.result(fit3), extra.pars = T)$extra.pars
  testEstimates(as.mitml.result(fit2), extra.pars = T)$extra.pars
  </code></pre>
  <blockquote>
  <p>Error in UseMethod(&quot;vcov&quot;) :    no applicable method for 'vcov'
  applied to an object of class &quot;lqmm&quot;</p>
  </blockquote>
  <p>The Pooled Random Effects information I need for both lmer and lqmm with sjPlot::tab_model and stargazer:</p>
  <ul>
  <li>sigma^2: Pooled Residual Variance.</li>
  <li>tau_00Month: Pooled Variance
  explained by the month (between month differences).</li>
  <li>ICC: Pooled
  sigma^2/ (sigma^2+tau_00Month).</li>
  <li>N_Month: n. Months used in the
  regression.</li>
  <li>Marginal R2/ Conditional R2:  The marginal R-squared
  considers only the variance of the fixed effects, while the
  conditional R-squared takes both the fixed and random effects into
  account.</li>
  <li>Residual Scale Parameter:  also would appreciate it if somebody clarifies what this is calculating.</li>
  <li>Log-Likelihood:</li>
  <li>Akaike Inf. Crit.:</li>
  </ul>