*Become a Bayesian master you will*

`bayestestR`

is a lightweight package providing utilities to describe posterior distributions and Bayesian models.

Run the following:

Click on the buttons above to access the package **documentation** and the **easystats blog**, and check-out these vignettes:

- Get Started with Bayesian Analysis
- Example 1: Initiation to Bayesian models
- Example 2: Confirmation of Bayesian skills
- Example 3: Become a Bayesian master

- Credible Intervals (CIs)
- Probability of Direction (pd)
- Region of Practical Equivalence (ROPE)
- Bayes Factors (BF)
- Comparison of Point-Estimates
- Comparison of Indices of Effect Existence
- Reporting Guidelines

** describe_posterior()** is the master function with which you can compute all of the indices cited below

** map_estimate()** find the

** hdi()** computes the

Unlike equal-tailed intervals (see ci) 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.

By default, `hdi()`

returns the 89% intervals (`ci = 0.89`

), deemed to be more stable than, for instance, 95% intervals (Kruschke, 2014). An effective sample size of at least 10.000 is recommended if 95% intervals should be computed (Kruschke 2014, p. 183ff). Moreover, 89 is the highest prime number that does not exceed the already unstable 95% threshold (McElreath, 2015).

** rope()** computes the proportion (in percentage) of the HDI (default to the 89% HDI) of a posterior distribution that lies within a region of practical equivalence.

Statistically, the probability of a posterior distribution of being different from 0 does not make much sense (the probability of it being different from a single point being infinite). Therefore, the idea underlining ROPE is to let the user define an area around the null value enclosing values that are *equivalent to the null* value for practical purposes (Kruschke 2010, 2011, 2014).

Kruschke (2018) suggests that such null value could be set, by default, to the -0.1 to 0.1 range of a standardized parameter (negligible effect size according to Cohen, 1988). This could be generalized: For instance, for linear models, the ROPE could be set as `0 +/- .1 * sd(y)`

. This ROPE range can be automatically computed for models using the rope_range function.

Kruschke (2010, 2011, 2014) suggests using the proportion of the 95% (or 90%, considered more stable) HDI that falls within the ROPE as an index for “null-hypothesis” testing (as understood under the Bayesian framework, see equivalence_test).

** equivalence_test()** a

** p_direction()** computes the

**Relationship with the p-value**: In most cases, it seems that the *pd* corresponds to the frequentist one-sided *p*-value through the formula `p-value = (1-pd/100)`

and to the two-sided *p*-value (the most commonly reported) through the formula `p-value = 2*(1-pd/100)`

. Thus, a `pd`

of `95%`

, `97.5%`

`99.5%`

and `99.95%`

corresponds approximately to a two-sided *p*-value of respectively `.1`

, `.05`

, `.01`

and `.001`

. See the *reporting guidelines*.

** bayesfactor_savagedickey()** computes the ratio between the density of a single value (typically the null) in two distributions, typically the posterior vs. the prior distributions. This method is used to examine if the hypothesis value is less or more likely given the observed data.

```
prior <- rnorm(1000, mean = 0, sd = 1)
posterior <- rnorm(1000, mean = 1, sd = 0.7)
bayesfactor_savagedickey(posterior, prior, direction = "two-sided", hypothesis = 0)
```

** p_map()** computes a Bayesian equivalent of the p-value, related to the odds that a parameter (described by its posterior distribution) has against the null hypothesis (

** rope_range()**: This function attempts at automatically finding suitable “default” values for the Region Of Practical Equivalence (ROPE). Kruschke (2018) suggests that such null value could be set, by default, to a range from

`-0.1`

to `0.1`

of a standardized parameter (negligible effect size according to Cohen, 1988), which can be generalised for linear models to `-0.1 * sd(y), 0.1 * sd(y)`

. For logistic models, the parameters expressed in log odds ratio can be converted to standardized difference through the formula `sqrt(3)/pi`

, resulting in a range of `-0.05`

to `-0.05`

.** estimate_density()**: This function is a wrapper over different methods of density estimation. By default, it uses the base R

`density`

with by default uses a different smoothing bandwidth (`"SJ"`

) from the legacy default implemented the base R `density`

function (`"nrd0"`

). However, Deng & Wickham suggest that `method = "KernSmooth"`

is the fastest and the most accurate.** distribution()**: Generate a sample of size n with near-perfect distributions.

** density_at()**: Compute the density of a given point of a distribution.

You can cite the package as following:

- Makowski, D., Ben-Shachar M. S., & Lüdecke, D. (2019).
*Understand and Describe Bayesian Models and Posterior Distributions using bayestestR*. Available from https://github.com/easystats/bayestestR. DOI:10.5281/zenodo.2556486.