How to preform Anova + Tukey for within-subject design
조회 수: 9 (최근 30일)
이전 댓글 표시
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')
[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')
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
댓글 수: 0
답변 (1개)
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')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Analysis of Variance and Covariance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!