T-Test2 on a singleton dimension

12 visualizaciones (últimos 30 días)
Manny Hernandez
Manny Hernandez el 3 de Jun. de 2021
Comentada: the cyclist el 4 de Jun. de 2021
I am conducting a two-sample t-test on some self-organizing maps data. I am trying to obtain p-values at every grid cell between each node:
somVariable = sMap.codebook % 30 x7326 [double] ; node x [latxlon]
[sNum,sGrid] = size(somVariable);
pTest = NaN(sGrid,sNum);
for i = 1:sNum
[~,p] = ttest2(somVariable(1,:),somVariable(i,:),'VarType','equal');
pTest(:,i) = p';
clear p
end
but encounter an issue in which matlab jumps to the non-singleton dimension (7326) and I obtain one p-value. Is there a way to force matlab to recognize a singleton dimension as the starting dimension to test at each grid cell?
Thanks!
  2 comentarios
Scott MacKenzie
Scott MacKenzie el 3 de Jun. de 2021
I see some issues in your code and question. For example, ttest2 only returns one p-value. So, p and p' are the same.
the cyclist
the cyclist el 4 de Jun. de 2021
@Manny Hernandez, I'm confused by which elements of your data you are trying to apply the t-test to. Let's take a small example. Suppose somVariable were:
somVariable = [ 2 3 5 7;
11 13 17 19;
23 29 31 37];
Exactly which t-tests are you trying to do? The way your code is written, you calculate three p-values:
  • Row 1 vs. Row 1 (p = 1)
  • Row 1 vs. Row 2 (p = 0.0024)
  • Row 1 vs. Row 3 (p = 0.0002)
and then those three p-values are replicated four times (because you have defined pTest to have as many rows as somVariable has columns).
somVariable = [ 2 3 5 7;
11 13 17 19;
23 29 31 37];
[sNum,sGrid] = size(somVariable);
pTest = NaN(sGrid,sNum);
for i = 1:sNum
[~,p] = ttest2(somVariable(1,:)',somVariable(i,:)','VarType','equal');
pTest(:,i) = p';
clear p
end
disp(pTest)
1.0000 0.0024 0.0002 1.0000 0.0024 0.0002 1.0000 0.0024 0.0002 1.0000 0.0024 0.0002

Iniciar sesión para comentar.

Respuestas (0)

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by