2
votes

It seems in the latest version of pandas, all the ols functionality has been deprecated (pandas.stats is effectively gone, and doesn't have PanelOLS or the ols function). I am trying to run a panel regression with statsmodels, but can't find an effective way to do so? Previously I could use code like this:

panel_ols = ols(y=DataFrame, x=DataFrame, ...,)

This would estimate coefficients using all the data in a single panel regression.

Any way to do this now?

1
You could use the sklearn OLS Regressor classifier.cs95
In addition to @cᴏʟᴅsᴘᴇᴇᴅ recommendation, numpy has builtin functionality for OLS regression. See- docs.scipy.org/doc/numpy/reference/generated/…Andrew L

1 Answers

1
votes

Based on statsmodel docs, it appears you want Linear Mixed Effects Models, but I'm not a big user of statsmodels so I'm just going by documentation.

Some more general info on the status of panel and OLS: panel is deprecated and OLS has been removed as of pandas version 0.20.1. Here is the info from "What's New":

Deprecate Panel

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)