Skip to content

linearmodels/panel-ols-without-effects

Pack Severity Fix Versions
linearmodels warning none, edit by hand All versions

In linearmodels, PanelOLS without effects fits pooled OLS, despite its name. Pass entity_effects=True or time_effects=True for fixed effects.

fixed = PanelOLS(y, X).fit()
fixed = PanelOLS(y, X, entity_effects=True).fit()
pooled = PooledOLS(y, X).fit()

The rule reports PanelOLS(...) with none of entity_effects, time_effects and other_effects, and PanelOLS.from_formula with a formula that has no effects term. The name of the class reads like a fixed effects estimator, but without one of the three it fits pooled OLS.

xpd has no automatic fix, so make the change by hand.

On the wage panel, on 7.1 and 7.0, the three models gave the following coefficients:

Model Coefficient of exper
PanelOLS(y, X) 0.0349
PooledOLS(y, X) 0.0349
PanelOLS(y, X, entity_effects=True) 0.0698

The rule reports 37 calls in 25 of the 950 public files. Among them are results named fe_model and mod_fe, and a function whose docstring starts "One- and two-way fixed effects estimator for panel data" and whose body is PanelOLS(y, exogenous).fit(). A call that passes any of the three keywords is left alone, also with the value False, and so is a call that unpacks its keywords. A formula with a C() term may hold the effects as dummies and is left alone too.

In linearmodels, PanelOLS has no effects unless it is told to, so this call fits pooled OLS. On the wage panel it returned the coefficients of PooledOLS, with exper at 0.0349, against 0.0698 with entity_effects=True. Pass entity_effects=True or time_effects=True for fixed effects, or use PooledOLS to say that none is meant.

See all rules in the linearmodels pack.