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

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 Kommentar

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.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

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 Kommentare

Many thanks for your reply, and thanks for the suggestion of these two functions. However, if I am not wrong, these allow me to check the normality of my data, but not get a p value from the rho value, right?
My pleasure.
They allow you to get a p-value from a z-score.
Another option is the Statistics and Machine Learning Toolbox corr (link) function. It is not the same as corrcoef, and may do what you want.
Also, if I remember correctly, the diagonal in the ‘P’ matrix for both should be 0, not 1. I have not used either function in a while.
Thanks again. I had a look at the functions, I think that normcdf is actually what I need, because I already had calculated the correlations. Now I have another doubt, how can I deal with positive and negative z-scores? Can I treat them equally? Or do I have to use 1-normcdf for the negative ones? Thank you again, Chiara
My pleasure.
The positive and negative z-scores will take care of themselves. The normal distribution is defined over (-Inf,+Inf), so you can either subtract them from 1, or more easily, just use the absolute values (or the negative of the absolute values) of the z-scores, depending on what you want.
Example
pv = normcdf([-1.96 1.96])
pc = 1-pv
pv =
0.024998 0.975
pc =
0.975 0.024998
A further doubt: I am actually working on Fisher's transformed z-scores, not the classical z-scores. Does this make any difference?
According to Fisher's z' (link) and an extended discussion Speaking Stata: Correlation with confidence, or Fisher's z revisited (link), that is appropriate, and the transformed z-scores are normally distributed. You can use the normcdf function.
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.
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by