How is the partial correlation computed?
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Given a matrix X, partialcorr(X) returns a 2D-array but according to the definition of the partial correlation coefficient a 3D-array should be returned. So, how is partialcorr(X) to be interpreted?
0 Kommentare
Antworten (2)
Adam Danz
am 11 Mai 2020
Bearbeitet: Adam Danz
am 11 Mai 2020
(Answering this question 4 years later)
A partial correlation should not return a 3D array. Here' the correct way to interpret the results of a partial correlation.
Load built-in data
load hospital
% Convert Sex and Smoker to dummy variables
hospital.SexID = grp2idx(hospital.Sex);
hospital.SmokerID = grp2idx(hospital.Smoker);
Compute a partial correlation between Sex, Weight, and Smoker status while controlling for Age
A = hospital.SexID;
B = hospital.Weight;
C = hospital.SmokerID;
D = hospital.Age;
[R1, p1] = partialcorr([A,B,C], D);
Combine correlation and significance values into a table and interpret results:
R values are the correlation and p values are significance.
T = array2table([R1,p1],'VariableNames',...
{'R_SexID','R_Weight','R_SmokerID','P_SexID','P_Weight','P_SmokerID'},...
'RowNames',{'SexID','Weight','SmokerID'})
T =
3×6 table
R_SexID R_Weight R_SmokerID P_SexID P_Weight P_SmokerID
_______ ________ __________ __________ __________ __________
SexID 1 0.94464 0.20841 0 9.6402e-49 0.03844
Weight 0.94464 1 0.21135 9.6402e-49 0 0.03573
SmokerID 0.20841 0.21135 1 0.03844 0.03573 0
The correlation between sex and weight while controlling for age is ~0.94 (p<0.001).
The correlation between weight and smoking status while controlling for age is ~0.211 (p<0.05)
Compute a partial correlation without using partialcorr()
As evidence that partialcorr() is accurate, you can compute a partial correlation between variables A and B while controlling for C using,
where r(_,_) is the correlation between two vectors.
Compute the correlation between sex and weight while controlling for age:
R2 = (corr(A,B) - (corr(A,C)*corr(B,C))) / sqrt((1-corr(A,C)^2) * (1-corr(B,C)^2));
R2 =
0.9424 % which matches our calculation using partialcorr()
0 Kommentare
Kiran
am 9 Feb. 2016
As per the following documentation link:
Output of partialcorr(X) should be 2D array. Could you please elaborate why you think it should be 3D array?
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!