T-test on correlation coefficients from 2 samples

Hi all,
I have two 360x360 matrices from two different samples. I am trying to run a ttest on each entry in one matrix with the corresponding entry in the other matrix, so (1,2) with (1,2) and (4,3) with (4,3) for example. This is the code that I currently have:
for i=1:360
for j=1:360
[h_cm(i,j),p_cm(i,j)] = ttest2(cm(i,j),control(i,j));
end
end
As you can see, I am using a for loop. However, the output tables for h_cm and p_cm are populated with NaNs. Can anyone see where I'm going wrong?

3 comentarios

dpb
dpb el 2 de Jul. de 2019
Yeah, you're trying to run a t-test on a single element for a population sample so you've zero DOF left.
Perhaps you're intending to compare the columns of each array as the samples from the two populations? Other than that, have no klew what you're trying to do on an element-by-element basis.
BTW, ttest2 is vectorized to handle arrays for x,y as columnar data; no loops needed if that is, indeed the intent.
Yes I do want to do an element by element comparison within a matrix. Is there another MATLAB function that might be better suited for this?
The data from each matrix has already been averaged from 5 data sets if that helps.
dpb
dpb el 2 de Jul. de 2019
Editada: dpb el 2 de Jul. de 2019
Well, you can't compute the test statistic without the underlying data -- you'll have to back up a step to the point before you did the averaging--or you could compute the t statistic from the sample means and standard deviations, but there's not a builtin ML function that does the computation that way; only from the population samples. So, you'll have to write it yourself altho it isn't at all a difficult calculation, just not pre-packaged solution.

Iniciar sesión para comentar.

Respuestas (0)

Productos

Versión

R2018b

Preguntada:

el 1 de Jul. de 2019

Editada:

dpb
el 2 de Jul. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by