Why are the results of the three-way ANOVA all Nan ?
%the 4 numbers in each row correspond to the methods ‘A’; ‘B’; ‘C’ and ‘Alt’
%low iq with break
productivity_scores_li_yb = [
4.4 3.4 2.4 3.9;
4.1 3.8 1.8 2.7;
3.8 4.3 1.7 2.1;
4.4 4.4 1.9 2.6;
4.7 3.6 2.5 2.4;
3.3 3.9 2.0 3.2;
3.8 3.9 2.3 2.5;
4.3 2.8 2.5 3.5;
4.9 3.3 2.3 3.6;
3.8 4.0 1.8 2.9;
];
%high iq with break
productivity_scores_hi_yb = [
3.5 4.2 3.7 2.2;
3.7 4.2 2.4 1.4;
4.9 4.2 2.8 1.8;
3.5 2.7 2.8 1.3;
4.5 3.8 2.4 1.7;
4.7 4.2 3.5 2.8;
3.6 3.3 2.7 1.2;
3.1 3.9 3.5 2.1;
4.5 3.4 2.8 2.5;
3.0 4.3 3.2 1.5;
];
%low iq without break
productivity_scores_li_nb = [
3.5 2.9 3.2 4.0;
3.2 1.7 3.3 3.8;
3.4 2.8 4.0 3.1;
4.6 3.1 3.4 3.7;
4.0 2.6 3.5 3.2;
3.6 1.7 3.4 3.4;
3.9 2.4 3.6 3.7;
4.3 3.0 3.6 3.3;
3.9 2.8 3.3 3.3;
3.5 1.7 3.3 3.4;
];
%high iq without break
productivity_scores_hi_nb = [
3.7 2.0 3.1 4.1;
3.9 2.6 2.8 3.2;
4.0 3.1 2.9 3.6;
4.0 1.8 3.1 4.1;
4.4 2.0 3.1 4.0;
4.0 2.0 3.8 3.2;
3.6 2.9 3.7 3.4;
3.8 2.0 2.7 3.3;
4.8 2.9 3.5 2.8;
3.8 2.7 3.3 3.6;
];
%Reshape data into a single column vector
scores = [productivity_scores_li_yb(:); productivity_scores_hi_yb(:);
productivity_scores_li_nb(:); productivity_scores_hi_nb(:)];
%Create factor vectors as string arrays
n = 10; % number of participants in each group
methods = 4; % number of learning methods
iq = [repmat({‘Low’}, n*methods*2, 1); repmat({‘High’}, n*methods*2, 1)]
break_status = [repmat({‘Yes’}, n*methods*2, 1); repmat({‘No’}, n*methods*2, 1)]
method = repmat({‘A’; ‘B’; ‘C’; ‘Alt’}, n*4, 1)
%Perform three-way ANOVA
[p, tbl, stats] = anovan(scores, {iq break_status method}, ‘model’, ‘full’, …
‘varnames’, {‘IQ’, ‘Break’, ‘Method’}, ‘display’, ‘on’);%the 4 numbers in each row correspond to the methods ‘A’; ‘B’; ‘C’ and ‘Alt’
%low iq with break
productivity_scores_li_yb = [
4.4 3.4 2.4 3.9;
4.1 3.8 1.8 2.7;
3.8 4.3 1.7 2.1;
4.4 4.4 1.9 2.6;
4.7 3.6 2.5 2.4;
3.3 3.9 2.0 3.2;
3.8 3.9 2.3 2.5;
4.3 2.8 2.5 3.5;
4.9 3.3 2.3 3.6;
3.8 4.0 1.8 2.9;
];
%high iq with break
productivity_scores_hi_yb = [
3.5 4.2 3.7 2.2;
3.7 4.2 2.4 1.4;
4.9 4.2 2.8 1.8;
3.5 2.7 2.8 1.3;
4.5 3.8 2.4 1.7;
4.7 4.2 3.5 2.8;
3.6 3.3 2.7 1.2;
3.1 3.9 3.5 2.1;
4.5 3.4 2.8 2.5;
3.0 4.3 3.2 1.5;
];
%low iq without break
productivity_scores_li_nb = [
3.5 2.9 3.2 4.0;
3.2 1.7 3.3 3.8;
3.4 2.8 4.0 3.1;
4.6 3.1 3.4 3.7;
4.0 2.6 3.5 3.2;
3.6 1.7 3.4 3.4;
3.9 2.4 3.6 3.7;
4.3 3.0 3.6 3.3;
3.9 2.8 3.3 3.3;
3.5 1.7 3.3 3.4;
];
%high iq without break
productivity_scores_hi_nb = [
3.7 2.0 3.1 4.1;
3.9 2.6 2.8 3.2;
4.0 3.1 2.9 3.6;
4.0 1.8 3.1 4.1;
4.4 2.0 3.1 4.0;
4.0 2.0 3.8 3.2;
3.6 2.9 3.7 3.4;
3.8 2.0 2.7 3.3;
4.8 2.9 3.5 2.8;
3.8 2.7 3.3 3.6;
];
%Reshape data into a single column vector
scores = [productivity_scores_li_yb(:); productivity_scores_hi_yb(:);
productivity_scores_li_nb(:); productivity_scores_hi_nb(:)];
%Create factor vectors as string arrays
n = 10; % number of participants in each group
methods = 4; % number of learning methods
iq = [repmat({‘Low’}, n*methods*2, 1); repmat({‘High’}, n*methods*2, 1)]
break_status = [repmat({‘Yes’}, n*methods*2, 1); repmat({‘No’}, n*methods*2, 1)]
method = repmat({‘A’; ‘B’; ‘C’; ‘Alt’}, n*4, 1)
%Perform three-way ANOVA
[p, tbl, stats] = anovan(scores, {iq break_status method}, ‘model’, ‘full’, …
‘varnames’, {‘IQ’, ‘Break’, ‘Method’}, ‘display’, ‘on’); %the 4 numbers in each row correspond to the methods ‘A’; ‘B’; ‘C’ and ‘Alt’
%low iq with break
productivity_scores_li_yb = [
4.4 3.4 2.4 3.9;
4.1 3.8 1.8 2.7;
3.8 4.3 1.7 2.1;
4.4 4.4 1.9 2.6;
4.7 3.6 2.5 2.4;
3.3 3.9 2.0 3.2;
3.8 3.9 2.3 2.5;
4.3 2.8 2.5 3.5;
4.9 3.3 2.3 3.6;
3.8 4.0 1.8 2.9;
];
%high iq with break
productivity_scores_hi_yb = [
3.5 4.2 3.7 2.2;
3.7 4.2 2.4 1.4;
4.9 4.2 2.8 1.8;
3.5 2.7 2.8 1.3;
4.5 3.8 2.4 1.7;
4.7 4.2 3.5 2.8;
3.6 3.3 2.7 1.2;
3.1 3.9 3.5 2.1;
4.5 3.4 2.8 2.5;
3.0 4.3 3.2 1.5;
];
%low iq without break
productivity_scores_li_nb = [
3.5 2.9 3.2 4.0;
3.2 1.7 3.3 3.8;
3.4 2.8 4.0 3.1;
4.6 3.1 3.4 3.7;
4.0 2.6 3.5 3.2;
3.6 1.7 3.4 3.4;
3.9 2.4 3.6 3.7;
4.3 3.0 3.6 3.3;
3.9 2.8 3.3 3.3;
3.5 1.7 3.3 3.4;
];
%high iq without break
productivity_scores_hi_nb = [
3.7 2.0 3.1 4.1;
3.9 2.6 2.8 3.2;
4.0 3.1 2.9 3.6;
4.0 1.8 3.1 4.1;
4.4 2.0 3.1 4.0;
4.0 2.0 3.8 3.2;
3.6 2.9 3.7 3.4;
3.8 2.0 2.7 3.3;
4.8 2.9 3.5 2.8;
3.8 2.7 3.3 3.6;
];
%Reshape data into a single column vector
scores = [productivity_scores_li_yb(:); productivity_scores_hi_yb(:);
productivity_scores_li_nb(:); productivity_scores_hi_nb(:)];
%Create factor vectors as string arrays
n = 10; % number of participants in each group
methods = 4; % number of learning methods
iq = [repmat({‘Low’}, n*methods*2, 1); repmat({‘High’}, n*methods*2, 1)]
break_status = [repmat({‘Yes’}, n*methods*2, 1); repmat({‘No’}, n*methods*2, 1)]
method = repmat({‘A’; ‘B’; ‘C’; ‘Alt’}, n*4, 1)
%Perform three-way ANOVA
[p, tbl, stats] = anovan(scores, {iq break_status method}, ‘model’, ‘full’, …
‘varnames’, {‘IQ’, ‘Break’, ‘Method’}, ‘display’, ‘on’); anova MATLAB Answers — New Questions