# between subjects factors still not implemented as of 2019-02-27
from statsmodels.stats.anova import AnovaRM
aovrm = AnovaRM(df, depvar="rt", subject="id", within=["iv"])
fit = aovrm.fit()
fit.summary()
%load_ext rpy2.ipython
from rpy2.robjects import pandas2ri
R_data = pandas2ri.py2ri(final_data)
# switch_conditions is repeated, rest are between
%%R -i R_data -o afex_model
library(afex)
# Convert to numeric, due to pandas converting everything to strings
R_data <- transform(R_data, participant = as.numeric(participant))
R_data <- transform(R_data, ratings = as.numeric(ratings))
R_data <- transform(R_data, switch_conditions = as.numeric(switch_conditions))
afex_model <- aov_ez(
"participant",
"ratings",
R_data,
between=c("question_conditions", "complexity"),
within=c("switch_conditions"),
type=3, #type of sum squares to use; default is 3
anova_table = list(es = "pes") # partial eta-squared; default is ges (generalized eta-squared)
)