Description Usage Arguments Details Value Note Author(s) References See Also Examples
This function computes Bayes factors for the trend and intercept differences between two phases of a single subject data sequence, using Gibbs sampling. Posterior samples of parameters are also provided.
1 2 3 4 5 6 7 |
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. |
intArea |
Only used if |
slpArea |
Only used if |
leftSidedInt |
Only used if |
leftSidedSlp |
Only used if |
r.scaleInt |
Prior scale for the intercept difference (see Details below). |
r.scaleSlp |
Prior scale for the trend difference (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?. |
return.onesided |
Return one sided Bayes factors? |
This function computes Bayes factors for the differences in trend and intercept between two data sequences from a single subject, using Gibbs sampling. The Bayes factor for trend difference compares the null hypothesis of no true trend difference against the alternative hypothesis of a true trend difference. The Bayes factor for intercept difference compares the null hypothesis of no true intercept difference against the alternative hypothesis of a true intercept difference. Also, a joined Bayes factor for the trend and intercept combined is provided. Bayes factors larger than 1 support the null hypothesis, Bayes factors smaller than 1 support 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), sig*delta (difference between intercepts), beta0 (overall trend), sig*beta1 (difference between trends), sig2 (variance of the random shocks), and rho (auto-correlation).
Cauchy priors are placed on the standardized trend and intercept differences. The r.scaleInt
and r.scaleSlp
arguments
control the scales of these Cauchy priors, with r.scaleInt = 1
and r.scaleSlp = 1
yielding standard Cauchy priors.
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 theta. 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.
A list containing the following:
logbf |
MCMC estimates of the log two sided point null Bayes factors, computed using the Savage-Dickey method (Morey, Rouder, Pratte, and Speckman, submitted). |
chains |
Only returned if |
acc |
Only returned if |
logbfArea |
Only returned if |
logbfOnesided |
Only returned if |
For a more accurate method of computing the Bayes factor, see trendtest.MC.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/
trendtest.MC.AR
, ttest.Gibbs.AR
, ttest.MCGQ.AR
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ## 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 factors
logBFs = trendtest.Gibbs.AR(data[1:10], data[11:25])
## Obtain log Bayes factors, chains, and log interval null Bayes factors
output = trendtest.Gibbs.AR(data[1:10], data[11:25],
return.chains = TRUE, intArea = c(-0.2,0.2),
slpArea = 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)
|
|
| | 0%
|
|= | 1%
|
|= | 2%
|
|== | 3%
|
|=== | 4%
|
|==== | 5%
|
|==== | 6%
|
|===== | 7%
|
|====== | 8%
|
|====== | 9%
|
|======= | 10%
|
|======== | 11%
|
|======== | 12%
|
|========= | 13%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 16%
|
|============ | 17%
|
|============= | 18%
|
|============= | 19%
|
|============== | 20%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 23%
|
|================= | 24%
|
|================== | 25%
|
|================== | 26%
|
|=================== | 27%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 30%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 33%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 36%
|
|========================== | 37%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 40%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 43%
|
|=============================== | 44%
|
|================================ | 45%
|
|================================ | 46%
|
|================================= | 47%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 50%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 53%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 56%
|
|======================================== | 57%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 60%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 63%
|
|============================================= | 64%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 67%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 70%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 73%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 77%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 80%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 83%
|
|=========================================================== | 84%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 87%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 90%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 93%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 97%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 100%
rho acceptance rate: 0.3153153
|
| | 0%
|
|= | 1%
|
|= | 2%
|
|== | 3%
|
|=== | 4%
|
|==== | 5%
|
|==== | 6%
|
|===== | 7%
|
|====== | 8%
|
|====== | 9%
|
|======= | 10%
|
|======== | 11%
|
|======== | 12%
|
|========= | 13%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 16%
|
|============ | 17%
|
|============= | 18%
|
|============= | 19%
|
|============== | 20%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 23%
|
|================= | 24%
|
|================== | 25%
|
|================== | 26%
|
|=================== | 27%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 30%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 33%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 36%
|
|========================== | 37%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 40%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 43%
|
|=============================== | 44%
|
|================================ | 45%
|
|================================ | 46%
|
|================================= | 47%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 50%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 53%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 56%
|
|======================================== | 57%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 60%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 63%
|
|============================================= | 64%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 67%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 70%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 73%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 77%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 80%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 83%
|
|=========================================================== | 84%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 87%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 90%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 93%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 97%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 100%
rho acceptance rate: 0.3153153
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
mu0 76.2327 8.9496 0.283010 0.30156
sig*delta 8.2158 13.6878 0.432847 0.43285
beta0 -2.4518 1.1545 0.036509 0.03651
sig*beta1 -3.2708 2.6657 0.084296 0.08179
sig2 346.6500 111.6138 3.529537 5.83900
g1 12.7221 216.6363 6.850641 6.85064
g2 5.6421 82.7235 2.615946 2.61595
rho 0.1277 0.1119 0.003538 0.01062
2. Quantiles for each variable:
2.5% 25% 50% 75% 97.5%
mu0 57.84865 70.87614 76.3184 81.5305 93.31316
sig*delta -17.44681 -0.64663 7.6457 16.8342 35.66630
beta0 -4.76458 -3.16681 -2.4553 -1.7659 -0.09218
sig*beta1 -8.76121 -4.89039 -3.3302 -1.5983 1.98036
sig2 199.16324 268.89154 322.5940 398.6094 632.04269
g1 0.16935 0.55290 1.1664 2.9099 30.91282
g2 0.14644 0.40099 0.7333 1.6430 18.34464
rho 0.00636 0.04428 0.1036 0.1757 0.42986
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.