Correlation analysis is to measure the correlation between two variables. Important things is this measure just focused on the degree of correlation. but do not explain the exact causality between two values. If you want to get exact causality between the independent variable and dependent variable in given the mathematical equation, you should use the regression test.
There are several types of correlation coefficient to explain correlation.
Today I will focus on the one of the famous tests which is "Pearson correlation coefficient".
This is a value of the linear correlation range from +1 to -1.
Positive 1 represents strong correlation between two variables. But negative 1 indicates that two variable is likely to be inversely proportional relation.
correlation is close to -1 correlation is close to +1
We can get this value using R command.
[ TEST1]
> cor(x,y)
[1] 0.968
> x
[1] 1 2 3 4 5
> y
[1] 1.0 1.7 3.0 4.0 4.0
>
> cor(x,y)
[1] 0.968
[TEST2]
> x
[1] 1 2 3 4 5
> yy
[1] 5 4 3 2 1
> cor(x,yy)
[1] -1
As you can the data of TEST1, x value and y value is proportional, however values of TEST2 is inversely proportional. As a result, correlation value can be expected under the rule I already mentioned.
If you want to get a significant test result of given correlations, you can do it this way.
Null hypothesis is that correlation is equal to 0, in other words two variables do not have any correlation. Both tests produce a p-value which is very low, so both tests reject null hypothesis and in favor of alternative hypothesis.
> cor.test(x,y, method='pearson')
Pearson's product-moment correlation
data: x and y
t = 6.6811, df = 3, p-value = 0.006839
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.5873523 0.9979680
sample estimates:
cor
0.968
> cor.test(x,yy, method='pearson')
Pearson's product-moment correlation
data: x and yy
t = -116235962, df = 3, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-1 -1
sample estimates:
cor
-1
댓글 없음:
댓글 쓰기