Clear Filters
Clear Filters

Matlab function that can calculate pvalues from z-scores rho-values in a connectivity matrix

23 views (last 30 days)
I am performing connectivity analyses and my output for each subject is a very big matrix (44x44) with rho values that I transformed in z scores. I then averaged these together among all my subjects. I work with Matlab and I would like to calculate the pvalue from the rho z-scores I have in each of the 1936 cells. I know that there are calculators of pvalues from rho-values available online, but of course I can't do it manually for each of my cell, so I am looking for a Matlab function that can help me doing that in my whole big matrix. Does anyone know anything about this? I haven't been able to find anything except for the classical 'corrcoef' function, but this is not helpful, my correlations have been already performed! Any suggestion is really appreciated! Thanks, Chiara
  1 Comment
turquoise_squid
turquoise_squid on 6 Jul 2018
Dear Chiara, did you find an answer for you question? I can replicate the same finding that you had with the diagonals having the value 0.8413 instead of the expected p-value of 0 in the p-value matrix. Any help on this would be greatly appreciated.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 17 Jul 2017
Your z-scores imply that you are assuming your data are normally distributed.
Use the Statistics and Machine Learning Toolbox normcdf (link) function to calculate the probabilities.
You can also calculate it from the erfc function with:
P = @(z) erfc(-z/sqrt(2))/2; % Equivalent to ‘normcdf’
  8 Comments
Chiara Bulgarelli
Chiara Bulgarelli on 19 Jul 2017
Thanks again for your reply. I am afraid that I am doing something wrong somewhere, I just don't get where. In my Fisher z-scores transformed matrix, the diagonal is composed by 1 and not by 0 , as you suggested. Also, if I am using the normcdf function, the p value of the diagonal is 0.8413. This is not correct, right? I have read about an inverse Fisher transformation, but it is not clear the formula to apply it.
Star Strider
Star Strider on 19 Jul 2017
My pleasure.
The Fisher’s z-score is the correct statistic to use.
The matrix diagonal I was referring to are in the ‘P’ matrices returned by corr and corrcoef. Those should be zero, but are actually calculated correctly as 1. So if yours are also 1, the calculation is correct, although the interpretation implies that they should be 0.
You need to calculate the p-value individually for every element in your z matrix. The normcdf function will accept matrix arguments, and do this automatically.
I do not understand the p-value of 0.8413, or what the problem is with it. The normcdf function (without other arguments) assumes a mean of 0 and a standard deviation of 1, so your z-scores should work.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!