1

R: Two-Way Repeated-Measure Robust ANOVA| Different Conditions

Dear community,

I have a data frame, that looks something like this:

participant_nr condition side value_1 value_2
01 B left 13 77
01 C left 20 93
01 A left 9 60
01 C right 23 100
01 A right 11 70
01 B right 17 85
02 C left 18 79
02 A left 7 58
02 B left 12 79
02 A right 11 74
02 B right 15 90
02 C right 20 105

This is a within subject design. My experimental design measured the 2 different dependent variable (value_1 and value_2) in different conditions. The conditions depend on the experimental manipulations (A,B,C). These manipulations were applied for the left and the right side. I would like to conduct a repeated-measures ANOVA in order to investigate the effect of the condition (A, B or C), side (right or left) and the interaction of condition and side on the mean values of the 2 dependent varibales. I already checked the ANOVA-Assumptions and decided to go with a robust ANOVA. Also, I reshaped the data-frame from long format to wide format. Now the data frame looks something like this:

participant_nr condition side value_1 value_2 condition side value_1 value_2 condition side value_1 value_2 condition side value_1 value_2 condition side value_1 value_2 condition side value_1 value_2
01 B left 13 77 C left 20 93 A left 9 60 C right 23 100 A right 11 70 B right 17 85
02 C left 18 79 A left 7 58 B left 12 79 A right 11 74 B right 15 90 C right 20 105

As you can see, the order in which I tested the conditions were randomized. Usually, I would use anova_test() or the aov() function in order to perform the two-way ANOVA. I never worked with an within-subject design before. And since the data are counterbalanced, I don't have an idea how I should tell my code how to match the correct values from the dependent variables with the correct information from the trials.

Thank you in advance!

John
  • 19
  • 4

1 Answers1

0

Running manova gave a rank error on your data, but a MANOVA is really like doing ANOVA with each response variable (and this is often done after an omnibus MANOVA test). With two within-group factors (no interaction), condition is significant for both responses but side is only marginally significant for the first response.

text="
01 B left 13 77
01 C left 20 93
01 A left 9 60
01 C right 23 100
01 A right 11 70
01 B right 17 85
02 C left 18 79
02 A left 7 58
02 B left 12 79
02 A right 11 74
02 B right 15 90
02 C right 20 105"
DF=read.table(text=text)
colnames(DF)=c('participant_nr', 'condition', 'side', 'value_1', 'value_2')

fit1 <- aov(value_1 ~ condition + side + Error(participant_nr/(condition+side)), data=DF)
summary(fit1)

fit2 <- aov(value_2 ~ condition + side + Error(participant_nr/(condition+side)), data=DF)
summary(fit2)

Output

Error: participant_nr
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  1  8.333   8.333               

Error: participant_nr:condition
          Df Sum Sq Mean Sq
condition  2  199.3   99.63

Error: participant_nr:side
     Df Sum Sq Mean Sq
side  1   24.3    24.3

Error: Within
          Df Sum Sq Mean Sq F value  Pr(>F)   
condition  2  34.07   17.03   34.07 0.00308 **
side       1   2.70    2.70    5.40 0.08080 . 
Residuals  4   2.00    0.50                   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Error: participant_nr
          Df    Sum Sq   Mean Sq F value Pr(>F)
Residuals  1 1.818e-27 1.818e-27               

Error: participant_nr:condition
          Df Sum Sq Mean Sq
condition  2   1428   714.1

Error: participant_nr:side
     Df Sum Sq Mean Sq
side  1    572     572

Error: Within
          Df Sum Sq Mean Sq F value Pr(>F)  
condition  2 280.47  140.23   9.246 0.0316 *
side       1   0.30    0.30   0.020 0.8950  
Residuals  4  60.67   15.17                 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Vons
  • 3,277
  • 2
  • 16
  • 19
  • Thank you very much. I am honestly not supposed to use MANOVA in this context, since the vaslue 1 and 2 are from different experiments and are analyzed separately. The data I gave here were purely fictional, only for clarifying the code. I solved the problem now like that: res.aov <- anova_test( data = Data_complete_trials_factor, dv = value_1, wid = participant_nr, within = c(condition, side) ) get_anova_table(res.aov) – John Jun 19 '23 at 11:43