MATLAB Answers

Repeated Measure ANOVA in MATLAB for voice parameter significance

조회 수: 42(최근 30일)
Savi Gaur
Savi Gaur 2021년 9월 25일 8:29
답변: Scott MacKenzie 2021년 9월 26일 21:44
I have n=32 sample size, measured for 2 main parameter uttered speech and visual reaction time (RT) at 4 different times T1 baseline, T2 10 PM, T3 3AM and T4 next morning 7AM.. From the voice data 4 voice parameters Frequency, Jitter, Shimmer and HNR have been extracted using Praat software. I want find out significant difference between voice parameters and reactiong time for these 4 time intervals using R ANOVA in MATLAB. PLease give suggestions and solutions.
  댓글 수: 5
Savi Gaur
Savi Gaur 2021년 9월 26일 18:20
Yes,
Ok
How to apply R_ANOVA and Posthoc

댓글을 달려면 로그인하십시오.

답변(1개)

Scott MacKenzie
Scott MacKenzie 2021년 9월 26일 21:44
Here's what I put together. I really don't like the table created by ranova, so I'm including a function I use to convert the ranova output table to a more conventional format. The analysis below is only for the RT dependent variable. You can repeat this for the other dependent variables. Note in the ANOVA table that the F-statistic is the same as in your Statistica figure.
The post hoc pairwise tests using multcompare reveal that the means for all pairs differ significantly.
file = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/749649/Q2.xlsx';
T = readtable(file);
rtData = reshape(T.RT, [], 4);
rtTable = array2table(rtData);
% repeated measures ANOVA: effect of 'Time of measurement' on RT
rtTable.Properties.VariableNames = {'T1', 'T2', 'T3', 'T4'};
withinDesign = table([1 2 3 4]','VariableNames',{'Time_of_measurement'});
withinDesign.Time_of_measurement = categorical(withinDesign.Time_of_measurement);
rm = fitrm(rtTable,'T1-T4 ~ 1','WithinDesign',withinDesign);
ranovatbl = ranova(rm,'WithinModel','Time_of_measurement');
% create and output conventional ANOVA table
disp(anovaTable(ranovatbl, 'RT'));
ANOVA table for RT ========================================================================================= Effect df SS MS F p ----------------------------------------------------------------------------------------- Participant 31 123508.92814 3984.15897 Time_of_measurement 3 223869.84408 74623.28136 98.078 0.0000 Participant(Time_of_measurement) 93 70759.90447 760.85919 =========================================================================================
% post hoc pairwise comparisions test
multcompare(rm, 'Time_of_measurement')
ans = 12×7 table
Time_of_measurement_1 Time_of_measurement_2 Difference StdErr pValue Lower Upper _____________________ _____________________ __________ ______ __________ _______ _______ 1 2 -25.841 3.4856 1.4331e-07 -35.301 -16.381 1 3 -75.706 6.6621 3.7783e-09 -93.787 -57.624 1 4 -107.19 9.6884 3.7861e-09 -133.48 -80.894 2 1 25.841 3.4856 1.4331e-07 16.381 35.301 2 3 -49.865 5.8456 1.1039e-08 -65.73 -34 2 4 -81.348 8.6812 4.6427e-09 -104.91 -57.787 3 1 75.706 6.6621 3.7783e-09 57.624 93.787 3 2 49.865 5.8456 1.1039e-08 34 65.73 3 4 -31.483 5.0389 3.5197e-06 -45.159 -17.807 4 1 107.19 9.6884 3.7861e-09 80.894 133.48 4 2 81.348 8.6812 4.6427e-09 57.787 104.91 4 3 31.483 5.0389 3.5197e-06 17.807 45.159
% -------------------------------------------------------------------------
% generate conventional ANOVA table
% -------------------------------------------------------------------------
% Scott's function to create a conventional ANOVA table from the
% overly-complicated and confusing table created by ranova
function [s] = anovaTable(AT, dvName)
c = table2cell(AT);
% remove erroneous entries in F and p columns
for i=1:size(c,1)
if c{i,4} == 1
c(i,4) = {''};
end
if c{i,5} == .5
c(i,5) = {''};
end
end
% use conventional labels in Effect column
effect = AT.Properties.RowNames;
for i=1:length(effect)
tmp = effect{i};
tmp = erase(tmp, '(Intercept):');
tmp = strrep(tmp, 'Error', 'Participant');
effect(i) = {tmp};
end
% determine the required width of the table
fieldWidth1 = max(cellfun('length', effect)); % width of Effect column
fieldWidth2 = 57; % width for df, SS, MS, F, and p columns
barDouble = sprintf('%s\n', repmat('=', 1, fieldWidth1 + fieldWidth2));
barSingle = sprintf('%s\n', repmat('-', 1, fieldWidth1 + fieldWidth2));
% re-organize the data
c = c(2:end,[2 1 3 4 5]);
c = [num2cell(repmat(fieldWidth1, size(c,1), 1)), effect(2:end), c]';
% create the ANOVA table
s = sprintf('ANOVA table for %s\n', dvName);
s = [s barDouble];
s = [s sprintf('%-*s %4s %11s %14s %9s %9s\n', fieldWidth1, 'Effect', 'df', 'SS', 'MS', 'F', 'p')];
s = [s barSingle];
s = [s, sprintf('%-*s %4d %14.5f %14.5f %10.3f %10.4f\n', c{:})];
s = [s, barDouble];
end

Community Treasure Hunt

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

Start Hunting!

Translated by