How to find a correlation coefficient of each variable from a multivariable dataset?
9 次查看(过去 30 天)
显示 更早的评论
I have a set of data with 3 variables, and I know the the associated correlation should look like
. Is there anyway that matlab uses the data set and gives the coeffcicients for the correlation (a,b & c)?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/321619/image.png)
0 个评论
回答(1 个)
Puru Kathuria
2020-7-20
Hi,
Correlation can be observed between all pair of features and it can tell you how strongly are those variables related.
Correlation among those variables can be positive(when both variables grow in the same direction), negative(when variables grow in the opposite direction) or no correlation at all. And there are multiple ways to observe correlation in the data.
First, you can plot your pair of variables and analyse the plots visually, this can be done using pair plotting [Link1, Link2, Link3]. Using this technique you will see C(M,2) number of plots, thus we prefer this plot when we have a limited number of variables to analyse. Like in your case, M being 3 is a small number to analyse visually.
Second, you can find a linear correlation coefficient, Pearson’s coefficient[Link4] is the most commonly used. This acts as a metric to calculate the correlation among variables. This correlation coefficient ranges from −1 to 1, where 1 implies perfect positive correlation, -1 implies a perfect negative correlation and 0 implies no correlation. [Link5]
%%%%%%% Example: %%%%%%%
data = readmatrix("sampleData.xlsx"); %read data from the file
% plotmatrix :
% Returns a plot where every pair of variables are plotted against each other. If the
% number of variables are N then the plot will have N^2 sub plots where diagonals of the
% plot shows the probability distribution of the variable
plotmatrix(data)
% corrplot :
% creates a matrix of plots showing correlations
% among pairs of variables in input data.
% Also, computes the correlation coefficients
corrplot(data)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!