cor.origin: Correlation Through the Origin

Description Usage Arguments Value Note Author(s) References Examples

View source: R/PHYLOGR.R

Description

Return the correlation through the origin of two vectors. Generally used for indepdendent contrasts

Usage

1
cor.origin(x, y)

Arguments

x

A vector

y

A vector (of same size as x)

Value

The correlation of x and y, from a model without intercept (i.e., forcing the line through the origin).

Note

This is a very simple function, provided for convenience. You can obtain the p-value, if you wish, with the usual formula for the t-statistic: 2*(1 - pt(sqrt(df) * abs(rho) / sqrt(1 - rho^2), df)) where rho is the correlation through the origin and df are the appropriate degrees of freedom —generally N-1—; by using the absolute value of the coefficient and finding 2 * the probability of upper tail (1 - pt) this works for both positive and negative correlation coefficients.

Author(s)

R. Diaz-Uriarte and T. Garland, Jr.

References

Diaz-Uriarte, R., and Garland, T., Jr., in prep. PHYLOGR: an R package for the analysis of comparative data via Monte Carlo simulations and generalized least squares approaches.

Examples

1
2
3
4
5
6
 x <- rnorm(100)
 y <- rnorm(100)
 rho <- cor.origin(x,y)
 rho # the correlation
 2 * (1 - pt(sqrt(99) * abs(rho) / sqrt(1 - rho^2), 99))  # the p-value
 

rdiaz02/PHYLOGR documentation built on April 22, 2020, 11:41 p.m.