How to check whether partial correlation is significant or not at 5% significance level?
5 次查看(过去 30 天)
显示 更早的评论
I tried this approach:
for i=1:6
datainput1=alldata(:,i);
for j=i+1:7
datainput2=alldata(:,j);
for k=i+2:8
datainput3=alldata(:,k);
[rho(i,j,k),pval(i,j,k)] = partialcorri(datainput1,datainput2,datainput3);
end
end
end
But this gave me a 3-D matrix of P values.
No how can I check for significant or not?
0 个评论
回答(1 个)
Prasanna
2024-10-6
Hi Rahul,
To check whether the partial correlations are significant at the 5% significance level, you can compare each p-value in your 3-D matrix to the significance level (0.05). If a p-value is less than 0.05, the corresponding partial correlation is considered significant.
For the same, in the code you have included, you can iterate through the 3D matrix of p-values and print each partial correlation to check if it is significant or not. A sample code to perform the same is given below assuming the ‘alldata’ variable refers to the table present in the ‘Dataset.xlsx’ file:
for i = 1:6
datainput1 = alldata(:, i);
for j = i+1:7
datainput2 = alldata(:, j);
for k = i+2:8
datainput3 = alldata(:, k);
[rho(i, j, k), pval(i, j, k)] = partialcorri(datainput1, datainput2, datainput3);
% Check if the p-value is less than 0.05
if pval(i, j, k) < 0.05
fprintf('Partial correlation between variables %d, %d, and %d is significant (p = %.4f)\n', i, j, k, pval(i, j, k));
else
fprintf('Partial correlation between variables %d, %d, and %d is not significant (p = %.4f)\n', i, j, k, pval(i, j, k));
end
end
end
end
For more information regarding ‘partialcorri’, you can refer the following documentation: https://www.mathworks.com/help/releases/r2023a/stats/partialcorri.html
Hope this helps!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!