easystats / insight

:crystal_ball: Easy access to model information for various model objects
https://easystats.github.io/insight/
GNU General Public License v3.0
389 stars 39 forks source link

inconsistency between the prior scale information included in output dataframe #222

Closed IndrajeetPatil closed 3 years ago

IndrajeetPatil commented 3 years ago

@mattansb Thinking of this further, another thing I notice is that Prior_Scale values are NA for anovaBF outputs.

Should we be including rscaleFixed and rscaleRandom argument values here?

library(BayesFactor)
#> Loading required package: coda
#> Loading required package: Matrix
#> ************
#> Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).
#> 
#> Type BFManual() to open the manual.
#> ************
library(parameters)

data(puzzles)

result = anovaBF(RT ~ shape*color + ID, data = puzzles, whichRandom = "ID",
                 whichModels = 'top', progress=FALSE)

as.data.frame(model_parameters(result))$Prior_Scale
#>  [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
mattansb commented 3 years ago

Not sure what you expect on the parameters side? This is the default behavior of correlationBF / ttestBF (different tests use differently scales priors...).

IndrajeetPatil commented 3 years ago

Ach, apologies. I thought we had opinionated priors for these tests, but now that you mention this, I realize this inconsistency stems from BayesFactor itself.

IndrajeetPatil commented 3 years ago

@mattansb Thinking of this further, another thing I notice is that Prior_Scale values are NA for anovaBF outputs.

Should we be including rscaleFixed and rscaleRandom argument values here?

library(BayesFactor)
#> Loading required package: coda
#> Loading required package: Matrix
#> ************
#> Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).
#> 
#> Type BFManual() to open the manual.
#> ************
library(parameters)

data(puzzles)

result = anovaBF(RT ~ shape*color + ID, data = puzzles, whichRandom = "ID",
                 whichModels = 'top', progress=FALSE)

as.data.frame(model_parameters(result))$Prior_Scale
#>  [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
mattansb commented 3 years ago

It's hard to match the different parameters to the rscale* values (I've had a little back and forth about this with Richard some time ago). That is why, currently, bayestestR::describe_prior() behaves like this:

describe_prior(result)
#>    Parameter Prior_Distribution Prior_Location Prior_Scale
#> 1      fixed             cauchy              0   0.5000000
#> 2     random             cauchy              0   1.0000000
#> 3 continuous             cauchy              0   0.3535534

(And does not return the dist/loc/scale on a parameter basis...)

It is unfortunate that the docs and internals from BayesFactor are somewhat opaque... ๐Ÿคทโ€โ™‚๏ธ

I suggest opening this as a feature request on bayestestR - if it works there, it will work here as well.

DominiqueMakowski commented 3 years ago

Doesn't describe_priors rely itself on insight::get_priors ๐Ÿ˜

I'm not sure I understand what is the issue?

IndrajeetPatil commented 3 years ago

The issue is that Prior_Scale column from model_parameters for anovaBF contains NAs, while it is not NA for the other BF tests.

For example, one-sample t-test

    library(BayesFactor)
    library(parameters)

    model <- ttestBF(x = rnorm(100, 1, 1))
    as.data.frame(model_parameters(model))
    #>    Parameter    Median    CI_low  CI_high pd ROPE_Percentage Prior_Distribution
    #> 1 Difference 0.8943024 0.7003134 1.105907  1               0             cauchy
    #>   Prior_Location Prior_Scale Effects   Component           BF
    #> 1              0   0.7071068   fixed conditional 7.536535e+15
strengejacke commented 3 years ago

This is what I get:

library(BayesFactor)
#> Loading required package: coda
#> Loading required package: Matrix
#> ************
#> Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).
#> 
#> Type BFManual() to open the manual.
#> ************
data(puzzles)

result = anovaBF(RT ~ shape*color + ID, data = puzzles, whichRandom = "ID",
                 whichModels = 'top', progress=FALSE)

insight::get_priors(result)
#>    Parameter Distribution Location     Scale
#> 1      fixed       cauchy        0 0.5000000
#> 2     random       cauchy        0 1.0000000
#> 3 continuous       cauchy        0 0.3535534

bayestestR::describe_posterior(result)
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#>              Parameter     Median CI      CI_low    CI_high      pd ROPE_CI
#> 20                  mu 44.9995360 89 43.81886593 46.0112048 1.00000      89
#> 22         shape-round  0.4287515 89  0.14221308  0.7567978 0.98975      89
#> 23        shape-square -0.4287515 89 -0.75679784 -0.1422131 0.98975      89
#> 1          color-color -0.4286762 89 -0.73877251 -0.1367203 0.98750      89
#> 2  color-monochromatic  0.4286762 89  0.13672027  0.7387725 0.98750      89
#> 8                 ID-1  2.4739495 89  1.09330337  3.9717513 0.99625      89
#> 12                ID-2  0.4195921 89 -0.94950711  1.8824135 0.69700      89
#> 13                ID-3  0.8798805 89 -0.56285774  2.3080603 0.85300      89
#> 14                ID-4  0.4767006 89 -0.89647667  1.8895565 0.69275      89
#> 15                ID-5  3.1602326 89  1.73420933  4.6631944 1.00000      89
#> 16                ID-6  0.4772122 89 -1.01083371  1.8206981 0.69625      89
#> 17                ID-7 -3.1566652 89 -4.61220177 -1.6353605 0.99975      89
#> 18                ID-8 -0.2518115 89 -1.67235185  1.2315339 0.58625      89
#> 19                ID-9 -2.4922985 89 -3.90178050 -1.0604600 0.99625      89
#> 9                ID-10  0.6498484 89 -0.66506693  2.1864021 0.78450      89
#> 10               ID-11  0.6704275 89 -0.77048153  2.0721755 0.78175      89
#> 11               ID-12 -3.3874473 89 -4.89478836 -1.9327297 0.99975      89
#> 24                sig2  1.7511495 89  1.18317492  2.5900721 1.00000      89
#> 7              g_shape  0.3527367 89  0.01828558  2.2414989 1.00000      89
#> 5              g_color  0.3418209 89  0.02022153  2.2027349 1.00000      89
#> 6                 g_ID  2.6587834 89  0.80518350  5.3445872 1.00000      89
#> 3           continuous         NA NA          NA         NA      NA      NA
#> 4                fixed         NA NA          NA         NA      NA      NA
#> 21              random         NA NA          NA         NA      NA      NA
#>    ROPE_low ROPE_high ROPE_Percentage        BF Prior_Distribution
#> 20     -0.1       0.1      0.00000000 2.6132620               <NA>
#> 22     -0.1       0.1      0.00000000 0.2381810               <NA>
#> 23     -0.1       0.1      0.00000000 0.2362146               <NA>
#> 1      -0.1       0.1      0.00000000 2.6132620               <NA>
#> 2      -0.1       0.1      0.00000000 0.2381810               <NA>
#> 8      -0.1       0.1      0.00000000 0.2362146               <NA>
#> 12     -0.1       0.1      0.07862960 2.6132620               <NA>
#> 13     -0.1       0.1      0.05953384 0.2381810               <NA>
#> 14     -0.1       0.1      0.09126650 0.2362146               <NA>
#> 15     -0.1       0.1      0.00000000 2.6132620               <NA>
#> 16     -0.1       0.1      0.08480764 0.2381810               <NA>
#> 17     -0.1       0.1      0.00000000 0.2362146               <NA>
#> 18     -0.1       0.1      0.10249930 2.6132620               <NA>
#> 19     -0.1       0.1      0.00000000 0.2381810               <NA>
#> 9      -0.1       0.1      0.07722550 0.2362146               <NA>
#> 10     -0.1       0.1      0.06402696 2.6132620               <NA>
#> 11     -0.1       0.1      0.00000000 0.2381810               <NA>
#> 24     -0.1       0.1      0.00000000 0.2362146               <NA>
#> 7      -0.1       0.1      0.11738276 2.6132620               <NA>
#> 5      -0.1       0.1      0.13591688 0.2381810               <NA>
#> 6      -0.1       0.1      0.00000000 0.2362146               <NA>
#> 3        NA        NA              NA        NA             cauchy
#> 4        NA        NA              NA        NA             cauchy
#> 21       NA        NA              NA        NA             cauchy
#>    Prior_Location Prior_Scale
#> 20             NA          NA
#> 22             NA          NA
#> 23             NA          NA
#> 1              NA          NA
#> 2              NA          NA
#> 8              NA          NA
#> 12             NA          NA
#> 13             NA          NA
#> 14             NA          NA
#> 15             NA          NA
#> 16             NA          NA
#> 17             NA          NA
#> 18             NA          NA
#> 19             NA          NA
#> 9              NA          NA
#> 10             NA          NA
#> 11             NA          NA
#> 24             NA          NA
#> 7              NA          NA
#> 5              NA          NA
#> 6              NA          NA
#> 3               0   0.3535534
#> 4               0   0.5000000
#> 21              0   1.0000000

