Skip to content

linearmodels

The linearmodels pack catches formulas and arguments that fit the wrong model, mismatched covariance options, runtime errors on linearmodels 7.1, statsmodels attribute names used on linearmodels results, and removed APIs on files that import linearmodels. Rules fire only on calls and results bound to linearmodels imports.

Rules Safe fix Unsafe fix Manual fix
25 0 16 9
Rule Severity Fix What it finds
formula-without-constant warning unsafe linearmodels adds no intercept to a formula, where statsmodels and R add one, so the estimates change.
effects-outside-panel-ols error none In linearmodels, only PanelOLS reads effect terms in a formula, and the other panel models drop them without an error.
effects-keyword-with-formula error unsafe In linearmodels, PanelOLS.from_formula has no entity_effects argument and raises TypeError, because the formula holds the effects.
formula-power-term error unsafe A linearmodels formula reads ** as a power of interactions, so exper**2 is just exper, with no error.
first-difference-constant error unsafe In linearmodels, FirstDifferenceOLS takes no constant, so a 1 term or add_constant raises ValueError.
weights-column-name error unsafe In linearmodels, weights takes the values and not the name of a column, so a name raises.
Rule Severity Fix What it finds
panel-ols-without-effects warning none In linearmodels, PanelOLS without effects fits pooled OLS, despite its name.
too-many-effects error none In linearmodels, PanelOLS takes at most two effects, so three raise ValueError.
time-before-entity-index warning unsafe The linearmodels panel models read the first index level as the entity and the second as the time, and here the time comes first, so the effects are on the wrong level.
use-lsdv warning unsafe On linearmodels PanelOLS, use_lsdv=True builds a dummy column for each entity, which was up to 1,508 times slower and gave the same coefficients.
Rule Severity Fix What it finds
clustered-without-clusters error none A clustered fit in linearmodels needs the intended groups.
cov-option-without-cov-type error unsafe In linearmodels, a fit can reject or ignore a covariance option when the selected covariance does not use it.
unknown-cov-type error unsafe Each linearmodels estimator accepts its own covariance names.
kernel-default-bandwidth warning unsafe The default kernel bandwidth changed in linearmodels 7.1, so results change between versions and 7.1 warns.
panel-default-covariance info unsafe In linearmodels, PanelOLS, PooledOLS, RandomEffects and FirstDifferenceOLS default to unadjusted covariance.
Rule Severity Fix What it finds
iv-missing-arguments error none The linearmodels instrument models take dependent, exog, endog and instruments in that order, so a call with fewer arguments raises TypeError.
iv-arguments-swapped warning unsafe The linearmodels instrument models take exog before endog, and these arguments are named the other way round, so the model instruments the wrong variables.
iv-without-exog warning none With exog=None, the instrument model has no intercept, because linearmodels adds none, so the estimates are biased.
manual-two-stage warning none Using linearmodels to fit a second regression on the fitted values of a first one is two stage least squares by hand, and its standard errors come from the wrong residuals.
absorb-not-categorical info none In linearmodels, AbsorbingLS absorbs a column as fixed effects only when its dtype is categorical, so a numeric id becomes one continuous regressor.
Rule Severity Fix What it finds
statsmodels-result-name error unsafe A linearmodels result does not have the statsmodels names, so summary(), bse and similar names raise.
invalid-compare-precision error unsafe In linearmodels, compare takes only "tstats", "std_errors" or "pvalues" for precision, so another value raises ValueError.
hand-written-hausman info none linearmodels has both Hausman tests built in, so a hand-written one is extra code to keep right.
Rule Severity Fix What it finds
removed-in-linearmodels error unsafe These modules and methods were removed from linearmodels, so the import or the call raises.
deprecated-in-linearmodels warning unsafe These imports, keywords and names warn on linearmodels 7.1, and 8.0 removes them.