How to check whether partial correlation is significant or not at 5% significance level?
6 次查看(过去 30 天)
显示 更早的评论
I have to check check whether partial correlation is significant or not at 5% significance level. I have calculated the partial correlation by using the predefined command in Matlab "partialcorri''. Which gave me R values and P values. I have attached my code below:
Kindly suggest me whethe it is right or not??
alldata=xlsread('Dataset',1,'A2:H68');
datainput1=alldata(:,1);
for j=2:8
datainput2=alldata(:,j);
[rho(j),pval(j)] = partialcorri(datainput1,datainput2);
lprctl(j)=prctile(pval(:,j),2.5);
uprctl(j)=prctile(pval(:,j),97.5);
if (pval(j)<lprctl(j) || pval(j)>uprctl(j))
fprintf('input %d is significant\n',j)
else
fprintf('input %d is not significant\n',j)
end
end
I want to check the significant partial correlation of Data 1 (which is the 1st column in the Dataset) with other Data at 5% significance level.
0 个评论
回答(2 个)
MarKf
2023-5-2
编辑:MarKf
2023-5-2
A partial correlation means you are controlling or "partialing out" some variance that is explained by -usually- another (3rd) variable or a series of factors. The function partialcorri does take only 2 inputs, but then there should be some addtional variables (as columns I'm guessing) in x, for which the function is controlling for. So, since with your code both x and y have one column and the same n of values (67), then you are doing a simple correlation ([rho(j),pval(j)]=corr(datainput1,datainput2); would give the same results; btw y is datainput1).
After that there is no need to take a percentile of pval, that's already significant if <0.05 (by convention). So the above (normal, non partial) correlations are all significant, tho some much more. You may want to control for multiple comparisons (7 above) so maybe (conservatively) accept only pval<(0.05/7). Maybe you meant to include more variables to your partial correlation, something like this:
alldata = xlsread(websave('rd', "https://nl.mathworks.com/matlabcentral/answers/uploaded_files/1372129/Dataset.xlsx"),1,'A2:H68');
datainput1=alldata(:,1);
datainput2=alldata(:,2:5);
[rho,pval] = partialcorri(datainput1,datainput2);
log10(pval)
Which means the correlation between column 2 (x) and column 1 (y) after controlling for the effects of columns 3 to 5 has pval<10e-12.
% for j=2:8
% datainput2=alldata(:,j);
% [rho(j),pval(j)] = partialcorri(datainput1,datainput2);
% end
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!