parameters::model_parameters(result)
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> # Extra Parameters 
#> 
#> Parameter | Median |         89% CI |   pd | % in ROPE |   BF
#> -------------------------------------------------------------
#> mu        |  45.00 | [43.99, 46.21] | 100% |        0% | 2.61
#> sig2      |   1.75 | [ 1.16,  2.51] | 100% |        0% | 0.24
#> g_shape   |   0.36 | [ 0.02,  2.35] | 100% |    13.17% | 2.61
#> g_color   |   0.35 | [ 0.02,  2.25] | 100% |    12.58% | 0.24
#> g_ID      |   2.64 | [ 0.83,  5.29] | 100% |        0% | 0.24
#> 
#> # Fixed Effects 
#> 
#> Parameter           | Median |         89% CI |     pd | % in ROPE |   BF
#> -------------------------------------------------------------------------
#> shape-round         |   0.43 | [ 0.11,  0.73] | 98.67% |        0% | 0.24
#> shape-square        |  -0.43 | [-0.73, -0.11] | 98.67% |        0% | 0.24
#> color-color         |  -0.43 | [-0.73, -0.12] | 99.12% |        0% | 2.61
#> color-monochromatic |   0.43 | [ 0.12,  0.73] | 99.12% |        0% | 0.24
#> 
#> # Random Effects 
#> 
#> Parameter | Median |         89% CI |     pd | % in ROPE |   BF
#> ---------------------------------------------------------------
#> ID-1      |   2.49 | [ 0.99,  3.93] | 99.62% |        0% | 0.24
#> ID-2      |   0.45 | [-1.10,  1.82] | 68.20% |     9.35% | 2.61
#> ID-3      |   0.91 | [-0.58,  2.34] | 83.90% |     6.04% | 0.24
#> ID-4      |   0.45 | [-0.96,  1.87] | 69.27% |     8.59% | 0.24
#> ID-5      |   3.18 | [ 1.66,  4.63] | 99.92% |        0% | 2.61
#> ID-6      |   0.43 | [-0.99,  1.85] | 70.33% |     9.46% | 0.24
#> ID-7      |  -3.19 | [-4.70, -1.69] | 99.95% |        0% | 0.24
#> ID-8      |  -0.23 | [-1.67,  1.25] | 60.58% |    10.28% | 2.61
#> ID-9      |  -2.48 | [-3.97, -1.04] | 99.42% |        0% | 0.24
#> ID-10     |   0.66 | [-0.80,  2.10] | 77.72% |     7.89% | 0.24
#> ID-11     |   0.66 | [-0.80,  2.16] | 77.30% |     7.64% | 2.61
#> ID-12     |  -3.40 | [-4.84, -1.92] | 99.95% |        0% | 0.24

Created on 2020-09-12 by the reprex package (v0.3.0)

strengejacke commented 3 years ago

Please re-open an issue if it's not resolved, else the discussion gets lost.

IndrajeetPatil commented 3 years ago

Ah, thanks for the details. I guess then the issue is if the info about prior scale present in bayestestR::describe_posterior can also be included in parameters::model_parameters for anovaBF outputs.

mattansb commented 3 years ago

(note that I fixed the weird BF column given here - these should all be the same value for a given model)

I thought the issue was that the location/scale were not given for each parameter (what Indrajeet wanted?), but is given for the different parameter types (fixed, random...).

-- Mattan S. Ben-Shachar, PhD student Department of Psychology & Zlotowski Center for Neuroscience Ben-Gurion University of the Negev The Developmental ERP Lab

On Sat, Sep 12, 2020, 09:47 Indrajeet Patil notifications@github.com wrote:

Ah, thanks for the details. I guess then the issue is if the info about prior scale present in bayestestR::describe_posterior can also be included in parameters::model_parameters.

โ€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/easystats/bayestestR/issues/336#issuecomment-691427675, or unsubscribe https://github.com/notifications/unsubscribe-auth/AINRP6EQCANYPZI6J5N4J7TSFMKRXANCNFSM4RH5SNBA .

DominiqueMakowski commented 3 years ago

If I understand, in order to fix it and to have prior information displayed alongside each parameter, we would in theory need to retrieve which parameters are "continuous" "fixed" and "random" and combine accordingly with the parameters table is that correct?

strengejacke commented 3 years ago

Yes, that's how I understood this as well.

DominiqueMakowski commented 3 years ago

I feel like it would make sense to retrieve this kind of info at insight's level no?

IndrajeetPatil commented 3 years ago

Should I transfer this issue to insight repo then?

DominiqueMakowski commented 3 years ago

I think so yes? Because it's not really tied to Bayesian stuff per se but rather an issue of retrieving / tidying some info from a given package ๐Ÿคทโ€โ™‚๏ธ

strengejacke commented 3 years ago

Now we need someone who knows whether a parameter is fixed, random or continuous.

mattansb commented 3 years ago

This won't work for the cases detailed in #223 ...

get_type <- function(trm) {
  if (grepl(":", trm, fixed = TRUE)) {
    trm <- unlist(strsplit(trm, ":", fixed = TRUE))
  }

  if (any(trm %in% dataTypes[["random"]])) {
    "random"
  } else if (any(trm %in% dataTypes[["continuous"]])) {
    "continuous"
  } else if (any(trm %in% dataTypes[["fixed"]])) {
    "fixed"
  } else {
    ""
  }
}

library(BayesFactor)
#> Loading required package: coda
#> Loading required package: Matrix
#> ************
#> Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).
#> 
#> Type BFManual() to open the manual.
#> ************

iris$ID <- factor(rep(1:30, each = 5))
res <- lmBF(Sepal.Length ~ Species * Sepal.Width + Petal.Width + ID + Sepal.Width:ID, data = iris,
            whichRandom = c("ID","Sepal.Width:ID"),
            progress = FALSE)
#> Warning in doNwaySampling(method, y, X, rscale, iterations, gMap, incCont, :
#> Some NAs were removed from sampling results: 10000 in total.

pars <- insight::get_parameters(res)

if (insight::model_info(res)$is_linear) {
  dataTypes <- res@numerator[[1]]@dataTypes
  dataTypes <- tapply(names(dataTypes), dataTypes, "[", simplify = FALSE)

  par_names_clean <- sub("\\-(.*)", "", colnames(pars))
  # par_names_clean <- par_names_clean[-(which(par_names_clean=="sig2"):length(par_names_clean))]

  par_types <- sapply(par_names_clean, get_type)
}

par_types <- setNames(names(par_types),par_types)

priors <- insight::get_priors(res)
idx <- sapply(names(par_types), function(x) {
  if (!any(i <- x==priors$Parameter)) return(NA)
  which(i)
})

priors <- priors[idx,]
priors$Parameter <- colnames(pars)

priors
#>                                         Parameter Distribution Location
#> NA                                             mu         <NA>       NA
#> 1                                  Species-setosa       cauchy        0
#> 1.1                            Species-versicolor       cauchy        0
#> 1.2                             Species-virginica       cauchy        0
#> 3                         Sepal.Width-Sepal.Width       cauchy        0
#> 3.1                       Petal.Width-Petal.Width       cauchy        0
#> 2                                            ID-1       cauchy        0
#> 2.1                                          ID-2       cauchy        0
#> 2.2                                          ID-3       cauchy        0
#> 2.3                                          ID-4       cauchy        0
#> 2.4                                          ID-5       cauchy        0
#> 2.5                                          ID-6       cauchy        0
#> 2.6                                          ID-7       cauchy        0
#> 2.7                                          ID-8       cauchy        0
#> 2.8                                          ID-9       cauchy        0
#> 2.9                                         ID-10       cauchy        0
#> 2.10                                        ID-11       cauchy        0
#> 2.11                                        ID-12       cauchy        0
#> 2.12                                        ID-13       cauchy        0
#> 2.13                                        ID-14       cauchy        0
#> 2.14                                        ID-15       cauchy        0
#> 2.15                                        ID-16       cauchy        0
#> 2.16                                        ID-17       cauchy        0
#> 2.17                                        ID-18       cauchy        0
#> 2.18                                        ID-19       cauchy        0
#> 2.19                                        ID-20       cauchy        0
#> 2.20                                        ID-21       cauchy        0
#> 2.21                                        ID-22       cauchy        0
#> 2.22                                        ID-23       cauchy        0
#> 2.23                                        ID-24       cauchy        0
#> 2.24                                        ID-25       cauchy        0
#> 2.25                                        ID-26       cauchy        0
#> 2.26                                        ID-27       cauchy        0
#> 2.27                                        ID-28       cauchy        0
#> 2.28                                        ID-29       cauchy        0
#> 2.29                                        ID-30       cauchy        0
#> 3.2      Species:Sepal.Width-setosa.&.Sepal.Width       cauchy        0
#> 3.3  Species:Sepal.Width-versicolor.&.Sepal.Width       cauchy        0
#> 3.4   Species:Sepal.Width-virginica.&.Sepal.Width       cauchy        0
#> 2.30                             Sepal.Width:ID-1       cauchy        0
#> 2.31                             Sepal.Width:ID-2       cauchy        0
#> 2.32                             Sepal.Width:ID-3       cauchy        0
#> 2.33                             Sepal.Width:ID-4       cauchy        0
#> 2.34                             Sepal.Width:ID-5       cauchy        0
#> 2.35                             Sepal.Width:ID-6       cauchy        0
#> 2.36                             Sepal.Width:ID-7       cauchy        0
#> 2.37                             Sepal.Width:ID-8       cauchy        0
#> 2.38                             Sepal.Width:ID-9       cauchy        0
#> 2.39                            Sepal.Width:ID-10       cauchy        0
#> 2.40                            Sepal.Width:ID-11       cauchy        0
#> 2.41                            Sepal.Width:ID-12       cauchy        0
#> 2.42                            Sepal.Width:ID-13       cauchy        0
#> 2.43                            Sepal.Width:ID-14       cauchy        0
#> 2.44                            Sepal.Width:ID-15       cauchy        0
#> 2.45                            Sepal.Width:ID-16       cauchy        0
#> 2.46                            Sepal.Width:ID-17       cauchy        0
#> 2.47                            Sepal.Width:ID-18       cauchy        0
#> 2.48                            Sepal.Width:ID-19       cauchy        0
#> 2.49                            Sepal.Width:ID-20       cauchy        0
#> 2.50                            Sepal.Width:ID-21       cauchy        0
#> 2.51                            Sepal.Width:ID-22       cauchy        0
#> 2.52                            Sepal.Width:ID-23       cauchy        0
#> 2.53                            Sepal.Width:ID-24       cauchy        0
#> 2.54                            Sepal.Width:ID-25       cauchy        0
#> 2.55                            Sepal.Width:ID-26       cauchy        0
#> 2.56                            Sepal.Width:ID-27       cauchy        0
#> 2.57                            Sepal.Width:ID-28       cauchy        0
#> 2.58                            Sepal.Width:ID-29       cauchy        0
#> 2.59                            Sepal.Width:ID-30       cauchy        0
#> NA.1                                         sig2         <NA>       NA
#> NA.2                                    g_Species         <NA>       NA
#> NA.3                                         g_ID         <NA>       NA
#> NA.4                                 g_continuous         <NA>       NA
#>          Scale
#> NA          NA
#> 1    0.5000000
#> 1.1  0.5000000
#> 1.2  0.5000000
#> 3    0.3535534
#> 3.1  0.3535534
#> 2    1.0000000
#> 2.1  1.0000000
#> 2.2  1.0000000
#> 2.3  1.0000000
#> 2.4  1.0000000
#> 2.5  1.0000000
#> 2.6  1.0000000
#> 2.7  1.0000000
#> 2.8  1.0000000
#> 2.9  1.0000000
#> 2.10 1.0000000
#> 2.11 1.0000000
#> 2.12 1.0000000
#> 2.13 1.0000000
#> 2.14 1.0000000
#> 2.15 1.0000000
#> 2.16 1.0000000
#> 2.17 1.0000000
#> 2.18 1.0000000
#> 2.19 1.0000000
#> 2.20 1.0000000
#> 2.21 1.0000000
#> 2.22 1.0000000
#> 2.23 1.0000000
#> 2.24 1.0000000
#> 2.25 1.0000000
#> 2.26 1.0000000
#> 2.27 1.0000000
#> 2.28 1.0000000
#> 2.29 1.0000000
#> 3.2  0.3535534
#> 3.3  0.3535534
#> 3.4  0.3535534
#> 2.30 1.0000000
#> 2.31 1.0000000
#> 2.32 1.0000000
#> 2.33 1.0000000
#> 2.34 1.0000000
#> 2.35 1.0000000
#> 2.36 1.0000000
#> 2.37 1.0000000
#> 2.38 1.0000000
#> 2.39 1.0000000
#> 2.40 1.0000000
#> 2.41 1.0000000
#> 2.42 1.0000000
#> 2.43 1.0000000
#> 2.44 1.0000000
#> 2.45 1.0000000
#> 2.46 1.0000000
#> 2.47 1.0000000
#> 2.48 1.0000000
#> 2.49 1.0000000
#> 2.50 1.0000000
#> 2.51 1.0000000
#> 2.52 1.0000000
#> 2.53 1.0000000
#> 2.54 1.0000000
#> 2.55 1.0000000
#> 2.56 1.0000000
#> 2.57 1.0000000
#> 2.58 1.0000000
#> 2.59 1.0000000
#> NA.1        NA
#> NA.2        NA
#> NA.3        NA
#> NA.4        NA

