Skip to content

IV with multiple endogenous variables #1117

@leostimpfle

Description

@leostimpfle

What is an instrumental variable formula with multiple endogenous variables expected to do? I don't think this documented anywhere. The fixest documentation explicitly mentions the possibility to include multiple endogenous variables but doesn't appear to say much else:

To include several endogenous regressors, just use "+", like in: fml = y ~ x1 | x_endo1 + x_end2 ~ x_inst1 + x_inst2

In Pyfixest the formula Y ~ 1 | X1 + X2 ~ Z1 + Z2 is currently parsed as Y~X1+X2|X1~Z1+Z2. Is this correct?

from pyfixest.estimation.FormulaParser import FixestFormulaParser
fml = "Y ~ 1 | X1 + X2 ~ Z1 + Z2"
FixestFormulaParser(fml).FixestFormulaDict["0"][0].fml

Estimates are close but not identical between pyfixest and fixest:

pyfixest

data = pf.get_data(N=1_000, seed=0, model="Feols")
fml = "Y ~ 1 | X1 + X2 ~ Z1 + Z2"
py = pf.feols(fml=fml, data=data).tidy()
             Estimate  Std. Error    t value  Pr(>|t|)      2.5%     97.5%
Coefficient                                                               
Intercept    1.304583    0.141534   9.217428  0.000000  1.026843  1.582323
X1           0.358530    0.124630   2.876750  0.004104  0.113962  0.603098
X2          -0.305560    0.022170 -13.782747  0.000000 -0.349065 -0.262055

fixest

import rpy2.robjects as ro
from rpy2.robjects import pandas2ri
from rpy2.robjects.packages import importr

pandas2ri.activate()
fixest = importr("fixest")
broom = importr("broom")


r = fixest.feols(
    ro.Formula(fml),
    data=data,
    se="hetero",
)
pd.DataFrame(broom.tidy_fixest(r, conf_int=ro.BoolVector([True])))
             0         1         2         3         4         5         6
0  (Intercept)  1.304262  0.134144  9.722851       0.0  1.041025    1.5675
1       fit_X1  0.358995  0.123502  2.906808  0.003732  0.116642  0.601349
2       fit_X2 -0.302835    0.0232 -13.05321       0.0 -0.348362 -0.257309

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocsImprovements or additions to documentationquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions