The vignette of ivreg
https://cran.r-project.org/web/packages/ivreg/vignettes/ivreg.html says As listing exogenous variables in both parts on the right-hand side of the formula may become tedious if there are many of them, an additional convenience option is to use a three-part right side like y ~ x1 | x2 | z1 + z2, listing the exogenous, endogenous, and instrumental variables (for the endogenous variables only), respectively.
I absolutely agree, that repeating a lot of variables is tedious. What am I missing to use the three-part notation?
# data
data("SchoolingReturns")
# ivreg basic
library(ivreg)
ivreg(log(packs) ~ log(rprice) + log(rincome) | salestax + log(rincome), data = CigaretteDemand)
# don't want to repeat all endogenous variables
# ivreg formulas DV ~ exo | endo | instrument
# three part right hand side not working
ivreg(log(packs) ~ log(rprice) | log(rincome) | salestax, data = CigaretteDemand)
ivreg
was masked by another iv-package. Problematic:
data("SchoolingReturns")
library(ivreg)
library(AER)
ivreg(log(packs) ~ log(rincome) | log(rprice) | salestax, data = CigaretteDemand)
Error in ivreg(log(packs) ~ log(rincome) | log(rprice) | salestax, data = CigaretteDemand) :
length(formula)[2] %in% 1:2 ist nicht TRUE
All good:
data("SchoolingReturns")
library(ivreg)
ivreg(log(packs) ~ log(rincome) | log(rprice) | salestax, data = CigaretteDemand)