我尝试使用Python-statsmodels线性混合效应模型来拟合有两个随机截获的模型,例如两个组。我不知道如何初始化这个模型。在
下面是一个例子。我有如下数据(取自here):subject gender scenario attitude frequency
F1 F 1 pol 213.3
F1 F 1 inf 204.5
F1 F 2 pol 285.1
F1 F 2 inf 259.7
F1 F 3 pol 203.9
F1 F 3 inf 286.9
F1 F 4 pol 250.8
F1 F 4 inf 276.8
我想建立一个线性混合效应模型,有两个随机效应——一个用于主题组,一个用于场景组。我正在努力做到:
^{pr2}$
我一直收到这个错误:LinAlgError: Singular matrix
它在R中工作得很好。当我在R中将lme4与基于公式的渲染一起使用时,它非常适合:politeness.model = lmer(frequency ~ attitude + gender +
(1|subject) + (1|scenario), data=politeness)
我不明白为什么会这样。当我使用任意一个随机效果/组时,例如model = sm.MixedLM.from_formula("frequency ~ attitude + gender", data, groups=data['subject'])
然后我得到:Mixed Linear Model Regression Results
====