Sunday, June 14, 2020

cor

Correlation coefficient. A measure of the linear relationship between two variables. This is a unitless value.

In the R docs, var is listed on the same page as var (variance) and cov (covariance).

When you want to try and predict the effect an x value has on a y value, your calculate correlation (usually represented with 'r').

When r is greater than zero, it indicates a positive correlation, and when less than zero, it indicates a negative correlation. An r of zero means no correlation.

Correlation is a linear measure. Therefore you can only use it when a plot of the x/y relationship is more linear than otherwise.

R Example

> duration = faithful$eruptions   # eruption durations 
> waiting = faithful$waiting      # the waiting period 
> cor(duration, waiting)          # apply the cor function 

[1] 0.90081 

The value of r is nearly 1 (one), a positive correlation.

No comments:

Post a Comment

Please help to combat malicious use of the Internet.