Empty plot in 4.3.5?
inigourrestarazu opened this issue · 3 comments
Hi!
I am not able to reproduce the plot in section 4.3.5. I copy-pasted the code in the whole chapter, but the bars of the plot are missing. The problem is somehow related to the "df_recall_ext", because when I drop it from the pp_check
function, I get the posterior predictive plot for the sizes in "df_recall".
I don't know if it's just my problem.
I just tried it and it worked for me. I'm using bayesplot_1.9.0, are you using an older version perhaps?
can you past all the code that you run, the output of df_recall_ext
, and the output of sessionInfo()
?
Hi, there!
The version I have for bayesplot is 1.10. Anyway, it may totally be my thing. I don't usually load the packages, but specify package::function
and it may be related to that.
The code:
df_recall <- bcogsci::df_recall
df_recall <- df_recall %>% dplyr::mutate(
c_set_size = set_size - mean(set_size)
)
fit_recall <-
brms::brm(correct ~ 1 + c_set_size,
data = df_recall,
family = brms::bernoulli(link = "logit"),
prior = c(
brms::prior(normal(0, 1.5), class = Intercept),
brms::prior(normal(0, 0.1), class = b, coef = c_set_size)
))
df_recall_ext <- df_recall %>%
bind_rows(tibble(
set_size = rep(c(3, 5, 7), 23),
c_set_size = set_size -
mean(df_recall$set_size),
correct = 0
))
# nicer label for the facets:
set_size <- paste("set size", 2:8) %>%
setNames(-3:3)
pp_check(fit_recall,
type = "stat_grouped",
stat = "mean",
group = "c_set_size",
newdata = df_recall_ext,
facet_args = list(
ncol = 1, scales = "fixed",
labeller = as_labeller(set_size)
),
binwidth = 0.02
)
Output of df_recall_ext
df_recall_ext
# A tibble: 161 × 8
subj set_size correct trial session block tested c_set_size
<chr> <dbl> <dbl> <int> <int> <int> <int> <dbl>
1 10 4 1 1 1 1 2 -1
2 10 8 0 4 1 1 8 3
3 10 2 1 9 1 1 2 -3
4 10 6 1 23 1 1 2 1
5 10 4 1 5 1 2 3 -1
6 10 8 0 7 1 2 5 3
7 10 6 1 10 1 2 3 1
8 10 2 1 19 1 2 1 -3
9 10 2 1 9 1 3 2 -3
10 10 6 0 16 1 3 5 1
# … with 151 more rows
# ℹ Use `print(n = ...)` to see more rows
SessionInfo:
sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 13.2.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
other attached packages:
[1] forcats_0.5.2 stringr_1.5.0
[3] dplyr_1.0.10 purrr_1.0.1
[5] readr_2.1.3 tidyr_1.3.0
[7] tibble_3.1.8 ggplot2_3.4.0
[9] tidyverse_1.3.2 brms_2.18.0
[11] Rcpp_1.0.10 bcogsci_0.0.0.9000
[13] tidybayes_3.0.2
loaded via a namespace (and not attached):
[1] readxl_1.4.1 backports_1.4.1
[3] plyr_1.8.8 igraph_1.3.5
[5] splines_4.2.0 svUnit_1.0.6
[7] crosstalk_1.2.0 rstantools_2.2.0
[9] inline_0.3.19 digest_0.6.31
[11] htmltools_0.5.4 fansi_1.0.4
[13] magrittr_2.0.3 checkmate_2.1.0
[15] googlesheets4_1.0.1 tzdb_0.3.0
[17] modelr_0.1.10 RcppParallel_5.1.6
[19] matrixStats_0.63.0 xts_0.12.2
[21] timechange_0.1.1 prettyunits_1.1.1
[23] colorspace_2.1-0 rvest_1.0.3
[25] ggdist_3.2.0 haven_2.5.1
[27] rbibutils_2.2.13 xfun_0.35
[29] jsonlite_1.8.4 callr_3.7.3
[31] crayon_1.5.2 lme4_1.1-31
[33] zoo_1.8-11 glue_1.6.2
[35] gargle_1.2.1 gtable_0.3.1
[37] emmeans_1.8.3 sjstats_0.18.2
[39] sjmisc_2.8.9 distributional_0.3.1
[41] pkgbuild_1.4.0 rstan_2.21.8
[43] abind_1.4-5 scales_1.2.1
[45] mvtnorm_1.1-3 DBI_1.1.3
[47] ggeffects_1.1.4 miniUI_0.1.1.1
[49] xtable_1.8-4 performance_0.10.1
[51] stats4_4.2.0 StanHeaders_2.21.0-7
[53] DT_0.26 httr_1.4.4
[55] datawizard_0.6.4 htmlwidgets_1.5.4
[57] threejs_0.3.3 arrayhelpers_1.1-0
[59] posterior_1.3.1 ellipsis_0.3.2
[61] pkgconfig_2.0.3 loo_2.5.1
[63] farver_2.1.1 dbplyr_2.2.1
[65] utf8_1.2.2 tidyselect_1.2.0
[67] labeling_0.4.2 rlang_1.0.6
[69] reshape2_1.4.4 later_1.3.0
[71] munsell_0.5.0 cellranger_1.1.0
[73] tools_4.2.0 cli_3.6.0
[75] generics_0.1.3 sjlabelled_1.2.0
[77] broom_1.0.1 evaluate_0.18
[79] fastmap_1.1.0 yaml_2.3.6
[81] fs_1.5.2 processx_3.8.0
[83] knitr_1.41 nlme_3.1-160
[85] mime_0.12 xml2_1.3.3
[87] compiler_4.2.0 bayesplot_1.10.0
[89] shinythemes_1.2.0 rstudioapi_0.14
[91] reprex_2.0.2 stringi_1.7.8
[93] ps_1.7.2 Brobdingnag_1.2-9
[95] lattice_0.20-45 Matrix_1.5-3
[97] nloptr_2.0.3 markdown_1.4
[99] shinyjs_2.1.0 tensorA_0.36.2
[101] vctrs_0.5.2 pillar_1.8.1
[103] lifecycle_1.0.3 Rdpack_2.4
[105] bridgesampling_1.1-2 estimability_1.4.1
[107] insight_0.18.8 httpuv_1.6.6
[109] extraDistr_1.9.1 R6_2.5.1
[111] promises_1.2.0.1 gridExtra_2.3
[113] codetools_0.2-18 boot_1.3-28.1
[115] colourpicker_1.2.0 MASS_7.3-58.1
[117] gtools_3.9.4 assertthat_0.2.1
[119] withr_2.5.0 shinystan_2.6.0
[121] hms_1.1.2 bayestestR_0.13.0
[123] parallel_4.2.0 grid_4.2.0
[125] sjPlot_2.8.12 coda_0.19-4
[127] minqa_1.2.5 rmarkdown_2.18
[129] googledrive_2.0.0 lubridate_1.9.0
[131] shiny_1.7.3 base64enc_0.1-3
[133] dygraphs_1.1.1.6
The plot:
I'm sorry I never came back to this. I can generate the plot with your code.