correlate {CPC} | R Documentation |
Test for Bivariate Correlation
Description
Calculates correlation coefficient between two variables and returns a list containing the correlation estimate, its standard error, the p-value of a null-hypothesis significance test, and the number of observations used.
Usage
correlate(x, y, ...)
Arguments
x |
a numeric vector. |
y |
a numeric vector. |
... |
arguments passed to |
Details
Additional arguments to alter the type of null hypothesis significance test, the method used to
calculate the correlation coefficient, the confidence level, or other options should be passed to
correlate
() and will be inherited by cor.test()
. Note that unlike
cor.test()
, both arguments x
and y
are required.
Value
Returns a list with elements containing the correlation coefficient estimate, its associated standard error, the p-value of a null-hypothesis significance test, and the number of observations used, all as numeric vectors of length 1.
Examples
data <- matrix(c(rnorm(50, 0, 1), rnorm(50, 5, 1)), ncol = 2, byrow = TRUE)
correlate(data[, 1], data[, 2])