corTest: Calculate correlations between two vectors

Description Usage Arguments Value Author(s)

View source: R/MatCor.R

Description

This function takes 2 numeric vectors and calculate the correlation between them. The cor.test function from the stats-package is used to calculate pearson, spearman, or kendal correlation. A more complex model is supported by setting the method argument to "lm", and assign a model matrix to the design argument.

Usage

1
corTest(x, y, method, ...)

Arguments

x

numeric vectors of data values.

y

numeric vectors of data values. Must have the same length as x.

method

character value indicating which correlation method to be used One of "peason", "kendall", "spearman", or "lm". If "lm" is used, a design argument must be specified.

...

other arguments. If either of "person", "kendal", or "spearman" is specified, any other arguments in the cor.test function can be used. If "lm" is specified, a design matrix must be passed. The design matrix can be built using the model.matrix function.

Value

A named vector with length of 3 is returned

stat

the value of the test statistic.

estimate

the estimated measure of association. Corresponds to the "r" for pearson, "rho" for spearman, "tau" for kendal, and coefficient for lm

pval

the p-value of the test.

Author(s)

Chenghao Zhu


zhuchcn/MatCorR documentation built on Nov. 5, 2019, 1:27 p.m.