Kruskal Wallace Test on Column

3 visualizaciones (últimos 30 días)
Sarah Yun
Sarah Yun el 15 de Dic. de 2019
Editada: Adam Danz el 17 de Dic. de 2019
Hi,
I have three seperate tables.
There is one column in each table I want to compare - temperature
The data are not normally distributed.
So, I can use a Kruskal Wallace test to compare the means of the three columns
My problem: the test seems to work on 1 array only (x) - but I have three
How should I write the code to conduct the test?
I tried concatenating the tables but they each have a different number of rows - so it is not working.
Advice welcome.

Respuestas (1)

Adam Danz
Adam Danz el 15 de Dic. de 2019
Editada: Adam Danz el 15 de Dic. de 2019
The p = kruskalwallis(x) test works on columns of x. If all of your tables have the same number of rows, you just have to extract the values from each table into a matrix. If the tables only have 1 variable, as you described, it's as easy as,
T1 = table(rand(20,1));
T2 = table(rand(20,1)+1);
T3 = table(rand(20,1)+.5);
p = kruskalwallis([T1{:,:},T2{:,:},T3{:,:}])
% or
p = kruskalwallis([T1.Var1,T2.Var1,T3.Var1])
If the tables do not have equal rows, you must concatenate them into a single column and use a grouping variable p = kruskalwallis(x,group)
x = [T1.Va1;T2.Var1;T3.Var1];
group = [1 + zeros(size(T1.Var1)); 2 + zeros(size(T2.Var1)); 3 + zeros(size(T3.Var1))];
p = kruskalwallis(x,group)
  2 comentarios
Sarah Yun
Sarah Yun el 15 de Dic. de 2019
Hi Adam,
Unfortunately, my 3 tables do not have equal rows. So, I must use a grouping variable. Please can you help me with this? Thank you. Sarah.
Adam Danz
Adam Danz el 15 de Dic. de 2019
Editada: Adam Danz el 17 de Dic. de 2019
Yep! I just added an example at the bottom of my answer. If you get stuck, show me the code you're using and describe the problem and I'd be happy to help straighten things out.

Iniciar sesión para comentar.

Categorías

Más información sobre Hypothesis Tests en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by