Correlation between three variables in MATLAB

社会主义新天地 提交于 2019-12-24 16:34:04

问题


In MATLAB, I have the following:

A, B, C are 1 x 101 row vectors. I know that for 'i' from 1 to 101, A(i), B(i), and C(i) are linearly correlated.

How can I identify the dependence between A, B, and C?


回答1:


For the degree of correlation, you can use corrcoef:

data = [A(:) B(:) C(:)];
correlation = corrcoef(data);

Here's a test case that shows positive/negative correlation as well as the degree of correlation, with

N = 10000;
A = randn(N,1);
B =  3*A + randn(N,1);
C = -2*A + 20*randn(N,1);

correlation =

    1.0000    0.9473   -0.1005
    0.9473    1.0000   -0.0927
   -0.1005   -0.0927    1.0000


来源:https://stackoverflow.com/questions/29550242/correlation-between-three-variables-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!