statsmodels 线性回归 - patsy 公式包含模型中的所有预测变量 [英] statsmodels linear regression - patsy formula to include all predictors in model
问题描述
假设我有一个数据帧(我们称之为 DF
),其中 y
是因变量,x1, x2, x3
是我的独立变量变量.在 R 中,我可以使用以下代码拟合线性模型,.
将包含模型中的所有自变量:
Say I have a dataframe (let's call it DF
) where y
is the dependent variable and x1, x2, x3
are my independent variables. In R I can fit a linear model using the following code, and the .
will include all of my independent variables in the model:
# R code for fitting linear model
result = lm(y ~ ., data=DF)
如果没有明确地将我的所有自变量添加到公式中,我无法弄清楚如何使用 patsy 公式使用 statsmodels 来做到这一点.patsy 是否与 R 的 .
等效?我没有在 patsy 文档中找到它.
I can't figure out how to do this with statsmodels using patsy formulas without explicitly adding all of my independent variables to the formula. Does patsy have an equivalent to R's .
? I haven't had any luck finding it in the patsy documentation.
推荐答案
不,不幸的是,patsy 中还没有这个.请参阅此问题.
No this doesn't exist in patsy yet, unfortunately. See this issue.
这篇关于statsmodels 线性回归 - patsy 公式包含模型中的所有预测变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!