Giter VIP home page Giter VIP logo

Comments (4)

strengejacke avatar strengejacke commented on August 17, 2024

Do you have a reproducible example?

from performance.

jpcsuarez avatar jpcsuarez commented on August 17, 2024

Thanks for the quick response. Kindly see the following example. x1 (or the first variable of the zero-component) gets omitted. The same thing happens to my larger hurdle/zero-inflated glmmTMB files.

library(glmmTMB)
library(performance)

hnb <- readRDS(file='dummy_glmmTMB.RDS')
summary(hnb)

 Family: truncated_nbinom2  ( log )
Formula:          retweet_count ~ 1 + x1 + x2 + x3
Zero inflation:                 retweet_count ~ 1 + x1 + x2 + x3
Data: df

      AIC       BIC    logLik  deviance  df.resid 
 297794.3  297888.2 -148888.2  297776.3    249991 


Dispersion parameter for truncated_nbinom2 family (): 5.62e-10 

Conditional model:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept) -15.707384 229.293433  -0.069   0.9454    
x1           -0.436397   0.048344  -9.027   <2e-16 ***
x2           -0.015658   0.007164  -2.186   0.0289 *  
x3           -0.147176   0.007903 -18.624   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Zero-inflation model:
             Estimate Std. Error z value Pr(>|z|)    
(Intercept)  2.200223   0.009541  230.62   <2e-16 ***
x1          -0.242178   0.019934  -12.15   <2e-16 ***
x2          -0.044450   0.002258  -19.69   <2e-16 ***
x3           0.227055   0.007253   31.30   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
check_collinearity(hnb)

# Check for Multicollinearity

* conditional component:

Low Correlation

 Term  VIF   VIF 95% CI Increased SE Tolerance Tolerance 95% CI
   x1 1.07 [1.07, 1.08]         1.03      0.93     [0.93, 0.94]
   x2 1.19 [1.18, 1.19]         1.09      0.84     [0.84, 0.85]
   x3 1.11 [1.11, 1.12]         1.05      0.90     [0.90, 0.90]

* zero inflated component:

Low Correlation

 Term  VIF   VIF 95% CI Increased SE Tolerance Tolerance 95% CI
   x2 1.04 [1.03, 1.04]         1.02      0.96     [0.96, 0.97]
   x3 1.03 [1.02, 1.03]         1.01      0.97     [0.97, 0.98]

dummy_glmmTMB.zip

from performance.

strengejacke avatar strengejacke commented on August 17, 2024

Thanks! You misspecified the ziformula - glmmTMB should throw a warning indicating that the ziformula doesn't require an outcome. Removing the LHS from the ziformula fixes your issue:

library(glmmTMB)
library(performance)

hnb <- readRDS(file = "c:/Users/mail/Desktop/dummy_glmmTMB.RDS")
d <- insight::get_data(hnb, verbose = FALSE)

m <- glmmTMB(
  retweet_count ~ x1 + x2 + x3,
  data = d,
  family = truncated_nbinom2,
  ziformula = ~ x1 + x2 + x3,
  dispformula = ~1
)
check_collinearity(m)
#> # Check for Multicollinearity
#> 
#> * conditional component:
#> 
#> Low Correlation
#> 
#>  Term  VIF   VIF 95% CI Increased SE Tolerance Tolerance 95% CI
#>    x1 1.07 [1.07, 1.08]         1.03      0.93     [0.93, 0.94]
#>    x2 1.19 [1.18, 1.19]         1.09      0.84     [0.84, 0.85]
#>    x3 1.11 [1.11, 1.12]         1.05      0.90     [0.90, 0.90]
#> 
#> * zero inflated component:
#> 
#> Low Correlation
#> 
#>  Term  VIF   VIF 95% CI Increased SE Tolerance Tolerance 95% CI
#>    x1 1.04 [1.03, 1.04]         1.02      0.96     [0.96, 0.97]
#>    x2 1.03 [1.02, 1.03]         1.01      0.97     [0.97, 0.98]
#>    x3 1.02 [1.01, 1.02]         1.01      0.98     [0.98, 0.99]

m <- glmmTMB(
  retweet_count ~ x1 + x2 + x3,
  data = d,
  family = truncated_nbinom2,
  ziformula = retweet_count ~ x1 + x2 + x3,
  dispformula = ~1
)
#> Warning in f(init, x[[i]]): discarding LHS of second argument
check_collinearity(m)
#> # Check for Multicollinearity
#> 
#> * conditional component:
#> 
#> Low Correlation
#> 
#>  Term  VIF   VIF 95% CI Increased SE Tolerance Tolerance 95% CI
#>    x1 1.07 [1.07, 1.08]         1.03      0.93     [0.93, 0.94]
#>    x2 1.19 [1.18, 1.19]         1.09      0.84     [0.84, 0.85]
#>    x3 1.11 [1.11, 1.12]         1.05      0.90     [0.90, 0.90]
#> 
#> * zero inflated component:
#> 
#> Low Correlation
#> 
#>  Term  VIF   VIF 95% CI Increased SE Tolerance Tolerance 95% CI
#>    x2 1.04 [1.03, 1.04]         1.02      0.96     [0.96, 0.97]
#>    x3 1.03 [1.02, 1.03]         1.01      0.97     [0.97, 0.98]

Created on 2023-12-21 with reprex v2.0.2

from performance.

jpcsuarez avatar jpcsuarez commented on August 17, 2024

Ah my mistake then, thanks so much! Everything works now.

Maybe one last question: will check_overdispersion() be available someday for pscl based models?

from performance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.