Skip to content

Commit

Permalink
Prepare CRAN release (#697)
Browse files Browse the repository at this point in the history
* Prepare CRAN release

* styler

* wordlist

* warning

* readme

* news
  • Loading branch information
strengejacke authored Feb 7, 2025
1 parent 0f34eeb commit f94b514
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 34 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ tests\^spelling
\.lintr$
^CRAN-SUBMISSION$
^data-raw$
^tests/testthat/_snaps/.

^man/figures/JASP.
^man/figures/b.
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: bayestestR
Title: Understand and Describe Bayesian Models and Posterior Distributions
Version: 0.15.1.2
Version: 0.15.2
Authors@R:
c(person(given = "Dominique",
family = "Makowski",
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
* `describe_posterior()` no longer re-samples a model when computing
indices.

* `describe_posterior()` calls tests only when needed. Before, there was a
minimal overhead by calling tests that were not requested.

## Bug fixes

* Fixed failing test for Mac OS.

# bayestestR 0.15.1

## Changes
Expand Down
2 changes: 1 addition & 1 deletion R/describe_posterior.R
Original file line number Diff line number Diff line change
Expand Up @@ -1449,4 +1449,4 @@ describe_posterior.BFBayesFactor <- function(posterior,
)

return(is.character(test) && length(test) > 0L && any(need_rope %in% tolower(test)))
}
}
14 changes: 7 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ knitr::opts_chunk$set(
)
```

[![DOI](https://joss.theoj.org/papers/10.21105/joss.01541/status.svg)](https://doi.org/10.21105/joss.01541) [![status](https://tinyverse.netlify.com/badge/bayestestR)](https://CRAN.R-project.org/package=bayestestR) [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.01541/status.svg)](https://doi.org/10.21105/joss.01541)

***Become a Bayesian master you will***

Expand Down Expand Up @@ -95,14 +95,14 @@ In the Bayesian framework, parameters are estimated in a probabilistic fashion a
- [**Centrality**](https://easystats.github.io/bayestestR/articles/web_only/indicesEstimationComparison.html)
- `mean()`, `median()` or [`map_estimate()`](https://easystats.github.io/bayestestR/reference/map_estimate.html) for an estimation of the mode.
- [`point_estimate()`](https://easystats.github.io/bayestestR/reference/point_estimate.html) can be used to get them at once and can be run directly on models.

- [**Uncertainty**](https://easystats.github.io/bayestestR/articles/credible_interval.html)
- [`hdi()`](https://easystats.github.io/bayestestR/reference/hdi.html) for *Highest Density Intervals (HDI)*, [`spi()`](https://easystats.github.io/bayestestR/reference/spi.html) for *Shortest Probability Intervals (SPI)* or [`eti()`](https://easystats.github.io/bayestestR/reference/eti.html) for *Equal-Tailed Intervals (ETI)*.
- [`ci()`](https://easystats.github.io/bayestestR/reference/ci.html) can be used as a general method for Confidence and Credible Intervals (CI).

- [**Effect Existence**](https://easystats.github.io/bayestestR/articles/indicesExistenceComparison.html): whether an effect is different from 0.
- [`p_direction()`](https://easystats.github.io/bayestestR/reference/p_direction.html) for a Bayesian equivalent of the frequentist *p*-value (see [Makowski et al., 2019](https://doi.org/10.3389/fpsyg.2019.02767))
- [`p_pointnull()`](https://easystats.github.io/bayestestR/reference/p_map.html) represents the odds of null hypothesis (*h0 = 0*) compared to the most likely hypothesis (the MAP).
- [`p_pointnull()`](https://easystats.github.io/bayestestR/reference/p_map.html) represents the odds of null hypothesis (*h0 = 0*) compared to the most likely hypothesis (the MAP).
- [`bf_pointnull()`](https://easystats.github.io/bayestestR/reference/bayesfactor_parameters.html) for a classic *Bayes Factor (BF)* assessing the likelihood of effect presence against its absence (*h0 = 0*).

- [**Effect Significance**](https://easystats.github.io/bayestestR/articles/indicesExistenceComparison.html): whether the effect size can be considered as non-negligible.
Expand Down Expand Up @@ -199,7 +199,7 @@ While the **median** and the **mean** are available through base R functions, [`

[`hdi()`](https://easystats.github.io/bayestestR/reference/hdi.html) computes the **Highest Density Interval (HDI)** of a posterior distribution, i.e., the interval which contains all points within the interval have a higher probability density than points outside the interval. The HDI can be used in the context of Bayesian posterior characterization as **Credible Interval (CI)**.

Unlike equal-tailed intervals (see [`eti()`](https://easystats.github.io/bayestestR/reference/eti.html)) that typically exclude 2.5\% from each tail of the distribution, the HDI is *not* equal-tailed and therefore always includes the mode(s) of posterior distributions.
Unlike equal-tailed intervals (see [`eti()`](https://easystats.github.io/bayestestR/reference/eti.html)) that typically exclude 2.5\% from each tail of the distribution, the HDI is *not* equal-tailed and therefore always includes the mode(s) of posterior distributions.

```{r message=FALSE, warning=FALSE}
posterior <- distribution_chisquared(10000, 4)
Expand Down Expand Up @@ -322,9 +322,9 @@ ggplot(dat4, aes(x = x, y = y, fill = fill)) +

### Bayes Factor

[`bayesfactor_parameters()`](https://easystats.github.io/bayestestR/reference/bayesfactor_parameters.html) computes Bayes factors against the null (either a point or an interval), bases on prior and posterior samples of a single parameter. This Bayes factor indicates the degree by which the mass of the posterior distribution has shifted further away from or closer to the null value(s) (relative to the prior distribution), thus indicating if the null value has become less or more likely given the observed data.
[`bayesfactor_parameters()`](https://easystats.github.io/bayestestR/reference/bayesfactor_parameters.html) computes Bayes factors against the null (either a point or an interval), bases on prior and posterior samples of a single parameter. This Bayes factor indicates the degree by which the mass of the posterior distribution has shifted further away from or closer to the null value(s) (relative to the prior distribution), thus indicating if the null value has become less or more likely given the observed data.

When the null is an interval, the Bayes factor is computed by comparing the prior and posterior odds of the parameter falling within or outside the null; When the null is a point, a Savage-Dickey density ratio is computed, which is also an approximation of a Bayes factor comparing the marginal likelihoods of the model against a model in which the tested parameter has been restricted to the point null [@wagenmakers2010bayesian].
When the null is an interval, the Bayes factor is computed by comparing the prior and posterior odds of the parameter falling within or outside the null; When the null is a point, a Savage-Dickey density ratio is computed, which is also an approximation of a Bayes factor comparing the marginal likelihoods of the model against a model in which the tested parameter has been restricted to the point null [@wagenmakers2010bayesian].


```{r message=FALSE, warning=FALSE}
Expand Down
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# bayestestR <img src='man/figures/logo.png' align="right" height="139" />

[![DOI](https://joss.theoj.org/papers/10.21105/joss.01541/status.svg)](https://doi.org/10.21105/joss.01541)
[![status](https://tinyverse.netlify.com/badge/bayestestR)](https://CRAN.R-project.org/package=bayestestR)
[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)

***Become a Bayesian master you will***

Expand Down Expand Up @@ -46,9 +44,9 @@ badge](https://easystats.r-universe.dev/badges/bayestestR)](https://easystats.r-
The *bayestestR* package is available on CRAN, while its latest
development version is available on R-universe (from *rOpenSci*).

| Type | Source | Command |
|-------------|------------|------------------------------------------------------------------------------|
| Release | CRAN | `install.packages("bayestestR")` |
| Type | Source | Command |
|----|----|----|
| Release | CRAN | `install.packages("bayestestR")` |
| Development | R-universe | `install.packages("bayestestR", repos = "https://easystats.r-universe.dev")` |

Once you have downloaded the package, you can then load it using:
Expand Down Expand Up @@ -159,9 +157,9 @@ describe_posterior(
)
## Summary of Posterior Distribution
##
## Parameter | Median | 95% CI | pd | ps
## --------------------------------------------------
## Posterior | -0.01 | [-1.98, 1.93] | 50.52% | 0.46
## Parameter | Median | 95% CI | pd | ps
## ----------------------------------------------------
## Posterior | 3.05e-03 | [-1.92, 1.95] | 50.09% | 0.46
```

`describe_posterior()` works for many objects, including more complex
Expand Down Expand Up @@ -464,7 +462,7 @@ Compute the density of a given point of a distribution.

``` r
density_at(rnorm(1000, 1, 1), 1)
## [1] 0.41
## [1] 0.36
```

## Code of Conduct
Expand All @@ -477,7 +475,7 @@ By contributing to this project, you agree to abide by its terms.
# References

<div id="refs" class="references csl-bib-body hanging-indent"
line-spacing="2">
entry-spacing="0" line-spacing="2">

<div id="ref-kruschke2018rejecting" class="csl-entry">

Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ lm
maths
mattansb
mcmc
mfx
modelling
nbinom
neq
Expand Down
Binary file modified man/figures/unnamed-chunk-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/unnamed-chunk-12-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/unnamed-chunk-14-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/unnamed-chunk-16-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 12 additions & 14 deletions tests/testthat/test-rope.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,19 @@ test_that("rope", {
})


test_that("BayesFactor", {
skip_on_os(c("linux", "mac"))
skip_if_not_or_load_if_installed("BayesFactor")

mods <- regressionBF(mpg ~ am + cyl, mtcars, progress = FALSE)
rx <- suppressMessages(rope(mods, verbose = FALSE))
expect_equal(rx$ROPE_high, -rx$ROPE_low, tolerance = 0.01)
expect_equal(rx$ROPE_high[1], 0.6026948, tolerance = 0.01)
})


skip_if_not_or_load_if_installed("brms")
skip_on_os("windows")
skip_on_os(c("windows", "mac"))

set.seed(123)
model <- suppressWarnings(brms::brm(mpg ~ wt + gear, data = mtcars, iter = 500))
Expand All @@ -107,8 +118,6 @@ test_that("rope (brms)", {
expect_equal(rope$ROPE_Percentage, c(0.00, 0.00, 0.50), tolerance = 0.1)
})

skip_on_os("mac")

model <- suppressWarnings(brm(bf(mvbind(mpg, disp) ~ wt + gear) + set_rescor(TRUE), data = mtcars, iter = 500, refresh = 0))
rope <- rope(model, verbose = FALSE)

Expand All @@ -122,14 +131,3 @@ test_that("rope (brms, multivariate)", {
tolerance = 0.1
)
})

skip_on_os("linux")

test_that("BayesFactor", {
skip_if_not_or_load_if_installed("BayesFactor")

mods <- regressionBF(mpg ~ am + cyl, mtcars, progress = FALSE)
rx <- suppressMessages(rope(mods, verbose = FALSE))
expect_equal(rx$ROPE_high, -rx$ROPE_low, tolerance = 0.01)
expect_equal(rx$ROPE_high[1], 0.6026948, tolerance = 0.01)
})
2 changes: 1 addition & 1 deletion vignettes/bayes_factors.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ than the prior densities.
In `bayestestR`, this can be achieved with the `si()` function:

```{r}
my_first_si <- si(model, BF = 1)
my_first_si <- si(model, BF = 1, verbose = FALSE)
print(my_first_si)
```
Expand Down

0 comments on commit f94b514

Please sign in to comment.