jzs_partcor: A default Bayesian hypothesis test for partial correlation...

Description Usage Arguments Details Value Author(s) References Examples

View source: R/jzs_partcor.R

Description

This function can be used to perform a default Bayesian hypothesis test for partial correlation, using a Jeffreys-Zellner-Siow prior set-up (Liang et al., 2008).

Usage

1
2
jzs_partcor(V1, V2, control, 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.

control

a numeric vector of the same length as V1 and V2. This variable is partialled out of the correlation between V1 and V2.

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.

Details

See Wetzels & Wagenmakers, 2012.

Value

The function returns a list with the following items:

PartCoef

Mean of the posterior samples of the unstandardized partial correlation (the regression coefficient beta in the equation V2 = intercept + alpha*control + beta*V1).

BayesFactor

The Bayes factor for the existence of a partial correlation between V1 and V2, controlled for the control variable. A value greater than one indicates evidence in favor of partial correlation, a value smaller than one indicates evidence against partial correlation.

PosteriorProbability

The posterior probability for the existence of a partial correlation between V1 and V2, controlled for the control variable.

beta

The posterior samples for the regression coefficient beta. This is the unstandardized partial correlation.

jagssamples

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

Author(s)

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

References

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
# simulate partially correlated data
X <- rnorm(50,0,1)
C <- .5*X + rnorm(50,0,1)
Y <- .3*X + .6*C + rnorm(50,0,1)

# run jzs_partcor
res <- jzs_partcor(X,Y,C)

# plot posterior samples
plot(res$beta_samples)

# plot traceplot
plot(res$jagssamples)
# where the first chain (theta[1]) is for tau' and the second chain (theta[2]) for beta


## End(Not run)

MicheleNuijten/BayesMed documentation built on Jan. 31, 2020, 7:45 a.m.