Closed DominiqueMakowski closed 2 years ago
insight::clean_parameters()
comes close to what you're looking for, I guess, and was written exactly for this purpose. Mostly to support printing by components.
library(rstanarm)
#> Loading required package: Rcpp
#> This is rstanarm version 2.21.1
#> - See https://mc-stan.org/rstanarm/articles/priors for changes to default priors!
#> - Default priors may change, so it's safest to specify priors, even if equivalent to the defaults.
#> - For execution on a local, multicore CPU with excess RAM we recommend calling
#> options(mc.cores = parallel::detectCores())
data <- lme4::sleepstudy
model <- rstanarm::stan_lmer(Reaction ~ Days + (1 | Subject), data = data, refresh = 0)
insight::clean_parameters(model)
#> Parameter Effects Component
#> 1 (Intercept) fixed conditional
#> 2 Days fixed conditional
#> 3 b[(Intercept) Subject:308] random conditional
#> 4 b[(Intercept) Subject:309] random conditional
#> 5 b[(Intercept) Subject:310] random conditional
#> 6 b[(Intercept) Subject:330] random conditional
#> 7 b[(Intercept) Subject:331] random conditional
#> 8 b[(Intercept) Subject:332] random conditional
#> 9 b[(Intercept) Subject:333] random conditional
#> 10 b[(Intercept) Subject:334] random conditional
#> 11 b[(Intercept) Subject:335] random conditional
#> 12 b[(Intercept) Subject:337] random conditional
#> 13 b[(Intercept) Subject:349] random conditional
#> 14 b[(Intercept) Subject:350] random conditional
#> 15 b[(Intercept) Subject:351] random conditional
#> 16 b[(Intercept) Subject:352] random conditional
#> 17 b[(Intercept) Subject:369] random conditional
#> 18 b[(Intercept) Subject:370] random conditional
#> 19 b[(Intercept) Subject:371] random conditional
#> 20 b[(Intercept) Subject:372] random conditional
#> 21 Sigma[Subject:(Intercept),(Intercept)] random conditional
#> 22 sigma fixed sigma
#> Group Cleaned_Parameter
#> 1 (Intercept)
#> 2 Days
#> 3 Intercept: Subject Subject:308
#> 4 Intercept: Subject Subject:309
#> 5 Intercept: Subject Subject:310
#> 6 Intercept: Subject Subject:330
#> 7 Intercept: Subject Subject:331
#> 8 Intercept: Subject Subject:332
#> 9 Intercept: Subject Subject:333
#> 10 Intercept: Subject Subject:334
#> 11 Intercept: Subject Subject:335
#> 12 Intercept: Subject Subject:337
#> 13 Intercept: Subject Subject:349
#> 14 Intercept: Subject Subject:350
#> 15 Intercept: Subject Subject:351
#> 16 Intercept: Subject Subject:352
#> 17 Intercept: Subject Subject:369
#> 18 Intercept: Subject Subject:370
#> 19 Intercept: Subject Subject:371
#> 20 Intercept: Subject Subject:372
#> 21 SD/Cor: Subject (Intercept)
#> 22 sigma
Created on 2022-03-26 by the reprex package (v2.0.1)
that's awesome! should we add clean_parameters inside parameters(group_level = TRUE) to have more consistent outputs?
It's added as attributes attr(params, "parameter_info")
, and used in the format.parameters_stan()
method for printing. So the "printing" should be identical.
Indeed it is! Sorry I missed this :) What do you think about adding the Group / Level columns in the main output (not just as an attribute)? It'd be easier to work with
should be resolved in #686, let's wait for tests, to see whether any code breaks...
Close this?
Frequentist models have a "EFfects" and "Group" columns, quite convenient to filter out desired group-level parameters, but Bayesian models don't
Created on 2022-03-26 by the reprex package (v2.0.1)