# 2-way ANOVA in Python statsmodels yields different Sum of Squares than SPSS

I am learning to use Python for my statistical analyses, and while figuring out how to perform a 2-way ANOVA with statsmodels I found that my Python code yielded slightly aberrant values. Comparing the outputs you can see that the SS_Factor_1 values, and the Adjusted R2 are different for Python vs SPSS/Graphpad. Is this because of a mistake in my code, or some other reason? Are these differences due to something inherent in each software and so small I should just ignore them?

Python code:

formula = 'dependent_variable ~ C(factor_1) * C(factor_2)'
model = ols(formula, data=df_freq_time).fit()
aov_table = anova_lm(model, typ=2)
aov_table


Python output:

Also R2 = 0.722, and adj R2 = 0.694

SPSS 2-way ANOVA results:

• Do you get the same numbers in python if you use type 3 ANOVA, typ=3? (The differences are small, but look too small for differences in definition and too large for purely numerical precision issues.) – Josef Sep 20 '18 at 1:01