Correlation between several variables

19 ビュー (過去 30 日間)
Oleksandr Puchak
Oleksandr Puchak 2021 年 4 月 23 日
編集済み: the cyclist 2021 年 4 月 23 日
Could anyone help me with the code please, please?
I have a table of 11 variables. Each variable has 500 observations.
The first ten variables (x1 through to x10) are the so-called predicotrs , the last variable is y, which is the dependent variable.
How can I compute the correlation of y with each of the 10 predictors and also determine their signidicance?
Is there a command that allows me to present the result in some sort of table?
Or do I have to construct the for loop?
The task is to find the most 3 correlated variables with y and the least 3 correlated varaibles with y.
My code:
head(Data)
for i=1:10
vari=Data(:,i)
var11=Data(:,11)
corr(vari,var1)
end
Do you think this can be improved?
Why can I not do corr(Data(:,1:10),Data(:,11))?

採用された回答

the cyclist
the cyclist 2021 年 4 月 23 日
編集済み: the cyclist 2021 年 4 月 23 日
I think I would use the corrcoef function:
[r,p] = corrcoef(Data);
and just focus on the last column of the r and p outputs, which will be the correlation and p-value of the y with the 10 explanatory variables.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProbability Distributions and Hypothesis Tests についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by