I stumbled upon an issue with the
ivmodel package: when exogenous covariates are included in the model, the
ivmodel function yields different estimates than the
ivmodelFormula function, although the latter seems to be a wrapper of the former. Here is a minimal reproducible example:
library(ivmodel) data(card.data) summary(ivmodel(Y=card.data$lwage, D=card.data$educ, Z=card.data$nearc4, X=card.data$exper)) summary(ivmodelFormula(lwage ~ educ + exper | nearc4 + exper, data=card.data)) summary(ivmodel(Y=card.data$lwage, D=card.data$educ, Z=card.data$nearc4)) summary(ivmodelFormula(lwage ~ educ | nearc4, data=card.data))
The two first lines run the model with the exogenous covariate
exper, while the two last run the model without the covariate. However, the three last lines yield the same result.
What is happening? Why does
ivmodelFormula seem to ignore the covariates? Is there an error in the package, or does this mean that
ivmodelFormula is not a wrapper for
ivmodel after all?