cem icon indicating copy to clipboard operation
cem copied to clipboard

att fails with factor treatments

Open jcfisher opened this issue 6 years ago • 0 comments

When you create a cem object using a factor variable as a treatment, attempting to use att to run a logistic regression on that object fails.

It looks like this is happening because of line 372 (using the GitHub formatting) of the att command, tmp.data[, obj$treatment] <- 0. Assigning 0 to the factor variable changes the variable to a numeric, and then the prd <- predict(out, tmp.data, type = "response") command on the following line fails because the treatment variable is the wrong type.

To fix this, you might want to change the assignment on line 258 to assign the reference level of the factor variable if the treatment variable is a factor. Alternatively, you could just coerce everything to numeric, or throw a warning if you try to run att with a factor treatment.

Let me know if I can help resolve this in any way.

jcfisher avatar Aug 09 '18 02:08 jcfisher