Skip to content

linearmodels/iv-without-exog

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

With exog=None, the instrument model has no intercept, because linearmodels adds none, so the estimates are biased. Pass a column of ones as exog.

model = IV2SLS(y, None, x, z)
model = IV2SLS(y, sm.add_constant(controls), x, z)

The rule reports None written as the exog of an instrument model that has an endogenous regressor. The model then has no intercept.

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

Over 2,000 draws of 500 rows from y = 2 + x + error with one instrument, the two forms gave the following mean estimates:

exog Mean estimate of the coefficient on x, which is 1
None 2.002
a constant column 0.990

On the mroz data the coefficient on educ was 0.0928 without exog and 0.0664 with a constant and exper. Data with mean zero needs no intercept, so the rule is a warning.

exog is None here, so the model has no intercept, because linearmodels adds none. In a simulation with a true coefficient of 1.0 and an intercept of 2.0, the mean estimate was 2.002 without exog and 0.990 with a constant column. Pass a column of ones as exog, such as sm.add_constant, unless the data has mean zero.

See all rules in the linearmodels pack.