Skip to content

linearmodels/effects-keyword-with-formula

Pack Severity Fix Versions
linearmodels error unsafe, with xpd check --fix --unsafe-fixes All versions

In linearmodels, PanelOLS.from_formula has no entity_effects argument and raises TypeError, because the formula holds the effects. Write EntityEffects or TimeEffects as a term of the formula.

model = PanelOLS.from_formula("lwage ~ 1 + exper", data, entity_effects=True)
model = PanelOLS.from_formula("lwage ~ 1 + exper + EntityEffects", data)

The rule reports entity_effects= or time_effects= given to PanelOLS.from_formula. The constructor takes the two keywords, but from_formula reads the effects from the formula.

xpd check --fix --unsafe-fixes applies the fixes of this rule. Check the result, because an unsafe fix can change what the code does.

With the unsafe fix, the term EntityEffects or TimeEffects is added to a formula written as a string, in place of entity_effects=True or time_effects=True. The call raised before the fix. A formula that is not a string, a keyword that is not True, and a call with both keywords have no fix.

7.1 and 7.0 raised TypeError: PanelOLS.from_formula() got an unexpected keyword argument 'entity_effects'. Three of the 950 public files have the form.

In linearmodels, PanelOLS.from_formula has no entity_effects argument and raises TypeError, because the formula holds the effects. Write EntityEffects as a term of the formula in place of entity_effects=True, as in "y ~ 1 + x + EntityEffects".

See all rules in the linearmodels pack.