2

When trying to graph the conditional fixed effects of a glmmTMB model with two random intercepts in GGally I get the error:

There was an error calling "tidy_fun()". Most likely, this is because the function supplied in "tidy_fun=" was misspelled, does not exist, is not compatible with your object, or was missing necessary arguments (e.g. "conf.level=" or "conf.int="). See error message below. Error: Error in "stop_vctrs()": ! Can't recycle "..1" (size 3) to match "..2" (size 2).`

I have tinkered with figuring out the issue and it seems to be related to the two random intercepts included in the model. I have also tried extracting the coefficient and standard error information separately through broom.mixed::tidy and then feeding the data frame into GGally:ggcoef() with no avail. Any suggestions?

# Example with built-in randu data set
data(randu)
randu$A <- factor(rep(c(1,2), 200))
randu$B <- factor(rep(c(1,2,3,4), 100))

# Model
test <- glmmTMB(y ~ x + z + (0 +x|A) + (1|B), family="gaussian", data=randu)

# A few of my attempts at graphing--works fine when only one random effects term is in model
ggcoef_model(test)

ggcoef_model(test, tidy_fun = broom.mixed::tidy)

ggcoef_model(test, tidy_fun = broom.mixed::tidy, conf.int = T, intercept=F)

ggcoef_model(test, tidy_fun = broom.mixed::tidy(test, effects="fixed", component = "cond", conf.int = TRUE))

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
Charlie_J
  • 89
  • 6

1 Answers1

1

There are some (old!) bugs that have recently been fixed (here, here) that would make confidence interval reporting on RE parameters break for any model with multiple random terms (I think). I believe that if you are able to install updated versions of both glmmTMB and broom.mixed:

remotes::install_github("glmmTMB/glmmTMB/glmmTMB@ci_tweaks")
remotes::install_github("bbolker/broom.mixed")

then ggcoef_model(test) will work.

enter image description here

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • Thanks Ben, that works. However, I am still getting the same error when I try and plot a model with a large fixed theta for the conditional term. Any suggestions? Model example: ```test <- glmmTMB(y ~ x + z + (0 +x|A) + (1|B), family="gaussian", data=randu, start = list(theta = c(0,log(1e3))), map = list(theta = factor(c(1,NA))))``` – Charlie_J Jun 10 '22 at 23:10
  • Another buglet. I'll work on it. – Ben Bolker Jun 11 '22 at 01:00
  • 1
    OK, I think this should work OK with mapped parameters now, as long as you stick to Wald intervals and don't try with uniroot/profile intervals ... – Ben Bolker Jun 18 '22 at 01:46