P value of corrcoef() is aways different !
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Damiano Capocci
le 13 Mar 2018
Commenté : the cyclist
le 15 Mar 2018
Hi, in my tests i've introduced Matlab corrcoef(). But if i repeat this test i'm used to obtain different results for p value. The same thing if i cosider rand() function. So :
t=1:200000;
a=rand(1,200000);
[l,p]=corrcoef(a,t)
first time
l =
1.0000 0.0016
0.0016 1.0000
p =
1.0000 0.4742
0.4742 1.0000
second time
l =
1.0000 0.0025
0.0025 1.0000
p =
1.0000 0.2729
0.2729 1.0000
third time
l =
1.0000 -0.0000
-0.0000 1.0000
p =
1.0000 0.9941
0.9941 1.0000
what is the meaning of these results?
2 commentaires
Jeff Miller
le 13 Mar 2018
You seem to be generating new random values of 'a' for each run, so the correlations of those values to 't' (which are returned in 'l') naturally vary randomly as well. Since the correlations vary, so do their associated p values. What aspect of this is surprising to you?
Réponse acceptée
the cyclist
le 14 Mar 2018
Modifié(e) : the cyclist
le 14 Mar 2018
I'll one up you. I ran your code 10,000 times and calculated the P value for each run.
Here's the code:
NT = 10000;
pvec = nan(1,NT);
t=1:200000; for n = 1:NT
a=rand(1,200000); [~,p]=corrcoef(a,t);
pvec(n) = p(1,2);
end
figure histogram(pvec) title(['Distribution of P values after ',sprintf('%d',NT),' trials']) xlabel('P') ylabel('Frequency of occurrence')
Here's resulting the distribution ...
Uniformly distributed P values (with a bit of sampling error). Exactly what I would expect. What were you expecting, and why?
2 commentaires
the cyclist
le 15 Mar 2018
A uniform distribution of the P value is exactly what I would expect from a good generator. The two distributions you are comparing are not correlated. Therefore, you would expect a P value of 0.05 or less to occur 5% of the time. You would expect a P value of 0.1 or less to occur 10% of the time.
This is exactly the result (within sampling error).
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!