Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DHARMa: fittedModel not in class of supported models for a glmmTMB model #414

Open
Franelizabethgalvez opened this issue Jun 3, 2024 · 3 comments
Labels

Comments

@Franelizabethgalvez
Copy link

Hi, I was trying to correct a warning message from DHARMa: Warning message:
In simulateResiduals(fittedModel = m2) :DHARMa: fittedModel not in class of supported models. Absolutely no guarantee that this will work!

For this model:
m1<-glmmTMB(NPQ ~ Temp*LUZ*Tiempo + (1|ID) + (1|Intensidad), data=dp, family=beta_family(link="logit"), ziformula= ~(1|Intensidad))

Despite installing the current (development) version from this repository. (devtools::install_github(repo = "florianhartig/DHARMa", subdir = "DHARMa", dependencies = T) the warning keeps appearing and the plot does not appear, but says: Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y'

I have checked other models that used to work fine with DHARMa and now I get the same warning and error,

Unfortunately my other computer was stolen and I don't know what version of DHARMa I had, but with this version installed it should work.

This code: devtools::install_github(repo = "florianhartig/DHARMa", subdir = "DHARMa", dependencies = T, build_vignettes = T) gives me this error:Error: Vignette re-building failed. Execution halted Error: Failed to install 'DHARMa' from GitHub: Failed to install 'glmmTMB' from GitHub: ! System command 'R' failed ding ‘troubleshooting.rmd’ only runs the installation omitting: build_vignettes = T , maybe that's the problem!!

My R version: R 4.4.0 GUI 1.80 Big Sur ARM build in macOS 13.0

If anyone has any recommendations or help, I would appreciate it.

THANKS!! ;)

@florianhartig
Copy link
Owner

florianhartig commented Jun 4, 2024

I'm a bit surprised by the warning - could you paste a reproducible example? See also https://github.com/florianhartig/DHARMa/wiki/Asking-for-help

EDIT: what I mean is can you dput your data or produce a reduced example?

@Franelizabethgalvez
Copy link
Author

Franelizabethgalvez commented Jun 4, 2024

Hi, thanks for the reply! ;) (I managed to solve the problem, but I still leave the example for anyone who has the same problem in the future)

Sorry for not providing a reproducible example, but here it is:

For this data: dp<-read.delim("UV_T_NPQ_0_24h.txt", header=T, stringsAsFactors=T)

dp$Temp<-factor(dp$Temp)
dp$Tiempo<-factor(dp$Tiempo)
dp$LUZ<-factor(dp$LUZ)
dp$ID<-factor(dp$ID)

Fit this model: m1<-glmmTMB(NPQ ~ Temp*LUZ*Tiempo + (1|ID) + (1|Intensidad), data=dp, family=beta_family(link="logit"), ziformula= ~(1|Intensidad))

When checking residuals :
library("DHARMa")
m2simuOutput <- simulateResiduals(fittedModel = m1)
this warning appeared: Warning message: In simulateResiduals(fittedModel = m2) :DHARMa: fittedModel not in class of supported models. Absolutely no guarantee that this will work!
when running the plot :
plot(m2simuOutput)
this error appeared: Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y'

Try to install the current (development) version: devtools::install_github(repo = "florianhartig/DHARMa", subdir = "DHARMa", dependencies = T, build_vignettes = T) but I got error with build_vignettes so I removed it. Then I restarted R and then removed stringsAsFactors=T when I loaded my data and finally DHARMa ran without warnings or errors.

UV_T_NPQ_0_24h.txt

Thanks for your quick response ;)

Session info:
R version 4.4.0 (2024-04-24)
Platform: aarch64-apple-darwin20
Running under: macOS Ventura 13.0

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Santiago
tzcode source: internal

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

