フィルターのクリア

How to preform Anova + Tukey for within-subject design

3 ビュー (過去 30 日間)
Itay Coifman
Itay Coifman 2022 年 2 月 8 日
編集済み: Scott MacKenzie 2022 年 2 月 9 日
Hey all, I am trying to write a code to analyze my experiment results:
My experiment is a within-subject design,each subject (1-5) has done the test at 8 different levels (NL_0,NL_1,TH_450...SH_1350).
The "df.csv" attached describe my results, after transforming the data for within-subject analysis I got "testDf.csv" (might not be needed at all...).
First I want to perform an ANOVA test, and afterward, I want to perform a Tukey test to compare all the levels combinations.
If it was a between-subject design i would use:
df = readtable('df.csv')
df = 40×3 table
subject trialName y _______ ___________ ______ 1 {'NL_0' } 13.3 1 {'NL_1' } 14.543 1 {'SH_1350'} 15.326 1 {'SH_450' } 13.926 1 {'SH_900' } 14.999 1 {'TH_1350'} 14.677 1 {'TH_450' } 14.565 1 {'TH_900' } 14.628 2 {'NL_0' } 13.503 2 {'NL_1' } 13.655 2 {'SH_1350'} 15.159 2 {'SH_450' } 14.014 2 {'SH_900' } 13.967 2 {'TH_1350'} 14.142 2 {'TH_450' } 13.376 2 {'TH_900' } 13.813
[p,tbl,stats] = anova1(df.y,df.trialName)
confidanceLevel = 0.05;
[c,m,h,gnames] = multcompare(stats,'Alpha',confidanceLevel);
After reading some questions at the forum, I figured that I need to use something more like this one:
testDf = readtable('testDf.csv')
testDf = 5×9 table
Subject NL_0 NL_1 SH_1350 SH_450 SH_900 TH_1350 TH_450 TH_900 _______ ______ ______ _______ ______ ______ _______ ______ ______ 1 13.3 14.543 15.326 13.926 14.999 14.677 14.565 14.628 2 13.503 13.655 15.159 14.014 13.967 14.142 13.376 13.813 3 16.356 16.029 16.695 16.005 16.727 16.772 16.504 16.805 4 13.98 13.563 15.107 14.232 14.627 14.188 14.381 14.09 5 14.41 14.344 16.66 15.733 16.126 15.602 15.495 15.146
measurements = table([1 2 3 4 5 6 7 8]','VariableNames',{'Measurements'});
rm = fitrm(testDf,"NL_0,NL_1,SH_1350,SH_450,SH_900,TH_1350,TH_450,TH_900~Subject"...
,'WithinDesign',measurements);
ranovatbl = ranova(rm)
tbl = multcompare(rm,'NL_0')
The multicompare doesn't work, and I think I have done something wrong in the process of getting there...
I would really appreciate your help.
Thanks,
Itay

回答 (1 件)

Scott MacKenzie
Scott MacKenzie 2022 年 2 月 9 日
編集済み: Scott MacKenzie 2022 年 2 月 9 日
I believe the issue is you've incorrectly specified the variable as the second argument in multcompare. Try
tbl = multcompare(rm, 'Measurements')

カテゴリ

Help Center および File ExchangeAnalysis of Variance and Covariance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by