TWO WAY ANOVA - MATLAB
ANOVA (analysis of variance)
In this project, an two way anova code is prepared. This code gives the f_ratio values of a mathematics analysis for anova.A MATLAB code is attached here. In this code ,a seprate initial values are assumed .To simulate it for your problem, copy the code and paste it in your MATLAB editor window and change the initial values and run it.You will get your f_ratio values for treatments,blocks.Compare it with the FT_table and inference the problem.The code and the link for the FT_table is attached here.
FT_table link:http://www.socr.ucla.edu/Applets.dir/F_Table.html
clear all
close all
clc
[y]=[37 38 38 32;31 40 43 31;36 33 41 38];
a=size(y,1);
b=size(y,2);
T=sum(y,'all');
Ti=sum(y,2);
Tj=sum(y,1);
%C_correction factor
C=T.^2/(a*b);
%SST_sum_of_squares_total
SST=sumsqr(y)-C;
%SSTr_sum_of_squares_tratment
SSTr=(sumsqr(Ti)/b)-C;
%SSB_sum_of_squares_blocks
SSB=(sumsqr(Tj)/a)-C;
%SSE_sum_of_squares_error
SSE=SST-(SSTr+SSB);
%degree_of_freedom_for_treatment,blocks,errors
DFTr=a-1;
DFB=b-1;
DFE=(a-1)*(b-1);
%means_of_squares_of_treatments,blocks,errors
MSTr=SSTr./DFTr;
MSB=SSB./DFB;
MSE=SSE./DFE;
%for_F_ratio
if MSE>MSTr
FTr=MSE/MSTr
else FTr=MSTr/MSE
end
if MSE>MSB
FTr=MSE/MSB
else FTr=MSB/MSE
end
plot(y,'*')
%now compare the calculated F values with the FT table of a given alpha
%value and interpret the results
The graph/plot for the analysis is given here.But the graph is a complex one.