Created on 2020-09-15 by the reprex package (v0.3.0)

strengejacke commented 3 years ago

We should first fix clean_parameters() for such models. This is usually the base for matching parameters:

library(insight)
library(BayesFactor)
#> Loading required package: coda
#> Loading required package: Matrix
#> ************
#> Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).
#> 
#> Type BFManual() to open the manual.
#> ************
iris$ID <- factor(rep(1:30, each = 5))
m1 <- lmBF(Sepal.Length ~ Species * Sepal.Width + Petal.Width + ID + Sepal.Width:ID, data = iris,
            rscaleCont = c(Sepal.Width = 0.123, Petal.Width = 0.321),
            whichRandom = c("ID","Sepal.Width:ID"))
#> Warning in rscale[rscaleTypes == "continuous"] <- rscaleCont: number of items to
#> replace is not a multiple of replacement length
#> Warning in doNwaySampling(method, y, X, rscale, iterations, gMap, incCont, :
#> Some NAs were removed from sampling results: 10000 in total.
clean_parameters(m1)
#> Warning in rscale[rscaleTypes == "continuous"] <- rscaleCont: number of items to
#> replace is not a multiple of replacement length
#>                                        Parameter Effects   Component
#> 1                                 Species-setosa   fixed conditional
#> 2                             Species-versicolor   fixed conditional
#> 3                              Species-virginica   fixed conditional
#> 4                                    Sepal.Width   fixed conditional
#> 5                                    Petal.Width   fixed conditional
#> 6                                           ID-1   fixed conditional
#> 7                                           ID-2   fixed conditional
#> 8                                           ID-3   fixed conditional
#> 9                                           ID-4   fixed conditional
#> 10                                          ID-5   fixed conditional
#> 11                                          ID-6   fixed conditional
#> 12                                          ID-7   fixed conditional
#> 13                                          ID-8   fixed conditional
#> 14                                          ID-9   fixed conditional
#> 15                                         ID-10   fixed conditional
#> 16                                         ID-11   fixed conditional
#> 17                                         ID-12   fixed conditional
#> 18                                         ID-13   fixed conditional
#> 19                                         ID-14   fixed conditional
#> 20                                         ID-15   fixed conditional
#> 21                                         ID-16   fixed conditional
#> 22                                         ID-17   fixed conditional
#> 23                                         ID-18   fixed conditional
#> 24                                         ID-19   fixed conditional
#> 25                                         ID-20   fixed conditional
#> 26                                         ID-21   fixed conditional
#> 27                                         ID-22   fixed conditional
#> 28                                         ID-23   fixed conditional
#> 29                                         ID-24   fixed conditional
#> 30                                         ID-25   fixed conditional
#> 31                                         ID-26   fixed conditional
#> 32                                         ID-27   fixed conditional
#> 33                                         ID-28   fixed conditional
#> 34                                         ID-29   fixed conditional
#> 35                                         ID-30   fixed conditional
#> 36      Species:Sepal.Width-setosa.&.Sepal.Width   fixed conditional
#> 37  Species:Sepal.Width-versicolor.&.Sepal.Width   fixed conditional
#> 38   Species:Sepal.Width-virginica.&.Sepal.Width   fixed conditional
#> 39                              Sepal.Width:ID-1   fixed conditional
#> 40                              Sepal.Width:ID-2   fixed conditional
#> 41                              Sepal.Width:ID-3   fixed conditional
#> 42                              Sepal.Width:ID-4   fixed conditional
#> 43                              Sepal.Width:ID-5   fixed conditional
#> 44                              Sepal.Width:ID-6   fixed conditional
#> 45                              Sepal.Width:ID-7   fixed conditional
#> 46                              Sepal.Width:ID-8   fixed conditional
#> 47                              Sepal.Width:ID-9   fixed conditional
#> 48                             Sepal.Width:ID-10   fixed conditional
#> 49                             Sepal.Width:ID-11   fixed conditional
#> 50                             Sepal.Width:ID-12   fixed conditional
#> 51                             Sepal.Width:ID-13   fixed conditional
#> 52                             Sepal.Width:ID-14   fixed conditional
#> 53                             Sepal.Width:ID-15   fixed conditional
#> 54                             Sepal.Width:ID-16   fixed conditional
#> 55                             Sepal.Width:ID-17   fixed conditional
#> 56                             Sepal.Width:ID-18   fixed conditional
#> 57                             Sepal.Width:ID-19   fixed conditional
#> 58                             Sepal.Width:ID-20   fixed conditional
#> 59                             Sepal.Width:ID-21   fixed conditional
#> 60                             Sepal.Width:ID-22   fixed conditional
#> 61                             Sepal.Width:ID-23   fixed conditional
#> 62                             Sepal.Width:ID-24   fixed conditional
#> 63                             Sepal.Width:ID-25   fixed conditional
#> 64                             Sepal.Width:ID-26   fixed conditional
#> 65                             Sepal.Width:ID-27   fixed conditional
#> 66                             Sepal.Width:ID-28   fixed conditional
#> 67                             Sepal.Width:ID-29   fixed conditional
#> 68                             Sepal.Width:ID-30   fixed conditional
#> 69                                          ID-1  random conditional
#> 70                                          ID-2  random conditional
#> 71                                          ID-3  random conditional
#> 72                                          ID-4  random conditional
#> 73                                          ID-5  random conditional
#> 74                                          ID-6  random conditional
#> 75                                          ID-7  random conditional
#> 76                                          ID-8  random conditional
#> 77                                          ID-9  random conditional
#> 78                                         ID-10  random conditional
#> 79                                         ID-11  random conditional
#> 80                                         ID-12  random conditional
#> 81                                         ID-13  random conditional
#> 82                                         ID-14  random conditional
#> 83                                         ID-15  random conditional
#> 84                                         ID-16  random conditional
#> 85                                         ID-17  random conditional
#> 86                                         ID-18  random conditional
#> 87                                         ID-19  random conditional
#> 88                                         ID-20  random conditional
#> 89                                         ID-21  random conditional
#> 90                                         ID-22  random conditional
#> 91                                         ID-23  random conditional
#> 92                                         ID-24  random conditional
#> 93                                         ID-25  random conditional
#> 94                                         ID-26  random conditional
#> 95                                         ID-27  random conditional
#> 96                                         ID-28  random conditional
#> 97                                         ID-29  random conditional
#> 98                                         ID-30  random conditional
#> 99                                            mu   fixed       extra
#> 100                      Sepal.Width-Sepal.Width   fixed       extra
#> 101                      Petal.Width-Petal.Width   fixed       extra
#> 102                                         sig2   fixed       extra
#> 103                                    g_Species   fixed       extra
#> 104                                         g_ID   fixed       extra
#> 105                                 g_continuous   fixed       extra
#>                                Cleaned_Parameter
#> 1                                 Species-setosa
#> 2                             Species-versicolor
#> 3                              Species-virginica
#> 4                                    Sepal.Width
#> 5                                    Petal.Width
#> 6                                           ID-1
#> 7                                           ID-2
#> 8                                           ID-3
#> 9                                           ID-4
#> 10                                          ID-5
#> 11                                          ID-6
#> 12                                          ID-7
#> 13                                          ID-8
#> 14                                          ID-9
#> 15                                         ID-10
#> 16                                         ID-11
#> 17                                         ID-12
#> 18                                         ID-13
#> 19                                         ID-14
#> 20                                         ID-15
#> 21                                         ID-16
#> 22                                         ID-17
#> 23                                         ID-18
#> 24                                         ID-19
#> 25                                         ID-20
#> 26                                         ID-21
#> 27                                         ID-22
#> 28                                         ID-23
#> 29                                         ID-24
#> 30                                         ID-25
#> 31                                         ID-26
#> 32                                         ID-27
#> 33                                         ID-28
#> 34                                         ID-29
#> 35                                         ID-30
#> 36      Species:Sepal.Width-setosa.&.Sepal.Width
#> 37  Species:Sepal.Width-versicolor.&.Sepal.Width
#> 38   Species:Sepal.Width-virginica.&.Sepal.Width
#> 39                              Sepal.Width:ID-1
#> 40                              Sepal.Width:ID-2
#> 41                              Sepal.Width:ID-3
#> 42                              Sepal.Width:ID-4
#> 43                              Sepal.Width:ID-5
#> 44                              Sepal.Width:ID-6
#> 45                              Sepal.Width:ID-7
#> 46                              Sepal.Width:ID-8
#> 47                              Sepal.Width:ID-9
#> 48                             Sepal.Width:ID-10
#> 49                             Sepal.Width:ID-11
#> 50                             Sepal.Width:ID-12
#> 51                             Sepal.Width:ID-13
#> 52                             Sepal.Width:ID-14
#> 53                             Sepal.Width:ID-15
#> 54                             Sepal.Width:ID-16
#> 55                             Sepal.Width:ID-17
#> 56                             Sepal.Width:ID-18
#> 57                             Sepal.Width:ID-19
#> 58                             Sepal.Width:ID-20
#> 59                             Sepal.Width:ID-21
#> 60                             Sepal.Width:ID-22
#> 61                             Sepal.Width:ID-23
#> 62                             Sepal.Width:ID-24
#> 63                             Sepal.Width:ID-25
#> 64                             Sepal.Width:ID-26
#> 65                             Sepal.Width:ID-27
#> 66                             Sepal.Width:ID-28
#> 67                             Sepal.Width:ID-29
#> 68                             Sepal.Width:ID-30
#> 69                                          ID-1
#> 70                                          ID-2
#> 71                                          ID-3
#> 72                                          ID-4
#> 73                                          ID-5
#> 74                                          ID-6
#> 75                                          ID-7
#> 76                                          ID-8
#> 77                                          ID-9
#> 78                                         ID-10
#> 79                                         ID-11
#> 80                                         ID-12
#> 81                                         ID-13
#> 82                                         ID-14
#> 83                                         ID-15
#> 84                                         ID-16
#> 85                                         ID-17
#> 86                                         ID-18
#> 87                                         ID-19
#> 88                                         ID-20
#> 89                                         ID-21
#> 90                                         ID-22
#> 91                                         ID-23
#> 92                                         ID-24
#> 93                                         ID-25
#> 94                                         ID-26
#> 95                                         ID-27
#> 96                                         ID-28
#> 97                                         ID-29
#> 98                                         ID-30
#> 99                                            mu
#> 100                      Sepal.Width-Sepal.Width
#> 101                      Petal.Width-Petal.Width
#> 102                                         sig2
#> 103                                    g_Species
#> 104                                         g_ID
#> 105                                 g_continuous

