@@ -313,11 +313,13 @@ check_collinearity.betamfx <- check_collinearity.logitor
313313
314314# ' @rdname check_collinearity
315315# ' @export
316- check_collinearity.glmmTMB <- function (x ,
317- component = " all" ,
318- ci = 0.95 ,
319- verbose = TRUE ,
320- ... ) {
316+ check_collinearity.glmmTMB <- function (
317+ x ,
318+ component = " all" ,
319+ ci = 0.95 ,
320+ verbose = TRUE ,
321+ ...
322+ ) {
321323 component <- insight :: validate_argument(
322324 component ,
323325 c(" all" , " conditional" , " count" , " zi" , " zero_inflated" )
@@ -327,11 +329,13 @@ check_collinearity.glmmTMB <- function(x,
327329
328330
329331# ' @export
330- check_collinearity.MixMod <- function (x ,
331- component = " all" ,
332- ci = 0.95 ,
333- verbose = TRUE ,
334- ... ) {
332+ check_collinearity.MixMod <- function (
333+ x ,
334+ component = " all" ,
335+ ci = 0.95 ,
336+ verbose = TRUE ,
337+ ...
338+ ) {
335339 component <- insight :: validate_argument(
336340 component ,
337341 c(" all" , " conditional" , " count" , " zi" , " zero_inflated" )
@@ -341,11 +345,13 @@ check_collinearity.MixMod <- function(x,
341345
342346
343347# ' @export
344- check_collinearity.hurdle <- function (x ,
345- component = " all" ,
346- ci = 0.95 ,
347- verbose = verbose ,
348- ... ) {
348+ check_collinearity.hurdle <- function (
349+ x ,
350+ component = " all" ,
351+ ci = 0.95 ,
352+ verbose = verbose ,
353+ ...
354+ ) {
349355 component <- insight :: validate_argument(
350356 component ,
351357 c(" all" , " conditional" , " count" , " zi" , " zero_inflated" )
@@ -355,11 +361,13 @@ check_collinearity.hurdle <- function(x,
355361
356362
357363# ' @export
358- check_collinearity.zeroinfl <- function (x ,
359- component = " all" ,
360- ci = 0.95 ,
361- verbose = verbose ,
362- ... ) {
364+ check_collinearity.zeroinfl <- function (
365+ x ,
366+ component = " all" ,
367+ ci = 0.95 ,
368+ verbose = verbose ,
369+ ...
370+ ) {
363371 component <- insight :: validate_argument(
364372 component ,
365373 c(" all" , " conditional" , " count" , " zi" , " zero_inflated" )
@@ -369,11 +377,13 @@ check_collinearity.zeroinfl <- function(x,
369377
370378
371379# ' @export
372- check_collinearity.zerocount <- function (x ,
373- component = " all" ,
374- ci = 0.95 ,
375- verbose = verbose ,
376- ... ) {
380+ check_collinearity.zerocount <- function (
381+ x ,
382+ component = " all" ,
383+ ci = 0.95 ,
384+ verbose = verbose ,
385+ ...
386+ ) {
377387 component <- insight :: validate_argument(
378388 component ,
379389 c(" all" , " conditional" , " count" , " zi" , " zero_inflated" )
@@ -385,11 +395,17 @@ check_collinearity.zerocount <- function(x,
385395# utilities ---------------------------------
386396
387397.check_collinearity_zi_model <- function (x , component , ci = 0.95 , verbose = TRUE ) {
388- if (component == " count" ) component <- " conditional"
389- if (component == " zi" ) component <- " zero_inflated"
398+ if (component == " count" ) {
399+ component <- " conditional"
400+ }
401+ if (component == " zi" ) {
402+ component <- " zero_inflated"
403+ }
390404
391405 mi <- insight :: model_info(x , verbose = FALSE )
392- if (! mi $ is_zero_inflated ) component <- " conditional"
406+ if (! mi $ is_zero_inflated ) {
407+ component <- " conditional"
408+ }
393409
394410 if (component == " all" ) {
395411 cond <- .check_collinearity(x , " conditional" , ci = ci , verbose = verbose )
@@ -439,7 +455,10 @@ check_collinearity.zerocount <- function(x,
439455 if (isTRUE(verbose )) {
440456 insight :: format_alert(
441457 paste(
442- sprintf(" Could not extract the variance-covariance matrix for the %s component of the model." , component ),
458+ sprintf(
459+ " Could not extract the variance-covariance matrix for the %s component of the model." ,
460+ component
461+ ),
443462 " Please try to run `vcov(model)`, which may help identifying the problem."
444463 )
445464 )
@@ -453,13 +472,15 @@ check_collinearity.zerocount <- function(x,
453472 if (is.null(term_assign ) || all(is.na(term_assign ))) {
454473 if (verbose ) {
455474 insight :: format_alert(
456- sprintf(" Could not extract model terms for the %s component of the model." , component )
475+ sprintf(
476+ " Could not extract model terms for the %s component of the model." ,
477+ component
478+ )
457479 )
458480 }
459481 return (NULL )
460482 }
461483
462-
463484 # we have rank-deficiency here. remove NA columns from assignment
464485 if (isTRUE(attributes(v )$ rank_deficient ) && ! is.null(attributes(v )$ na_columns_index )) {
465486 term_assign <- term_assign [- attributes(v )$ na_columns_index ]
@@ -482,9 +503,11 @@ check_collinearity.zerocount <- function(x,
482503
483504 # hurdle or zeroinfl model can have no zero-inflation formula, in which case
484505 # we have the same formula as for conditional formula part
485- if (inherits(x , c(" hurdle" , " zeroinfl" , " zerocount" )) &&
486- component == " zero_inflated" &&
487- is.null(f [[" zero_inflated" ]])) {
506+ if (
507+ inherits(x , c(" hurdle" , " zeroinfl" , " zerocount" )) &&
508+ component == " zero_inflated" &&
509+ is.null(f [[" zero_inflated" ]])
510+ ) {
488511 f $ zero_inflated <- f $ conditional
489512 }
490513
@@ -503,7 +526,10 @@ check_collinearity.zerocount <- function(x,
503526 if (n.terms < 2 ) {
504527 if (isTRUE(verbose )) {
505528 insight :: format_alert(
506- sprintf(" Not enough model terms in the %s part of the model to check for multicollinearity." , component )
529+ sprintf(
530+ " Not enough model terms in the %s part of the model to check for multicollinearity." ,
531+ component
532+ )
507533 )
508534 }
509535 return (NULL )
@@ -639,17 +665,20 @@ check_collinearity.zerocount <- function(x,
639665 tryCatch(
640666 {
641667 if (inherits(x , c(" hurdle" , " zeroinfl" , " zerocount" ))) {
642- term_assign <- switch (component ,
668+ term_assign <- switch (
669+ component ,
643670 conditional = attr(insight :: get_modelmatrix(x , model = " count" ), " assign" ),
644671 zero_inflated = attr(insight :: get_modelmatrix(x , model = " zero" ), " assign" )
645672 )
646673 } else if (inherits(x , " glmmTMB" )) {
647- term_assign <- switch (component ,
674+ term_assign <- switch (
675+ component ,
648676 conditional = attr(insight :: get_modelmatrix(x ), " assign" ),
649677 zero_inflated = .zi_term_assignment(x , component , verbose = verbose )
650678 )
651679 } else if (inherits(x , " MixMod" )) {
652- term_assign <- switch (component ,
680+ term_assign <- switch (
681+ component ,
653682 conditional = attr(insight :: get_modelmatrix(x , type = " fixed" ), " assign" ),
654683 zero_inflated = attr(insight :: get_modelmatrix(x , type = " zi_fixed" ), " assign" )
655684 )
@@ -692,7 +721,10 @@ check_collinearity.zerocount <- function(x,
692721 }))
693722
694723 if (insight :: is_gam_model(x )) {
695- model_params <- as.vector(unlist(insight :: find_parameters(x )[c(component , " smooth_terms" )]))
724+ model_params <- as.vector(unlist(insight :: find_parameters(x )[c(
725+ component ,
726+ " smooth_terms"
727+ )]))
696728 } else {
697729 model_params <- insight :: find_parameters(x )[[component ]]
698730 }
0 commit comments