Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documenting return section for BayesFactor objects #297

Closed
IndrajeetPatil opened this issue Sep 10, 2020 · 7 comments
Closed

documenting return section for BayesFactor objects #297

IndrajeetPatil opened this issue Sep 10, 2020 · 7 comments
Assignees
Labels
docs 📚 Something to be adressed in docs and/or vignettes

Comments

@IndrajeetPatil
Copy link
Member

Although most of the outputs from model_parameters for BayesFactor objects are clear, sometimes it's hard to figure out what some terms correspond to. And the documentation for this function doesn't have any information about this.

For example-
the first four rows here correspond to model-average posterior summary

    library(BayesFactor)
    library(magrittr)

    anovaBF(formula = Sepal.Length ~ Species, data = iris) %>%
      parameters::model_parameters(., priors = FALSE, centrality = "mean") %>%
      as.data.frame()
    #>            Parameter        Mean       CI_low    CI_high      pd
    #> 1                 mu  5.84403632  5.775817530  5.9097313 1.00000
    #> 2     Species-setosa -0.82709743 -0.917829717 -0.7252568 1.00000
    #> 3 Species-versicolor  0.09180601  0.002343341  0.1861748 0.93675
    #> 4  Species-virginica  0.73529142  0.640733329  0.8310193 1.00000
    #> 5               sig2  0.27070721  0.218365419  0.3194694 1.00000
    #> 6          g_Species  4.87206772  0.245442872  7.4836032 1.00000
    #>   ROPE_Percentage Effects   Component           BF
    #> 1        0.000000   fixed       extra 1.425293e+28
    #> 2        0.000000   fixed conditional 1.425293e+28
    #> 3        0.547599   fixed conditional 1.425293e+28
    #> 4        0.000000   fixed conditional 1.425293e+28
    #> 5        0.000000   fixed       extra 1.425293e+28
    #> 6        0.000000   fixed       extra 1.425293e+28

and agree with columns from JASP:

image

But, as a user, I may not know that mu corresponds to intercept and don't know what do sig2 and g_Species here refer to.

@IndrajeetPatil IndrajeetPatil added the docs 📚 Something to be adressed in docs and/or vignettes label Sep 10, 2020
@strengejacke
Copy link
Member

I think this is something for @mattansb. For Bayesian models, model_parameters() is not much more than a wrapper around bayestestR::describe_posterior() + bayestestR::diagnostic_posterior().

@mattansb
Copy link
Member

I can do most of these, I think:

  • ttestBF():
    • Difference: the raw difference between the
  • correlationBF():
    • rho: linear correlation estimate (eqivilant to pearsons r)
  • contingencyTableBF:
    • {none extracted - yet}
  • proportionBF():
    • {none extracted - yet}
  • lmBF() / generalTestBF() / regressionBF() / anovaBF()
    • whatever fixed / random effects parameters...
    • mu: mean-centered intercept? I think
    • sig2: model's sigma
    • g / g_*: these are the g parameters. See ANOVA BF paper.

Where should these definitions go? insight? parameters?

@strengejacke
Copy link
Member

@IndrajeetPatil
Copy link
Member Author

@mattansb Maybe this is confusion on my part, but is this expected?

# data
set.seed(123)
df <- dplyr::filter(.data = gapminder::gapminder, continent == "Africa")

# one-sample t-test
mod <- BayesFactor::ttestBF(x = df$gdpPercap, mu = 10000) 
#> t is large; approximation invoked.

# median value
median(df$gdpPercap)
#> [1] 1192.138

# raw difference
10000 - median(df$gdpPercap)
#> [1] 8807.862

# extracting details
parameters::model_parameters(mod)
#> Parameter  |   Median |                   89% CI |   pd | % in ROPE |              Prior | Effects |   Component |     BF
#> -------------------------------------------------------------------------------------------------------------------------
#> Difference | 8.01e+06 | [  7.32e+06,   8.78e+06] | 100% |        0% | Cauchy (0 +- 0.71) |   fixed | conditional | > 1000

If the parameter here is the raw difference, I was expecting the estimate to be around ~ 8800, but it is actually 8010000.

mattansb added a commit to easystats/insight that referenced this issue Sep 23, 2020
@mattansb
Copy link
Member

No, this is a gross little bug - fixed!

set.seed(123)

x <- rnorm(100)
mod <- BayesFactor::ttestBF(x = x, mu = 10) 
#> t is large; approximation invoked.

# raw difference
10 - median(x)
#> [1] 9.938244

# extracting details
parameters::model_parameters(mod, test = NULL)
#> Parameter  | Median |        89% CI |              Prior | Effects |   Component |     BF
#> -----------------------------------------------------------------------------------------
#> Difference |   9.91 | [9.78, 10.06] | Cauchy (0 +- 0.71) |   fixed | conditional | > 1000

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

@IndrajeetPatil
Copy link
Member Author

Thanks for fixing this so quickly!

@strengejacke Do you think there will be a new release of insight any time soon?
This bug fix is definitely going to lead to some failing tests in my packages and I would like to coordinate my releases accordingly.

@strengejacke
Copy link
Member

easystats::on_CRAN()
#> insight     0.4 weeks

And just ~1 week before that update, there was the previous submission, so actually the next release is no planned before end of October.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs 📚 Something to be adressed in docs and/or vignettes
Projects
None yet
Development

No branches or pull requests

3 participants