Which to use? ols & AnovaRM?

46 views
Skip to first unread message

Steven Qian

unread,
Jun 17, 2021, 12:03:44 AM6/17/21
to pystatsmodels
Hi list,

I'm trying to apply ANOVA to my dataset using Statsmodels. My dataset has 1 dependent variable and 2 independent variables (2*3), and my experiment has a repeated measure design (i.e. each subject went through all 6 conditions). 

The dataset looks like below:

   participant   flicker compatibility  RT_Correct
0         p902   24T/18F    Compatible  429.655444
1         p902   24T/18F  Incompatible  446.960620
2         p902  Standard    Compatible  407.060181
3         p902  Standard  Incompatible  444.329519
4         p902   18T/24F    Compatible  420.293485
..         ...       ...           ...         ...
67        p914   24T/18F  Incompatible  496.470059
68        p914  Standard    Compatible  450.323597
69        p914  Standard  Incompatible  472.085922
70        p914   18T/24F    Compatible  453.960939
71        p914   18T/24F  Incompatible  493.016592

I've tried both ols() and AnovaRM() on my dataset, and the results seemed quite different between these two methods. My codes are as below: 

ols() method:
rtC_model = ols('RT_Correct ~ C(flicker) + C(compatibility) + C(flicker) * C(compatibility)', data = data).fit()
print(anova_lm(rtC_model))

outputs:
                               df         sum_sq  ...         F    PR(>F)
C(flicker)                    2.0     476.886996  ...  0.062084  0.939859
C(compatibility)              1.0   26490.565175  ...  6.897424  0.010720
C(flicker):C(compatibility)   2.0      59.264498  ...  0.007715  0.992315
Residual                     66.0  253482.652342  ...       NaN       NaN

AnovaRM() method:
rtC_model = AnovaRM(data = data, depvar = 'RT_Correct', subject = 'participant', within = ['flicker','compatibility']).fit()
print(rtC_model.summary())

outputs:
                       Anova
===================================================
                      F Value Num DF  Den DF Pr > F
---------------------------------------------------
flicker                4.9123 2.0000 22.0000 0.0172
compatibility         95.9265 1.0000 11.0000 0.0000
flicker:compatibility  0.7530 2.0000 22.0000 0.4827
===================================================

I'm wondering which method is more appropriate to use. It will be very appreciated if anyone can help me with this :) Thanks in advance!

Best,
Steven
Reply all
Reply to author
Forward
0 new messages