other attached packages:
[1] DHARMa_0.4.6 ggeffects_1.5.2 forecast_8.22.0 lsmeans_2.30-0
[5] emmeans_1.10.1 multcompView_0.1-10 multcomp_1.4-25 TH.data_1.1-2
[9] survival_3.5-8 mvtnorm_1.2-4 betareg_3.1-4 doBy_4.6.21
[13] see_0.8.4.2 report_0.5.8.3 parameters_0.21.7.2 modelbased_0.8.7.1
[17] effectsize_0.8.8.1 datawizard_0.10.0.6 correlation_0.8.4.3 bayestestR_0.13.2.2
[21] easystats_0.7.1.3 insight_0.19.11.4 performance_0.11.0.9 sjlabelled_1.2.0
[25] sjmisc_2.8.10 sjPlot_2.8.16 lubridate_1.9.3 forcats_1.0.0
[29] stringr_1.5.1 purrr_1.0.2 readr_2.1.5 tidyr_1.3.1
[33] tibble_3.2.1 tidyverse_2.0.0 reshape_0.8.9 bbmle_1.0.25.1
[37] knitr_1.47 TMB_1.9.11 glmmTMB_1.1.9-9000 lme4_1.1-35.3
[41] Matrix_1.7-0 car_3.1-2 carData_3.0-5 MASS_7.3-60.2
[45] magrittr_2.0.3 ggpubr_0.6.0 ggplot2_3.5.1 plyr_1.8.9
[49] dplyr_1.1.4 devtools_2.4.5 usethis_2.2.3 remotes_2.5.0
[53] pkgbuild_1.4.4

loaded via a namespace (and not attached):
[1] rstudioapi_0.16.0 estimability_1.5.1 modeltools_0.2-23 nloptr_2.0.3
[5] fs_1.6.4 vctrs_0.6.5 memoise_2.0.1 minqa_1.2.7
[9] rstatix_0.7.2 htmltools_0.5.8.1 curl_5.2.1 broom_1.0.6
[13] Formula_1.2-5 TTR_0.24.4 htmlwidgets_1.6.4 sandwich_3.1-0
[17] zoo_1.8-12 cachem_1.1.0 commonmark_1.9.1 mime_0.12
[21] lifecycle_1.0.4 pkgconfig_2.0.3 gap_1.5-3 R6_2.5.1
[25] fastmap_1.2.0 rbibutils_2.2.16 shiny_1.8.1.1 digest_0.6.35
[29] numDeriv_2016.8-1.1 colorspace_2.1-0 pkgload_1.3.4 fansi_1.0.6
[33] timechange_0.3.0 abind_1.4-5 mgcv_1.9-1 compiler_4.4.0
[37] microbenchmark_1.4.10 withr_3.0.0 tseries_0.10-56 backports_1.5.0
[41] ggsignif_0.6.4 sjstats_0.19.0 sessioninfo_1.2.2 tools_4.4.0
[45] lmtest_0.9-40 quantmod_0.4.26 httpuv_1.6.15 nnet_7.3-19
[49] quadprog_1.5-8 glue_1.7.0 nlme_3.1-164 promises_1.3.0
[53] grid_4.4.0 generics_0.1.3 gtable_0.3.5 tzdb_0.4.0
[57] hms_1.1.3 xml2_1.3.6 Deriv_4.1.3 utf8_1.2.4
[61] flexmix_2.3-19 pillar_1.9.0 later_1.3.2 splines_4.4.0
[65] lattice_0.22-6 tidyselect_1.2.1 miniUI_0.1.1.1 reformulas_0.2.0
[69] urca_1.3-3 xfun_0.44 timeDate_4032.109 stringi_1.8.4
[73] boot_1.3-30 codetools_0.2-20 cli_3.6.2 xtable_1.8-4
[77] Rdpack_2.6 munsell_0.5.1 modelr_0.1.11 Rcpp_1.0.12
[81] coda_0.19-4.1 parallel_4.4.0 bdsmatrix_1.3-7 ellipsis_0.3.2
[85] fracdiff_1.5-3 gap.datasets_0.0.6 profvis_0.3.8 urlchecker_1.0.1
[89] xts_0.13.2 scales_1.3.0 rlang_1.1.3 cowplot_1.1.3

@florianhartig florianhartig changed the title DHARMa: fittedModel not in class of supported models?? V. 0.4.6 DHARMa: fittedModel not in class of supported models for a glmmTMB model Jun 5, 2024
@florianhartig
Copy link
Owner

Hi @Franelizabethgalvez,

glad that this is solved. It sounds still a bit odd to me because glmmTMB is supported and should't be flagged, and also the stringAsFactors = T shouldn't really change anything if your data was coded correct in the first place.

If I were you, I would definitely investigate what changed in your model between the two ways to provide the data, and please feel free to add here any insight you have.

Best
F

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants