A support interval contains only the values of the parameter that predict the observed data better
than average, by some degree *k*; these are values of the parameter that are associated with an
updating factor greater or equal than *k*. From the perspective of the Savage-Dickey Bayes factor, testing
against a point null hypothesis for any value within the support interval will yield a Bayes factor smaller
than *1/k*.
**For more info, in particular on specifying correct priors for factors with more than 2 levels,
see the Bayes factors vignette.**

## Usage

```
si(posterior, prior = NULL, BF = 1, verbose = TRUE, ...)
# S3 method for numeric
si(posterior, prior = NULL, BF = 1, verbose = TRUE, ...)
# S3 method for stanreg
si(
posterior,
prior = NULL,
BF = 1,
verbose = TRUE,
effects = c("fixed", "random", "all"),
component = c("location", "conditional", "all", "smooth_terms", "sigma", "auxiliary",
"distributional"),
parameters = NULL,
...
)
# S3 method for brmsfit
si(
posterior,
prior = NULL,
BF = 1,
verbose = TRUE,
effects = c("fixed", "random", "all"),
component = c("location", "conditional", "all", "smooth_terms", "sigma", "auxiliary",
"distributional"),
parameters = NULL,
...
)
# S3 method for blavaan
si(
posterior,
prior = NULL,
BF = 1,
verbose = TRUE,
effects = c("fixed", "random", "all"),
component = c("location", "conditional", "all", "smooth_terms", "sigma", "auxiliary",
"distributional"),
parameters = NULL,
...
)
# S3 method for emmGrid
si(posterior, prior = NULL, BF = 1, verbose = TRUE, ...)
# S3 method for data.frame
si(posterior, prior = NULL, BF = 1, verbose = TRUE, ...)
```

## Arguments

- posterior
A numerical vector,

`stanreg`

/`brmsfit`

object,`emmGrid`

or a data frame - representing a posterior distribution(s) from (see 'Details').- prior
An object representing a prior distribution (see 'Details').

- BF
The amount of support required to be included in the support interval.

- verbose
Toggle off warnings.

- ...
Arguments passed to and from other methods. (Can be used to pass arguments to internal

`logspline::logspline()`

.)- effects
Should results for fixed effects, random effects or both be returned? Only applies to mixed models. May be abbreviated.

- component
Should results for all parameters, parameters for the conditional model or the zero-inflated part of the model be returned? May be abbreviated. Only applies to brms-models.

- parameters
Regular expression pattern that describes the parameters that should be returned. Meta-parameters (like

`lp__`

or`prior_`

) are filtered by default, so only parameters that typically appear in the`summary()`

are returned. Use`parameters`

to select specific parameters for the output.

## Value

A data frame containing the lower and upper bounds of the SI.

Note that if the level of requested support is higher than observed in the data, the
interval will be `[NA,NA]`

.

## Details

This method is used to compute support intervals based on prior and posterior distributions.
For the computation of support intervals, the model priors must be proper priors (at the very least
they should be *not flat*, and it is preferable that they be *informative* - note
that by default, `brms::brm()`

uses flat priors for fixed-effects; see example below).

### Choosing a value of `BF`

The choice of `BF`

(the level of support) depends on what we want our interval to represent:

A

`BF`

= 1 contains values whose credibility is not decreased by observing the data.A

`BF`

> 1 contains values who received more impressive support from the data.A

`BF`

< 1 contains values whose credibility has*not*been impressively decreased by observing the data. Testing against values outside this interval will produce a Bayes factor larger than 1/`BF`

in support of the alternative. E.g., if an SI (BF = 1/3) excludes 0, the Bayes factor against the point-null will be larger than 3.

## Note

There is also a `plot()`

-method implemented in the see-package.

## Setting the correct `prior`

For the computation of Bayes factors, the model priors must be proper priors
(at the very least they should be *not flat*, and it is preferable that
they be *informative*); As the priors for the alternative get wider, the
likelihood of the null value(s) increases, to the extreme that for completely
flat priors the null is infinitely more favorable than the alternative (this
is called *the Jeffreys-Lindley-Bartlett paradox*). Thus, you should
only ever try (or want) to compute a Bayes factor when you have an informed
prior.

(Note that by default, `brms::brm()`

uses flat priors for fixed-effects;
See example below.)

It is important to provide the correct `prior`

for meaningful results.

When

`posterior`

is a numerical vector,`prior`

should also be a numerical vector.When

`posterior`

is a`data.frame`

,`prior`

should also be a`data.frame`

, with matching column order.When

`posterior`

is a`stanreg`

,`brmsfit`

or other supported Bayesian model:`prior`

can be set to`NULL`

, in which case prior samples are drawn internally.`prior`

can also be a model equivalent to`posterior`

but with samples from the priors*only*. See`unupdate()`

.**Note:**When`posterior`

is a`brmsfit_multiple`

model,`prior`

**must**be provided.

When

`posterior`

is an`emmGrid`

/`emm_list`

object:`prior`

should also be an`emmGrid`

/`emm_list`

object equivalent to`posterior`

but created with a model of priors samples*only*. See`unupdate()`

.`prior`

can also be the original (posterior)*model*. If so, the function will try to update the`emmGrid`

/`emm_list`

to use the`unupdate()`

d prior-model. (*This cannot be done for*)`brmsfit`

models.**Note**: When the`emmGrid`

