ttest2 with a group describing independent values (statistics)

1 回表示 (過去 30 日間)
Pedro Gomis
Pedro Gomis 2021 年 1 月 5 日
編集済み: Jeff Miller 2021 年 1 月 9 日
Hi,
I use Matlab ttest2 function to assess if observations from vectors x and y come from populations with different means. The function works fine if vectors are passed as arguments:
[h, p] = ttest2(x, y)
My data includes biomarker (as blood pressure) in x and y during day and night, respectively. Therefore, we assess paired groups into a matrix [x y], where:
x = [120, 110.5, 123, 140, 142, 151, 121, 119, 110, 115, 130]' % there are more observations
y = [118, 110, 120, 135, 134, 140, 120, 116, 110, 113 ,127]' % there are more observations
m = [x y];
The point is that we also want to compare unpaired or independent groups (males vs. females), at day and night. For this, a third column is included defining the group (male=0, female=1) in matrix [x y g], where
g = [0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1]' % there are more observations
m = [x y g];
Function anova1() has the functionality of including a group as second argument for each observation in x or y.
I wonder if it is possible to use ttest2 function in anova1() fashion, something like
[h, p] = ttest2(x, g) % where x contains the observation and g contains categorical values
To compare the biomarker, e.g. during night, between male and female, without rearrenge vectors
Thanks

採用された回答

Jeff Miller
Jeff Miller 2021 年 1 月 5 日
編集済み: Jeff Miller 2021 年 1 月 9 日
No, it is not possible to use ttest2 as you suggest.
Your design has 2 factors: gender and time (day/night) with repeated measures on the time factor, and you can conveniently analyze it with 'fitlm' and 'ranova', something like this (note the categorical conversions added on edit):
x = [120, 110.5, 123, 140, 142, 151, 121, 119, 110, 115, 130]'; % there are more observations
y = [118, 110, 120, 135, 134, 140, 120, 116, 110, 113 ,127]'; % there are more observations
g = [0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1]'; % there are more observations
m = [x y g];
t = array2table(m,'VariableNames',{'x','y','gender'});
t.gender = categorical(t.gender);
timeDesign = table([1 2]','VariableNames',{'time'});
timeDesign.time = categorical(timeDesign.time);
rm = fitrm(t,'x-y~gender','WithinDesign',timeDesign);
ranova(rm,'WithinModel','time')
  1 件のコメント
Pedro Gomis
Pedro Gomis 2021 年 1 月 5 日
Thanks for your answer!
I will try fitrm and repeated measures anova.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRepeated Measures and MANOVA についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by