|
> I want to calculate P value from r without using function [r,
> P]=corrcoef() (because computation complexity issues):
...
> r = v1 * ( v2' ) / sqrt( ( v1 * v1' ) * ( v2 * v2' ) );
Diego, your formula is for a correlation coefficient not corrected for the
mean of each sample (assuming each mean is known to be zero). That's not the
usual thing done in statistics, but perhaps it is appropriate for your case.
Even if you don't want to use corrcoef, you may want to look inside that
file. There's code to transform the correlation to a t statistic, and
there's code to compute the p-value for that statistic. You'll want to use
N-1 rather than N-2 as your degrees of freedom value if you don't correct
for the mean. Alternatively, if the sample size is large, you could just use
a normal approximation to the p-value, in place of one based on Student's t
distribution.
Check out a book on regression analysis for more details.
-- Tom
|