Skip to content
New issue

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

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

Already on GitHub? # to your account

visualisation_recipe() : check for multiple CIs #141

Open
bwiernik opened this issue Aug 18, 2021 · 4 comments
Open

visualisation_recipe() : check for multiple CIs #141

bwiernik opened this issue Aug 18, 2021 · 4 comments

Comments

@bwiernik
Copy link
Contributor

If a modelbased object contains multiple CIs, visualization_recipe() currently produces an invalid plot call. It should check for multiple CI columns and then iterate over them with alpha = .3 or so ribbons.

m <- lm(mpg ~ disp, data = mtcars)
modelbased::estimate_expectation(
  m, ci = c(.50, .80, .95)
) |> plot()
#> Registered S3 methods overwritten by 'modelbased':
#>   method                     from      
#>   plot.visualisation_recipe  datawizard
#>   print.visualisation_recipe datawizard
#> Error in FUN(X[[i]], ...): object 'CI_low' not found

Created on 2021-08-18 by the reprex package (v2.0.0)

@DominiqueMakowski
Copy link
Member

Should work now :)

plot(modelbased::estimate_relation(lm(mpg ~ disp, data = mtcars), ci = c(.50, .80, .95)))

Created on 2021-08-19 by the reprex package (v2.0.1)

@lnalborczyk
Copy link

lnalborczyk commented Oct 26, 2022

Hi, it seems a similar problem persists with estimate_grouplevel(), when trying to generate estimates of type "total".

For instance,

library(lme4)
data(sleepstudy)
model <- lmer(formula = Reaction ~ 1 + Days + (1 + Days | Subject), data = sleepstudy)
estimate_grouplevel(model = model, type = "total")

Outputs no CI... The same goes for:

estimate_grouplevel(model = model, type = "total", ci = 0.95)

I can retrieve my 95% CI by specifying multiple ci values, for instance,

estimate_grouplevel(model = model, type = "total", ci = c(0, 0.95) )

But then, the output can not be easily plotted via plot() because it has multiple CI_low and CI_high columns... The following command:

estimate_grouplevel(model = model, type = "total", ci = c(0, 0.95) ) %>% plot()

results in this error:

Error in FUN(X[[i]], ...) : object 'CI_low' not found

Any idea on how to plot estimates from estimate_grouplevel() of type "total"?

Thank you!

Ladislas

@DominiqueMakowski
Copy link
Member

Salut Ladislas,

estimate_grouplevel() likely needs some overhaul, because it's not really stable at the moment (including plotting). I'll try to look into that soon

@lnalborczyk
Copy link

Hi Dominique,

OK, thank you for your prompt answer, and thank you for developing/maintaining the package!

Ladislas

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

No branches or pull requests

4 participants