Filtered variable levels in a table reappearing after calling ANOVAN
Informazioni
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Mostra commenti meno recenti
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 Commenti
Jeff Miller
il 26 Mag 2018
It's hard to believe that this is an anovan problem. Are you sure t1_data has what you think it has in the first version?
Bryan Wilson
il 29 Mag 2018
Bryan Wilson
il 30 Mag 2018
Modificato: Bryan Wilson
il 30 Mag 2018
Risposte (0)
Questa domanda è chiusa.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!