equiv_bf {baymedr} R Documentation

## Bayes factor for equivalence designs

### Description

equiv_bf computes a Bayes factor for equivalence designs with a continuous dependent variable.

### Usage

equiv_bf(
x = NULL,
y = NULL,
n_x = NULL,
n_y = NULL,
mean_x = NULL,
mean_y = NULL,
sd_x = NULL,
sd_y = NULL,
ci_margin = NULL,
ci_level = NULL,
interval = 0,
interval_std = TRUE,
prior_scale = 1/sqrt(2)
)


### Arguments

 x A numeric vector of observations for the control group. y A numeric vector of observations for the experimental group. n_x A numeric vector of length one, specifying the sample size of the control group. n_y A numeric vector of length one, specifying the sample size of the experimental group. mean_x A numeric vector of length one, specifying the mean of the dependent variable in the control group. mean_y A numeric vector of length one, specifying the mean of the dependent variable in the experimental group. sd_x A numeric vector of length one, specifying the standard deviation of the dependent variable in the control group. Only sd_x and sd_y OR ci_margin and ci_level should be defined (see Details). sd_y A numeric vector of length one, specifying the standard deviation of the dependent variable in the experimental group. Only sd_x and sd_y OR ci_margin and ci_level should be defined (see Details). ci_margin A numeric vector of length one, specifying the margin of the confidence interval (i.e., the width of the confidence interval divided by 2) of the mean difference on the dependent variable between the experimental and control groups. The value should be a positive number Only sd_x and sd_y OR ci_margin and ci_level should be defined (see Details). ci_level A numeric vector of length one, specifying the confidence level of ci_margin. The value must be between 0 and 1 (e.g., 0.95 for a 95% confidence interval). Only sd_x and sd_y OR ci_margin and ci_level should be defined (see Details). interval A numeric vector of length one or two, specifying the boundaries of the equivalence interval. If a numeric vector of length one is specified, a symmetric equivalence interval will be used (e.g., a 0.1 is equivalent to c(-0.1, 0.1)). A numeric vector of length two provides the possibility to specify an asymmetric equivalence interval (e.g., c(-0.1, 0.2)). The default is 0, indicating a point null hypothesis rather than an interval (see Details). interval_std A logical vector of length one, specifying whether the equivalence interval (i.e., interval) is given in standardized (TRUE; the default) or unstandardized (FALSE) units. prior_scale A numeric vector of length one, specifying the scale of the Cauchy prior distribution for the effect size under the alternative hypothesis (see Details). The default value is r = 1 / sqrt(2).

### Details

The equivalence design has the following hypotheses: The null hypothesis (i.e., H0) states that the population means of the experimental group (e.g., a new medication) and the control group (e.g., a placebo or an already existing medication) are (practically) equivalent; the alternative hypothesis (i.e., H1) states that the population means of the two groups are not equivalent. The dependent variable must be continuous.

Since the main goal of equiv_bf is to establish equivalence, the resulting Bayes factor quantifies evidence in favor of the null hypothesis (i.e., BF01). Evidence for the alternative hypothesis can easily be calculated by taking the reciprocal of the original Bayes factor (i.e., BF10 = 1 / BF01). Quantification of evidence in favor of the null hypothesis is logically sound and legitimate within the Bayesian framework (see e.g., van Ravenzwaaij et al., 2019).

equiv_bf can be utilized to calculate a Bayes factor based on raw data (i.e., if arguments x and y are defined) or summary statistics (i.e., if arguments n_x, n_y, mean_x, and mean_y are defined). In the latter case, either values for the arguments sd_x and sd_y OR ci_margin and ci_level can be supplied. Arguments with 'x' as a name or suffix correspond to the control group, whereas arguments with 'y' as a name or suffix correspond to the experimental group.

The equivalence interval can be specified with the argument interval. However, it is not compulsory to specify an equivalence interval (see van Ravenzwaaij et al., 2019). The default value of the argument interval is 0, indicating a point null hypothesis. If an interval is preferred, the argument interval can be set in two ways: A symmetric interval can be defined by either specifying a numeric vector of length one (e.g., 0.1, which is converted to c(-0.1, 0.1)) or a numeric vector of length two (e.g., c(-0.1, 0.1)); an asymmetric interval can be defined by specifying a numeric vector of length two (e.g., c(-0.1, 0.2)). It can be specified whether the equivalence interval (i.e., interval) is given in standardized or unstandardized units with the interval_std argument, where TRUE, corresponding to standardized units, is the default.

