problem with the anova calculation
2 次查看(过去 30 天)
显示 更早的评论
I have a problem with the calculation of the ANOVA. What is wrong with my code?
C_t = [30; 30; 30; 30; 30; 30; 30; 120; 120; 120; 120; 120; 120; 120; 120];
pick = [0; 0.026; 0.0550; 0.120 ; 0.320 ; 0.62 ; 1.2; 0 ;0.03; 0.066; 0.110 ; 0.220; 0.4; 0.740; 1.73];
tbl = table(C_t,pick,'VariableNames',{'C_t','pick'});
tbl.C_t = categorical(tbl.C_t);
mdl = fitlm(tbl,'pick')
tbl = anova(mdl,'summary'
0 个评论
采纳的回答
Jeff Miller
2022-12-6
Just change one line to this
mdl = fitlm(tbl,'pick~C_t')
4 个评论
Jeff Miller
2022-12-10
You can't. This is not a software problem, it is a limitation of your design. With only two values of X (30, 120), a straight line goes through the two (X, avg Y) pairs perfectly, so your data provide no information about whether there would be any deviation from a straight line fit ("lack of fit") if you had a third X value.
更多回答(1 个)
James Water Bird
2022-12-6
C_t = [30; 30; 30; 30; 30; 30; 30; 120; 120; 120; 120; 120; 120; 120; 120];
pick = [0; 0.026; 0.0550; 0.120 ; 0.320 ; 0.62 ; 1.2; 0 ;0.03; 0.066; 0.110 ; 0.220; 0.4; 0.740; 1.73];
% Use the table() function to create a table from the data
tbl = table(C_t,pick,'VariableNames',{'C_t','pick'});
% Convert the 'C_t' column to a categorical variable
tbl.C_t = categorical(tbl.C_t);
% Use the fitlm() function to fit a linear regression model to the data
mdl = fitlm(tbl,'pick')
% Use the anova() function to perform an analysis of variance on the model
tbl = anova(mdl,'summary')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Analysis of Variance and Covariance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!