How to check whether partial correlation is significant or not at 5% significance level?
10 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Prasanna
on 6 Oct 2024 at 13:59
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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!