Description Usage Arguments Details Value Note Author(s) References See Also Examples

This function computes Bayes factors, or samples from the posterior, for one- and two-sample designs.

1 2 3 |

`x` |
a vector of observations for the first (or only) group |

`y` |
a vector of observations for the second group (or condition, for paired) |

`formula` |
for independent-group designs, a (optional) formula describing the model |

`mu` |
for one-sample and paired designs, the null value of the mean (or mean difference) |

`nullInterval` |
optional vector of length 2 containing lower and upper bounds of an interval hypothesis to test, in standardized units |

`paired` |
if |

`data` |
for use with |

`rscale` |
prior scale. A number of preset values can be given as strings; see Details. |

`posterior` |
if |

`...` |
further arguments to be passed to or from methods. |

The Bayes factor provided by `ttestBF`

tests the
null hypothesis that the mean (or mean difference) of a
normal population is *mu0* (argument
`mu`

). Specifically, the Bayes factor compares two
hypotheses: that the standardized effect size is 0, or
that the standardized effect size is not 0. For
one-sample tests, the standardized effect size is
*(mu-mu0)/sigma*; for two sample
tests, the standardized effect size is
*(mu2-mu1)/sigma*.

A noninformative Jeffreys prior is placed on the variance
of the normal population, while a Cauchy prior is placed
on the standardized effect size. The `rscale`

argument controls the scale of the prior distribution,
with `rscale=1`

yielding a standard Cauchy prior.
See the references below for more details.

For the `rscale`

argument, several named values are
recognized: "medium", "wide", and "ultrawide". For the
one-sample test, these correspond to *r* scale values
of 1/2, *sqrt(2)/2*, and 1, respectively.
For the two-sample test, they correspond to
*sqrt(2)/2*, 1, and
*sqrt(2)* respectively.

The Bayes factor is computed via Gaussian quadrature.

If `posterior`

is `FALSE`

, an object of class
`BFBayesFactor`

containing the computed model
comparisons is returned. If `nullInterval`

is
defined, then two Bayes factors will be computed: The
Bayes factor for the interval against the null hypothesis
that the standardized effect is 0, and the corresponding
Bayes factor for the compliment of the interval.

If `posterior`

is `TRUE`

, an object of class
`BFmcmc`

, containing MCMC samples from the posterior
is returned.

The default priors have scale has changed from 1 to
*√{2}/2* for the two-sample t test, and 1/2 for
the one-sample t test. The factor of *√{2}* in
the two-sample t test is to be consistent with Morey et
al. (2011) and Rouder et al. (2012), and the factor of
*1/2* in both is to better scale the expected effect
sizes; the previous scaling put more weight on larger
effect sizes. To obtain the same Bayes factors as Rouder
et al. (2009), change the prior scale to 1.

Richard D. Morey ([email protected])

Morey, R. D., Rouder, J. N., Pratte, M. S., & Speckman, P. L. (2011). Using MCMC chain outputs to efficiently estimate Bayes factors. Journal of Mathematical Psychology, 55, 368-378

Morey, R. D. \& Rouder, J. N. (2011). Bayes Factor Approaches for Testing Interval Null Hypotheses. Psychological Methods, 16, 406-419

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, 752-760

Perception and Cognition Lab (University of Missouri): Bayes factor calculators. http://pcl.missouri.edu/bayesfactor

1 2 3 4 5 6 7 8 9 10 | ```
## Sleep data from t test example
data(sleep)
plot(extra ~ group, data = sleep)
## paired t test
ttestBF(x = sleep$extra[sleep$group==1], y = sleep$extra[sleep$group==2], paired=TRUE)
## Sample from the corresponding posterior distribution
samples = ttestBF(x = sleep$extra[sleep$group==1], y = sleep$extra[sleep$group==2], paired=TRUE, posterior = TRUE, iterations = 1000)
plot(samples[,"mu"])
``` |

```
Loading required package: coda
Loading required package: Matrix
************
Welcome to BayesFactor 0.9.12-2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).
Type BFManual() to open the manual.
************
Bayes factor analysis
--------------
[1] Alt., r=0.707 : 17.25888 <U+00B1>0%
Against denominator:
Null, mu = 0
---
Bayes factor type: BFoneSample, JZS
```

BayesFactor documentation built on May 31, 2017, 4:17 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.