R: Function for Bayesian analysis of one- and two-sample designs
meta.ttestBF
R Documentation
Function for Bayesian analysis of one- and two-sample designs
Description
This function computes mata-analytic Bayes factors, or samples from the posterior, for
one- and two-sample designs where multiple t values have been observed.
a vector of sample sizes for the first (or only) condition
n2
a vector of sample sizes. If NULL, a one-sample design is assumed
nullInterval
optional vector of length 2 containing lower and upper bounds of
an interval hypothesis to test, in standardized units
rscale
prior scale. A number of preset values can be given as
strings; see Details.
posterior
if TRUE, return samples from the posterior instead
of Bayes factor
callback
callback function for third-party interfaces
...
further arguments to be passed to or from methods.
Details
The Bayes factor provided by meta.ttestBF tests the null hypothesis that
the true effect size (or alternatively, the noncentrality parameters) underlying a
set of t statistics is 0. Specifically, the Bayes factor compares two
hypotheses: that the standardized effect size is 0, or that the standardized
effect size is not 0. Note that there is assumed to be a single, common effect size
delta underlying all t statistics. 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 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 help for
ttestBF and the references below for more details.
The Bayes factor is computed via Gaussian quadrature. Posterior samples are
drawn via independent-candidate Metropolis-Hastings.
Value
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.
Note
To obtain the same Bayes factors as Rouder and Morey (2011),
change the prior scale to 1.
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, 225-237
Rouder, J. N. & Morey, R. D. (2011). A Bayes Factor Meta-Analysis of Bem's ESP Claim.
Psychonomic Bulletin & Review, 18, 682-689
See Also
ttestBF
Examples
## Bem's (2010) data (see Rouder & Morey, 2011)
t=c(-.15,2.39,2.42,2.43)
N=c(100,150,97,99)
## Using rscale=1 and one-sided test to be
## consistent with Rouder & Morey (2011)
bf = meta.ttestBF(t, N, rscale=1, nullInterval=c(0, Inf))
bf[1]
## plot posterior distribution of delta, assuming alternative
## turn off progress bar for example
samples = posterior(bf[1], iterations = 1000, progress = FALSE)
## Note that posterior() respects the nullInterval
plot(samples)
summary(samples)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(BayesFactor)
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.
************
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/BayesFactor/meta.ttestBF.Rd_%03d_medium.png", width=480, height=480)
> ### Name: meta.ttestBF
> ### Title: Function for Bayesian analysis of one- and two-sample designs
> ### Aliases: meta.ttestBF
> ### Keywords: htest
>
> ### ** Examples
>
> ## Bem's (2010) data (see Rouder & Morey, 2011)
> t=c(-.15,2.39,2.42,2.43)
> N=c(100,150,97,99)
>
> ## Using rscale=1 and one-sided test to be
> ## consistent with Rouder & Morey (2011)
> bf = meta.ttestBF(t, N, rscale=1, nullInterval=c(0, Inf))
> bf[1]
Bayes factor analysis
--------------
[1] Alt., r=1 0<d<Inf : 38.68248 <U+00B1>0%
Against denominator:
Null, d = 0
---
Bayes factor type: BFmetat, JZS
>
> ## plot posterior distribution of delta, assuming alternative
> ## turn off progress bar for example
> samples = posterior(bf[1], iterations = 1000, progress = FALSE)
Independent-candidate M-H acceptance rate: 100%
> ## Note that posterior() respects the nullInterval
> plot(samples)
> summary(samples)
Iterations = 1:1000
Thinning interval = 1
Number of chains = 1
Sample size per chain = 1000
1. Empirical mean and standard deviation for each variable,
plus standard error of the mean:
Mean SD Naive SE Time-series SE
0.171387 0.045474 0.001438 0.001633
2. Quantiles for each variable:
2.5% 25% 50% 75% 97.5%
0.08459 0.14063 0.17003 0.20200 0.26342
>
>
>
>
>
> dev.off()
null device
1
>