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

[Feature] report() for BayesFactor objects #420

Merged
merged 12 commits into from
Apr 1, 2024
Merged

Conversation

DominiqueMakowski
Copy link
Member

library(report)

rez <- BayesFactor::ttestBF(iris$Sepal.Width, iris$Sepal.Length)
report_statistics(rez)
#> [1] "BF10 > 1000"
report(rez, h0="the null hypothesis", h1="the alternative")
#> [1] "There is extreme evidence in favour of the alternative over the null hypothesis (BF10 > 1000)."

Created on 2024-03-28 with reprex v2.0.2

@mattansb
Copy link
Member

I really dislike that the default behavior of format_bf() is to truncate BFs like this... format_bf(exact = TRUE) is much better :/

library(report)

rez <- BayesFactor::ttestBF(iris$Sepal.Width, iris$Sepal.Length)
report_statistics(rez, exact = TRUE)
#> [1] "BF10 = 6.11e+107"
report(rez, exact = TRUE)
#> [1] "There is extreme evidence in favour of H1 over H0 (BF10 = 6.11e+107)."

Also works now (but can probably be better…)

rez <- BayesFactor::correlationBF(iris$Sepal.Width, iris$Sepal.Length, nullInterval = c(-0.1, 0.1))
report_statistics(rez, exact = TRUE)
#> Multiple `BFBayesFactor` models detected - reporting for the first
#>   numerator model.
#>   See help("get_parameters", package = "insight").
#> [1] "BF10 = 1.18"
report(rez, exact = TRUE)
#> Multiple `BFBayesFactor` models detected - reporting for the first
#>   numerator model.
#>   See help("get_parameters", package = "insight").
#> [1] "There is anecdotal evidence in favour of H1 over H0 (BF10 = 1.18)."

Also auto passes to bayestestR::bf_models() |> report() for linear models

rez <- BayesFactor::lmBF(mpg ~ hp, data = mtcars)
report(rez)
#> Bayes factors were computed with the `BayesFactor` package, using JZS priors.
#> Compared to the (Intercept only) model (the least supported model), we found
#> extreme evidence (BF = 5.70e+04) in favour of the hp model (the most supported
#> model).

Created on 2024-03-28 with reprex v2.1.0

@DominiqueMakowski
Copy link
Member Author

nice addition of the LM case!

default format

We can exact=TRUE in the example so that people are nudged to use it?

@mattansb
Copy link
Member

Yes please!

@rempsyc
Copy link
Member

rempsyc commented Mar 28, 2024

Thanks, but we see:

── R CMD check results ───────────────────────────────────── report 0.5.8.1 ────
Duration: 3m 47.5schecking Rd \usage sections ... WARNING
  Undocumented arguments in documentation object 'report.BFBayesFactor'
    ‘...’ ‘tableFunctions with \usage entries need to have the appropriate \alias
  entries, and all their arguments documented.
  The \usage entries must correspond to syntactically valid R code.
  See chapterWriting R documentation filesin theWriting R
  Extensionsmanual.

❯ checking for unstated dependencies in examples ... WARNING
  '::' or ':::' import not declared from: ‘BayesFactor'library' or 'require' call not declared from: ‘BayesFactorError in `build_reference_index()`:
! All topics must be included in reference indexMissing topics: report.BFBayesFactor
 Either add to _pkgdown.yml or use @keywords internal

@rempsyc
Copy link
Member

rempsyc commented Apr 1, 2024

  • Error in build_reference_index()
  • Some files don't follow the style guide ✅
  • Lints ✅

Snapshots are still failing, but I'm afraid we'll have to fix them in a different PR :/

@rempsyc
Copy link
Member

rempsyc commented Apr 1, 2024

Snapshots updated, closes #422

@rempsyc rempsyc linked an issue Apr 1, 2024 that may be closed by this pull request
@rempsyc
Copy link
Member

rempsyc commented Apr 1, 2024

Cannot fix this .01 snapshot value difference between local and GHA, so skipping it...

Error: Error: Snapshot of code has changed (variant 'windows'):
old vs new
  Code
    report_performance(x7)
  Output
-   The model's explanatory power is substantial (R2 = 0.83, 95% CI [0.79, 0.86],
+   The model's explanatory power is substantial (R2 = 0.83, 95% CI [0.79, 0.87],
    adj. R2 = 0.83) and the part related to the fixed effects alone (marginal R2)
    is of 0.95 (95% CI [0.93, 0.97])

@rempsyc rempsyc self-requested a review April 1, 2024 15:09
@rempsyc rempsyc merged commit a2c7709 into main Apr 1, 2024
23 of 27 checks passed
@rempsyc rempsyc deleted the report_BayesFactor branch April 1, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix failing snapshots2: report.brms
3 participants