[英]Running lmer (Linear Mixed Effects Regression) in Python
我想問一些關於在 Python 中運行lmer
(線性混合效應回歸)模型的問題。
這是我在lme4
包(在 R 中)中運行的兩行(或公式)。 有什么方法可以在 Python 中安裝如下模型?
TEST1 <- score ~ p1 + p2 + p3 + (1|v1) + (1|v2), data = df, control = lmerControl(boundary.tol = 1e-4, calc.derivs = FALSE))
TEST2 <- score ~ (1|v1) + (1|v2), data = df, control = lmerControl(boundary.tol = 1e-4, calc.derivs = FALSE))
If you aren't required to actually run the model in Python, you could call and run the LMER models in R directly from your Python environment.
您可以通過Rpy2 & rmagic 或Pymer4來做到這一點。 這兩個選項都允許您在 R 中使用 lme4 package,並可以選擇從 Python 環境(如 jupyter 筆記本)調用它們。
我寫了一個教程,說明如何使用此處提供的示例執行此操作: https://towardsdatascience.com/how-to-run-linear-mixed-effects-models-in-python-jupyter-notebooks-4f8079c4b589
正如 EJJ 所指出的,在 Python 中有 LMER 的實現,例如在statsmodels和Tensorflow中,但它們的使用似乎不如上述方法直觀。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.