'Building a 2sls with multiple endogenous variables in python
I am trying to build a 2sls model using linearmodels in python and the code is like this:
mod2 = 'log_origin ~ 1 + log_avg_speed + gaochun + gulou + jiangning + jianye + lishui + liuhe + pukou ' \
'+ qinhuai + qixia + xuanwu + yuhuatai + 27 + 28 + 29 + dawn + morning_peak + noon + evening_peak + night ' \
'+ [log_price/unit ~ log_price/unit_lag_96 + log_price/unit_lag_192] ' \
'+ [log_supply ~ log_supply_lag_96] + [log_adjacent_supply ~ log_adjacent_supply_lag_96]'
reg2 = IV2SLS.from_formula(mod2, df).fit(cov_type='robust')
print(reg2)
log_price/unit, log_supply and log_adjacent_supply are endogenous variables.
It reports error as follows.
ValueError: formula contains more then 2 separators (~)
It seems that the package doesn't support multiple endogenous variables or I'm not doing it rightly.
Is there a correct way to build a 2sls model with multiple endogenous variables using linearmodels or other packages?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
