Closed cjpratt94 closed 1 year ago
Which package versions do you use? For me, both models work fine. See reprex below (ignore the rendering):
library(glmmTMB)
library(sjPlot)
#generate data
set.seed(10)
y <- rnbinom(n = 1000, size = 7, prob = 0.5)
x <- rnorm(n =1000)
df <- data.frame(y, x)
#nbinom2
mod <- glmmTMB(y ~ x, data = df, family = nbinom2)
tab_model(mod) #runs fine
#> Random effect variances not available. Returned R2 does not account for random effects.
y | |||
---|---|---|---|
Predictors | Incidence Rate Ratios | CI | p |
(Intercept) | 7.14 | 6.91 – 7.38 | \<0.001 |
x | 0.98 | 0.95 – 1.01 | 0.252 |
Observations | 1000 | ||
R2 conditional / R2 marginal | NA / 0.000 |
#tweedie
mod1 <- glmmTMB(y ~ x, data = df, family = tweedie)
tab_model(mod1) #returns error`
y | |||
---|---|---|---|
Predictors | Estimates | CI | p |
(Intercept) | 7.14 | 6.92 – 7.37 | \<0.001 |
x | 0.98 | 0.95 – 1.01 | 0.241 |
Observations | 1000 |
Created on 2022-06-05 by the reprex package (v2.0.1)
Hi Daniel. Thanks for your response. I'm using the latest versions of both packages and of R, and have made sure not to load any other packages. Here is my sessionInfo:
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] LC_COLLATE=English_Canada.utf8 LC_CTYPE=English_Canada.utf8 LC_MONETARY=English_Canada.utf8 LC_NUMERIC=C LC_TIME=English_Canada.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] sjPlot_2.8.10 glmmTMB_1.1.3
loaded via a namespace (and not attached):
[1] sjlabelled_1.2.0 xfun_0.31 tidyselect_1.1.2 TMB_1.8.1 performance_0.9.0 purrr_0.3.4 splines_4.2.0 lattice_0.20-45 parameters_0.17.0
[10] colorspace_2.0-3 vctrs_0.4.1 generics_0.1.2 utf8_1.2.2 rlang_1.0.2 nloptr_2.0.1 pillar_1.7.0 glue_1.6.2 DBI_1.1.2
[19] modelr_0.1.8 effectsize_0.6.0.1 emmeans_1.7.4-1 lifecycle_1.0.1 sjmisc_2.8.9 munsell_0.5.0 gtable_0.3.0 bayestestR_0.12.1 mvtnorm_1.1-3
[28] coda_0.19-4 knitr_1.39 datawizard_0.4.1 fansi_1.0.3 broom_0.8.0 Rcpp_1.0.8.3 xtable_1.8-4 backports_1.4.1 scales_1.2.0
[37] ggeffects_1.1.2 lme4_1.1-29 ggplot2_3.3.6 insight_0.17.1 dplyr_1.0.9 numDeriv_2016.8-1.1 grid_4.2.0 sjstats_0.18.1 cli_3.3.0
[46] tools_4.2.0 magrittr_2.0.3 tibble_3.1.7 tidyr_1.2.0 crayon_1.5.1 pkgconfig_2.0.3 MASS_7.3-56 ellipsis_0.3.2 Matrix_1.4-1
[55] estimability_1.3 assertthat_0.2.1 minqa_1.2.4 R6_2.5.1 boot_1.3-28 nlme_3.1-157 compiler_4.2.0
Please try https://github.com/strengejacke/sjPlot/issues/769#issuecomment-1491384638, that should resolve this issue. Still cannot reproduce the errors, works fine for me. If you still encounter problems, please re-open or open a new issue. :-)
I am having issues getting
tab_model
to work on a glmmTMB object with a tweedie error distribution - I receive the following error:Error in dimnames(x) <- dn : length of 'dimnames' [1] not equal to array extent
The real model I've been working with is more complex, but the following example reproduces the error and shows that tab_model still works fine with glmmTMB objects fit using other error distributions (e.g. nbinom2):
`library(glmmTMB) library(sjPlot)
generate data
set.seed(10) y <- rnbinom(n = 1000, size = 7, prob = 0.5) x <- rnorm(n =1000)
df <- data.frame(y, x)
nbinom2
mod <- glmmTMB(y ~ x, data = df, family = nbinom2)
summary(mod)
tab_model(mod) #runs fine
tweedie
mod1 <- glmmTMB(y ~ x, data = df, family = tweedie)
summary(mod1)
tab_model(mod1) #returns error`