Learn R Programming

brainGraph (version 2.7.3)

cor.diff.test: Calculate the p-value for differences in correlation coefficients

Description

Given two sets of correlation coefficients and sample sizes, this function calculates and returns the z-scores and p-values associated with the difference between correlation coefficients. This function was adapted from http://stackoverflow.com/a/14519007/3357706.

Usage

cor.diff.test(r1, r2, n1, n2, alternative = c("two.sided", "less",
  "greater"))

Arguments

r1

Numeric (vector or matrix) of correlation coefficients, group 1

r2

Numeric (vector or matrix) of correlation coefficients, group 2

n1

Integer; number of observations, group 1

n2

Integer; number of observations, group 2

alternative

Character string specifying the alternative hypothesis test to use; one of: 'two.sided' (default), 'less', 'greater'

Value

A list containing:

p

The p-values

z

The z-score for the difference in correlation coefficients

See Also

Other Matrix functions: apply_thresholds, create_mats, symmetrize_mats

Examples

Run this code
# NOT RUN {
kNumSubjs <- summary(covars$Group)
corr.diffs <- cor.diff.test(corrs[[1]][[1]]$R, corrs[[2]][[1]]$R,
                            kNumSubjs[1], kNumSubjs[2], alternative='two.sided')
edge.diffs <- t(sapply(which(corr.diffs$p < .05), function(x)
                       mapply('[[',
                              dimnames(corr.diffs$p),
                              arrayInd(x, dim(corr.diffs$p)))
                              ))
# }

Run the code above in your browser using DataLab