Correlation using R

 

Correlation between displ and hwy:

> # Pearson correlation (default)
> cor(displ, hwy)
[1] -0.76602
> # Spearman correlation (non-parametric)
> cor(displ, hwy, method = c('spearman'))
[1] -0.8266576
> # Test significance
> cor.test(displ, hwy)

 Pearson's product-moment correlation

data: displ and hwy
t = -18.1508, df = 232, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.8142727 -0.7072539
sample estimates:
 cor 
-0.76602

 

 

See Also:

Do the same test in SAS

Leave a Reply

Your email address will not be published. Required fields are marked *