Using matlab to run ANOVA for group analyses

    All examples below are from an experiment in which there were 3 conditions, varying the Level of Abstraction in stimuli (anagrams). So in this case, we are looking to see if there is an effect of Level of Abstraction on Accuracy (i.e., if accuracy differs significantly across the three conditions).

    Here is an example of Matlab code that computes mixed effects ANOVA (treating subejcts as a random effect).

    And here is the results table that Matlab produces when the above code is run:

    In order to compute the statistics the way they are typically reported in published papers, we need to estimate the F value and its corresponding P value using the table above. Here is how to do that.

    The F value we need to report will be:

    F = Mean Sq. (ACC_LevelAbs) / Mean Sq. (ACC_LevelAbs*Subject), or

    F = 0.01654 / 0.1941 = 0.085213807

    The degrees of freedom would be
    DF1 = d. f. (ACC_LevelAbs) = 2
    DF2 = d. f. (ACC_LevelAbs*Subject) = 30

    And in order to look up the P value corresponding to this F value and these degrees of freedom, we can use the following code in Matlab:
    >> Fvalue = 0.085213807;
    >> df1 = 2;
    >> df2 = 30;
    >> Pvalue = 1 - cdf(’F', Fvalue,df1,df2)

    This code should return the P value — in our case, after rounding, P = 0.92.

    In the manuscript, this result could be reported as:
    “Mean accuracy did not differ significantly across conditions as indicated by a repeated-measures ANOVA (F[2,30] = 0.09, P = 0.92).”