我正在尝试创建具有主体内 ID 的混合模型以进行方差分析。这是我的代码:
formula = 'DepVar ~ C(Condition)*C(Passage)*C(Order) + (1|C(Participant))'
model = ols(formula, data=anova_df).fit()
“参与者”列中的数据是字符串。但是,当我尝试运行它时,出现以下错误:
PatsyError: Error evaluating factor: TypeError: unsupported operand type(s) for |: 'int' and '_CategoricalBox'
TaskTime ~ C(Condition)*C(Passage)*C(Order) + (1|C(Participant))
^^^^^^^^^^^^^^^^^^
删除 C 会出现另一个错误:
PatsyError: Error evaluating factor: TypeError: Cannot perform 'ror_' with a dtyped [object] array and scalar of type [bool]
TaskTime ~ C(Condition)*C(Passage)*C(Order) + (1|Participant)
我在这里做错了什么?我在 elsewhere 上读到,这是考虑重复措施的合适方法。
请注意,如果我将所有参与者 ID 从字符串转换为整数,则代码:
TaskTime ~ C(Condition)*C(Passage)*C(Order) + (1|Participant)
有效。然而,我听说这样做是不好的做法,因为参与者 ID 应该被明确对待。