似乎在最新版本的 pandas 中,所有 ols 功能都已被弃用(pandas.stats 实际上已经消失,并且没有 PanelOLS 或 ols 功能)。我正在尝试使用 statsmodels 运行面板回归,但找不到有效的方法?以前我可以使用这样的代码:
panel_ols = ols(y=DataFrame, x=DataFrame, ...,)
这将使用单个面板回归中的所有数据来估计系数。
现在有什么办法吗?
请您参考如下方法:
根据 statsmodel 文档,您似乎想要 Linear Mixed Effects Models ,但我不是 statsmodels 的大用户,所以我只是按照文档进行操作。
关于面板和 OLS 状态的一些更一般的信息:从 pandas 版本 0.20.1 开始,面板已被弃用并且 OLS 已被删除。以下是来自“What's New”的信息:
Panel is deprecated and will be removed in a future version. The recommended way to represent 3-D data are with a MultiIndex on a DataFrame via the to_frame() or with the xarray package. Pandas provides a to_xarray() method to automate this conversion. For more details see Deprecate Panel documentation (GH13563).
Remove OLS, Fama-Macbeth, etc.
pandas.stats.fama_macbeth, pandas.stats.ols, pandas.stats.plm and pandas.stats.var, as well as the top-level pandas.fama_macbeth and pandas.ols routines are removed. Similar functionaility can be found in the statsmodels package. (GH11898)
