15 views (last 30 days)

Show older comments

Heads up, I'm a MATLAB novice. I'm trying to run a Fisher's test on a one-way ANOVA that I conducted comparing the difference in 3 therapy groups. How do I print out the F-statistic for this multiple comparisons test?

The code I'm using:

%data input

ingroups = [5,4,6,7,5,6,7,5,5,6;6,7,7,5,7,7,8,6,7,7;7,8,7,7,8,5,6,7,7,7];

Mon = [5 4 6 7 5 6 7 5 5 6];

Bon = [6 7 7 5 7 7 8 6 7 7];

Feel = [7 8 7 7 8 5 6 7 7 7];

%transpose data rows in to columns for anova1

ingroups2 = transpose(ingroups);

%one-way ANOVA (treats columns as separate groups)

[p,tbl,stats] = anova1(ingroups2);

%Fisher's protected test (least significant difference)

[c,m,h,gnames] = multcompare(stats,'CType','lsd');

Adam Danz
on 15 Sep 2021

You are performing a one-way ANOVA which means your null hypothesis is that there is no difference in the population means of your 3 levels of some factor. This assumes the data in each factor are normally distributed. Below is a quick eye-ball check of that assumption. It's difficult to call these data normally distributed since you have so few data and they are intergers within a narrow range. If these are your real data, I would not be comfortable confirming the normality assumption and therefore I would not be comfortable relying on any parametric test including an ANOVA.

ingroups = [5,4,6,7,5,6,7,5,5,6;6,7,7,5,7,7,8,6,7,7;7,8,7,7,8,5,6,7,7,7]'; % Notice transpose!

tiledlayout(3,1)

nexttile(); histogram(ingroups(:,1)); title('Column 1')

nexttile(); histogram(ingroups(:,2)); title('Column 2')

nexttile(); histogram(ingroups(:,3)); title('Column 3')

Assuming the data provided are example data and that your real data are approximately normally distributed, I'll move on to your original question. The Fisher Exact Test is designed for 2x2 contingency tables. Since you have 3 levels, you'd likely want to use a chi-squared test instead. See Data Science Blog and Analysis of Categorical Data (PDF) for more info.

If you're just trying to get the F-statistic from the ANOVA table,

[p,tbl,stats] = anova1(ingroups,[],'off');

tbl(cellfun('isempty',tbl)) = {nan};

T = cell2table(tbl(2:end,:), 'VariableNames', tbl(1,:))

F = T.F(1)

Scott MacKenzie
on 19 Sep 2021

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

Start Hunting!