Created on 2020-09-17 by the reprex package (v0.3.0)

strengejacke commented 3 years ago

The issue in the above examples is:

> Warning in rscale[rscaleTypes == "continuous"] <- rscaleCont: number of items to

> replace is not a multiple of replacement length

IndrajeetPatil commented 3 years ago

Any possibility that this can be resolved before the next round (https://github.com/easystats/easystats/issues/76)?

I can then also do a next round of release for ggstatsverse packages then ๐Ÿ˜…

strengejacke commented 3 years ago

Yes, I think so. Next update for insight is still some weeks ahead.

IndrajeetPatil commented 3 years ago

Oh no, I forgot that this also needs to be resolved for the next tidyBF release ๐Ÿ˜ž

strengejacke commented 3 years ago

I looked into this some days ago, but it's something that should be addressed with some concentration, so I skipped this issue for this release and will get back to it when I find more time.

IndrajeetPatil commented 3 years ago

Yeah, no worries. I have a workaround solution using bayestestR::describe_prior, so all good for now.

IndrajeetPatil commented 3 years ago

Reminder for ourselves to also add then Prior_scale info for meta_random and meta_fixed objects in model_parameters output once this is resolved:

library(metaBMA)
#> Loading required package: Rcpp

data(towels)
set.seed(123)
mr <- 
  meta_random(
  logOR,
  SE,
  study,
  data = towels
)
#> Warning: There were 4 divergent transitions after warmup. See
#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
#> to find out why this is a problem and how to eliminate them.
#> Warning: Examine the pairs() plot to diagnose sampling problems

mr$jzs
#> $rscale_contin
#> [1] 0.5
#> 
#> $rscale_discrete
#> [1] 0.7071068
#> 
#> $centering
#> [1] TRUE

parameters::model_parameters(mr) 
#> Parameter | Coefficient |   SE |            CI |   BF |  Rhat |     ESS
#> -----------------------------------------------------------------------
#> Overall   |        0.18 | 0.10 | [-0.02, 0.38] | 2.00 | 1.000 | 3974.80
#> tau       |        0.14 | 0.10 | [ 0.02, 0.33] |      | 1.000 | 3145.40

Created on 2020-10-26 by the reprex package (v0.3.0.9001)

strengejacke commented 3 years ago

I think there's not much to do on insight side:

library(metaBMA)
#> Loading required package: Rcpp
data(towels)
set.seed(123)
mr <- 
  meta_random(
    logOR,
    SE,
    study,
    data = towels
  )
#> Warning: There were 4 divergent transitions after warmup. Increasing adapt_delta above 0.95 may help. See
#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
#> Warning: Examine the pairs() plot to diagnose sampling problems

insight::get_priors(mr)
#>     Parameter Distribution Location Scale
#> 1 (Intercept)         norm        0  0.30
#> 2         tau     invgamma        1  0.15

Created on 2020-10-26 by the reprex package (v0.3.0)

However, I'm not sure where the formatting of priors is taking place, bayestestR?

IndrajeetPatil commented 3 years ago

Why are the values from insight::get_priors here different than that contained in the object itself?

mr$jzs
#> $rscale_contin
#> [1] 0.5
#> 
#> $rscale_discrete
#> [1] 0.7071068
#> 
#> $centering
#> [1] TRUE
strengejacke commented 3 years ago

Not sure what jzs is, but get_priors() is consistent with the print()-method:

library(metaBMA)
#> Loading required package: Rcpp
data(towels)
set.seed(123)
mr <- 
  meta_random(
    logOR,
    SE,
    study,
    data = towels
  )

insight::get_priors(mr)
#>     Parameter Distribution Location Scale
#> 1 (Intercept)         norm        0  0.30
#> 2         tau     invgamma        1  0.15

mr
#> ### Bayesian Random-Effects Meta-Analysis ### 
#>    Prior on d:      'norm' (mean=0, sd=0.3) with support on the interval [-Inf,Inf]. 
#>    Prior on tau:    'invgamma' (shape=1, scale=0.15) with support on the interval [0,Inf]. 
#> 
#> # Bayes factors:
#>            (denominator)
#> (numerator) random_H0 random_H1
#>   random_H0         1     0.501
#>   random_H1         2     1.000
#> 
#> # Posterior summary statistics of random-effects model:
#>      mean    sd   2.5%   50% 97.5% hpd95_lower hpd95_upper  n_eff Rhat
#> d   0.182 0.104 -0.039 0.188 0.367      -0.021       0.381 3974.8    1
#> tau 0.136 0.099  0.033 0.108 0.404       0.020       0.330 3145.4    1

Created on 2020-10-26 by the reprex package (v0.3.0)

IndrajeetPatil commented 3 years ago

They are the priors used in JZS method for calculating Bayes Factors (e.g., https://link.springer.com/article/10.3758/PBR.16.2.225). BayesFactor package also uses this method.

But I also see your point. I am not sure what the best way to report priors here would be.

@mattansb Do you have thoughts on this?

mattansb commented 3 years ago

If I had to guess, insight::get_priors(mr) gives the raw priors (on the response scale) and mr$jzs gives the standardized priors.

strengejacke commented 3 years ago

Maybe someone can file a PR?

IndrajeetPatil commented 3 years ago

Any chance this can be fixed in the next release?

strengejacke commented 3 years ago

The "next release" will be within the next ~24 hours, so I'd say, no. ๐Ÿ˜ฌ

IndrajeetPatil commented 3 years ago

Any possibility we can get this fixed before the next release cycle?

strengejacke commented 3 years ago

I can't even remember the exact issue we had here... ^^

mattansb commented 3 years ago

The issue was to match a prior to each parameter ๐Ÿงถ

strengejacke commented 3 years ago
library(parameters)
library(BayesFactor)
iris$ID <- factor(rep(1:30, each = 5))
m1 <- lmBF(Sepal.Length ~ Species * Sepal.Width + Petal.Width + ID + Sepal.Width:ID, data = iris,
           rscaleCont = c(Sepal.Width = 0.123, Petal.Width = 0.321),
           whichRandom = c("ID","Sepal.Width:ID"))

model_parameters(m1)
#> # Extra Parameters
#> 
#> Parameter               |     pd |              Prior
#> -----------------------------------------------------
#> mu                      | 98.95% |                   
#> Sepal.Width-Sepal.Width | 99.12% | Cauchy (0 +- 0.12)
#> Petal.Width-Petal.Width | 99.08% | Cauchy (0 +- 0.32)
#> sig2                    |   100% |                   
#> g_Species               |   100% |                   
#> g_ID                    |   100% |                   
#> g_continuous            |   100% |                   
#> 
#> # Fixed Effects
#> 
#> Parameter                                    |     pd |              Prior
#> --------------------------------------------------------------------------
#> Species-setosa                               | 98.90% | Cauchy (0 +- 0.50)
#> Species-versicolor                           | 98.98% | Cauchy (0 +- 0.50)
#> Species-virginica                            | 98.98% | Cauchy (0 +- 0.50)
#> ID-1                                         | 99.00% | Cauchy (0 +- 1.00)
#> ID-1                                         | 99.00% | Cauchy (0 +- 1.00)
#> ID-2                                         | 98.90% | Cauchy (0 +- 1.00)
#> ID-2                                         | 98.90% | Cauchy (0 +- 1.00)
#> ID-3                                         | 98.98% | Cauchy (0 +- 1.00)
#> ID-3                                         | 98.98% | Cauchy (0 +- 1.00)
#> ID-4                                         | 98.98% | Cauchy (0 +- 1.00)
#> ID-4                                         | 98.98% | Cauchy (0 +- 1.00)
#> ID-5                                         | 98.92% | Cauchy (0 +- 1.00)
#> ID-5                                         | 98.92% | Cauchy (0 +- 1.00)
#> ID-6                                         | 99.08% | Cauchy (0 +- 1.00)
#> ID-6                                         | 99.08% | Cauchy (0 +- 1.00)
#> ID-7                                         | 98.98% | Cauchy (0 +- 1.00)
#> ID-7                                         | 98.98% | Cauchy (0 +- 1.00)
#> ID-8                                         | 98.98% | Cauchy (0 +- 1.00)
#> ID-8                                         | 98.98% | Cauchy (0 +- 1.00)
#> ID-9                                         | 98.95% | Cauchy (0 +- 1.00)
#> ID-9                                         | 98.95% | Cauchy (0 +- 1.00)
#> ID-10                                        | 98.98% | Cauchy (0 +- 1.00)
#> ID-10                                        | 98.98% | Cauchy (0 +- 1.00)
#> ID-11                                        | 98.98% | Cauchy (0 +- 1.00)
#> ID-11                                        | 98.98% | Cauchy (0 +- 1.00)
#> ID-12                                        | 98.90% | Cauchy (0 +- 1.00)
#> ID-12                                        | 98.90% | Cauchy (0 +- 1.00)
#> ID-13                                        | 99.08% | Cauchy (0 +- 1.00)
#> ID-13                                        | 99.08% | Cauchy (0 +- 1.00)
#> ID-14                                        | 99.10% | Cauchy (0 +- 1.00)
#> ID-14                                        | 99.10% | Cauchy (0 +- 1.00)
#> ID-15                                        | 99.02% | Cauchy (0 +- 1.00)
#> ID-15                                        | 99.02% | Cauchy (0 +- 1.00)
#> ID-16                                        | 99.02% | Cauchy (0 +- 1.00)
#> ID-16                                        | 99.02% | Cauchy (0 +- 1.00)
#> ID-17                                        | 99.00% | Cauchy (0 +- 1.00)
#> ID-17                                        | 99.00% | Cauchy (0 +- 1.00)
#> ID-18                                        | 99.17% | Cauchy (0 +- 1.00)
#> ID-18                                        | 99.17% | Cauchy (0 +- 1.00)
#> ID-19                                        | 99.02% | Cauchy (0 +- 1.00)
#> ID-19                                        | 99.02% | Cauchy (0 +- 1.00)
#> ID-20                                        | 98.90% | Cauchy (0 +- 1.00)
#> ID-20                                        | 98.90% | Cauchy (0 +- 1.00)
#> ID-21                                        | 98.90% | Cauchy (0 +- 1.00)
#> ID-21                                        | 98.90% | Cauchy (0 +- 1.00)
#> ID-22                                        | 99.02% | Cauchy (0 +- 1.00)
#> ID-22                                        | 99.02% | Cauchy (0 +- 1.00)
#> ID-23                                        | 99.02% | Cauchy (0 +- 1.00)
#> ID-23                                        | 99.02% | Cauchy (0 +- 1.00)
#> ID-24                                        | 98.95% | Cauchy (0 +- 1.00)
#> ID-24                                        | 98.95% | Cauchy (0 +- 1.00)
#> ID-25                                        | 99.00% | Cauchy (0 +- 1.00)
#> ID-25                                        | 99.00% | Cauchy (0 +- 1.00)
#> ID-26                                        | 99.12% | Cauchy (0 +- 1.00)
#> ID-26                                        | 99.12% | Cauchy (0 +- 1.00)
#> ID-27                                        | 98.95% | Cauchy (0 +- 1.00)
#> ID-27                                        | 98.95% | Cauchy (0 +- 1.00)
#> ID-28                                        | 98.92% | Cauchy (0 +- 1.00)
#> ID-28                                        | 98.92% | Cauchy (0 +- 1.00)
#> ID-29                                        | 98.95% | Cauchy (0 +- 1.00)
#> ID-29                                        | 98.95% | Cauchy (0 +- 1.00)
#> ID-30                                        | 99.02% | Cauchy (0 +- 1.00)
#> ID-30                                        | 99.02% | Cauchy (0 +- 1.00)
#> Species:Sepal.Width-setosa.&.Sepal.Width     | 98.95% | Cauchy (0 +- 0.12)
#> Species:Sepal.Width-versicolor.&.Sepal.Width | 98.92% | Cauchy (0 +- 0.12)
#> Species:Sepal.Width-virginica.&.Sepal.Width  | 99.05% | Cauchy (0 +- 0.12)
#> Sepal.Width:ID-1                             | 99.08% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-2                             | 98.92% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-3                             | 98.92% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-4                             | 99.10% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-5                             | 98.90% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-6                             | 99.10% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-7                             | 98.98% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-8                             | 99.05% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-9                             | 99.08% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-10                            | 98.92% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-11                            | 98.92% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-12                            | 99.05% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-13                            | 98.98% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-14                            | 98.92% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-15                            | 99.17% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-16                            | 98.98% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-17                            | 99.10% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-18                            | 99.17% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-19                            | 98.98% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-20                            | 99.00% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-21                            | 99.00% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-22                            | 98.98% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-23                            | 98.98% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-24                            | 99.20% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-25                            | 99.17% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-26                            | 98.95% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-27                            | 98.95% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-28                            | 98.92% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-29                            | 98.98% | Cauchy (0 +- 1.00)
#> Sepal.Width:ID-30                            | 99.10% | Cauchy (0 +- 1.00)
#> Petal.Width                                  |        | Cauchy (0 +- 0.32)
#> Sepal.Width                                  |        | Cauchy (0 +- 0.12)
#> 
#> # Random Effects
#> 
#> Parameter |     pd |           Prior
#> ------------------------------------
#> ID-1      | 99.00% | Cauchy (0 +- 1)
#> ID-1      | 99.00% | Cauchy (0 +- 1)
#> ID-2      | 98.90% | Cauchy (0 +- 1)
#> ID-2      | 98.90% | Cauchy (0 +- 1)
#> ID-3      | 98.98% | Cauchy (0 +- 1)
#> ID-3      | 98.98% | Cauchy (0 +- 1)
#> ID-4      | 98.98% | Cauchy (0 +- 1)
#> ID-4      | 98.98% | Cauchy (0 +- 1)
#> ID-5      | 98.92% | Cauchy (0 +- 1)
#> ID-5      | 98.92% | Cauchy (0 +- 1)
#> ID-6      | 99.08% | Cauchy (0 +- 1)
#> ID-6      | 99.08% | Cauchy (0 +- 1)
#> ID-7      | 98.98% | Cauchy (0 +- 1)
#> ID-7      | 98.98% | Cauchy (0 +- 1)
#> ID-8      | 98.98% | Cauchy (0 +- 1)
#> ID-8      | 98.98% | Cauchy (0 +- 1)
#> ID-9      | 98.95% | Cauchy (0 +- 1)
#> ID-9      | 98.95% | Cauchy (0 +- 1)
#> ID-10     | 98.98% | Cauchy (0 +- 1)
#> ID-10     | 98.98% | Cauchy (0 +- 1)
#> ID-11     | 98.98% | Cauchy (0 +- 1)
#> ID-11     | 98.98% | Cauchy (0 +- 1)
#> ID-12     | 98.90% | Cauchy (0 +- 1)
#> ID-12     | 98.90% | Cauchy (0 +- 1)
#> ID-13     | 99.08% | Cauchy (0 +- 1)
#> ID-13     | 99.08% | Cauchy (0 +- 1)
#> ID-14     | 99.10% | Cauchy (0 +- 1)
#> ID-14     | 99.10% | Cauchy (0 +- 1)
#> ID-15     | 99.02% | Cauchy (0 +- 1)
#> ID-15     | 99.02% | Cauchy (0 +- 1)
#> ID-16     | 99.02% | Cauchy (0 +- 1)
#> ID-16     | 99.02% | Cauchy (0 +- 1)
#> ID-17     | 99.00% | Cauchy (0 +- 1)
#> ID-17     | 99.00% | Cauchy (0 +- 1)
#> ID-18     | 99.17% | Cauchy (0 +- 1)
#> ID-18     | 99.17% | Cauchy (0 +- 1)
#> ID-19     | 99.02% | Cauchy (0 +- 1)
#> ID-19     | 99.02% | Cauchy (0 +- 1)
#> ID-20     | 98.90% | Cauchy (0 +- 1)
#> ID-20     | 98.90% | Cauchy (0 +- 1)
#> ID-21     | 98.90% | Cauchy (0 +- 1)
#> ID-21     | 98.90% | Cauchy (0 +- 1)
#> ID-22     | 99.02% | Cauchy (0 +- 1)
#> ID-22     | 99.02% | Cauchy (0 +- 1)
#> ID-23     | 99.02% | Cauchy (0 +- 1)
#> ID-23     | 99.02% | Cauchy (0 +- 1)
#> ID-24     | 98.95% | Cauchy (0 +- 1)
#> ID-24     | 98.95% | Cauchy (0 +- 1)
#> ID-25     | 99.00% | Cauchy (0 +- 1)
#> ID-25     | 99.00% | Cauchy (0 +- 1)
#> ID-26     | 99.12% | Cauchy (0 +- 1)
#> ID-26     | 99.12% | Cauchy (0 +- 1)
#> ID-27     | 98.95% | Cauchy (0 +- 1)
#> ID-27     | 98.95% | Cauchy (0 +- 1)
#> ID-28     | 98.92% | Cauchy (0 +- 1)
#> ID-28     | 98.92% | Cauchy (0 +- 1)
#> ID-29     | 98.95% | Cauchy (0 +- 1)
#> ID-29     | 98.95% | Cauchy (0 +- 1)
#> ID-30     | 99.02% | Cauchy (0 +- 1)
#> ID-30     | 99.02% | Cauchy (0 +- 1)

data(puzzles)

result = anovaBF(RT ~ shape*color + ID, data = puzzles, whichRandom = "ID",
                 whichModels = 'top', progress=FALSE)

model_parameters(result)
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> # Extra Parameters
#> 
#> Parameter | Median |         89% CI |   pd | % in ROPE |    BF
#> --------------------------------------------------------------
#> mu        |  45.00 | [43.91, 46.10] | 100% |        0% |  2.75
#> sig2      |   1.76 | [ 1.12,  2.45] | 100% |        0% | 0.265
#> g_shape   |   0.35 | [ 0.01,  2.23] | 100% |    44.73% |  2.75
#> g_color   |   0.36 | [ 0.02,  2.32] | 100% |    43.67% | 0.253
#> g_ID      |   2.64 | [ 0.76,  5.23] | 100% |        0% | 0.265
#> 
#> # Fixed Effects
#> 
#> Parameter             | Median |         89% CI |     pd | % in ROPE |              Prior |    BF
#> -------------------------------------------------------------------------------------------------
#> shape [round]         |   0.43 | [ 0.14,  0.74] | 99.00% |    12.69% | Cauchy (0 +- 0.50) | 0.253
#> shape [square]        |  -0.43 | [-0.74, -0.14] | 99.00% |    12.69% | Cauchy (0 +- 0.50) | 0.265
#> color                 |  -0.43 | [-0.73, -0.14] | 98.92% |    12.66% | Cauchy (0 +- 0.50) |  2.75
#> color [monochromatic] |   0.43 | [ 0.14,  0.73] | 98.92% |    12.66% | Cauchy (0 +- 0.50) | 0.253
#> 
#> # Random Effects
#> 
#> Parameter | Median |         89% CI |     pd | % in ROPE |           Prior |    BF
#> ----------------------------------------------------------------------------------
#> ID [1]    |   2.48 | [ 1.11,  3.96] | 99.62% |        0% | Cauchy (0 +- 1) | 0.265
#> ID [2]    |   0.48 | [-0.87,  1.99] | 70.33% |    21.68% | Cauchy (0 +- 1) |  2.75
#> ID [3]    |   0.92 | [-0.42,  2.43] | 85.50% |    15.45% | Cauchy (0 +- 1) | 0.253
#> ID [4]    |   0.46 | [-0.94,  1.95] | 70.03% |    22.04% | Cauchy (0 +- 1) | 0.265
#> ID [5]    |   3.19 | [ 1.75,  4.64] | 99.98% |        0% | Cauchy (0 +- 1) |  2.75
#> ID [6]    |   0.47 | [-0.93,  1.86] | 69.88% |    22.52% | Cauchy (0 +- 1) | 0.253
#> ID [7]    |  -3.14 | [-4.60, -1.70] | 99.98% |        0% | Cauchy (0 +- 1) | 0.265
#> ID [8]    |  -0.18 | [-1.70,  1.19] | 58.27% |    25.67% | Cauchy (0 +- 1) |  2.75
#> ID [9]    |  -2.47 | [-3.98, -1.07] | 99.67% |        0% | Cauchy (0 +- 1) | 0.253
#> ID [10]   |   0.69 | [-0.82,  2.03] | 77.03% |    19.77% | Cauchy (0 +- 1) | 0.265
#> ID [11]   |   0.67 | [-0.73,  2.13] | 77.62% |    18.81% | Cauchy (0 +- 1) |  2.75
#> ID [12]   |  -3.35 | [-4.95, -2.03] | 99.98% |        0% | Cauchy (0 +- 1) | 0.253

Created on 2021-01-03 by the reprex package (v0.3.0)

mattansb commented 3 years ago

In the first example,

#> mu                      | 98.95% |                   
#> Sepal.Width-Sepal.Width | 99.12% | Cauchy (0 +- 0.12)
#> Petal.Width-Petal.Width | 99.08% | Cauchy (0 +- 0.32)

Are fixed effects, and all the ID and Sepal.Width:ID parameters are random effects (some of which are doubled an also appear in the random effects part.