- anovan: https://www.mathworks.com/help/stats/anovan.html.
- multcompare: https://www.mathworks.com/help/stats/multcompare.html.
- interactionplot: https://www.mathworks.com/help/stats/interactionplot.html.
n-way anova with 2 seperate group and 2 seperate data
6 views (last 30 days)
Show older comments
Hi
Need a help with n-way anova. I've got exel table where A and B git values 0 - user incorrect answer and 1 - correct answer, and the labels to them like below:
A = [1 0 1 0 0 1 0]
B = [1 1 0 0 1 1 1]
LabelsA = [red blue white white white blue red]
LabelsB = [high medium medium high low low high]
And now, using the data I need to use anova to create table and multicompare of the stats to see: probability of the case A. Probability of the case 2 and probability A*B.
Additionally i need to draw the all variances probability like: x1 = red x2 = high, x1 = red x2 = medium ... x1 = white, x2 = low. so 9 pairs
Tried anova2 but i cannot do all of the variances with groups. Tried anovan but i can input in there only wektor of the data
Would be grateful for any tip.
0 Comments
Answers (1)
Shivansh
on 13 Sep 2024 at 12:30
Hi Luk,
You can use the "anovan" function with your data to achieve the desired analysis. You can first prepare the data for anova analysis, apply the "anovan" function, and then use "multcompare" to perform multiple comparisons on different groups.
Here is a sample code for your reference:
% Data
A = [1 0 1 0 0 1 0];
B = [1 1 0 0 1 1 1];
LabelsA = {'red', 'blue', 'white', 'white', 'white', 'blue', 'red'};
LabelsB = {'high', 'medium', 'medium', 'high', 'low', 'low', 'high'};
% Combine data into a single vector and create group labels
responses = [A, B];
group1 = [LabelsA, LabelsB]; % Combine labels for A and B
group2 = [repmat({'A'}, 1, length(A)), repmat({'B'}, 1, length(B))]; % Indicate source (A or B)
% Perform n-way ANOVA
[p, tbl, stats] = anovan(responses, {group1, group2}, 'model', 'interaction', 'varnames', {'Label', 'Source'});
% Display ANOVA table
disp(tbl);
% Perform multiple comparisons
results = multcompare(stats, 'Dimension', [1 2]); % Compare across both dimensions
% Display multiple comparison results
disp(results);
% Plot interaction plot for visual analysis
figure;
interactionplot(responses, {group1, group2}, 'varnames', {'Label', 'Source'});
The above code errors out in the "interactionplot" due to missing combinations of factor levels. It can happen when the random data doesn't cover all possible combinations of the factors, which is common with small datasets, or when factors are not fully crossed.
Please refer to the following documentation links for more information:
I hope this resolves your issue!
0 Comments
See Also
Categories
Find more on Repeated Measures and MANOVA in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!