I am trying to find the correlation coefficient in R between my dependent and independent variable.
data("mtcars")
my_data <- mtcars[, c(1,3,4,5,6,7)]
res <- cor(my_data)
round(res, 2)
As a result, I got a correlation matrix, some with +ve or -ve.
For ex: if correlation coefficient between mpg and disp is -0.85, how can I know which variable is decreasing and the one increasing?
Consider the following script, which just compares mpg
and disp
:
res1 <- cor(mtcars$mpg, mtcars$disp)
res2 <- cor(mtcars$disp, mtcars$mpg)
round(res1, 2)
round(res2, 2)
The output from both calls is -0.85
. In other words, the nature of the correlation coefficient is not about the order of one variable against the other. Rather, a negative correlation coefficient means that as mpg
increases, disp
tends to decrease. And we could also phrase this by saying that as disp
increases, mpg
tends to decrease.