easystats / see

:art: Visualisation toolbox for beautiful and publication-ready figures
https://easystats.github.io/see/
Other
874 stars 43 forks source link

Fix for compare_parameters(effects = "random") #338

Closed strengejacke closed 5 months ago

strengejacke commented 5 months ago
library(glmmTMB)
library(lme4)
library(blme)
library(ggplot2); theme_set(theme_bw())
library(easystats)

gdat <- readRDS(system.file("vignette_data", "gophertortoise.rds", package = "glmmTMB"))
form <- shells~prev + offset(log(Area)) + factor(year) + (1 | Site)
gmod_glmer <- glmer(form, family = poisson, data = gdat)

gmod_bglmer <- bglmer(form, family=poisson, data=gdat)
## cov.prior = gamma(shape = 2.5, rate = 0, common.scale = TRUE, posterior.scale = "sd"))
gmod_glmmTMB <- glmmTMB(form, family = poisson, data = gdat) ## 1e-5
## bglmer default corresponds to gamma(Inf, 2.5)
gprior <- data.frame(prior = "gamma(1e8, 2.5)",
                     class = "theta",
                     coef = "")
gmod_glmmTMB_p <- update(gmod_glmmTMB, priors = gprior)
vc1 <- c(VarCorr(gmod_glmmTMB_p)$cond$Site)
vc2 <- c(VarCorr(gmod_bglmer)$Site)
all.equal(vc1, vc2, tolerance = 5e-4)

compare_parameters(
  gmod_glmer, gmod_glmmTMB, gmod_bglmer, gmod_glmmTMB_p,
  effects = "random"
) |> plot()
codecov[bot] commented 5 months ago

Codecov Report

Attention: Patch coverage is 31.57895% with 13 lines in your changes are missing coverage. Please review.

:exclamation: No coverage uploaded for pull request base (main@6782928). Click here to learn what that means.

Files Patch % Lines
R/plot.compare_parameters.R 31.57% 13 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #338 +/- ## ======================================= Coverage ? 47.95% ======================================= Files ? 67 Lines ? 5086 Branches ? 0 ======================================= Hits ? 2439 Misses ? 2647 Partials ? 0 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.