📄 anova1w.m
字号:
function anova1w(dat,alpha)
%ANOVA1W One way analysis of variance
% Calculates one way ANOVA table and tests significance of
% between factors variation (it is assumed that each column
% of the data represents a different treatment). The inputs
% are the data table dat and the desired confidence level
% alpha, expressed as a fraction (e.g. .95, .99, etc.).
% The output is an ANOVA table.
% The I/O format is: anova1w(dat,alpha)
% Copyright
% Barry M. Wise
% 1994
[n,k] = size(dat);
xbar = mean(mean(dat));
xbari = mean(dat);
sst = sum(sum(dat.^2)) - (1/(n*k))*sum(sum(dat))^2;
sstr = (1/n)*sum(sum(dat).^2) - (1/(n*k))*sum(sum(dat))^2;
sse = sst - sstr;
msstr = sstr/(k-1);
msse = sse/((n-1)*k);
ff = msstr/msse;
disp(' ')
disp('___________________________________________________________')
disp(' Source of Sum of Degrees Mean')
disp(' Variation Squares of Freedom Square')
disp('___________________________________________________________')
s = sprintf('Between factors %11.4f %4.0f %10.4f',...
sstr,k-1,msstr);
disp(s)
disp('(columns)')
s = sprintf('Residual %11.4f %4.0f %10.4f',...
sse,(n-1)*k,msse);
disp(s), disp(' ')
s = sprintf('Total %11.4f %4.0f',sst,(k-1)+(n-1)*k);
disp(s)
disp(' ')
s = sprintf('Effect of factor = %g/%g = %g',msstr,msse,ff);
disp(s)
disp(' ')
fstatf = ftest(1-alpha,k-1,(n-1)*k);
pc = (alpha)*100;
s = sprintf('F at %g percent confidence = %g',pc,fstatf); disp(s)
if fstatf < ff
disp('Effect of factors IS significant')
else
disp('Effect of factors IS NOT significant')
end
disp(' ')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -