MATLAB: ANOVAN with possibility of columns as the variables as input

anovaanovanrmanova

Hi
Hi, I have my variables in columns in a long matrix (165x 18) (results of 165 participants on 18 different conditions), and need to test which of the variables are statistically different. However, in the matrix 3 within variables are present. Furthermore, there are some values missing (therefore i wont be able to make use of anova2)… I would like to investigate the effect these within variables together and seperately.
The within values are as followed:
MP = egocentric/allocentric.ambiguous –>>{'egocentric','egocentric','egocentric','egocentric','egocentric','egocentric','allocentric','allocentric','allocentric','allocentric','allocentric','allocentric','ambiguous','ambiguous','ambiguous','ambiguous','ambiguous','ambiguous'};
Trials = yes/no –> {'yes','yes','yes','no','no','no','yes','yes','yes','no','no','no','yes','yes','yes','no','no','no',};
digits = zero/two/five –> {'zero', 'two','five','zero', 'two','five','zero', 'two','five','zero', 'two','five','zero', 'two','five','zero', 'two','five',};
So, i know i need to make use of anovan, however I really struggle to make this work… Is there someone who could help me how to test this? I highly appreciate it, thank you in advance!
0 Comments

Best Answer

I don't quite understand you example, but for anovan, the expected input is a column vector of numbers (nx1) and a cell array of factors.
To create an input variable for multicolumn data, do the following:
X = data(:)
To create 3 factor variables, A, B and C, define each one separately. Each entry indicates the factor level for the corresponding value in X (0 or 1).
A = [0 0 1 1...];
B = [0 0 0 0 ...];
C = [0 0 0 0 ...];
If it helps, you can visualize it this way:
level | A | B | C | X
(1) | 0 | 0 | 0 | n1
(1) | 0 | 0 | 0 | n2
a | 1 | 0 | 0 | n3
a | 1 | 0 | 0 | n4
...
Finally, I can call the anovan function with the inputs I've created and specify that I want to use the full model (all possible interactions).
anovan(X(:),{A,B,C},'varnames',{'A','B','C'},"model","full")