ANOVAN with possibility of columns as the variables as input

1 view (last 30 days)
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

Accepted Answer

Cris LaPierre
Cris LaPierre on 22 Jan 2020
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")
  1 Comment
Cris LaPierre
Cris LaPierre on 22 Jan 2020
You can also specify specific interactions doing something like this
anovan(y,{A,B,A.*B,A.^2},'varnames',{'A','B','AB','A^2'})

Sign in to comment.

More Answers (2)

annie
annie on 22 Jan 2020
heyy thanks for the reply! but i still dont really understand it... cause if i do data(:) then i will get a 1854x1 vector and then i'm really confused how to specify the factor variables
  1 Comment
Cris LaPierre
Cris LaPierre on 22 Jan 2020
Your factors are what indicate the test conducted on each row. For this reason, each one (A, B and C) would be 1854x1 long.

Sign in to comment.


annie
annie on 22 Jan 2020
Ahh nevermind, i think i understand it! Thanks!!

Community Treasure Hunt

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

Start Hunting!