library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(brms)
#> Loading required package: Rcpp
#> Loading 'brms' package (version 2.22.0). Useful instructions
#> can be found by typing help('brms'). A more detailed introduction
#> to the package is available through vignette('brms_overview').
#>
#> Attaching package: 'brms'
#> The following object is masked from 'package:stats':
#>
#> ar
library(bayestestR)
## Simulate data
dd <- tibble(
y_1 = sample(letters[1:3], size = 100, replace = TRUE),
y_2 = sample(letters[1:3], size = 100, replace = TRUE))
## Make ordered
dd[1:2] <- dd |> lapply(\(x) x |> factor(ordered = TRUE, levels = letters[1:3]))
## Count unique observations
dd <- dd |> count(y_1,y_2)
## Ordered model
f1 <- bf(mvbind(y_1,y_2)|resp_weights(n) ~ 1, family = cumulative(link = "logit")) + set_rescor(FALSE)
m1 <- brm(f1, chains = 1, backend = "cmdstanr", data = dd,refresh = 0)
#> Start sampling
#> Running MCMC with 1 chain...
#>
#> Chain 1 finished in 0.1 seconds.
#> Loading required package: rstan
#> Loading required package: StanHeaders
#>
#> rstan version 2.32.6 (Stan version 2.32.2)
#> For execution on a local, multicore CPU with excess RAM we recommend calling
#> options(mc.cores = parallel::detectCores()).
#> To avoid recompilation of unchanged Stan programs, we recommend calling
#> rstan_options(auto_write = TRUE)
#> For within-chain threading using `reduce_sum()` or `map_rect()` Stan functions,
#> change `threads_per_chain` option:
#> rstan_options(threads_per_chain = 1)
## describe_posterior fails
m1 |> describe_posterior()
#> Warning in mapply(FUN = f, ..., SIMPLIFY = FALSE): longer argument not a
#> multiple of length of shorter
#> Warning in mapply(FUN = f, ..., SIMPLIFY = FALSE): longer argument not a
#> multiple of length of shorter
#> Error in fix.by(by.y, y): 'by' must specify a uniquely valid column
sessionInfo()
#> R version 4.4.2 (2024-10-31)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.2 LTS
#>
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=fi_FI.UTF-8 LC_COLLATE=en_US.UTF-8
#> [5] LC_MONETARY=fi_FI.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=fi_FI.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=fi_FI.UTF-8 LC_IDENTIFICATION=C
#>
#> time zone: Europe/Helsinki
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] bayestestR_0.15.2 brms_2.22.0 Rcpp_1.0.14 dplyr_1.1.4
#>
#> loaded via a namespace (and not attached):
#> [1] bridgesampling_1.1-2 tensorA_0.36.2.1 generics_0.1.3
#> [4] stringi_1.8.4 lattice_0.22-6 digest_0.6.37
#> [7] magrittr_2.0.3 evaluate_1.0.3 grid_4.4.2
#> [10] mvtnorm_1.3-3 fastmap_1.2.0 Matrix_1.7-2
#> [13] backports_1.5.0 Brobdingnag_1.2-9 scales_1.3.0
#> [16] abind_1.4-8 cli_3.6.3 rlang_1.1.5
#> [19] munsell_0.5.1 reprex_2.1.1.9000 withr_3.0.2
#> [22] yaml_2.3.10 tools_4.4.2 parallel_4.4.2
#> [25] rstantools_2.4.0 checkmate_2.3.2 coda_0.19-4.1
#> [28] colorspace_2.1-1 ggplot2_3.5.1 vctrs_0.6.5
#> [31] posterior_1.6.0 R6_2.5.1 matrixStats_1.5.0
#> [34] lifecycle_1.0.4 stringr_1.5.1 fs_1.6.5
#> [37] insight_1.0.2.9 pkgconfig_2.0.3 RcppParallel_5.1.10
#> [40] pillar_1.10.1 gtable_0.3.6 loo_2.8.0
#> [43] glue_1.8.0 xfun_0.50 tibble_3.2.1
#> [46] tidyselect_1.2.1 rstudioapi_0.17.1 knitr_1.49
#> [49] bayesplot_1.11.1 htmltools_0.5.8.1 nlme_3.1-167
#> [52] rmarkdown_2.29 compiler_4.4.2 distributional_0.5.0
Describe the bug
describe_posteriorfails with multivariate brms models that have weighted observations.To Reproduce
Expected behaviour
Expected behaviour is to report summaries of the posterior distrubution for these responses.
Specifiations (please complete the following information):