easystats/parameters

Error: Oops! Cannot create the reference grid. Please open an issue at

InkaMarei opened this issue · 4 comments

I have a problem with a GLMM constructed with glmmTMB. My variable is mortality and since I have zero inflation, I am using the nbinom2 error structure.
My model function looks accordingly:
Test4 <- glmmTMB(Mortality ~ poly(days,4)*Concentration+(1|Plot/subplot), REML=T, data=data, family=nbinom2(link="log"))

Because the estimation procedure of dfs for GLMMs is problematic, I would like to switch to the bootstrapping approach, to derive CIs which also works perfectly fine with the function:

test <- parameters::bootstrap_parameters(Test4, iterations = 1000,parallel = "multicore", n_cpus = 3)

However, to derive the estimated marginal means from my test object at specific days I code:

EMM<- emmeans(test, ~Treatment|days, at=list(days=c(2,10,20)), type="response")

Unfortunately I receive the following error:
Error: Oops! Cannot create the reference grid. Please open an issue at
https://github.com/easystats/parameters/issues.

I would value your support!

Do you have a reproducible example? Else, it is difficult to say something about the source of this error.
@mattansb Maybe you also have any ideas?

Hello,
thank you for coming back to me so quickly! I cannot share my own data, but I was able to reproduce the issue with the example data Salamander in glmmTMB:

m2 <- glmmTMB(count ~ spp + mined + (1|site), family=nbinom2, data=Salamanders)

BootSummary <- parameters::bootstrap_parameters(m2, iterations = 10)

EMM<- emmeans(BootSummary, ~ spp , type="response")

Error: Oops! Cannot create the reference grid. Please open an issue at
https://github.com/easystats/parameters/issues.

I first thought it is a version problem and updated my packages. Maybe you spot a mistake somewhere.

sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.utf8 LC_CTYPE=German_Germany.utf8
[3] LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C
[5] LC_TIME=German_Germany.utf8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] emmeans_1.8.2 glmmTMB_1.1.5

loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 lubridate_1.8.0 mvtnorm_1.1-3 lattice_0.20-45
[5] listenv_0.8.0 tidyr_1.2.1 zoo_1.8-11 assertthat_0.2.1
[9] digest_0.6.30 utf8_1.2.2 parallelly_1.32.1 R6_2.5.1
[13] plyr_1.8.7 backports_1.4.1 coda_0.19-4 ggplot2_3.4.0
[17] pillar_1.8.1 rlang_1.0.6 multcomp_1.4-20 rstudioapi_0.14
[21] minqa_1.2.5 car_3.1-1 furrr_0.3.1 nloptr_2.0.3
[25] Matrix_1.5-1 splines_4.2.1 lme4_1.1-31 TMB_1.9.1
[29] stringr_1.4.1 munsell_0.5.0 ARTool_0.11.1 broom_1.0.1
[33] numDeriv_2016.8-1.1 compiler_4.2.1 janitor_2.1.0 pkgconfig_2.0.3
[37] parameters_0.20.1.3 globals_0.16.2 broom.mixed_0.2.9.4 insight_0.18.8.12
[41] tidyselect_1.2.0 tibble_3.1.8 codetools_0.2-18 fansi_1.0.3
[45] future_1.29.0 dplyr_1.0.10 MASS_7.3-58.1 grid_4.2.1
[49] nlme_3.1-157 xtable_1.8-4 gtable_0.3.1 lifecycle_1.0.3
[53] DBI_1.1.3 magrittr_2.0.3 bayestestR_0.13.0.5 scales_1.2.1
[57] datawizard_0.6.5.5 estimability_1.4.1 cli_3.4.1 stringi_1.7.8
[61] XETAana_0.1.0 carData_3.0-5 snakecase_0.11.0 generics_0.1.3
[65] vctrs_0.5.0 boot_1.3-28.1 sandwich_3.0-2 TH.data_1.1-1
[69] tools_4.2.1 forcats_0.5.2 glue_1.6.2 purrr_0.3.5
[73] parallel_4.2.1 abind_1.4-5 survival_3.3-1 colorspace_2.0-3

I think this is happening because there is an extra row in the bootstrapped dataframe representing the dispersion intercept in a the nbinom2 family:

library(glmmTMB)
library(parameters)

m2 <- glmmTMB(count ~ spp + mined + (1 | site),
              family = nbinom2, data = Salamanders)

bootstrap_parameters(m2, iterations = 10) |> 
  as.data.frame()
#>     Parameter Coefficient      CI_low    CI_high   p
#> 1 (Intercept)  -1.5464931 -2.12553447 -1.2151131 0.0
#> 2       sppPR  -1.2706853 -1.48845219 -0.9792343 0.0
#> 3       sppDM   0.3979453  0.03406326  0.7311283 0.0
#> 4     sppEC-A  -0.6999619 -1.08440559 -0.4190783 0.0
#> 5     sppEC-L   0.5645030 -0.13390214  0.9733434 0.2
#> 6    sppDES-L   0.7924686  0.36426929  1.0715466 0.0
#> 7       sppDF   0.1725326 -0.03011180  0.5240801 0.4
#> 8     minedno   2.2055853  1.90054517  2.5885492 0.0
#> 9        <NA>          NA          NA         NA 0.6

Not sure how to fix this exactly - I don't think I wrote parameters:::bootstrap_model.glmmTMB()...

Yeah I realized that, too. Will look into it