For the calculation of the Bayes factor, a Cauchy prior density centered on 0 is chosen for the effect size under the alternative hypothesis. The standard Cauchy distribution, with a location parameter of 0 and a scale parameter of 1, resembles a standard Normal distribution, except that the Cauchy distribution has less mass at the center but heavier tails (Liang et al., 2008; Rouder et al., 2009). The argument prior_scale specifies the width of the Cauchy prior, which corresponds to half of the interquartile range. Thus, by adjusting the Cauchy prior scale with prior_scale, different ranges of expected effect sizes can be emphasized. The default prior scale is set to r = 1 / sqrt(2).

equiv_bf creates an S4 object of class baymedrEquivalence, which has multiple slots/entries (e.g., type of data, prior scale, Bayes factor, etc.; see Value). If it is desired to store or extract solely the Bayes factor, the user can do this with get_bf, by setting the S4 object as an argument (see Examples).

### Value

An S4 object of class baymedrEquivalence is returned. Contained are a description of the model and the resulting Bayes factor:

• test: The type of analysis

• hypotheses: A statement of the hypotheses

• h0: The null hypothesis

• h1: The alternative hypothesis

• interval: Specification of the equivalence interval in standardized and unstandardized units

• lower_std: The standardized lower boundary of the equivalence interval

• upper_std: The standardized upper boundary of the equivalence interval

• lower_unstd: The unstandardized lower boundary of the equivalence interval

• upper_unstd: The unstandardized upper boundary of the equivalence interval

• data: A description of the data

• type: The type of data ('raw' when arguments x and y are used or 'summary' when arguments n_x, n_y, mean_x, mean_y, sd_x, and sd_y (or ci_margin and ci_level instead of sd_x and sd_y) are used)

• ...: values for the arguments used, depending on 'raw' or summary'

• prior_scale: The width of the Cauchy prior distribution

• bf: The resulting Bayes factor

A summary of the model is shown by printing the object.

### References

Gronau, Q. F., Ly, A., & Wagenmakers, E.-J. (2020). Informed Bayesian t-tests. The American Statistician, 74(2), 137-143.

Liang, F., Paulo, R., Molina, G., Clyde, M. A., & Berger, J. O. (2008). Mixtures of g priors for Bayesian variable selection. Journal of the American Statistical Association, 103(481), 410-423.

Rouder, J. N., Speckman, P. L., Sun, D., Morey, R. D., & Iverson, G. (2009). Bayesian t tests for accepting and rejecting the null hypothesis. Psychonomic Bulletin & Review, 16(2), 225-237.

van Ravenzwaaij, D., Monden, R., Tendeiro, J. N., & Ioannidis, J. P. A. (2019). Bayes factors for superiority, non-inferiority, and equivalence designs. BMC Medical Research Methodology, 19(1), 71.

### Examples

## equiv_bf using raw data:

# Assign model to variable.
equiv_raw <- equiv_bf(x = rnorm(100, 10, 15),
y = rnorm(130, 13, 10))

# Extract Bayes factor from variable.
get_bf(equiv_raw)

# ----------
# ----------

## equiv_bf using summary statistics with data from Steiner et al. (2015).
## With a point null hypothesis:

# Assign model to variable.
equiv_sum_point <- equiv_bf(n_x = 560,
n_y = 538,
mean_x = 8.683,
mean_y = 8.516,
sd_x = 3.6,
sd_y = 3.6)

# Extract Bayes factor from model.
get_bf(equiv_sum_point)

# ----------
# ----------

## equiv_bf using summary statistics with data from Steiner et al. (2015).
## With an interval null hypothesis:

# Assign model to variable.
equiv_sum_interval <- equiv_bf(n_x = 560,
n_y = 538,
mean_x = 8.683,
mean_y = 8.516,
sd_x = 3.6,
sd_y = 3.6,
interval = 0.05)

# Extract Bayes factor from model.
get_bf(equiv_sum_interval)


[Package baymedr version 0.1.1 Index]