cocor.indep.groups {cocor}R Documentation

Compare two correlations based on independent groups

Description

Performs a test of significance for the difference between two correlation coefficients based on independent groups. The function expects correlation coefficients as input.

Usage

cocor.indep.groups(
  r1.jk,
  r2.hm,
  n1,
  n2,
  alternative = "two.sided",
  test = "all",
  alpha = 0.05,
  conf.level = 0.95,
  null.value = 0,
  data.name = NULL,
  var.labels = NULL,
  return.htest = FALSE
)

Arguments

r1.jk

A number specifying the correlation between j and k measured in group 1

r2.hm

A number specifying the correlation between h and m measured in group 2

n1

An integer defining the size of group 1

n2

An integer defining the size of group 2

alternative

A character string specifying whether the alternative hypothesis is two-sided ("two.sided"; default) or one-sided ("greater" or "less", depending on the direction). Optionally, the initial letter of the character strings ("t", "g", and "l)" can be used.

test

A vector of character strings specifying the tests to be used (fisher1925 or zou2007). Use all to apply all tests (default). For further information see the tests section below.

alpha

A number defining the alpha level for the hypothesis test. The default value is .05.

conf.level

A number defining the level of confidence for the confidence interval (if test zou2007 is used). The default value is .95.

null.value

A number defining the hypothesized difference between the two correlations used for testing the null hypothesis. The default value is 0. If the value is other than 0, only the test zou2007 that uses a confidence interval is available.

data.name

A vector of character strings describing the data/groups. The vector may contain one character string to describe both data sets/groups or two character strings to describe each data set/group separately.

var.labels

A vector of four character strings specifying the labels for j, k, h, and m (in this order).

return.htest

A logical indicating whether the result should be returned as a list containing a list of class 'htest' for each test. The default value is FALSE.

Value

Returns an S4 object of class 'cocor.indep.groups' with the following slots:

r1.jk

Input parameter

r2.hm

Input parameter

n1

Input parameter

n2

Input parameter

alternative

Input parameter

alpha

Input parameter

conf.level

Input parameter

null.value

Input parameter

data.name

Input parameter

var.labels

Input parameter

diff

Difference between the two correlations, r1.jk and r2.hm, that were compared

For each test a slot of the same name exists with a list containing the following elements:

statistic

The value of the test statistic (if test fisher1925 is used).

distribution

The distribution of the test statistic (if test fisher1925 is used).

p.value

The p-value of the test (if test fisher1925 is used).

conf.int

The confidence interval of the difference between the two correlations (if test zou2007 is used).

Tests

The tests make use of Fisher's r-to-Z transformation (1921, p. 26):

Z = \frac{1}{2}(ln(1+r) - ln(1-r)).

fisher1925:

Fisher's (1925) z

This significance test was first described in Fisher (1925, pp. 161-168) and its test statistic z is calculated as

z = \frac{Z_1 - Z_2}{\sqrt{\frac{1}{n_1 - 3} + \frac{1}{n_2 - 3}}}.

Z_1 and Z_2 are the two Z transformed correlations that are being compared. n_1 and n_2 specify the size of the two groups the correlations are based on. The equation is also given for example in Peters and van Voorhis (1940, p. 188) and Cohen, Cohen, West, and Aiken (2003, p. 49, formula 2.8.11).

zou2007:

Zou's (2007) confidence interval

This test calculates the confidence interval of the difference between the two correlation coefficients r_1 and r_2. If the confidence interval includes zero, the null hypothesis that the two correlations are equal must be retained. If the confidence interval does not include zero, the null hypothesis has to be rejected. A lower and upper bound for the interval (L and U, respectively) is given by

L = r_1 - r_2 - \sqrt{(r_1 - l_1)^2 + (u_2 - r_2)^2}

and

U = r_1 - r_2 + \sqrt{(u_1 - r_1)^2 + (r_2 - l_2)^2}

(Zou, 2007, p. 409). A lower and upper bound for the confidence interval of r_1 (l_1 and u_1) and r_2 (l_2 and u_2) are calculated as

l = \frac{exp(2l') - 1}{exp(2l') + 1},

u = \frac{exp(2u') - 1}{exp(2u') + 1}

(Zou, 2007, p. 406), where

l',u' = Z \pm z_{\frac{\alpha}{2}} \sqrt{\frac{1}{n - 3}}

(Zou, 2007, p. 406). \alpha denotes the desired alpha level of the confidence interval, whereas n specifies the size of the group the correlation is based on.

References

Cohen, J., Cohen, P., West, S. G., & Aiken, L. S. (2003). Applied Multiple Regression/Correlation Analysis for the Behavioral Sciences (3rd ed.). Mahwah, NJ: Erlbaum.

Fisher, R. A. (1921). On the probable error of a coefficient of correlation deduced from a small sample. Metron, 1, 1-32.

Fisher, R. A. (1925). Statistical methods for research workers. Edinburgh, Scotland: Oliver and Boyd. Retrieved from http://psychclassics.yorku.ca/

Peters, C. C., & Van Voorhis, W. R. (1940). Statistical procedures and their mathematical bases. New York: McGraw-Hill.

Zou, G. Y. (2007). Toward using confidence intervals to compare correlations. Psychological Methods, 12, 399-413. doi:10.1037/1082-989X.12.4.399

See Also

cocor, cocor.dep.groups.overlap, cocor.dep.groups.nonoverlap, as.htest

Examples

# Compare the difference between two correlations based
# on two independent groups:
r1.jk <- .7  # Correlation between age and intelligence measured in group 1
n1 <- 305    # Size of group 1

r2.hm <- .6  # Correlation between age and intelligence measured in group 2
n2 <- 210    # Size of group 2

cocor.indep.groups(r1.jk, r2.hm, n1, n2, data.name=c("group1", "group2"),
      var.labels=c("age", "intelligence", "age", "intelligence"))


[Package cocor version 1.1-4 Index]