Correct anova1 application
2 views (last 30 days)
Show older comments
Hi,
I have a dataset with n=140 number of simulations repeated unter the same conditions in my model. However, there is a source of variability embedded in the model, so I would like to test whether this has any significant effect on my results. Some reading led me to the conclusion that one-way ANOVA would be appropriate test to assess this, but reading into anova1 documentation got me a bit confused.
Below I am attaching results from my first n=5 number of simulations. My struggle is with defining a group in the context of anova1 function in Matlab. Is my group:
- one simulation repeat (n=100 000 data points, or MyData_ in the figure below),
- one data point in every repeat (n=140 data points),
- or is everything belonging to the same group, since the simulations were run with same parameters?
In addition, I know that ANOVA offers in-group and between-group differences, so I hope someone could elaborate on how to incorporate this information in my context.
I appreciate any help,
Best, Tea

0 Comments
Answers (1)
Ayush Aniket
on 23 Jan 2025 at 8:58
In the context of your simulations and the use of one-way ANOVA in MATLAB, the concept of "groups" is crucial for setting up your analysis correctly.
Given that you are interested in assessing the variability introduced by the model, you should likely treat each simulation repeat as a separate group as each simulation repeat (n=140) represents a different set of conditions or a different treatment (variability embedded in the model). This way, you can evaluate whether the variability between repeats is significant compared to the variability within each repeat.
Assuming you have collected data from each simulation repeat, you can organize your data for ANOVA like this:
% Example data setup
% Assume MyData is a matrix where each column represents a simulation repeat
% and each row represents a data point within that repeat.
MyData = rand(100000, 140); % Replace with your actual data
% Reshape data into a single vector
data = MyData(:);
% Create a group vector indicating which simulation each data point belongs to
group = repelem(1:140, 100000)';
% Perform one-way ANOVA
[p, tbl, stats] = anova1(data, group);
0 Comments
See Also
Categories
Find more on Analysis of Variance and Covariance 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!