Test for Zero Correlation

DESCRIPTION:
Tests whether two vectors are uncorrelated using Pearson's product moment correlation coefficient, Kendall's tau-statistic, or Spearman's rank correlation.

USAGE:
cor.test(x, y, alternative="two.sided", method="pearson")

REQUIRED ARGUMENTS:
x,y:
numerical vectors. x and y must have the same length greater than 2. Missing values (NAs) and +-Infs are allowed but ignored at calculation.

OPTIONAL ARGUMENTS:
alternative:
a character string describing the alternative hypothesis for the test of correlation between x and y. "two.sided" (non-zero), "greater" (greater than 0), or "less" (less than 0).
method:
the string "pearson", "kendall", or "spearman", depending on what coefficient of correlation should be used in the test statistic. Only the first character is necessary.

VALUE:
a list of class "htest", containing the following components:
statistic:
the value of the test statistic, a t-statistic or a normalized z-statistic with names attribute.
parameters:
the parameters of the null distribution of statistic containing its degrees of freedom when this is a t-distribution.
p.value:
the p-value under the null hypothesis that the correlation between x and y is zero.
estimate:
the value of the correlation coefficient with a names attribute which is either "tau" for Kendall's statistic, "cor" for Pearson's, or "rho" for Spearman's.
null.value:
the hypothesized value for the correlation between x and y, coef=0.
alternative:
the alternative hypothesis as entered, "two.sided", "greater", or "less".
method:
a string containing the name of the estimator used for the correlation coefficient: "Pearson's product-moment correlation", "Kendall's rank correlation tau", or "Spearman's rank correlation".
data.name:
a character string containing the actual names of the x and y vectors.

NULL:
x and y are mutually uncorrelated.

TEST:
When method="pearson" the data are assumed to come from a bivariate Normal distribution. If this is not the case, the other two methods offer nonparametric alternatives.

DETAILS:
If method="pearson" the (usual) Pearson's product moment correlation coefficient (r <- cor(x,y)) is computed, and divided by its standard error to produce a t-statistic with n-2 degrees of freedom, where n = length(x) = length(y). This statistic is given by t <- (sqrt(n-2)*r) / sqrt(1-r2).

If method="kendall" then Kendall's tau using ranks is computed.

If method="spearman" the rank correlation coefficient is used. See the printed help file in the S-PLUS Reference Manual for the estimators formulae.


REFERENCES:
Conover, W. J. (1980). Practical Nonparametric Statistics. 2nd. ed. New York: Wiley.

SEE ALSO:
cor .

EXAMPLES:
murder <- state.x77[,"Murder"]
illit <- state.x77[,"Illiteracy"]
cor.test(murder,illit,method="k")
# Transformations can be used
cor.test(log(x),log(y),alt="gr")