DeclareDesign / estimatr

estimatr: Fast Estimators for Design-Based Inference
https://declaredesign.org/r/estimatr
Other
131 stars 20 forks source link

Updating formulas does not work with iv_robust #353

Closed vsdornelas closed 4 years ago

vsdornelas commented 4 years ago
m1 <- iv_robust(Sepal.Length ~ Sepal.Width | Petal.Length, iris)

# Upon wanting to update the formula by, say, exchanging Sepal.Width for Petal.Width
m2 <- update(m1, . ~ Petal.Width | .)
# Error in clean_model_data(data = data, datargs, estimator = "iv") : 
#  Must specify a `formula` with both regressors and instruments. For example, `formula = y ~ x1 + x2 | x1 + z2` where x1 and x2 are the regressors and z1 and z2 are the instruments.
#
# See ?iv_robust.

And so is the case whichever way you try to update it (explictly writing the whole formula again, writing both regressor and instrument, etc.). By the way, there's a small typo in that error message, as it should have z1 instead of x1 after |.