Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Filtered variable levels in a table reappearing after calling ANOVAN
조회 수: 1 (최근 30일)
이전 댓글 표시
I'm seeing some funny behavior where items from a large table are getting passed on to the a smaller table, even when those data should be filtered out. In my data set "ShearBondData.mat" there are several levels under 'Project' and 'Task_AsphaltType'. I filter out most of these by picking only rows where 'Test1'=="x" and then running an ANOVA on the data subset. BUT, if I check the coefficient names in the stats output (t1_stats.coeffnames), I can see ALL the levels that were in the ShearBondData.mat file, as if they never got filtered out.
load ('ShearBondData.mat','-mat');
rows = ShearBondData.Test1 == "x";
t1_data = ShearBondData(rows,:);
y = t1_data.BondStrengthpsi;
g1 = t1_data.Project;
g2 = t1_data.AsphaltType;
names = {'Sample_source','AsphaltType'};
[t1_p,t1_tbl,t1_stats]= anovan(y,{g1,g2},'varnames',names);
t1_stats.coeffnames
%[t1_c,t1_m,t1_h,t1_gnames] = multcompare(t1_stats);
I tried to replicate the same thing below, but it seems to work fine. I'm filtering out only "Cool" vehicles, which excludes all vans. Then in the ANOVA output, the coeffnames shows only 'Car', 'Truck', 'Red', and 'White.' If it were behaving like my code above, you'd also see 'Van' listed. ANY IDEA WHAT'S GOING ON????
Vehicle = {'Car';'Car';'Car';'Car';...
'Truck';'Truck';'Truck';'Truck';...
'Van';'Van';'Van';'Van'};
IsCool = [1;1;1;1;1;1;1;1;0;0;0;0];
Color = {'Red';'Red';'White';'White';...
'Red';'Red';'White';'White';...
'Red';'Red';'White';'White'};
MPG = [25;35;29;30;15;11;12;10;13;9;20;15];
T = table(Vehicle,IsCool,Color,MPG);
rows = T.IsCool == 1;
t1 = T(rows,:);
y = t1.MPG;
g1 = t1.Vehicle;
g2 = t1.Color;
[p,tbl,stats]=anovan(y,{g1,g2},'varnames',{'Vehicle','Color'});
stats.coeffnames
댓글 수: 3
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!