cor.origin {PHYLOGR} | R Documentation |
Return the correlation through the origin of two vectors. Generally used for indepdendent contrasts
cor.origin(x, y)
x |
A vector |
y |
A vector (of same size as x) |
The correlation of x and y, from a model without intercept (i.e., forcing the line through the origin).
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) * 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.
R. Diaz-Uriarte and T. Garland, Jr.
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.
x <- rnorm(100) y <- rnorm(100) rho <- cor.origin(x,y) rho # the correlation 2 * (1 - pt(sqrt(99) * rho / sqrt(1 - rho^2), 99)) # the p-value