modelbased
modelbased copied to clipboard
visualisation_recipe() : check for multiple CIs
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)
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)
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
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
Hi Dominique,
OK, thank you for your prompt answer, and thank you for developing/maintaining the package!
Ladislas