easystats / see

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

Plotting data from `emmGrid` #30

Closed mattansb closed 5 years ago

mattansb commented 5 years ago

This would also mean that the plotting functions in see need to be updated to use as.data.frame(as.matrix(as.mcmc.emmGrid(x, names = FALSE))), right?

From here

strengejacke commented 5 years ago

I need a small update. I'm not sure which plotting methods actually are affected... Can you give an example what should be plotted?

mattansb commented 5 years ago

It seems like all of them except for bayesfactor_savagedickey and estimate_density:

library(rstanarm)
#> Loading required package: Rcpp
#> Registered S3 methods overwritten by 'ggplot2':
#>   method         from 
#>   [.quosures     rlang
#>   c.quosures     rlang
#>   print.quosures rlang
#> Registered S3 method overwritten by 'xts':
#>   method     from
#>   as.zoo.xts zoo
#> rstanarm (Version 2.18.2, packaged: 2018-11-08 22:19:38 UTC)
#> - Do not expect the default priors to remain the same in future rstanarm versions.
#> Thus, R scripts should specify priors explicitly, even if they are just the defaults.
#> - For execution on a local, multicore CPU with excess RAM we recommend calling
#> options(mc.cores = parallel::detectCores())
#> - Plotting theme set to bayesplot::theme_default().
library(emmeans)
library(bayestestR)
library(see)

junk <- capture.output(stan_model <- stan_lmer(extra ~ group + (1 | ID), data = sleep))
group_diff <- pairs(emmeans(stan_model, ~ group))

plot(bayesfactor_savagedickey(group_diff, prior = stan_model))
#> Computation of Bayes factors: sampling priors, please wait...


plot(ci(group_diff))
#> Warning in data.matrix(x): NAs introduced by coercion
#> Warning in min(x): no non-missing arguments to min; returning Inf
#> Warning in max(x): no non-missing arguments to max; returning -Inf
#> Warning in min(x): no non-missing arguments to min; returning Inf
#> Warning in max(x): no non-missing arguments to max; returning -Inf
#> Error in plot.window(...): need finite 'xlim' values

plot(equivalence_test(group_diff))
#> Error in `[.data.frame`(as.data.frame(model, stringsAsFactors = FALSE), : undefined columns selected

plot(estimate_density(group_diff))

plot(hdi(group_diff))
#> Warning in data.matrix(x): NAs introduced by coercion
#> Warning in min(x): no non-missing arguments to min; returning Inf
#> Warning in max(x): no non-missing arguments to max; returning -Inf
#> Warning in min(x): no non-missing arguments to min; returning Inf
#> Warning in max(x): no non-missing arguments to max; returning -Inf
#> Error in plot.window(...): need finite 'xlim' values

plot(p_direction(group_diff))
#> Error in `[.data.frame`(data, , x$Parameter): undefined columns selected

plot(rope(group_diff))
#> Error in `[.data.frame`(data, , levels_order): undefined columns selected

Created on 2019-06-15 by the reprex package (v0.3.0)

strengejacke commented 5 years ago

ok, thanks! I'll look into this, should go into the next update.