Closed a-torgovitsky closed 5 years ago
The error in the original example occurred because of collinearity. Having resolved #78, the original example is no longer problematic.
Below is an alternative example where the first subset condition restricts the sample to 0 observations. I'm not sure what kind of errors the user will be capable of generating, so I thought it would suffice to return the same error message that R would've returned when the regression fails, but also inform the user which IV specification is causing the problem.
> subsets <- l(x2 < -Inf, x2 < 1)
>
> devtools::load_all("../IVMTE/")
Loading ivmte
> test <- ivmte(data = df,
+ ivlike = ivlike,
+ subset = subsets,
+ target = "ate",
+ m0 = ~ u,
+ m1 = ~ u,
+ propensity = d ~ z
+ )
Obtaining propensity scores...
Generating target moments...
Integrating terms for control group...
Integrating terms for treated group...
Generating IV-like moments...
Error: IV-like specification 1 generates the following error:
0 (non-NA) cases. Check the specification and its corresponding
subset condition.
Let me know if you'd like any adjustments to that.
Perfect -- that's very informative!
Is there a way to give the user some more info? Simple example:
The first specification is problematic because I am regressing y on d and x2, but also using a subsetting mask that restricts to the subpopulation with x2 < 1 -- which here is just x2 = 0. So there is no variation in x2.
But as the user I receive this:
I could imagine that if I have many complicated specifications in an application that it's going to get really hard to track them down. Is there a way to just tell the user which specification is causing problems?