dunnett.m
% p = dunnett(stats, expt_idx, ctrl_idx)
% p is vector of p-values for comparing experimental value(s) (expt_idx) w/ a single
% control value (ctrl_idx), corrected by the Dunnett multiple comparison test
% stats is output from anova1
% idx are indicies of means of interest within stats datastructure
% p = dunnett(stats), then ctrl_idx=1, expt_idx=2:length(stats.means)
% p = dunnett(stats, expt_idx), then ctrl_idx=1
% p = dunnett(stats, [], ctrl_idx), then expt_idx=1:length(stats.means), but NOT ctrl_idx
% p = Dunnett's probability for non-zero difference between ctrl_idx and expt_idx means
% Based on Behavior Research Methods & Instrumentation (1981), vol. 13 (3), 363-366
% Dunlap, Marx, and Agamy Fortran IV source code adapted to Matlab
% The output from this function are consistent w/ the Dunnett test implemented in Prism 5.0a
%
% % Example
% % generate random data
% % groups ctrl and one are zero centered
% % groups two, three, and four are 2,3,4 centered respectively
%
% groupnames = {'ctrl','one','two','three','four'};
% datavector = [];
% k=1;
% for(i=1:length(groupnames))
% len = rand*20;
% while(len<10)
% len = rand*20;
% end
% if(i>2)
% datavector = [datavector i*rand(1,len)];
% else
% datavector = [datavector rand(1,len)];
% end
% for(j=1:len)
% group{k} = groupnames{i};
% k=k+1;
% end
% end
% [p,t,stats] = anova1(datavector,group); % perform one-way ANOVA
% p = dunnett(stats)
%
% p =
%
% NaN 0.9238 0.1639 0.0106 0.0002
%
% p(1) = 'ctrl' vs 'ctrl' = NaN p-value
% p(4) means 'three' is different from 'ctrl' w/ p-value 0.0106
% p(5) means 'four' is different from 'ctrl' w/ p-value 0.0002
%
% Navin Pokala 2012
Cite As
Navin Pokala (2024). dunnett.m (https://www.mathworks.com/matlabcentral/fileexchange/38157-dunnett-m), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.