
How is the partial correlation computed?
조회 수: 5 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Adam Danz
2020년 5월 11일
편집: Adam Danz
2020년 5월 11일
(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
Kiran
2016년 2월 9일
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?
참고 항목
카테고리
Help Center 및 File Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!