Someone I'm working with just made a couple of errors in using the code and asked me about them, so I figured I would list them here so maybe we could build some safeguards into the software.
they included the outcome and the condition variables in the covariate matrix. As it stands, I don't really know how best to protect against this, but if we allow users to specify covariates as a formula (like in estimatr) then we can test to see if any of the elements in the formula have the same name as the outcome and condition variables in the call. I wonder what other packages do?
I think that either the outcome or the treatment variable were factors. This sort of thing should be easy to test for, then we can give informative error messages.
(if we had a formula interface, I could imagine specifying like this:
loop(formula=Y~Tr,Z=~x1+x2,data=df)
then include the line
if(length(intersect(all.vars(formula),all.vars(Z)))) stop("Outcome and/or Treatment variables cannot be included as covariates.")
Someone I'm working with just made a couple of errors in using the code and asked me about them, so I figured I would list them here so maybe we could build some safeguards into the software.
estimatr
) then we can test to see if any of the elements in the formula have the same name as the outcome and condition variables in the call. I wonder what other packages do?(if we had a formula interface, I could imagine specifying like this:
then include the line
or something of that sort)