cor.test(x, y, alternative = "two.sided", method = "pearson", exact = NULL)
x, y
|
numeric vectors of data values. x and y
must have the same length.
|
alternative
|
indicates the alternative hypothesis and must be
one of "two.sided" , "greater" or "less" .
You can specify just the initial letter.
|
method
|
a string indicating which correlation coefficient is
used for the test. Must be one of "pearson" ,
"kendall" , or "spearman" . Only the first
character is necessary.
|
exact
| a logical indicating whether an exact p-value should be computed. |
cor.test
tests the null that x
and y
are
uncorrelated.method
is "pearson"
, the test statistic is based on
Pearson's product moment correlation coefficient cor(x, y)
and follows a t distribution with length(x)-2
degrees of
freedom.
If method
is "kendall"
or "spearman"
, Kendall's
tau or Spearman's rho, respectively, are used to estimate the
correlation. These tests should be used if the data do not
necessarily come from a bivariate normal distribution.
For Kendall's test, by default (if exact
is not specified),
an exact p-value is computed if both samples contain less than 50
finite values and there are no ties. Otherwise, as well as for
Spearman's test, the standardized estimate is used as the test
statistic, and is approximately normally distributed.
"htest"
containing the following
components:
statistic
| the value of the test statistic. |
parameter
| the degrees of freedom of the test statistic in the case that it follows a t distribution. |
p.value
| the p-value of the test. |
estimate
|
the estimated correlation coefficient, with names
attribute "cor" , "tau" , or "rho" ,
correspoding to the method employed.
|
null.value
|
the value of the correlation coefficient under the
null hypothesis, hence 0 .
|
alternative
| a character string describing the alternative hypothesis. |
method
| a string indicating how the correlation was estimated |
data.name
| a character string giving the names of the data. |