@@ -689,31 +689,8 @@ as.data.frame.VarCorr.lme <- function(x, row.names = NULL, optional = FALSE, ...
689689# store essential information about variance components...
690690# basically, this function should return lme4::VarCorr(x)
691691.get_variance_information <- function (model , model_component = " conditional" ) {
692- # reason to be installed
693- reason <- " to compute random effect variances for mixed models"
694-
695- # installed?
696- insight :: check_if_installed(" lme4" , reason = reason )
697-
698- if (inherits(model , " lme" )) {
699- insight :: check_if_installed(" nlme" , reason = reason )
700- }
701-
702- if (inherits(model , " clmm" )) {
703- insight :: check_if_installed(" ordinal" , reason = reason )
704- }
705-
706- if (inherits(model , " brmsfit" )) {
707- insight :: check_if_installed(" brms" , reason = reason )
708- }
709-
710- if (inherits(model , " cpglmm" )) {
711- insight :: check_if_installed(" cplm" , reason = reason )
712- }
713-
714- if (inherits(model , " rstanarm" )) {
715- insight :: check_if_installed(" rstanarm" , reason = reason )
716- }
692+ # check if packages are available
693+ .check_mixedmodels_namespace(model )
717694
718695 # stanreg
719696 # ---------------------------
@@ -835,6 +812,39 @@ as.data.frame.VarCorr.lme <- function(x, row.names = NULL, optional = FALSE, ...
835812}
836813
837814
815+ .check_mixedmodels_namespace <- function (model ) {
816+ # reason to be installed
817+ reason <- " to compute random effect variances for mixed models"
818+
819+ # installed?
820+ insight :: check_if_installed(" lme4" , reason = reason )
821+
822+ if (inherits(model , " lme" )) {
823+ insight :: check_if_installed(" nlme" , reason = reason )
824+ }
825+
826+ if (inherits(model , " glmmTMB" )) {
827+ insight :: check_if_installed(" glmmTMB" , reason = reason )
828+ }
829+
830+ if (inherits(model , " clmm" )) {
831+ insight :: check_if_installed(" ordinal" , reason = reason )
832+ }
833+
834+ if (inherits(model , " brmsfit" )) {
835+ insight :: check_if_installed(" brms" , reason = reason )
836+ }
837+
838+ if (inherits(model , " cpglmm" )) {
839+ insight :: check_if_installed(" cplm" , reason = reason )
840+ }
841+
842+ if (inherits(model , " rstanarm" )) {
843+ insight :: check_if_installed(" rstanarm" , reason = reason )
844+ }
845+ }
846+
847+
838848# glmmTMB returns a list of model information, one for conditional
839849# and one for zero-inflation part, so here we "unlist" it, returning
840850# only the conditional part.
0 commit comments