Skip to content

Instantly share code, notes, and snippets.

@AndrewLJackson
Created July 22, 2015 19:35
Show Gist options
  • Save AndrewLJackson/5c307cb548cb4c78f8b9 to your computer and use it in GitHub Desktop.
Save AndrewLJackson/5c307cb548cb4c78f8b9 to your computer and use it in GitHub Desktop.
Example for running various post hoc analyses on ANOVA models in matlab
strength = [82 86 79 83 84 85 86 87 74 82 ...
78 75 76 77 79 79 77 78 82 79];
alloy = {'st','st','st','st','st','st','st','st',...
'al1','al1','al1','al1','al1','al1',...
'al2','al2','al2','al2','al2','al2'};
% NB also works on two-way anovas using anova2()
[p, tbl, stats] = anova1(strength,alloy,'off')
% this line will compute pairwise comparisons, at the usual
% (and default if you omit this) alpha=0.05, use a
% Bonferroni correction, and not generate the interactive display.
c_tukey = multcompare(stats, 'Alpha',0.05, 'CType', 'bonferroni', 'Display', 'off')
% other options for 'CType' are 'hsd' = Tukey's test, 'dunn-sidak', 'lsd', 'scheffe'
% depending on which one you want. Bonferroni can be be a little harsh, and I
% mostly see Tukey's used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment