jzs_corSD: A default Bayesian hypothesis test for correlation using the...

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

Description

This function can be used to perform a default Bayesian hypothesis test for correlation, using the Savage-Dickey method (Dickey & Lientz, 1970). The test uses a Jeffreys-Zellner-Siow prior set-up (Liang et al., 2008).

Usage

1
2
3
4
jzs_corSD(V1, V2, 
          SDmethod = c("fit.st", "dnorm", "splinefun", "logspline"), 
          alternative = c("two.sided", "less", "greater"),
          n.iter=10000,n.burnin=500, standardize=TRUE)

Arguments

V1

a numeric vector.

V2

a numeric vector of the same length as V1.

SDmethod

specify the precise method with which the density of the posterior distribution will be estimated in order to compute the Savage-Dickey ratio.

alternative

specify the alternative hypothesis for the correlation coefficient: two.sided, greater than zero, or less than zero.

n.iter

number of total iterations per chain (see the package R2jags). Defaults to 10000.

n.burnin

length of burn in, i.e. number of iterations to discard at the beginning(see the package R2jags). Defaults to 500.

standardize

logical. Should the variables be standardized? Defaults to TRUE.

Value

A list containing the following components:

Correlation

The correlation coefficient for the relation between V1 and V2. The correlation coefficient is calculated by standardizing the mean of the posterior samples: mean(samples)*(sd(V1)/sd(V2)).

BayesFactor

The Bayes factor for the correlation coefficient. A value greater than one indicates evidence in favor of correlation, a value smaller than one indicates evidence against correlation.

PosteriorProbability

The posterior probability for the existence of a correlation between V1 and V2.

alpha

The posterior samples for the correlation coefficient alpha.

jagssamples

The JAGS output for the MCMC estimation of the path. This object can be used to construct a traceplot.

Warning

In some cases the SDmethod fit.st will fail to converge. If so, another optimization method is used, using different starting values. If the other optimization method does not converge either or gives you a negative Bayes factor (which is meaningless), you could try one of the other SDmethod options or see jzs_cor.

Author(s)

Michele B. Nuijten <m.b.nuijten@uvt.nl>, Ruud Wetzels, Dora Matzke, Conor V. Dolan, and Eric-Jan Wagenmakers.

References

Dickey, J. M., & Lientz, B. P. (1970). The weighted likelihood ratio, sharp hypotheses about chances, the order of a Markov chain. The Annals of Mathematical Statistics, 214-226.

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.

Nuijten, M. B., Wetzels, R., Matzke, D., Dolan, C. V., & Wagenmakers, E.-J. (2014). A default Bayesian hypothesis test for mediation. Behavior Research Methods. doi: 10.3758/s13428-014-0470-2

Wetzels, R., & Wagenmakers, E.-J. (2012). A Default Bayesian Hypothesis Test for Correlations and Partial Correlations. Psychonomic Bulletin & Review, 19, 1057-1064.

See Also

jzs_cor, jzs_partcorSD

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
# generate correlational data
X <- rnorm(100)
Y <- .4*X + rnorm(100,0,1)

# run jzs_cor
result <- jzs_corSD(X,Y)

# inspect posterior distribution 
plot(result$alpha_samples)

# print a traceplot of the chains
plot(result$jagssamples)


## End(Not run)

BayesMed documentation built on May 2, 2019, 9:27 a.m.