Description Usage Arguments Details Value Note Author(s) References See Also Examples
This function computes a Bayes factor for the mean difference between two phases of a single subject data sequence, using Gibbs sampling. Posterior samples of parameters are also provided.
1 2 | ttest.Gibbs.AR(before, after, iterations = 1000, areaNull = c(-0.2, 0.2), treat = NULL, r.scale = 1, alphaTheta = 1,
betaTheta = 5, sdMet = 0.3, progress = TRUE, return.chains = FALSE)
|
before |
A vector of observations, in time order, taken in Phase 1 (e.g., before the treatment). |
after |
A vector of observations, in time order, taken in Phase 2 (e.g., after the treatment). |
iterations |
Number of Gibbs sampler iterations to perform. |
areaNull |
Only used if |
treat |
Vector of dummy coding, indicating Phase 1 and Phase 2; default is -.5 for Phase 1 and .5 for Phase 2. |
r.scale |
Prior scale for delta (see Details below). |
alphaTheta |
The alpha parameter of the beta prior on theta (see Details below). |
betaTheta |
The beta parameter of the beta prior on theta (see Details below). |
sdMet |
Scale for the Metropolis-Hastings sampling of theta (see Details below). |
progress |
Report progress with a text progress bar? |
return.chains |
Return posterior samples of parameters?. |
This function computes a Bayes factor for the mean difference between two data sequences from a single subject, using Gibbs sampling. The Bayes factor compares the null hypothesis of no true mean difference against the alternative hypothesis of a true mean difference. A Bayes factor larger than 1 supports the null hypothesis, a Bayes factor smaller than 1 supports the alternative hypothesis. Auto-correlation of the errors is modeled by a first order auto-regressive process.
Posterior distributions of the model parameters can also be obtained. Model parameters of interest include mu0 (overall mean), delta (standardized mean difference), sig2 (variance of the random shocks), and rho (auto-correlation).
A Cauchy prior is placed on the standardized mean difference delta. The r.scale
argument controls the scale of
this Cauchy prior, with r.scale=1
yielding a standard Cauchy prior. A noninformative Jeffreys prior is
placed on the variance of the random shocks of the auto-regressive process. A beta prior is placed on the auto-correlation
rho. The alphaTheta
and betaTheta
arguments control the form of this beta prior.
Missing data are sampled from the likelihood function, conditioned at the observed data, at each iteration of the Gibbs sampler.
if return.chains=FALSE
: a scalar giving an MCMC estimate of the log Bayes factor, computed using the Savage-Dickey method (Morey, Rouder, Pratte, and Speckman, submitted)
if return.chains=TRUE
: a list containing the following:
logbf |
An MCMC estimate of the log Bayes factor, computed using the Savage-Dickey method (Morey, Rouder, Pratte, and Speckman, submitted). |
chains |
Only returned if |
acc |
Only returned if |
logbfArea |
Only returned if |
For a more accurate method of computing the Bayes factor, see ttest.MCGQ.AR
.
Richard D. Morey and Rivka de Vries
De Vries, R. M. \& Morey, R. D. (submitted). Bayesian hypothesis testing Single-Subject Data. Psychological Methods.
R code guide: http://drsmorey.org/research/rdmorey/
ttest.MCGQ.AR
, trendtest.Gibbs.AR
, trendtest.MC.AR
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## Define data
data = c(87.5, 82.5, 53.4, 72.3, 94.2, 96.6, 57.4, 78.1, 47.2,
80.7, 82.1, 73.7, 49.3, 79.3, 73.3, 57.3, 31.7, 50.4, 77.8,
67, 40.5, 1.6, 38.6, 3.2, 24.1)
## Obtain log Bayes factor
logBF = ttest.Gibbs.AR(data[1:10], data[11:25])
## Obtain log Bayes factor, chains, and log interval null Bayes factor
output = ttest.Gibbs.AR(data[1:10], data[11:25], return.chains = TRUE, areaNull = c(-0.2, 0.2))
## Look at the posterior distribution of the mean
plot(output$chains[,1])
## Obtain summary statistics of posterior distributions
summary(output$chains)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.