has undergone any transformations (`"log"`

,`"response"`

, etc.), or`regrid`

ing, then`prior`

must be an`emmGrid`

object, as stated above.

## References

Wagenmakers, E., Gronau, Q. F., Dablander, F., & Etz, A. (2018, November 22). The Support Interval. doi:10.31234/osf.io/zwnxb

## Examples

```
library(bayestestR)
prior <- distribution_normal(1000, mean = 0, sd = 1)
posterior <- distribution_normal(1000, mean = .5, sd = .3)
si(posterior, prior)
#> Warning: Support intervals might not be precise.
#> For precise support intervals, sampling at least 40,000 posterior
#> samples is recommended.
#> BF = 1 SI: [0.04, 1.04]
# \dontrun{
# rstanarm models
# ---------------
library(rstanarm)
contrasts(sleep$group) <- contr.equalprior_pairs # see vignette
stan_model <- stan_lmer(extra ~ group + (1 | ID), data = sleep)
#>
#> SAMPLING FOR MODEL 'continuous' NOW (CHAIN 1).
#> Chain 1:
#> Chain 1: Gradient evaluation took 3.5e-05 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.35 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1:
#> Chain 1:
#> Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 1:
#> Chain 1: Elapsed Time: 0.249379 seconds (Warm-up)
#> Chain 1: 0.152553 seconds (Sampling)
#> Chain 1: 0.401932 seconds (Total)
#> Chain 1:
#>
#> SAMPLING FOR MODEL 'continuous' NOW (CHAIN 2).
#> Chain 2:
#> Chain 2: Gradient evaluation took 2.4e-05 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.24 seconds.
#> Chain 2: Adjust your expectations accordingly!
#> Chain 2:
#> Chain 2:
#> Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 2:
#> Chain 2: Elapsed Time: 0.242844 seconds (Warm-up)
#> Chain 2: 0.179448 seconds (Sampling)
#> Chain 2: 0.422292 seconds (Total)
#> Chain 2:
#>
#> SAMPLING FOR MODEL 'continuous' NOW (CHAIN 3).
#> Chain 3:
#> Chain 3: Gradient evaluation took 2.1e-05 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.21 seconds.
#> Chain 3: Adjust your expectations accordingly!
#> Chain 3:
#> Chain 3:
#> Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 3: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 3:
#> Chain 3: Elapsed Time: 0.244303 seconds (Warm-up)
#> Chain 3: 0.1841 seconds (Sampling)
#> Chain 3: 0.428403 seconds (Total)
#> Chain 3:
#>
#> SAMPLING FOR MODEL 'continuous' NOW (CHAIN 4).
#> Chain 4:
#> Chain 4: Gradient evaluation took 2e-05 seconds
#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.2 seconds.
#> Chain 4: Adjust your expectations accordingly!
#> Chain 4:
#> Chain 4:
#> Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 4:
#> Chain 4: Elapsed Time: 0.262434 seconds (Warm-up)
#> Chain 4: 0.22897 seconds (Sampling)
#> Chain 4: 0.491404 seconds (Total)
#> Chain 4:
si(stan_model)
#> Sampling priors, please wait...
#> Warning: Support intervals might not be precise.
#> For precise support intervals, sampling at least 40,000 posterior
#> samples is recommended.
#> Support Interval
#>
#> Parameter | BF = 1 SI | Effects | Component
#> --------------------------------------------------
#> (Intercept) | [0.44, 2.71] | fixed | conditional
#> group1 | [0.41, 2.76] | fixed | conditional
si(stan_model, BF = 3)
#> Sampling priors, please wait...
#> Warning: Support intervals might not be precise.
#> For precise support intervals, sampling at least 40,000 posterior
#> samples is recommended.
#> Support Interval
#>
#> Parameter | BF = 3 SI | Effects | Component
#> --------------------------------------------------
#> (Intercept) | [0.74, 2.32] | fixed | conditional
#> group1 | [0.66, 2.45] | fixed | conditional
# emmGrid objects
# ---------------
library(emmeans)
group_diff <- pairs(emmeans(stan_model, ~group))
si(group_diff, prior = stan_model)
#> Sampling priors, please wait...
#> Warning: Support intervals might not be precise.
#> For precise support intervals, sampling at least 40,000 posterior
#> samples is recommended.
#> Support Interval
#>
#> Parameter | BF = 1 SI
#> --------------------------------
#> group1 - group2 | [-2.75, -0.51]
# brms models
# -----------
library(brms)
contrasts(sleep$group) <- contr.equalprior_pairs # see vingette
my_custom_priors <-
set_prior("student_t(3, 0, 1)", class = "b") +
set_prior("student_t(3, 0, 1)", class = "sd", group = "ID")
brms_model <- suppressWarnings(brm(extra ~ group + (1 | ID),
data = sleep,
prior = my_custom_priors,
refresh = 0
))
#> Compiling Stan program...
#> Start sampling
si(brms_model)
#> Sampling priors, please wait...
#> Warning: Support intervals might not be precise.
#> For precise support intervals, sampling at least 40,000 posterior
#> samples is recommended.
#> Support Interval
#>
#> Parameter | BF = 1 SI | Effects | Component
#> --------------------------------------------------
#> b_Intercept | [0.62, 2.48] | fixed | conditional
#> b_group1 | [0.75, 2.51] | fixed | conditional
# }
```