Multivariate analysis of variance in Matlab

14 views (last 30 days)
Hi all,
I am trying to run a n- way multivariate analysis of variance on the attached table.
each colum (a,b,c ...) is one dependent variable, while each row is one group.
each cell contains the values of that specific group for each dependent variable.
can you suggest me which function to use and how the data should be organized?
and in case they have to be rearranged in another way, can you suggest me a fast way to rearrange them?
Thank you very much
  1 Comment
Lorenzo
Lorenzo on 9 Jul 2021
I can't understand if for your data you need one-way MANOVA or n-way MANOVA? it seems that you have only one way (the 7 groups)?.
I would be interested also in N-way MANOVA but I suspect that in MATLAB only one-way is supported by the manova1 function.

Sign in to comment.

Accepted Answer

Jeff Miller
Jeff Miller on 28 Jan 2021
You need to arrange your data in a table with one row per individual group member. For example, your first group seems to have about 55 members that will go into 55 rows, your second group has about 133 members (133 rows), and so on. So, you need a table with about 700-800 rows, as the sum of the different group sizes.
In the required table, you need one column for each dependent variable, as you have now, plus you need one more column with values indicating group membership, e.g., values like "GroupA", GroupB", etc.
It isn't actually possible to produce the required table from the *.mat file that you posted, because it appears that you have some missing data. For example, in the first row (group) some variables have 55 scores but others have only 53 or 54. That makes it look like there were 55 members in that group but scores were lost on a few variables for a few of the group members. The manova depends on the correlations among variables, so the data set has to make it clear how the scores of different variables match up. This depends on which of the (say, 55) first group members were missing data on variables 2 and 7, for example, and there is no way to tell that from the posted mat file.
  3 Comments
Jeff Miller
Jeff Miller on 29 Jan 2021
Yes, it would be much easier to start with this second table (at least, much easier for me). This is very ugly code, but it might help you: Check carefully!
% Starting with the array t from your second .mat file:
% Use nan for all missing data:
t(t==9999) = nan;
t(t==8888) = nan;
% by the way, matlab's manova1 will ignore any row with missing data
% Convert array to table; slightly more convenient to handle (imho)
t2 = array2table(t);
% Make a new variable to for the group labels
t2.Group = repmat({'Group?'},height(t2),1);
% Set the group label for each group.
% You have to fill in the appropriate numbers (eg 45/49)
GroupA = t2.t1>=45 & t2.t1<=49;
t2.Group(GroupA) = repmat({'GroupA'},sum(GroupA),1);
GroupB = t2.t1>=50 & t2.t1<=54;
t2.Group(GroupB) = repmat({'GroupB'},sum(GroupB),1);
GroupC = t2.t1>=55 & t2.t1<=???;
t2.Group(GroupC) = repmat({'GroupC'},sum(GroupC),1);
% ... and so on for all of your groups
% Convert DVs back to numeric format for manova1
X = table2array(t2(:,2:11));
[d,p,stats] = manova1(X,t2.Group)
Riccardo Galli
Riccardo Galli on 1 Feb 2021
Thank you very much! I will try it now!

Sign in to comment.

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!